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