From 16b31a8828926c4738e95ef1ab7c5fbacd232942 Mon Sep 17 00:00:00 2001 From: Max Ziebell <1752114+worldoptimizer@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:00:20 +0200 Subject: [PATCH] v1.3.0 --- HypeReactiveContent.prod.min.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/HypeReactiveContent.prod.min.js b/HypeReactiveContent.prod.min.js index c983567..ca2d222 100644 --- a/HypeReactiveContent.prod.min.js +++ b/HypeReactiveContent.prod.min.js @@ -1,13 +1,14 @@ /* - Hype Reactive Content 1.2.2 + Hype Reactive Content 1.3.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\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 g=l.getAttribute(k+"-behavior");w(function(){a.triggerCustomBehaviorNamed(g)})()}}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.customDataUpdate&&a.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.2",setDefault:function(a,c){"object"==typeof a?_default=a:_default[a]=c},getDefault:q,enableReactiveObject:u,disableReactiveObject:y,debounceByRequestFrame:w}}()); +!1==="HypeReactiveContent"in window&&(window.HypeReactiveContent=function(){function p(a){return a?_default[a]:_default}function u(a,c){return a?a+"."+c:c}function v(a,c,d){d=d||"";return null==a||a[w]?a:new Proxy(a,{get:function(e,h,b){if("_key"===h)return d;if(h===w)return!0;e=Reflect.get(e,h,b);return"object"===typeof e?v(e,c,u(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 z(a){if(!a[w])return a;var c={},d;for(d in a)if(a.hasOwnProperty(d)){var e=a[d]; +c[d]="object"===typeof e?z(e):e}return c}function x(a){return function(){if(!a.timeout){var c=arguments;a.timeout=requestAnimationFrame(function(){a.apply(this,c);a.timeout=null}.bind(this))}}}function q(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 A(a,c,d){return d?q("return "+d,a,null,{element:c,type:"HypeReactiveScope"}):null}function B(a,c){var d=c.closest("[data-scope]");return d?A(a,c,d.getAttribute("data-scope")):null} +function y(a,c,d){var e=p("scopeSymbol"),h=e.length,b=null;a=a.trim();a.startsWith(e)?(a=a.slice(h),b=B(c,d)):a.includes(e)&&(b=a.slice(0,a.indexOf(e)),b=A(c,d,b),a=a.slice(a.indexOf(e)+h));return{value:a,scope:b}}function C(a){t.set(a,a.customData||{});Object.defineProperty(a,"customData",{get:function(){return t.get(a)},set:function(c){c=v(c,a.refreshReactiveContentDebounced);t.set(a,c);p("debounceCustomDataUpdate")?a.refreshReactiveContentDebounced():a.refreshReactiveContent()}})}function D(a, +c,d){!1==="HypeActionEvents"in window&&(c=d.customBehaviorName,"#"!=c.charAt(0)&&/[;=()]/.test(c)&&q(c,a,a.customData))}var t=new WeakMap;_default={scopeSymbol:"\u21e2",visibilitySymbol:"\ud83d\udc41\ufe0f",effectSymbol:"\u26a1\ufe0f",debounceCustomDataUpdate:!0};var w=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]"))&&q(l.getAttribute(k+ +"-action"),a,null,{element:b,type:f});if((l=b.closest("["+k+"-behavior]"))&&!h[l.id]){h[l.id]=!0;var g=l.getAttribute(k+"-behavior");x(function(){a.triggerCustomBehaviorNamed(g)})()}}var h={};a.refreshReactiveContent=function(b,f,k,l){void 0===b||void 0===f||/[;=()]/.test(f)||a.triggerCustomBehaviorNamed(u(l._key,b)+" equals "+("string"===typeof f?'"'+f+'"':f));void 0!==b&&(p("customDataUpdate")&&p("customDataUpdate")(b,f,k,l),a.customDataUpdate&&a.customDataUpdate(b,f,k,l),a.triggerCustomBehaviorNamed("customData was changed"), +a.triggerCustomBehaviorNamed(u(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=y(n,a,g),n=q("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=y(r,a,g),q(r.value,a,r.scope,{element:g,type:"HypeReactiveEffect"}));m&&(m=y(m,a,g),m=q("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=x(a.refreshReactiveContent); +a.resolveClosestScope=function(b){return B(a,b)};a.enableReactiveCustomData=function(b){var f=t.get(a)||{};a.customData=Object.assign(f,b||{})};C(a);a.enableReactiveCustomData(p("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:D});return{version:"1.3.0",setDefault:function(a,c){"object"==typeof a?_default=a:_default[a]=c},getDefault:p,enableReactiveObject:v,disableReactiveObject:z,debounceByRequestFrame:x}}());