@lume/variable
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -9,4 +9,4 @@ | ||
} | ||
LUME=function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=2)}([function(t,n,e){"use strict";(function(t){function r(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:Function("return this")()}e.d(n,"a",(function(){return r}))}).call(this,e(1))},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n,e){"use strict";e.r(n),e.d(n,"variable",(function(){return $t})),e.d(n,"autorun",(function(){return qt})),e.d(n,"reactive",(function(){return Wt})),e.d(n,"reactify",(function(){return Ht})),e.d(n,"untrack",(function(){return Kt})),e.d(n,"version",(function(){return Nt}));var r={};e.r(r),e.d(r,"$RAW",(function(){return X})),e.d(r,"SuspenseContext",(function(){return vt})),e.d(r,"afterEffects",(function(){return D})),e.d(r,"awaitSuspense",(function(){return _t})),e.d(r,"cancelCallback",(function(){return p})),e.d(r,"cloneProps",(function(){return ht})),e.d(r,"createContext",(function(){return F})),e.d(r,"createDeferred",(function(){return R})),e.d(r,"createDependentEffect",(function(){return M})),e.d(r,"createEffect",(function(){return k})),e.d(r,"createMemo",(function(){return T})),e.d(r,"createResource",(function(){return At})),e.d(r,"createResourceState",(function(){return xt})),e.d(r,"createRoot",(function(){return P})),e.d(r,"createSignal",(function(){return j})),e.d(r,"createState",(function(){return st})),e.d(r,"equalFn",(function(){return y})),e.d(r,"freeze",(function(){return C})),e.d(r,"getContextOwner",(function(){return q})),e.d(r,"isListening",(function(){return z})),e.d(r,"lazy",(function(){return Pt})),e.d(r,"mapArray",(function(){return at})),e.d(r,"onCleanup",(function(){return L})),e.d(r,"onError",(function(){return I})),e.d(r,"reconcile",(function(){return lt})),e.d(r,"requestCallback",(function(){return h})),e.d(r,"runtimeConfig",(function(){return pt})),e.d(r,"sample",(function(){return E})),e.d(r,"setDefaults",(function(){return dt})),e.d(r,"suspend",(function(){return kt})),e.d(r,"unwrap",(function(){return et})),e.d(r,"useContext",(function(){return $})),e.d(r,"useTransition",(function(){return jt}));let o=1,i=!1,u=!1,c=[],s=null,l=null,f=0,a=null,d=null;function h(t,n){a||function(){if(window&&window.MessageChannel){const t=new MessageChannel,n=t.port2;a=()=>n.postMessage(null),t.port1.onmessage=()=>{if(null!==d){const t=performance.now();f=t+5;const e=!0;try{d(e,t)?n.postMessage(null):d=null}catch(t){throw n.postMessage(null),t}}}}else{let t;a=()=>{t||(t=d,setTimeout(()=>{const n=performance.now();f=n+5;const e=t(!0,n);t=null,e&&a()},0))}}if(navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){const t=navigator.scheduling;l=()=>{const n=performance.now();return n>=f&&(!!t.isInputPending()||n>=300)}}else l=()=>performance.now()>=f}();let e=performance.now(),r=1073741823;n&&n.timeout&&(r=n.timeout);const s={id:o++,fn:t,startTime:e,expirationTime:e+r};return function(t,n){t.splice(function(){let e=0,r=t.length-1;for(;e<=r;){let o=r+e>>1,i=n.expirationTime-t[o].expirationTime;if(i>0)e=o+1;else{if(!(i<0))return o;r=o-1}}return e}(),0,n)}(c,s),i||u||(i=!0,d=g,a()),s}function p(t){t.fn=null}function g(t,n){i=!1,u=!0;try{return function(t,n){let e=n;s=c[0]||null;for(;null!==s&&(!(s.expirationTime>e)||t&&!l());){const t=s.fn;if(null!==t){s.fn=null;const n=s.expirationTime<=e;t(n),e=performance.now(),s===c[0]&&c.shift()}else c.shift();s=c[0]||null}return null!==s}(t,n)}finally{s=null,u=!1}}const y=(t,n)=>t===n,v=Symbol("error"),b={},w={owned:null,cleanups:null,context:null,owner:null};let m=null,_=null,A=null,S=null,O=[],x=0;function P(t,n){n&&(m=n);const e=_,r=m,o=0===t.length?w:{owned:null,cleanups:null,context:null,owner:r};let i;m=o,_=null;try{i=t(()=>K(o))}catch(t){const n=N(m,v);if(!n)throw t;n.forEach(n=>n(t))}finally{for(;O.length;)O.shift()();_=e,m=r}return i}function j(t,n){const e={value:t,observers:null,observerSlots:null,pending:b,comparator:n};return[V.bind(e),W.bind(e)]}function k(t,n){U(B(t,n))}function M(t,n,e){const r=Array.isArray(n)?(o=n,()=>{for(let t=0;t<o.length;t++)o[t]()}):n;var o;e=!!e,k(n=>{const o=_;return r(),e?e=!1:(_=null,n=t(n),_=o),n})}function T(t,n,e){const r=B(t,n);return r.pending=b,r.observers=null,r.observerSlots=null,r.comparator=e,U(r),V.bind(r)}function R(t,n){let e,r=n?n.timeoutMs:void 0;const[o,i]=j(t());return k(()=>{t(),e&&e.fn||(e=h(()=>i(t()),void 0!==r?{timeout:r}:void 0))}),o}function C(t){let n=A,e=A=[];const r=t();return A=n,H(()=>{for(let t=0;t<e.length;t+=1){const n=e[t];if(n.pending!==b){const t=n.pending;n.pending=b,W.call(n,t)}}}),r}function E(t){let n,e=_;return _=null,n=t(),_=e,n}function D(t){O.push(t)}function L(t){return null===m?console.warn("cleanups created outside a `createRoot` or `render` will never be run"):null===m.cleanups?m.cleanups=[t]:m.cleanups.push(t),t}function I(t){null===m?console.warn("error handlers created outside a `createRoot` or `render` will never be run"):null===m.context?m.context={[v]:[t]}:m.context[v]?m.context[v].push(t):m.context[v]=[t]}function z(){return null!==_}function F(t){const n=Symbol("context");return{id:n,Provider:Q(n),defaultValue:t}}function $(t){return N(m,t.id)||t.defaultValue}function q(){return m}function V(){if(this.state&&this.sources){const t=S;S=null,1===this.state?U(this):function t(n){n.state=0;for(let e=0;e<n.sources.length;e+=1){const r=n.sources[e];r.sources&&(1===r.state?G(r):2===r.state&&t(r))}}(this),S=t}if(_){const t=this.observers?this.observers.length:0;_.sources?(_.sources.push(this),_.sourceSlots.push(t)):(_.sources=[this],_.sourceSlots=[t]),this.observers?(this.observers.push(_),this.observerSlots.push(_.sources.length-1)):(this.observers=[_],this.observerSlots=[_.sources.length-1])}return this.value}function W(t){if(!this.comparator||!this.comparator(this.value,t)){if(A)return this.pending===b&&A.push(this),void(this.pending=t);this.value=t,!this.observers||S&&!this.observers.length||H(()=>{for(let t=0;t<this.observers.length;t+=1){const n=this.observers[t];if(n.observers&&2!==n.state&&J(n),n.state=1,S.length>1e6)throw new Error("Potential Infinite Loop Detected.");S.push(n)}})}}function U(t){if(!t.fn)return;K(t);const n=m,e=_,r=x;_=m=t;const o=t.fn(t.value);(!t.updatedAt||t.updatedAt<=r)&&(t.observers&&t.observers.length?W.call(t,o):t.value=o,t.updatedAt=r),_=e,m=n}function B(t,n){const e={fn:t,state:0,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:n,owner:m,context:null};return null===m?console.warn("computations created outside a `createRoot` or `render` will never be disposed"):m!==w&&(m.owned?m.owned.push(e):m.owned=[e]),e}function G(t){let n=1===t.state&&t;for(;t.fn&&(t=t.owner);)1===t.state&&(n=t);n&&U(n)}function H(t){if(S)return t();S=[],x++;try{t();for(let t=0;t<S.length;t+=1)try{G(S[t])}catch(t){const n=N(m,v);if(!n)throw t;n.forEach(n=>n(t))}}finally{for(S=null;O.length;)O.shift()()}}function J(t){for(let n=0;n<t.observers.length;n+=1){const e=t.observers[n];e.state||(e.state=2,e.observers&&J(e))}}function K(t){let n;if(t.sources){for(;t.sources.length;){const n=t.sources.pop(),e=t.sourceSlots.pop(),r=n.observers;if(r&&r.length){const t=r.pop(),o=n.observerSlots.pop();e<r.length&&(t.sourceSlots[o]=e,r[e]=t,n.observerSlots[e]=o)}}t.state=0}if(t.owned){for(n=0;n<t.owned.length;n++)K(t.owned[n]);t.owned=null}if(t.cleanups){for(n=0;n<t.cleanups.length;n++)t.cleanups[n]();t.cleanups=null}}function N(t,n){return t&&(t.context&&t.context[n]||t.owner&&N(t.owner,n))}function Q(t){return function(n){let e;return k(()=>{m.context={[t]:n.value},e=E(()=>function t(n){if("function"==typeof n)return T(()=>t(n()));if(Array.isArray(n)){const e=[];for(let r=0;r<n.length;r++){let o=t(n[r]);Array.isArray(o)?e.push.apply(e,o):e.push(o)}return e}return n}(n.children))}),e}}const X=Symbol("state-raw"),Y=Symbol("state-node"),Z=Symbol("state-proxy");function tt(t,n){return t[Z]||(t[Z]=new Proxy(t,n||ot))}function nt(t){return null!=t&&"object"==typeof t&&(t.__proto__===Object.prototype||Array.isArray(t))}function et(t){let n,e,r;if(n=null!=t&&t[X])return n;if(!nt(t))return t;if(Array.isArray(t)){Object.isFrozen(t)&&(t=t.slice(0));for(let n=0,o=t.length;n<o;n++)r=t[n],(e=et(r))!==r&&(t[n]=e)}else{Object.isFrozen(t)&&(t=Object.assign({},t));let n=Object.keys(t);for(let o=0,i=n.length;o<i;o++)r=t[n[o]],(e=et(r))!==r&&(t[n[o]]=e)}return t}function rt(t){let n=t[Y];return n||(t[Y]=n={}),n}const ot={get(t,n){if(n===X)return t;if(n===Z||n===Y)return;const e=t[n],r=nt(e);if(z()&&("function"!=typeof e||t.hasOwnProperty(n))){let o,i;r&&(o=rt(e))&&(i=o._||(o._=j()),i[0]()),o=rt(t),i=o[n]||(o[n]=j()),i[0]()}return r?tt(e):e},set:()=>!0,deleteProperty:()=>!0},it={get(t,n){if(n===X)return t;const e=t[n];return nt(e)?new Proxy(e,it):e},set:(t,n,e)=>(ut(t,n,et(e)),!0),deleteProperty:(t,n)=>(ut(t,n,void 0),!0)};function ut(t,n,e,r){if(!r&&t[n]===e)return;const o=Array.isArray(t)||!(n in t);void 0===e?delete t[n]:t[n]=e;let i,u=rt(t);(i=u[n])&&i[1](),o&&(i=u._)&&i[1]()}function ct(t,n,e=[]){let r,o=t;if(n.length>1){r=n.shift();const i=typeof r,u=Array.isArray(t);if(Array.isArray(r)){for(let o=0;o<r.length;o++)ct(t,[r[o]].concat(n),[r[o]].concat(e));return}if(u&&"function"===i){for(let o=0;o<t.length;o++)r(t[o],o)&&ct(t,[o].concat(n),[o].concat(e));return}if(u&&"object"===i){const{from:o=0,to:i=t.length-1,by:u=1}=r;for(let r=o;r<=i;r+=u)ct(t,[r].concat(n),[r].concat(e));return}if(n.length>1)return void ct(t[r],n,[r].concat(e));o=t[r],e=[r].concat(e)}let i=n[0];if("function"==typeof i){const t=void 0===r||nt(o)?new Proxy(o,it):o;if(i=i(t,e),i===t||void 0===i)return}i=et(i),void 0===r||nt(o)&&nt(i)&&!Array.isArray(i)?function(t,n,e){const r=Object.keys(n);for(let o=0;o<r.length;o+=1){const i=r[o];ut(t,i,n[i],e)}}(o,i):ut(t,r,i)}function st(t){const n=et(t||{});return[tt(n),function(...t){C(()=>ct(n,t))}]}function lt(t,n={}){const{merge:e,key:r="id"}=n;return n=>{if(!nt(n=et(n)))return t;!function t(n,e,r,o,i){let u=e[r];if(n===u)return;if(!nt(n)||!nt(u)||i&&n[i]!==u[i])return void(n!==u&&ut(e,r,n));if(Array.isArray(n)){if(n.length&&u.length&&(!o||i&&null!=n[0][i])){let e,r,c,s,l,f,a,d;for(c=0,s=Math.min(u.length,n.length);c<s&&(u[c]===n[c]||i&&u[c][i]===n[c][i]);c++)t(n[c],u,c,o,i);const h=new Array(n.length),p=new Map;for(s=u.length-1,l=n.length-1;s>=c&&l>=c&&(u[s]===n[l]||i&&u[s][i]===n[l][i]);s--,l--)h[l]=u[s];if(c>l||c>s){for(r=c;r<=l;r++)ut(u,r,n[r]);for(;r<n.length;r++)ut(u,r,h[r]),t(n[r],u,r,o,i);return void(u.length>n.length&&ut(u,"length",n.length))}for(a=new Array(l+1),r=l;r>=c;r--)f=n[r],d=i?f[i]:f,e=p.get(d),a[r]=void 0===e?-1:e,p.set(d,r);for(e=c;e<=s;e++)f=u[e],d=i?f[i]:f,r=p.get(d),void 0!==r&&-1!==r&&(h[r]=u[e],r=a[r],p.set(d,r));for(r=c;r<n.length;r++)r in h?(ut(u,r,h[r]),t(n[r],u,r,o,i)):ut(u,r,n[r])}else for(let e=0,r=n.length;e<r;e++)t(n[e],u,e,o,i);return void(u.length>n.length&&ut(u,"length",n.length))}const c=Object.keys(n);for(let e=0,r=c.length;e<r;e++)t(n[c[e]],u,c[e],o,i);const s=Object.keys(u);for(let t=0,e=s.length;t<e;t++)void 0===n[s[t]]&&ut(u,s[t],void 0)}(t,{state:n},"state",e,r)}}const ft=Symbol("fallback");function at(t,n,e){return"function"!=typeof n?(e=n||{},n=t,r):(e||(e={}),r(t));function r(t){let r=[],o=[],i=[],u=0;return L(()=>{for(let t=0,n=i.length;t<n;t++)i[t]()}),()=>{let c,s,l=t()||[];return E(()=>{let t,n,a,d,h,p,g,y,v=l.length;if(0===v){if(0!==u){for(c=0;c<u;c++)i[c]();i=[],r=[],o=[],u=0}e.fallback&&(r=[ft],o[0]=P(t=>(i[0]=t,e.fallback())),u=1)}else if(0===u){for(s=0;s<v;s++)r[s]=l[s],o[s]=P(f);u=v}else{for(a=new Array(v),d=new Array(v),h=0,p=Math.min(u,v);h<p&&r[h]===l[h];h++);for(p=u-1,g=v-1;p>=h&&g>=h&&r[p]===l[g];p--,g--)a[g]=o[p],d[g]=i[p];if(h>g){for(s=p;h<=s;s--)i[s]();const t=p-h+1;return t>0&&(o.splice(h,t),i.splice(h,t)),r=l.slice(0),u=v,o}if(h>p){for(s=h;s<=g;s++)o[s]=P(f);for(;s<v;s++)o[s]=a[s],i[s]=d[s];return r=l.slice(0),u=v,o}for(t=new Map,n=new Array(g+1),s=g;s>=h;s--)y=l[s],c=t.get(y),n[s]=void 0===c?-1:c,t.set(y,s);for(c=h;c<=p;c++)y=r[c],s=t.get(y),void 0!==s&&-1!==s?(a[s]=o[c],d[s]=i[c],s=n[s],t.set(y,s)):i[c]();for(s=h;s<v;s++)s in a?(o[s]=a[s],i[s]=d[s]):o[s]=P(f);u=o.length=v,r=l.slice(0)}return o});function f(t){return i[s]=t,n(l[s],s)}}}}function dt(t,n){const e=Object.keys(n);for(let r=0;r<e.length;r++){const o=e[r];!(o in t)&&(t[o]=n[o])}}function ht(t){const n={},e=Object.getOwnPropertyDescriptors(t);return Object.defineProperties(n,e),n}const pt={};function gt(t){pt.hydrate=t}function yt(){let t=0;const[n,e]=j(!1);return[n,()=>0==t++&&e(!0),()=>--t<=0&&e(!1)]}const vt=F({}),[bt,wt,mt]=yt();function _t(t){return new Promise(n=>{const e=t();k(()=>!vt.active()&&n(e))})}function At(t){const[n,e]=j(t),[r,o]=j(),[i,u]=j(),c=new Set;let s,l=!1,f=null;function a(t){s=void 0,C(()=>{e(t),l&&(l=!1,u());for(let t of c.keys())t.decrement();c.clear()})}return[function(){const t=$(vt),e=n();if(f)throw f;return r(),s&&t.increment&&!c.has(t)&&(t.increment(),c.add(t)),e},function(t){return f=null,null!=t&&"object"==typeof t&&"then"in t?(s=t,l||(l=!0,C(()=>{u(),o()})),t.then(n=>{s===t&&a(n)},n=>{s===t&&(f=n,a(void 0))})):(s=void 0,a(t)),()=>(i(),l)}]}function St(t){const n=j(),[e,r]=At(t);return[()=>(e(),n[0]()),n[1],r]}vt.active=bt,vt.increment=wt,vt.decrement=mt;const Ot={get(t,n){if(n===X)return t;if(n===Z||n===Y)return;const e=t[n],r=nt(e);if(z()&&("function"!=typeof e||t.hasOwnProperty(n))){let o,i;r&&(o=rt(e))&&(i=o._||(o._=j()),i[0]()),o=rt(t),i=o[n]||(o[n]=St(e)),i[0]()}return r?tt(e):e},set:()=>!0,deleteProperty:()=>!0};function xt(t){const n=et(t||{}),e=tt(n,Ot),r={};function o(...t){C(()=>ct(n,t))}return[e,function(t,e){const i=rt(n),u=Object.keys(t);for(let c=0;c<u.length;c++){const s=u[c],l=t[s],f=t=>(e?o(s,e(t)):ut(n,s,t),t),a=(i[s]||(i[s]=St(n[s])))[2](l&&"object"==typeof l&&"then"in l?l.then(f):f(l));!(s in r)&&Object.defineProperty(r,s,{get:()=>a()})}return r},o]}function Pt(t){return n=>{const e=pt.hydrate&&pt.hydrate.registry,r=pt.hydrate?{id:`${pt.hydrate.id}.${pt.hydrate.count++}`,count:0,registry:pt.hydrate.registry}:void 0;let o,i,u,c;return e?([o,i]=j(),t().then(t=>i(t.default))):([o,u]=At(),u(t().then(t=>t.default))),T(()=>(c=o())&&E(()=>{if(!r)return c(n);const t=pt.hydrate;gt(r);const e=c(n);return!t&>(),e}))}}function jt(t){const[n,e,r]=yt();return[n,n=>{const o=vt.transition;vt.transition={timeoutMs:t.timeoutMs,increment:e,decrement:r},e(),n(),r(),D(()=>vt.transition=o)}]}function kt(t){const{state:n}=$(vt);let e;return n?()=>"suspended"===n()?e:e=t():t}var Mt,Tt=e(0);const Rt=Object(Tt.a)(),Ct=null!==(Mt=Rt.SOLID)&&void 0!==Mt?Mt:Rt.SOLID=r,{createSignal:Et,createEffect:Dt,createRoot:Lt,sample:It}=Ct;function zt(){return this()}function Ft(t){return this(t)}function $t(t){const[n,e]=Et(t),r=t=>void 0===t?n():(e(t),t);return r.get=zt.bind(r),r.set=Ft.bind(r),r}function qt(t){let n;return Lt(e=>{n=e,Dt(t)}),n}function Vt(t,n,e){let r=t[n];return r||(t[n]=r=$t(e),r)}function Wt(t,n,e){const r=1===arguments.length&&"kind"in t;if(r){const n=t;return"class"===n.kind?{...n,finisher:Ut}:{...n,finisher(t){var e,r;return Gt(t.prototype,n.key),null!==(r=null===(e=n.finisher)||void 0===e?void 0:e.call(n,t))&&void 0!==r?r:t}}}if(1===arguments.length&&"function"==typeof t){return Ut(t)}return Gt(t,n,e)}function Ut(t){var n;return(n=class extends t{constructor(...n){super(...n),Ht(this,t)}}).__isReactive__=!0,n}const Bt=new WeakMap;function Gt(t,n,e){let r=Bt.get(t.constructor);r||Bt.set(t.constructor,r=[]),r.push(n);const o="v_"+n;let i,u,c,s=!1;if(e&&!("initializer"in e)||(s=!0,e||(e=Object.getOwnPropertyDescriptor(t,n))),e)if(i=e.get,u=e.set,i||u){if(!i||!u)return void console.warn('The `@reactive` decorator was used on an accessor named "'+n+'" which had a getter or a setter, but not both. Reactivity on accessors works only when accessors have both get and set. In this case the decorator does not do anything.');delete e.get,delete e.set}else{if(c=e.value,!e.writable)return void console.warn("The `@reactive` decorator was used on a property named "+n+" that is not writable. Reactivity is not enabled for non-writable properties.");delete e.value,delete e.writable}if(e={...e,get(){const t=Vt(this,o,c);return i?(t(),i.call(this)):t()},set(t){const e=Vt(this,o);u&&u.call(this,t),e(t),this.__propsSetAtLeastOnce__||(this.__propsSetAtLeastOnce__=new Set),this.__propsSetAtLeastOnce__.add(n)}},t.__reactifiedProps__||(t.__reactifiedProps__=new Set),t.__reactifiedProps__.add(n),!s)return e;Object.defineProperty(t,n,e)}function Ht(t,n){if(function(t){return"function"==typeof t}(n)){const e=n;let r=Bt.get(e);r&&function(t,n){for(const e of n)if(t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}}(t,r),r=e.reactiveProperties,Array.isArray(r)&&Jt(t,r)}else{Jt(t,n)}return t}function Jt(t,n){var e;for(const r of n){if(null===(e=t.__reactifiedProps__)||void 0===e?void 0:e.has(r))continue;const n=t[r];Gt(t,r),t[r]=n}}const Kt=It,Nt="0.2.2"}]); | ||
LUME=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";(function(t){function r(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:Function("return this")()}n.d(e,"a",(function(){return r}))}).call(this,n(1))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"variable",(function(){return $t})),n.d(e,"autorun",(function(){return qt})),n.d(e,"reactive",(function(){return Vt})),n.d(e,"reactify",(function(){return Ht})),n.d(e,"untrack",(function(){return Kt})),n.d(e,"version",(function(){return Nt}));var r={};n.r(r),n.d(r,"$RAW",(function(){return X})),n.d(r,"SuspenseContext",(function(){return vt})),n.d(r,"afterEffects",(function(){return E})),n.d(r,"awaitSuspense",(function(){return mt})),n.d(r,"cancelCallback",(function(){return p})),n.d(r,"cloneProps",(function(){return ht})),n.d(r,"createContext",(function(){return F})),n.d(r,"createDeferred",(function(){return L})),n.d(r,"createDependentEffect",(function(){return M})),n.d(r,"createEffect",(function(){return k})),n.d(r,"createMemo",(function(){return T})),n.d(r,"createResource",(function(){return St})),n.d(r,"createResourceState",(function(){return xt})),n.d(r,"createRoot",(function(){return P})),n.d(r,"createSignal",(function(){return j})),n.d(r,"createState",(function(){return ct})),n.d(r,"equalFn",(function(){return y})),n.d(r,"freeze",(function(){return R})),n.d(r,"getContextOwner",(function(){return q})),n.d(r,"isListening",(function(){return z})),n.d(r,"lazy",(function(){return Pt})),n.d(r,"mapArray",(function(){return at})),n.d(r,"onCleanup",(function(){return D})),n.d(r,"onError",(function(){return I})),n.d(r,"reconcile",(function(){return lt})),n.d(r,"requestCallback",(function(){return h})),n.d(r,"runtimeConfig",(function(){return pt})),n.d(r,"sample",(function(){return C})),n.d(r,"setDefaults",(function(){return dt})),n.d(r,"suspend",(function(){return kt})),n.d(r,"unwrap",(function(){return nt})),n.d(r,"useContext",(function(){return $})),n.d(r,"useTransition",(function(){return jt}));let o=1,i=!1,u=!1,s=[],c=null,l=null,f=0,a=null,d=null;function h(t,e){a||function(){if(window&&window.MessageChannel){const t=new MessageChannel,e=t.port2;a=()=>e.postMessage(null),t.port1.onmessage=()=>{if(null!==d){const t=performance.now();f=t+5;const n=!0;try{d(n,t)?e.postMessage(null):d=null}catch(t){throw e.postMessage(null),t}}}}else{let t;a=()=>{t||(t=d,setTimeout(()=>{const e=performance.now();f=e+5;const n=t(!0,e);t=null,n&&a()},0))}}if(navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){const t=navigator.scheduling;l=()=>{const e=performance.now();return e>=f&&(!!t.isInputPending()||e>=300)}}else l=()=>performance.now()>=f}();let n=performance.now(),r=1073741823;e&&e.timeout&&(r=e.timeout);const c={id:o++,fn:t,startTime:n,expirationTime:n+r};return function(t,e){t.splice(function(){let n=0,r=t.length-1;for(;n<=r;){let o=r+n>>1,i=e.expirationTime-t[o].expirationTime;if(i>0)n=o+1;else{if(!(i<0))return o;r=o-1}}return n}(),0,e)}(s,c),i||u||(i=!0,d=g,a()),c}function p(t){t.fn=null}function g(t,e){i=!1,u=!0;try{return function(t,e){let n=e;c=s[0]||null;for(;null!==c&&(!(c.expirationTime>n)||t&&!l());){const t=c.fn;if(null!==t){c.fn=null;const e=c.expirationTime<=n;t(e),n=performance.now(),c===s[0]&&s.shift()}else s.shift();c=s[0]||null}return null!==c}(t,e)}finally{c=null,u=!1}}const y=(t,e)=>t===e,v=Symbol("error"),b={},w={owned:null,cleanups:null,context:null,owner:null};let _=null,m=null,S=null,A=null,O=[],x=0;function P(t,e){e&&(_=e);const n=m,r=_,o=0===t.length?w:{owned:null,cleanups:null,context:null,owner:r};let i;_=o,m=null;try{i=t(()=>K(o))}catch(t){const e=N(_,v);if(!e)throw t;e.forEach(e=>e(t))}finally{for(;O.length;)O.shift()();m=n,_=r}return i}function j(t,e){const n={value:t,observers:null,observerSlots:null,pending:b,comparator:e};return[V.bind(n),W.bind(n)]}function k(t,e){U(B(t,e))}function M(t,e,n){const r=Array.isArray(e)?(o=e,()=>{for(let t=0;t<o.length;t++)o[t]()}):e;var o;n=!!n,k(e=>{const o=m;return r(),n?n=!1:(m=null,e=t(e),m=o),e})}function T(t,e,n){const r=B(t,e);return r.pending=b,r.observers=null,r.observerSlots=null,r.comparator=n,U(r),V.bind(r)}function L(t,e){let n,r=e?e.timeoutMs:void 0;const[o,i]=j(t());return k(()=>{t(),n&&n.fn||(n=h(()=>i(t()),void 0!==r?{timeout:r}:void 0))}),o}function R(t){let e=S,n=S=[];const r=t();return S=e,H(()=>{for(let t=0;t<n.length;t+=1){const e=n[t];if(e.pending!==b){const t=e.pending;e.pending=b,W.call(e,t)}}}),r}function C(t){let e,n=m;return m=null,e=t(),m=n,e}function E(t){O.push(t)}function D(t){return null===_?console.warn("cleanups created outside a `createRoot` or `render` will never be run"):null===_.cleanups?_.cleanups=[t]:_.cleanups.push(t),t}function I(t){null===_?console.warn("error handlers created outside a `createRoot` or `render` will never be run"):null===_.context?_.context={[v]:[t]}:_.context[v]?_.context[v].push(t):_.context[v]=[t]}function z(){return null!==m}function F(t){const e=Symbol("context");return{id:e,Provider:Q(e),defaultValue:t}}function $(t){return N(_,t.id)||t.defaultValue}function q(){return _}function V(){if(this.state&&this.sources){const t=A;A=null,1===this.state?U(this):function t(e){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];r.sources&&(1===r.state?G(r):2===r.state&&t(r))}}(this),A=t}if(m){const t=this.observers?this.observers.length:0;m.sources?(m.sources.push(this),m.sourceSlots.push(t)):(m.sources=[this],m.sourceSlots=[t]),this.observers?(this.observers.push(m),this.observerSlots.push(m.sources.length-1)):(this.observers=[m],this.observerSlots=[m.sources.length-1])}return this.value}function W(t){if(!this.comparator||!this.comparator(this.value,t)){if(S)return this.pending===b&&S.push(this),void(this.pending=t);this.value=t,!this.observers||A&&!this.observers.length||H(()=>{for(let t=0;t<this.observers.length;t+=1){const e=this.observers[t];if(e.observers&&2!==e.state&&J(e),e.state=1,A.length>1e6)throw new Error("Potential Infinite Loop Detected.");A.push(e)}})}}function U(t){if(!t.fn)return;K(t);const e=_,n=m,r=x;m=_=t;const o=t.fn(t.value);(!t.updatedAt||t.updatedAt<=r)&&(t.observers&&t.observers.length?W.call(t,o):t.value=o,t.updatedAt=r),m=n,_=e}function B(t,e){const n={fn:t,state:0,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:_,context:null};return null===_?console.warn("computations created outside a `createRoot` or `render` will never be disposed"):_!==w&&(_.owned?_.owned.push(n):_.owned=[n]),n}function G(t){let e=1===t.state&&t;for(;t.fn&&(t=t.owner);)1===t.state&&(e=t);e&&U(e)}function H(t){if(A)return t();A=[],x++;try{t();for(let t=0;t<A.length;t+=1)try{G(A[t])}catch(t){const e=N(_,v);if(!e)throw t;e.forEach(e=>e(t))}}finally{for(A=null;O.length;)O.shift()()}}function J(t){for(let e=0;e<t.observers.length;e+=1){const n=t.observers[e];n.state||(n.state=2,n.observers&&J(n))}}function K(t){let e;if(t.sources){for(;t.sources.length;){const e=t.sources.pop(),n=t.sourceSlots.pop(),r=e.observers;if(r&&r.length){const t=r.pop(),o=e.observerSlots.pop();n<r.length&&(t.sourceSlots[o]=n,r[n]=t,e.observerSlots[n]=o)}}t.state=0}if(t.owned){for(e=0;e<t.owned.length;e++)K(t.owned[e]);t.owned=null}if(t.cleanups){for(e=0;e<t.cleanups.length;e++)t.cleanups[e]();t.cleanups=null}}function N(t,e){return t&&(t.context&&t.context[e]||t.owner&&N(t.owner,e))}function Q(t){return function(e){let n;return k(()=>{_.context={[t]:e.value},n=C(()=>function t(e){if("function"==typeof e)return T(()=>t(e()));if(Array.isArray(e)){const n=[];for(let r=0;r<e.length;r++){let o=t(e[r]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}(e.children))}),n}}const X=Symbol("state-raw"),Y=Symbol("state-node"),Z=Symbol("state-proxy");function tt(t,e){return t[Z]||(t[Z]=new Proxy(t,e||ot))}function et(t){return null!=t&&"object"==typeof t&&(t.__proto__===Object.prototype||Array.isArray(t))}function nt(t){let e,n,r;if(e=null!=t&&t[X])return e;if(!et(t))return t;if(Array.isArray(t)){Object.isFrozen(t)&&(t=t.slice(0));for(let e=0,o=t.length;e<o;e++)r=t[e],(n=nt(r))!==r&&(t[e]=n)}else{Object.isFrozen(t)&&(t=Object.assign({},t));let e=Object.keys(t);for(let o=0,i=e.length;o<i;o++)r=t[e[o]],(n=nt(r))!==r&&(t[e[o]]=n)}return t}function rt(t){let e=t[Y];return e||(t[Y]=e={}),e}const ot={get(t,e){if(e===X)return t;if(e===Z||e===Y)return;const n=t[e],r=et(n);if(z()&&("function"!=typeof n||t.hasOwnProperty(e))){let o,i;r&&(o=rt(n))&&(i=o._||(o._=j()),i[0]()),o=rt(t),i=o[e]||(o[e]=j()),i[0]()}return r?tt(n):n},set:()=>!0,deleteProperty:()=>!0},it={get(t,e){if(e===X)return t;const n=t[e];return et(n)?new Proxy(n,it):n},set:(t,e,n)=>(ut(t,e,nt(n)),!0),deleteProperty:(t,e)=>(ut(t,e,void 0),!0)};function ut(t,e,n,r){if(!r&&t[e]===n)return;const o=Array.isArray(t)||!(e in t);void 0===n?delete t[e]:t[e]=n;let i,u=rt(t);(i=u[e])&&i[1](),o&&(i=u._)&&i[1]()}function st(t,e,n=[]){let r,o=t;if(e.length>1){r=e.shift();const i=typeof r,u=Array.isArray(t);if(Array.isArray(r)){for(let o=0;o<r.length;o++)st(t,[r[o]].concat(e),[r[o]].concat(n));return}if(u&&"function"===i){for(let o=0;o<t.length;o++)r(t[o],o)&&st(t,[o].concat(e),[o].concat(n));return}if(u&&"object"===i){const{from:o=0,to:i=t.length-1,by:u=1}=r;for(let r=o;r<=i;r+=u)st(t,[r].concat(e),[r].concat(n));return}if(e.length>1)return void st(t[r],e,[r].concat(n));o=t[r],n=[r].concat(n)}let i=e[0];if("function"==typeof i){const t=void 0===r||et(o)?new Proxy(o,it):o;if(i=i(t,n),i===t||void 0===i)return}i=nt(i),void 0===r||et(o)&&et(i)&&!Array.isArray(i)?function(t,e,n){const r=Object.keys(e);for(let o=0;o<r.length;o+=1){const i=r[o];ut(t,i,e[i],n)}}(o,i):ut(t,r,i)}function ct(t){const e=nt(t||{});return[tt(e),function(...t){R(()=>st(e,t))}]}function lt(t,e={}){const{merge:n,key:r="id"}=e;return e=>{if(!et(e=nt(e)))return t;!function t(e,n,r,o,i){let u=n[r];if(e===u)return;if(!et(e)||!et(u)||i&&e[i]!==u[i])return void(e!==u&&ut(n,r,e));if(Array.isArray(e)){if(e.length&&u.length&&(!o||i&&null!=e[0][i])){let n,r,s,c,l,f,a,d;for(s=0,c=Math.min(u.length,e.length);s<c&&(u[s]===e[s]||i&&u[s][i]===e[s][i]);s++)t(e[s],u,s,o,i);const h=new Array(e.length),p=new Map;for(c=u.length-1,l=e.length-1;c>=s&&l>=s&&(u[c]===e[l]||i&&u[c][i]===e[l][i]);c--,l--)h[l]=u[c];if(s>l||s>c){for(r=s;r<=l;r++)ut(u,r,e[r]);for(;r<e.length;r++)ut(u,r,h[r]),t(e[r],u,r,o,i);return void(u.length>e.length&&ut(u,"length",e.length))}for(a=new Array(l+1),r=l;r>=s;r--)f=e[r],d=i?f[i]:f,n=p.get(d),a[r]=void 0===n?-1:n,p.set(d,r);for(n=s;n<=c;n++)f=u[n],d=i?f[i]:f,r=p.get(d),void 0!==r&&-1!==r&&(h[r]=u[n],r=a[r],p.set(d,r));for(r=s;r<e.length;r++)r in h?(ut(u,r,h[r]),t(e[r],u,r,o,i)):ut(u,r,e[r])}else for(let n=0,r=e.length;n<r;n++)t(e[n],u,n,o,i);return void(u.length>e.length&&ut(u,"length",e.length))}const s=Object.keys(e);for(let n=0,r=s.length;n<r;n++)t(e[s[n]],u,s[n],o,i);const c=Object.keys(u);for(let t=0,n=c.length;t<n;t++)void 0===e[c[t]]&&ut(u,c[t],void 0)}(t,{state:e},"state",n,r)}}const ft=Symbol("fallback");function at(t,e,n){return"function"!=typeof e?(n=e||{},e=t,r):(n||(n={}),r(t));function r(t){let r=[],o=[],i=[],u=0;return D(()=>{for(let t=0,e=i.length;t<e;t++)i[t]()}),()=>{let s,c,l=t()||[];return C(()=>{let t,e,a,d,h,p,g,y,v=l.length;if(0===v){if(0!==u){for(s=0;s<u;s++)i[s]();i=[],r=[],o=[],u=0}n.fallback&&(r=[ft],o[0]=P(t=>(i[0]=t,n.fallback())),u=1)}else if(0===u){for(c=0;c<v;c++)r[c]=l[c],o[c]=P(f);u=v}else{for(a=new Array(v),d=new Array(v),h=0,p=Math.min(u,v);h<p&&r[h]===l[h];h++);for(p=u-1,g=v-1;p>=h&&g>=h&&r[p]===l[g];p--,g--)a[g]=o[p],d[g]=i[p];if(h>g){for(c=p;h<=c;c--)i[c]();const t=p-h+1;return t>0&&(o.splice(h,t),i.splice(h,t)),r=l.slice(0),u=v,o}if(h>p){for(c=h;c<=g;c++)o[c]=P(f);for(;c<v;c++)o[c]=a[c],i[c]=d[c];return r=l.slice(0),u=v,o}for(t=new Map,e=new Array(g+1),c=g;c>=h;c--)y=l[c],s=t.get(y),e[c]=void 0===s?-1:s,t.set(y,c);for(s=h;s<=p;s++)y=r[s],c=t.get(y),void 0!==c&&-1!==c?(a[c]=o[s],d[c]=i[s],c=e[c],t.set(y,c)):i[s]();for(c=h;c<v;c++)c in a?(o[c]=a[c],i[c]=d[c]):o[c]=P(f);u=o.length=v,r=l.slice(0)}return o});function f(t){return i[c]=t,e(l[c],c)}}}}function dt(t,e){const n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r];!(o in t)&&(t[o]=e[o])}}function ht(t){const e={},n=Object.getOwnPropertyDescriptors(t);return Object.defineProperties(e,n),e}const pt={};function gt(t){pt.hydrate=t}function yt(){let t=0;const[e,n]=j(!1);return[e,()=>0==t++&&n(!0),()=>--t<=0&&n(!1)]}const vt=F({}),[bt,wt,_t]=yt();function mt(t){return new Promise(e=>{const n=t();k(()=>!vt.active()&&e(n))})}function St(t){const[e,n]=j(t),[r,o]=j(),[i,u]=j(),s=new Set;let c,l=!1,f=null;function a(t){c=void 0,R(()=>{n(t),l&&(l=!1,u());for(let t of s.keys())t.decrement();s.clear()})}return[function(){const t=$(vt),n=e();if(f)throw f;return r(),c&&t.increment&&!s.has(t)&&(t.increment(),s.add(t)),n},function(t){return f=null,null!=t&&"object"==typeof t&&"then"in t?(c=t,l||(l=!0,R(()=>{u(),o()})),t.then(e=>{c===t&&a(e)},e=>{c===t&&(f=e,a(void 0))})):(c=void 0,a(t)),()=>(i(),l)}]}function At(t){const e=j(),[n,r]=St(t);return[()=>(n(),e[0]()),e[1],r]}vt.active=bt,vt.increment=wt,vt.decrement=_t;const Ot={get(t,e){if(e===X)return t;if(e===Z||e===Y)return;const n=t[e],r=et(n);if(z()&&("function"!=typeof n||t.hasOwnProperty(e))){let o,i;r&&(o=rt(n))&&(i=o._||(o._=j()),i[0]()),o=rt(t),i=o[e]||(o[e]=At(n)),i[0]()}return r?tt(n):n},set:()=>!0,deleteProperty:()=>!0};function xt(t){const e=nt(t||{}),n=tt(e,Ot),r={};function o(...t){R(()=>st(e,t))}return[n,function(t,n){const i=rt(e),u=Object.keys(t);for(let s=0;s<u.length;s++){const c=u[s],l=t[c],f=t=>(n?o(c,n(t)):ut(e,c,t),t),a=(i[c]||(i[c]=At(e[c])))[2](l&&"object"==typeof l&&"then"in l?l.then(f):f(l));!(c in r)&&Object.defineProperty(r,c,{get:()=>a()})}return r},o]}function Pt(t){return e=>{const n=pt.hydrate&&pt.hydrate.registry,r=pt.hydrate?{id:`${pt.hydrate.id}.${pt.hydrate.count++}`,count:0,registry:pt.hydrate.registry}:void 0;let o,i,u,s;return n?([o,i]=j(),t().then(t=>i(t.default))):([o,u]=St(),u(t().then(t=>t.default))),T(()=>(s=o())&&C(()=>{if(!r)return s(e);const t=pt.hydrate;gt(r);const n=s(e);return!t&>(),n}))}}function jt(t){const[e,n,r]=yt();return[e,e=>{const o=vt.transition;vt.transition={timeoutMs:t.timeoutMs,increment:n,decrement:r},n(),e(),r(),E(()=>vt.transition=o)}]}function kt(t){const{state:e}=$(vt);let n;return e?()=>"suspended"===e()?n:n=t():t}var Mt,Tt=n(0);const Lt=Object(Tt.a)(),Rt=null!==(Mt=Lt.SOLID)&&void 0!==Mt?Mt:Lt.SOLID=r,{createSignal:Ct,createEffect:Et,createRoot:Dt,sample:It}=Rt;function zt(){return this()}function Ft(t){return this(t)}function $t(t){const[e,n]=Ct(t),r=t=>void 0===t?e():(n(t),t);return r.get=zt.bind(r),r.set=Ft.bind(r),r}function qt(t){let e;return Dt(n=>{e=n,Et(t)}),e}function Vt(t,e,n){const r=1===arguments.length&&"kind"in t;if(r){const e=t;return"class"===e.kind?{...e,finisher:Wt}:{...e,finisher(t){var n,r;return Bt(t.prototype,e.key),null!==(r=null===(n=e.finisher)||void 0===n?void 0:n.call(e,t))&&void 0!==r?r:t}}}if(1===arguments.length&&"function"==typeof t){return Wt(t)}return Bt(t,e,n)}function Wt(t){var e;return(e=class extends t{constructor(...e){super(...e),Ht(this,t)}}).__isReactive__=!0,e}const Ut=new WeakMap;function Bt(t,e,n){let r=Ut.get(t.constructor);r||Ut.set(t.constructor,r=[]),r.push(e);const o="v_"+e;let i,u,s,c=!1;if(n&&!("initializer"in n)||(c=!0,n||(n=Object.getOwnPropertyDescriptor(t,e))),n)if(i=n.get,u=n.set,i||u){if(!i||!u)return void console.warn('The `@reactive` decorator was used on an accessor named "'+e+'" which had a getter or a setter, but not both. Reactivity on accessors works only when accessors have both get and set. In this case the decorator does not do anything.');delete n.get,delete n.set}else{if(s=n.value,!n.writable)return void console.warn("The `@reactive` decorator was used on a property named "+e+" that is not writable. Reactivity is not enabled for non-writable properties.");delete n.value,delete n.writable}if(n={...n,get:i?function(){return Gt(this,o,s)(),i.call(this)}:function(){return Gt(this,o,s)()},set:u?function(t){u.call(this,t);Gt(this,o)(t),this.__propsSetAtLeastOnce__||(this.__propsSetAtLeastOnce__=new Set),this.__propsSetAtLeastOnce__.add(e)}:function(t){Gt(this,o)(t),this.__propsSetAtLeastOnce__||(this.__propsSetAtLeastOnce__=new Set),this.__propsSetAtLeastOnce__.add(e)}},t.__reactifiedProps__||(t.__reactifiedProps__=new Set),t.__reactifiedProps__.add(e),!c)return n;Object.defineProperty(t,e,n)}function Gt(t,e,n){let r=t[e];return r||(t[e]=r=$t(n),r)}function Ht(t,e){if(function(t){return"function"==typeof t}(e)){const n=e;let r=Ut.get(n);r&&function(t,e){for(const n of e)if(t.hasOwnProperty(n)){const e=t[n];delete t[n],t[n]=e}}(t,r),r=n.reactiveProperties,Array.isArray(r)&&Jt(t,r)}else{Jt(t,e)}return t}function Jt(t,e){var n;for(const r of e){if(null===(n=t.__reactifiedProps__)||void 0===n?void 0:n.has(r))continue;const e=t[r];Bt(t,r),t[r]=e}}const Kt=It,Nt="0.2.3"}]); | ||
//# sourceMappingURL=global.js.map | ||
@@ -18,3 +18,3 @@ import * as SOLID from 'solid-js'; | ||
export declare const untrack: typeof SOLID.sample; | ||
export declare const version = "0.2.2"; | ||
export declare const version = "0.2.3"; | ||
export {}; |
@@ -33,9 +33,2 @@ var _a; | ||
} | ||
function __getReactiveVar(instance, vName, initialValue = undefined) { | ||
let v = instance[vName]; | ||
if (v) | ||
return v; | ||
instance[vName] = v = variable(initialValue); | ||
return v; | ||
} | ||
export function reactive(protoOrClassElement, name, descriptor) { | ||
@@ -117,19 +110,28 @@ const isDecoratorV2 = arguments.length === 1 && 'kind' in protoOrClassElement; | ||
...descriptor, | ||
get() { | ||
const v = __getReactiveVar(this, vName, initialValue); | ||
if (originalGet) { | ||
get: originalGet | ||
? function () { | ||
const v = __getReactiveVar(this, vName, initialValue); | ||
v(); | ||
return originalGet.call(this); | ||
} | ||
return v(); | ||
}, | ||
set(newValue) { | ||
const v = __getReactiveVar(this, vName); | ||
if (originalSet) | ||
: function () { | ||
const v = __getReactiveVar(this, vName, initialValue); | ||
return v(); | ||
}, | ||
set: originalSet | ||
? function (newValue) { | ||
originalSet.call(this, newValue); | ||
v(newValue); | ||
if (!this.__propsSetAtLeastOnce__) | ||
this.__propsSetAtLeastOnce__ = new Set(); | ||
this.__propsSetAtLeastOnce__.add(propName); | ||
}, | ||
const v = __getReactiveVar(this, vName); | ||
v(newValue); | ||
if (!this.__propsSetAtLeastOnce__) | ||
this.__propsSetAtLeastOnce__ = new Set(); | ||
this.__propsSetAtLeastOnce__.add(propName); | ||
} | ||
: function (newValue) { | ||
const v = __getReactiveVar(this, vName); | ||
v(newValue); | ||
if (!this.__propsSetAtLeastOnce__) | ||
this.__propsSetAtLeastOnce__ = new Set(); | ||
this.__propsSetAtLeastOnce__.add(propName); | ||
}, | ||
}; | ||
@@ -145,2 +147,9 @@ if (!prototype.__reactifiedProps__) | ||
} | ||
function __getReactiveVar(instance, vName, initialValue = undefined) { | ||
let v = instance[vName]; | ||
if (v) | ||
return v; | ||
instance[vName] = v = variable(initialValue); | ||
return v; | ||
} | ||
export function reactify(obj, propsOrClass) { | ||
@@ -185,3 +194,3 @@ if (isClass(propsOrClass)) { | ||
export const untrack = sample; | ||
export const version = '0.2.2'; | ||
export const version = '0.2.3'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@lume/variable", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Create and react to reactive variables.", | ||
@@ -5,0 +5,0 @@ "author": "Joe Pea <joe@trusktr.io>", |
@@ -89,15 +89,2 @@ import * as SOLID from 'solid-js' | ||
function __getReactiveVar<T>(instance: Obj<Variable<T>>, vName: string, initialValue: T = undefined!): Variable<T> { | ||
// NOTE alternatively, we could use a WeakMap instead of exposing the | ||
// variable on the instance. We could also use Symbols keys for | ||
// semi-privacy. | ||
let v: Variable<T> = instance[vName] | ||
if (v) return v | ||
instance[vName] = v = variable<T>(initialValue) | ||
return v | ||
} | ||
export function reactive(protoOrClassElement: any, name?: string, descriptor?: PropertyDescriptor): any { | ||
@@ -227,32 +214,41 @@ // If used as a newer Babel decorator | ||
...descriptor, | ||
get(this: any): unknown { | ||
// XXX this causes initialValue to be held onto even if the original | ||
// prototype value has changed. In pratice the original prototype | ||
// values usually never change, and these days people don't normally | ||
// use prototype values to begin with. | ||
const v = __getReactiveVar(this, vName, initialValue) | ||
get: originalGet | ||
? function(this: any): unknown { | ||
// track reactivity, but get the value from the original getter | ||
if (originalGet) { | ||
// track reactivity, but get the value from the original getter | ||
v() | ||
return originalGet.call(this) | ||
} | ||
// XXX this causes initialValue to be held onto even if the original | ||
// prototype value has changed. In pratice the original prototype | ||
// values usually never change, and these days people don't normally | ||
// use prototype values to begin with. | ||
const v = __getReactiveVar(this, vName, initialValue) | ||
v() | ||
return v() | ||
}, | ||
set(this: any, newValue: unknown) { | ||
const v = __getReactiveVar(this, vName) | ||
return originalGet!.call(this) | ||
} | ||
: function(this: any): unknown { | ||
const v = __getReactiveVar(this, vName, initialValue) | ||
return v() | ||
}, | ||
set: originalSet | ||
? function(this: any, newValue: unknown) { | ||
originalSet!.call(this, newValue) | ||
if (originalSet) originalSet.call(this, newValue) | ||
const v = __getReactiveVar(this, vName) | ||
v(newValue) | ||
v(newValue) | ||
// XXX __propsSetAtLeastOnce__ is a Set that tracks which reactive | ||
// properties have been set at least once. @lume/element uses this | ||
// to detect if a reactive prop has been set, and if so will not | ||
// overwrite the value with any value from custom element | ||
// pre-upgrade. | ||
if (!this.__propsSetAtLeastOnce__) this.__propsSetAtLeastOnce__ = new Set<string>() | ||
this.__propsSetAtLeastOnce__.add(propName) | ||
} | ||
: function(this: any, newValue: unknown) { | ||
const v = __getReactiveVar(this, vName) | ||
v(newValue) | ||
// XXX __propsSetAtLeastOnce__ is a Set that tracks which reactive | ||
// properties have been set at least once. @lume/element uses this | ||
// to detect if a reactive prop has been set, and if so will not | ||
// overwrite the value with any value from custom element | ||
// pre-upgrade. | ||
if (!this.__propsSetAtLeastOnce__) this.__propsSetAtLeastOnce__ = new Set<string>() | ||
this.__propsSetAtLeastOnce__.add(propName) | ||
}, | ||
if (!this.__propsSetAtLeastOnce__) this.__propsSetAtLeastOnce__ = new Set<string>() | ||
this.__propsSetAtLeastOnce__.add(propName) | ||
}, | ||
} | ||
@@ -276,2 +272,15 @@ | ||
function __getReactiveVar<T>(instance: Obj<Variable<T>>, vName: string, initialValue: T = undefined!): Variable<T> { | ||
// NOTE alternatively, we could use a WeakMap instead of exposing the | ||
// variable on the instance. We could also use Symbols keys for | ||
// semi-privacy. | ||
let v: Variable<T> = instance[vName] | ||
if (v) return v | ||
instance[vName] = v = variable<T>(initialValue) | ||
return v | ||
} | ||
type AnyClass = new (...args: any[]) => object | ||
@@ -337,2 +346,2 @@ type AnyClassWithReactiveProps = (new (...args: any[]) => object) & {reactiveProperties?: string[]} | ||
export const version = '0.2.2' | ||
export const version = '0.2.3' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
181255
1690