diff --git a/HypeReactiveContent.prod.min.js b/HypeReactiveContent.prod.min.js index 729641d..d43cc93 100644 --- a/HypeReactiveContent.prod.min.js +++ b/HypeReactiveContent.prod.min.js @@ -1,13 +1,13 @@ /* - Hype Reactive Content 1.1.9 + Hype Reactive Content 1.2.0 copyright (c) 2022 Max Ziebell, (https://maxziebell.de). MIT-license */ !1==="HypeReactiveContent"in window&&(window.HypeReactiveContent=function(){function q(a){return a?_default[a]:_default}function t(a,c){return a?a+"."+c:c}function u(a,c,d){d=d||"";return null==a||a[v]?a:new Proxy(a,{get:function(e,h,b){if("_key"===h)return d;if(h===v)return!0;e=Reflect.get(e,h,b);return"object"===typeof e?u(e,c,t(d,h)):e},set:function(e,h,b,f){var k=Reflect.set(e,h,b,f);c(h,b,e,f);return k}})}function y(a){if(!a[v])return a;var c={},d;for(d in a)if(a.hasOwnProperty(d)){var e=a[d]; c[d]="object"===typeof e?y(e):e}return c}function w(a){return function(){if(!a.timeout){var c=arguments;a.timeout=requestAnimationFrame(function(){a.apply(this,c);a.timeout=null}.bind(this))}}}function p(a,c,d,e){if(d){if("object"!==typeof d)return null}else{if(void 0===d)return null;d=c.customData}e=e||{};if(!1!=="HypeActionEvents"in window)return c.triggerAction(a,{element:e.element,event:{type:e.type},scope:d});try{var h=new Proxy(Object.assign({element:e.element,$elm:e.element},c),{set:function(b, f,k,l){return Reflect.get(b,f,l)?Reflect.set(b,f,k,l):Reflect.set(d,f,k)},get:function(b,f,k){return(b=Reflect.get(b,f,k))?b:Reflect.get(d,f)},has:function(b,f,k){return b.hasOwnProperty(f)||window[f]?Reflect.has(b,f,k):!0}});return(new Function("$context","with($context){ "+a+"}"))(h)}catch(b){console.error(b)}}function z(a,c,d){return d?p("return "+d,a,null,{element:c,type:"HypeReactiveScope"}):null}function A(a,c){var d=c.closest("[data-scope]");return d?z(a,c,d.getAttribute("data-scope")):null} -function x(a,c,d){var e=q("scopeSymbol"),h=e.length,b=null;a=a.trim();a.startsWith(e)?(a=a.slice(h),b=A(c,d)):a.includes(e)&&(b=a.slice(0,a.indexOf(e)),b=z(c,d,b),a=a.slice(a.indexOf(e)+h));return{value:a,scope:b}}function B(a,c,d){!1==="HypeActionEvents"in window&&(c=d.customBehaviorName,"#"!=c.charAt(0)&&/[;=()]/.test(c)&&p(c,a,a.customData))}_default={scopeSymbol:"\u21e2",visibilitySymbol:"\ud83d\udc41"};var v=Symbol("isProxy");!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners=[]); -window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(a,c,d){function e(b,f,k,l,g){(l=b.closest("["+k+"-action]"))&&p(l.getAttribute(k+"-action"),a,null,{element:b,type:f});if((l=b.closest("["+k+"-behavior]"))&&!h[l.id]){h[l.id]=!0;var m=l.getAttribute(k+"-behavior");w(function(){a.triggerCustomBehaviorNamed(m)})()}}var h={};a.refreshReactiveContent=function(b,f,k,l){void 0===b||void 0===f||/[;=()]/.test(f)||a.triggerCustomBehaviorNamed(t(l._key,b)+" equals "+("string"===typeof f? -'"'+f+'"':f));void 0!==b&&(q("customDataUpdate")&&q("customDataUpdate")(b,f,k,l),a.triggerCustomBehaviorNamed("customData was changed"),a.triggerCustomBehaviorNamed(t(l._key,b)+" was updated"));f=document.getElementById(a.currentSceneId());h={};f.querySelectorAll("[data-visibility], [data-content], [data-effect]").forEach(function(g){var m=g.getAttribute("data-content"),n=g.getAttribute("data-visibility"),r=g.getAttribute("data-effect");n&&(n=x(n,a,g),n=p("return "+n.value,a,n.scope,{element:g,type:"HypeReactiveVisibility"}), -"none"==g.style.display&&(g.style.display="block"),n=n?"visible":"hidden",n!==g.style.visibility&&(g.style.visibility=n,b&&e(g,"HypeReactiveVisibiltyChanged","data-visibility-changed",!0,!0)));r&&(r=x(r,a,g),p(r.value,a,r.scope,{element:g,type:"HypeReactiveEffect"}));m&&(m=x(m,a,g),m=p("return "+m.value,a,m.scope,{element:g,type:"HypeReactiveContent"}),m=void 0!==m?m:"",m!==g.innerHTML&&(g.innerHTML=m,b&&e(g,"HypeReactiveContentChanged","data-content-changed",!0,!0)))});!1!=="HypeDataMagic"in window&& -HypeDataMagic.getDefault("refreshOnCustomData")&&a.refresh()};a.refreshReactiveContentDebounced=w(a.refreshReactiveContent);a.resolveClosestScope=function(b){return A(a,b)};a.enableReactiveCustomData=function(b){a.customData=Object.assign(a.customData,b||{});a.customData=u(a.customData,a.refreshReactiveContentDebounced)};a.enableReactiveCustomData(q("customData")||{});a.functions().HypeReactiveContent&&a.functions().HypeReactiveContent(a,c,d)}});window.HYPE_eventListeners.push({type:"HypeScenePrepareForDisplay", -callback:function(a,c,d){a.refreshReactiveContentDebounced()}});!1==="HypeActionEvents"in window&&window.HYPE_eventListeners.push({type:"HypeTriggerCustomBehavior",callback:B});return{version:"1.1.9",setDefault:function(a,c){"object"==typeof a?_default=a:_default[a]=c},getDefault:q,enableReactiveObject:u,disableReactiveObject:y,debounceByRequestFrame:w}}()); +function x(a,c,d){var e=q("scopeSymbol"),h=e.length,b=null;a=a.trim();a.startsWith(e)?(a=a.slice(h),b=A(c,d)):a.includes(e)&&(b=a.slice(0,a.indexOf(e)),b=z(c,d,b),a=a.slice(a.indexOf(e)+h));return{value:a,scope:b}}function B(a,c,d){!1==="HypeActionEvents"in window&&(c=d.customBehaviorName,"#"!=c.charAt(0)&&/[;=()]/.test(c)&&p(c,a,a.customData))}_default={scopeSymbol:"\u21e2",visibilitySymbol:"\u2600\ufe0f",effectSymbol:"\u26a1\ufe0f"};var v=Symbol("isProxy");!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners= +[]);window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(a,c,d){function e(b,f,k,l,g){(l=b.closest("["+k+"-action]"))&&p(l.getAttribute(k+"-action"),a,null,{element:b,type:f});if((l=b.closest("["+k+"-behavior]"))&&!h[l.id]){h[l.id]=!0;var m=l.getAttribute(k+"-behavior");w(function(){a.triggerCustomBehaviorNamed(m)})()}}var h={};a.refreshReactiveContent=function(b,f,k,l){void 0===b||void 0===f||/[;=()]/.test(f)||a.triggerCustomBehaviorNamed(t(l._key,b)+" equals "+("string"=== +typeof f?'"'+f+'"':f));void 0!==b&&(q("customDataUpdate")&&q("customDataUpdate")(b,f,k,l),a.triggerCustomBehaviorNamed("customData was changed"),a.triggerCustomBehaviorNamed(t(l._key,b)+" was updated"));f=document.getElementById(a.currentSceneId());h={};f.querySelectorAll("[data-visibility], [data-content], [data-effect]").forEach(function(g){var m=g.getAttribute("data-content"),n=g.getAttribute("data-visibility"),r=g.getAttribute("data-effect");n&&(n=x(n,a,g),n=p("return "+n.value,a,n.scope,{element:g, +type:"HypeReactiveVisibility"}),"none"==g.style.display&&(g.style.display="block"),n=n?"visible":"hidden",n!==g.style.visibility&&(g.style.visibility=n,b&&e(g,"HypeReactiveVisibiltyChanged","data-visibility-changed",!0,!0)));r&&(r=x(r,a,g),p(r.value,a,r.scope,{element:g,type:"HypeReactiveEffect"}));m&&(m=x(m,a,g),m=p("return "+m.value,a,m.scope,{element:g,type:"HypeReactiveContent"}),m=void 0!==m?m:"",m!==g.innerHTML&&(g.innerHTML=m,b&&e(g,"HypeReactiveContentChanged","data-content-changed",!0,!0)))}); +!1!=="HypeDataMagic"in window&&HypeDataMagic.getDefault("refreshOnCustomData")&&a.refresh()};a.refreshReactiveContentDebounced=w(a.refreshReactiveContent);a.resolveClosestScope=function(b){return A(a,b)};a.enableReactiveCustomData=function(b){a.customData=Object.assign(a.customData,b||{});a.customData=u(a.customData,a.refreshReactiveContentDebounced)};a.enableReactiveCustomData(q("customData")||{});a.functions().HypeReactiveContent&&a.functions().HypeReactiveContent(a,c,d)}});window.HYPE_eventListeners.push({type:"HypeScenePrepareForDisplay", +callback:function(a,c,d){a.refreshReactiveContentDebounced()}});!1==="HypeActionEvents"in window&&window.HYPE_eventListeners.push({type:"HypeTriggerCustomBehavior",callback:B});return{version:"1.2.0",setDefault:function(a,c){"object"==typeof a?_default=a:_default[a]=c},getDefault:q,enableReactiveObject:u,disableReactiveObject:y,debounceByRequestFrame:w}}());