@calmdown/pyxis 1.0.0-rc.2 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-dev.d.ts +606 -358
- package/dist/core-dev.js +1316 -875
- package/dist/core-dev.js.map +1 -1
- package/dist/core.d.ts +620 -322
- package/dist/core.js +2028 -1
- package/dist/core.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +2 -4
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/package.json +2 -6
- package/dist/main.d.ts +0 -67
- package/dist/main.js +0 -29
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2029 @@
|
|
|
1
|
-
function e(e){return e.$fn(e.$a0,e.$a1)}function t(e,t=s()){n(t,{$fn:r,$a0:t,$a1:e})}function n(e,t){(e.$onMount??=[]).push(t)}function r(e,t){let n=t();n&&a(e,{$fn:n})}function i(e,t=s()){a(t,{$fn:e})}function a(e,t){(e.$onUnmount??=[]).push(t)}let o=null;function s(){return o}function c(e){let t=o;return o=e,t}function l(e,t,n){let r=o;o=e;try{return t(n)}finally{o=r}}function u(e,t,n){d(e,t,{$fn:n}),n()}function d(e,t,n){t.$dt?(t.$dt.$an=n,n.$ap=t.$dt):t.$dh=n,n.$target=t,t.$dt=n,e.$dt?(e.$dt.$ln=n,n.$lp=e.$dt):e.$dh=n,n.$lifecycle=e,e.$dt=n}function f(e){let t=e.$target;if(!t)return;e.$ap?e.$ap.$an=e.$an:t.$dh===e&&(t.$dh=e.$an),e.$an?e.$an.$ap=e.$ap:t.$dt===e&&(t.$dt=e.$ap),e.$target=null,e.$ap=null,e.$an=null;let n=e.$lifecycle;e.$lp?e.$lp.$ln=e.$ln:n.$dh===e&&(n.$dh=e.$ln),e.$ln?e.$ln.$lp=e.$lp:n.$dt===e&&(n.$dt=e.$lp),e.$lifecycle=null,e.$lp=null,e.$ln=null}function p(e){let t=e.$dh,n,r;for(;t;)n=t.$target,t.$ap?t.$ap.$an=t.$an:n.$dh===t&&(n.$dh=t.$an),t.$an?t.$an.$ap=t.$ap:n.$dt===t&&(n.$dt=t.$ap),r=t.$ln,t.$lifecycle=null,t.$target=null,t.$ap=null,t.$an=null,t.$lp=null,t.$ln=null,t=r;e.$dh=null,e.$dt=null}function m(t){let n=!1,r=[],i=[],a={$epoch:1,$onTick:r,$onTock:i,$scheduleTick:()=>{n||(n=!0,t(o))}},o=()=>{try{let t=0,n;for(;t<r.length;t+=1)n=r[t],n.$life===n.$lifecycle.$life&&e(n);for(t=0;t<i.length;t+=1)n=i[t],n.$life===n.$lifecycle.$life&&e(n)}finally{n=!1,r.length=0,i.length=0,a.$epoch+=1}};return a}function h(e,t,n){let r=e.$scheduler;n.$se!==r.$epoch&&(n.$lifecycle=e,n.$life=e.$life,n.$se=r.$epoch,t.push(n),r.$scheduleTick())}function g(e,t){h(e,e.$scheduler.$onTick,t)}function _(e,t=s()){h(t,t.$scheduler.$onTick,{$fn:e})}function v(e,t){h(e,e.$scheduler.$onTock,t)}function y(e,t=s()){h(t,t.$scheduler.$onTock,{$fn:e})}function b(e,t=s()){S({$lifecycle:t,$life:t.$life,$block:e,$react:x,$cycle:0})}function x(e,t){if(e.$cycle>t){f(this);return}g(e.$lifecycle,e.$resolve??={$fn:S,$a0:e})}function S(e){e.$life===e.$lifecycle.$life&&(e.$dispose?.(),e.$dispose=T(e),!e.$tracksUnmount&&e.$dispose&&(e.$tracksUnmount=!0,a(e.$lifecycle,{$fn:C,$a0:e})))}function C(e){e.$dispose?.(),e.$dispose=null}let w=null;function T(e){e.$deps??=new WeakMap,e.$cycle+=1;let t=w,n=c(e.$lifecycle);w=e;try{return e.$block()}finally{c(n),w=t}}function E(e){if(!w||w.$life!==w.$lifecycle.$life)return;let t=w.$deps.get(e);t?(t.$a1=w.$cycle,t.$lifecycle||d(w.$lifecycle,e,t)):(d(w.$lifecycle,e,t={$fn:w.$react,$a0:w,$a1:w.$cycle}),w.$deps.set(e,t))}function D(e){let t=w;w=null;try{return e()}finally{w=t}}const O=Symbol();function k(e,t=s()){return M(e)?e:{[O]:!0,$value:e,$tracksValue:!0,$lifecycle:t,$lastValue:e,get:A,set:j}}function A(){return this.$value}function j(e){return Object.is(this.$value,e)?!1:(this.$value=e,!0)}function M(e){return typeof e==`object`&&!!e&&e[O]===!0}function N(e){return M(e)?(E(e),e.get()):e}function ee(e){return M(e)?e.get():e}function te(e,t,n=!1){return M(e)?((e.set(t)||n)&&(e.$force||=n,g(e.$lifecycle,e.$notify??={$fn:P,$a0:e})),e.get()):e}function ne(e,t,n=!1){return M(e)?((e.set(t(e.get()))||n)&&(e.$force||=n,g(e.$lifecycle,e.$notify??={$fn:P,$a0:e})),e.get()):e}function P(t){if(t.$tracksValue){let e=t.get();if(Object.is(t.$lastValue,e)&&!t.$force)return;t.$lastValue=e}t.$force=!1;let n=t.$dh,r;for(;n;)r=n.$an,e(n),n=r}function re(e,t,n,r,i,a){let{adapter:o}=t.$ng,s=null;M(e)?u(t.$ng,e,()=>{s=o.text(e.get()?.toString()??``,s)}):s=o.text(e.toString(),null),H(s,null,t,n,i,a)}const F=Symbol();function ie(e,t){let n={adapter:e,mounted:!1,$isGroup:!0,$scheduler:m(e.tick),$extensions:t,$life:1,$pg:null,$ng:null,unmount:()=>B(n),mount:(t,r)=>{let i=!!e.batch,a=i?e.batch():t;z(r,n,a,t,null,i),i&&e.insert(a,t,null)}};return n.$ng=n,n}function I(e,t=null){let n=e.$ng,r={adapter:n.adapter,mounted:!1,$isGroup:!0,$scheduler:n.$scheduler,$extensions:n.$extensions,$life:1,$pg:n,$ng:null};return r.$ng=r,L(r,e,t),r}function L(e,t,n=null){n?.$pg===t?n.$hp?(e.$hp=n.$hp,e.$hn=n,n.$hp.$hn=e,n.$hp=e):(e.$hp=null,e.$hn=t.$hh,t.$hh===n&&(n.$hp=e),t.$hh=e):(t.$ht?(t.$ht.$hn=e,e.$hp=t.$ht):t.$hh=e,t.$ht=e)}function R(e){e.$hp?e.$hp.$hn=e.$hn:e.$pg?.$hh===e&&(e.$pg.$hh=e.$hn),e.$hn?e.$hn.$hp=e.$hp:e.$pg?.$ht===e&&(e.$pg.$ht=e.$hp),e.$hp=null,e.$hn=null}function z(e,t,n,r,i,a){if(t.mounted){oe(t,n,i);return}let o=c(t);try{V(e,t,n,r,i,a)}finally{c(o),t.mounted=!0,t.$pg?.mounted!==!1&&ae(t)}}function ae(t){let n=t.$hh;for(;n;)ae(n),n=n.$hn;let r;if(t.$isGroup&&t.mounted&&(r=t.$onMount)){let n=c(t);try{r.forEach(e)}finally{r.length=0,c(n)}}}function oe(e,t,n){let{adapter:r}=e,i=e.$hh;for(;i;)i.$isNative?r.insert(i.$nn,t,n):oe(i,t,n),i=i.$hn}function B(t,n=!0){if(t.$isGroup){if(t.mounted){let n;if(n=t.$onUnmount){let r=c(t);try{n.forEach(e)}finally{n.length=0,c(r)}}t.mounted=!1,t.$life+=1}p(t)}let{adapter:r}=t.$ng,i=t.$hh,a;for(;i;)i.$isNative&&n?(r.remove(i.$nn),B(i,!1)):B(i,n),a=i.$hn,i.$hp=null,i.$hn=null,i=a;t.$hh=null,t.$ht=null}function V(e,t,n,r,i,a){switch(typeof e){case`object`:if(e===null)break;if(Array.isArray(e)){let{length:o}=e,s=0;for(;s<o;s+=1)V(e[s],t,n,r,i,a);break}if(!M(e)){e[F]?.(e,t,n,r,i,a);break}case`string`:case`number`:case`boolean`:case`bigint`:re(e,t,n,r,i,a);break}}function H(e,t,n,r,i,a){let o=n;if(o.$isGroup){let t=null;if(i){let e=n.$ht;for(;e;){if(e.$isNative&&e.$nn===i){t=e;break}e=e.$hp}}L(o={$isNative:!0,$pg:o,$ng:o,$nn:e},n,t)}V(t,o,e,e,null,a),n.$ng.adapter.insert(e,r,i)}function se(e,t,n,r,i,a){V(e.children,t,n,r,i,a)}function ce(){return{$symbol:Symbol()}}let U=null,W=!1;function G(){return U}function K(e){U=e,W=!1}function le(e){let{$symbol:t}=e,n=U,r;for(;n&&!(r=n[t]);)n=n.$parent;return r??null}function ue(e,t){(!W||!U)&&(W=!0,U={$parent:U});let n=s(),r={[O]:!0,$lifecycle:n,$tracksValue:!0,$value:t,get:fe,set:pe};if(t===void 0){let t=le(e);t&&(r.get=de,r.$ancestor=t,d(n,t,r.$dep={$fn:P,$a0:r}))}return U[e.$symbol]=r,r}function de(){return this.$ancestor.get()}function fe(){return this.$value}function pe(e){let t;return this.$ancestor?(t=this.$ancestor.get(),f(this.$dep),this.$dep=null,this.$ancestor=null,this.get=fe):t=this.$value,this.$value=e,!Object.is(t,e)}let me=function(e){return e[e.Change=1]=`Change`,e[e.Insert=2]=`Insert`,e[e.Remove=3]=`Remove`,e[e.Clear=4]=`Clear`,e}({});function q(){return{changes:[],lengthChange:0}}function he({changes:e},t,n,r){let i=J(e,t,be);if(i<0)e.splice(~i,0,{kind:1,index:t,oldItem:n,newItem:r});else{let a=e[i];switch(a.kind){case 1:case 2:a.newItem=r;break;case 3:e.splice(i+1,0,{kind:1,index:t,oldItem:n,newItem:r});break}}}function ge(e,t,n){let{changes:r}=e,i=J(r,t,xe);if(i<0)i=~i,r.splice(i,0,{kind:2,index:t,newItem:n});else{let e=r[i];switch(e.kind){case 1:case 2:r.splice(i,0,{kind:2,index:t,newItem:n});break;case 3:e.kind=1,e.newItem=n;break}}let{length:a}=r;for(;++i<a;)r[i].index+=1;e.lengthChange+=1}function _e(e,t,n){let{changes:r}=e,i=J(r,t,be);if(i<0)i=~i,r.splice(i,0,{kind:3,index:t,oldItem:n});else{let e=r[i];switch(e.kind){case 1:e.kind=3,e.newItem=void 0;break;case 2:r.splice(i--,1);break;case 3:r.splice(++i,0,{kind:3,index:t,oldItem:n});break}}let{length:a}=r;for(;++i<a;)--r[i].index;--e.lengthChange}function ve(e,t){let{changes:n}=e;n.length=0,n.push({kind:4,index:-1}),e.lengthChange-=t}function ye(e,t,n,r){let i=0,a=t.length,o=n.length;for(;i<a&&i<o&&r(t[i],n[i]);)i+=1;if(i===a&&i===o)return;for(;a>i&&o>i&&r(t[a-1],n[o-1]);)--a,--o;let s=(Math.min(a,o)+1)*2,c=a+o,l={$eq:r,$list0:t,$list1:n,$index0:i,$index1:i,$N:a,$M:o,$Z:s,$c:0,$buffer:new(c<=255?Uint8Array:c<=65535?Uint16Array:Uint32Array)(s+s),$stack:[],$stackTop:0,$pxs:-1,$pxe:-1,$pys:-1,$pye:-1,$oxs:-1,$oxe:-1,$oys:-1,$oye:-1},u=0,d,f,p,m,h,g;do{if(Se(l),l.$c===1)d=l.$oxs,f=l.$oxe,p=l.$oys,m=l.$oye;else if(l.$pxs>=0)d=l.$pxs,f=l.$pxe,p=l.$pys,m=l.$pye;else break;for(h=d;h<f;h+=1)_e(e,d+u,t[h]);for(g=p;g<m;g+=1)ge(e,d+u,n[g]),u+=1;u-=f-d}while(l.$c<2)}const be=(e,t,n,r,i)=>{let a=n;for(;++a<i&&e[a].index===t;);return a-1},xe=(e,t,n,r,i)=>{let a=n;for(;--a>=r&&e[a].index===t;);return a+1};function J(e,t,n){let r=0,i=e.length,a,o;for(;r<i;)if(a=r+i>>>1,o=e[a].index,t<o)i=a;else if(t>o)r=a+1;else return n(e,t,a,r,i);return~r}function Se(e){let{$list0:t,$list1:n,$buffer:r,$stack:i,$eq:a}=e,{$index0:o,$index1:s,$N:c,$M:l,$Z:u,$c:d,$stackTop:f}=e,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M;for(;;)switch(d){case 0:Z_block:for(;c>0&&l>0;){p=c-l,m=c+l,h=m&1,g=o+c-1,_=s+l-1,b=(m+h)/2,r.fill(0,0,u+u);h_loop:for(y=0;y<=b;y+=1){for(S=2*Math.max(0,y-l)-y,C=y-2*Math.max(0,y-c),x=S;x<=C;x+=2){for(w=r[x-1-u*Math.floor((x-1)/u)],T=r[x+1-u*Math.floor((x+1)/u)],E=x===-y||x!==y&&w<T?T:w+1,D=E-x,O=E,k=D;O<c&&k<l&&a(t[o+O],n[s+k]);)O+=1,k+=1;if(r[x-u*Math.floor(x/u)]=O,h===1&&(v=p-x)>=1-y&&v<y&&O+r[u+v-u*Math.floor(v/u)]>=c)if(y>1||O!==E){i[f++]=o+O,i[f++]=s+k,i[f++]=c-O,i[f++]=l-k,c=E,l=D,u=2*(Math.min(c,l)+1);continue Z_block}else break h_loop}for(x=S;x<=C;x+=2){for(A=r[u+x-1-u*Math.floor((x-1)/u)],j=r[u+x+1-u*Math.floor((x+1)/u)],E=x===-y||x!==y&&A<j?j:A+1,D=E-x,O=E,k=D;O<c&&k<l&&a(t[g-O],n[_-k]);)O+=1,k+=1;if(r[u+x-u*Math.floor(x/u)]=O,h===0&&(v=p-x)>=-y&&v<=y&&O+r[v-u*Math.floor(v/u)]>=c)if(y>0||O!==E){i[f++]=o+c-E,i[f++]=s+l-D,i[f++]=E,i[f++]=D,c-=O,l-=k,u=2*(Math.min(c,l)+1);continue Z_block}else break h_loop}}if(c!==l){l>c?(o+=c,s+=c,l-=c,c=0):(o+=l,s+=l,c-=l,l=0);break}}if(c+l!==0){if(e.$pxe===o||e.$pye===s)e.$pxe=o+c,e.$pye=s+l;else if(M=e.$pxs,e.$oxs=e.$pxs,e.$oxe=e.$pxe,e.$oys=e.$pys,e.$oye=e.$pye,e.$pxs=o,e.$pxe=o+c,e.$pys=s,e.$pye=s+l,M>=0){e.$index0=o,e.$index1=s,e.$N=c,e.$M=l,e.$Z=u,e.$stackTop=f,e.$c=1;return}}case 1:if(f===0){e.$c=2;return}l=i[--f],c=i[--f],s=i[--f],o=i[--f],u=2*(Math.min(c,l)+1),d=0}}function Ce(e,t=s()){let n={[O]:!0,$lifecycle:t,use:we,get:De};return n.use(e,!1),n}function we(e,t=!0){this.$dep&&f(this.$dep);let n=this.get();M(e)?(this.$bound=e,this.$value=null,this.get=Te,this.set=Ee,d(this.$lifecycle,e,this.$dep??={$fn:P,$a0:this})):(this.$bound=null,this.$value=e,this.get=De,this.set=Oe),t&&!Object.is(n,this.get())&&g(this.$lifecycle,this.$notify??={$fn:P,$a0:this})}function Te(){return this.$bound.get()}function Ee(e){let t=this.$bound;return t.set(e)&&g(t.$lifecycle,t.$notify??={$fn:P,$a0:t}),!1}function De(){return this.$value}function Oe(){return!1}const ke={};function Y(e,t,n){let r=Ae(t)?t:ke,i={},{length:a}=n,o=0,s;for(;o<a;o+=1)s=n[o],i[s]=Ce(r[s],e);return i.proxied=t,i}function X(e,t,n){let r=Ae(t)?t:ke,{length:i}=n;e.proxied=t;let a=0,o;for(;a<i;a+=1)o=n[a],e[o].use(r[o])}function Ae(e){return typeof e==`object`&&!!e}function je(e,t,n,r,i,a){let o=e.source,s=e.proxy,c=s!==void 0,u=e.children[0],f=I(t),p=G(),{adapter:m}=f,h=!!m.batch,g=m.marker(),_,v=!!o.$delta;d(f,o,{$fn:()=>{if(v){v=!1;return}let{changes:e,lengthChange:t}=o.$delta,n=e.length,i=_.length+t,a=Array(i),d=[],y=[],b,x=0,S=0,C=0,w=0,T,E,D,O=!1,k=r,A=null;for(;S<n;S+=1){for(T=e[S];w<T.index;)a[w++]=_[C++];switch(T.kind){case 1:b=a[w++]=_[C++],c?X(b.$data,T.newItem,s):(B(b),E=_[C]?.$marker??g,H(b.$marker,null,b,r,E,!1),K(p),z(l(b,u,b.$data=T.newItem),b,r,r,E,!1));break;case 2:!c||x<t?(b=a[w++]=I(f,_[C]),b.$marker=m.marker(),b.$data=c?Y(b,T.newItem,s):T.newItem,x+=1,E=_[C]?.$marker??g,O||(h?(O=!0,k=m.batch(),A=null):A=E),H(b.$marker,null,b,k,A,O),K(p),z(l(b,u,b.$data),b,k,r,A,O),O&&(x>=t||!(D=e[S+1])||D.kind!==2||D.index!==w)&&(m.insert(k,r,E),k=r,O=!1)):d.push({$index:w++,$item:T.newItem});break;case 3:b=_[C++],c?y.push(b):B(b),R(b);break;case 4:if(c)y=_,y.forEach(R),C=_.length;else for(;C<_.length;)b=_[C++],B(b),R(b);break}}for(;w<i;)a[w++]=_[C++];let j=d.length-1,M=y.length-1;for(;j>=0;)D=d[j--],b=a[D.$index]=y[M--],X(b.$data,D.$item,s),L(b,f,E=a[D.$index+1]),K(p),z(l(b,u,b.$data),b,r,r,E?.$marker??g,!1);for(;M>=0;)b=y[M--],B(b),R(b);_=a}});{let e=n,t=i,d=h&&!a&&o.$items.length>0;d&&(e=m.batch(),t=null);let p=d||a;_=o.$items.map(n=>{let i=I(f);return i.$marker=m.marker(),i.$data=c?Y(i,n,s):n,H(i.$marker,null,i,e,t,p),z(l(i,u,i.$data),i,e,r,t,p),i}),H(g,null,f,e,t,p),d&&m.insert(e,n,i)}z(null,f,n,r,i,a)}const Me=/^([^:]+?):(.+)$/,Z=Symbol();function Q(e,t,n,r,i,a){let o=t.$ng,{adapter:s,$extensions:c}=o,l=s.element(e[Z]),d,f,p;for(d in e)if(f=Me.exec(d),p=e[d],f)c[f[1]]?.set(l,f[2],p,o);else if(d!==`children`)if(M(p)){let e=d,t=p;u(o,t,()=>{s.set(l,e,t.get())})}else s.set(l,d,p);H(l,e.children,t,n,i,a)}function Ne(e,t,n,r,i,a){let o=e.when;if(!M(o)&&o===!1)return;let{children:s,data:c}=e,u=e.proxy,f=Object.hasOwn(e,`data`)?s[0]:()=>s,p=c;u&&(M(c)?(p=Y(t.$ng,c.get(),u),d(t.$ng,c,{$fn:()=>{X(p,c.get(),u)}})):p=Y(t.$ng,c,u));let m=t.$ng.adapter,h=!!m.batch;if(!(M(o)||M(f)||!u&&M(c))){let e=h&&!a,o=n,s=i;e&&(o=m.batch(),s=null),V(f(p),t,o,r,s,e||a),e&&m.insert(o,n,i);return}let g=I(t),_=G(),v=i;b(()=>{if(N(o)===!1)return;let e=h&&!a,t=n,i=v;return e&&(t=m.batch(),i=null),K(_),z(l(g,N(f),N(p)),g,t,r,i,e||a),e&&m.insert(t,n,v),()=>B(g)},t.$ng),v=m.marker(),H(v,null,t,n,i,a),a=!1,n=r}function Pe(e,t=s()){let n={[O]:!0,$dirty:!1,$value:null,$tracksValue:!0,$lifecycle:t,$life:t.$life,$lastValue:null,$cycle:0,$block:e,$react:Fe,get:Ie,set:Le},r=T(n);return n.$value=r,n.$lastValue=r,n}function Fe(e,t){if(e.$life!==e.$lifecycle.$life||e.$cycle>t){f(this);return}e.$dirty=!0,g(e.$lifecycle,e.$notify??={$fn:P,$a0:e})}function Ie(){return this.$dirty&&this.$life===this.$lifecycle.$life&&(this.$value=T(this),this.$dirty=!1),this.$value}function Le(){return!1}function Re(e,t=s()){return{$lifecycle:t,$items:e?Array.from(e):[],$delta:null,[Symbol.iterator]:Ge,size:Be,get:Ve,delta:He,raw:Ue,forEach:We,set:Ke,clear:qe,insertAt:Je,insertFirst:Ye,insertLast:Xe,remove:Ze,removeAt:Qe,removeFirst:$e,removeLast:et}}function ze(e,t,n=nt){let r=e.$items;e.$items=t.slice(),ye(e.$delta??=q(),r,t,n),$(e)}function Be(){return E(this),this.$items.length}function Ve(e){return E(this),this.$items[e]}function He(){return E(this),this.$delta}function Ue(){return this.$items}function We(e,t){E(this),this.$items.forEach(e,t)}function Ge(){return E(this),this.$items[Symbol.iterator]()}function Ke(e,t){tt(this,e);let n=this.$items[e];Object.is(t,n)||(this.$items[e]=t,this.$dh&&(he(this.$delta??=q(),e,n,t),$(this)))}function qe(){let e=this.$items.length;this.$items.length=0,this.$dh&&(ve(this.$delta??=q(),e),$(this))}function Je(e,t){let{$items:n}=this;e===n.length?n.push(t):(tt(this,e),this.$items.splice(e,0,t)),this.$dh&&(ge(this.$delta??=q(),e,t),$(this))}function Ye(e){this.insertAt(0,e)}function Xe(e){this.insertAt(this.$items.length,e)}function Ze(e){let t=this.$items.indexOf(e);return t===-1?!1:(this.removeAt(t),!0)}function Qe(e){tt(this,e);let t=this.$items.splice(e,1)[0];return this.$dh&&(_e(this.$delta??=q(),e,t),$(this)),t}function $e(){return this.$items.length>0?this.removeAt(0):void 0}function et(){let{length:e}=this.$items;return e>0?this.removeAt(e-1):void 0}function tt(e,t){if(t>=e.$items.length||t<0)throw RangeError()}function nt(e,t){return Object.is(e,t)}function $(e){g(e.$lifecycle,e.$notify??={$fn:rt,$a0:e}),v(e.$lifecycle,e.$cleanup??={$fn:it,$a0:e})}function rt(t){let n=t.$dh,r;for(;n;)r=n.$an,e(n),n=r}function it(e){e.$delta=null}const at={set:(e,t,r)=>{let i;switch(t){case`atom`:if(!M(r))return;i=ot;break;case`call`:if(typeof r!=`function`)return;i=st;break;default:return}let o=s();n(o,{$fn:i,$a0:r,$a1:e}),a(o,{$fn:i,$a0:r,$a1:null})}};function ot(e,t){e.set(t)}function st(e,t){e(t)}function ct(e,t,n){let{length:r}=n,i=0,a=t[0];for(;i<r;)a+=e(n[i])+t[++i];return a}function lt(e,...t){return ct(N,e,t)}function ut(e,...t){return ct(ee,e,t)}function dt(e){let t={},n={build:()=>ie(e,t),extend:(e,r)=>(t[e]=r,n)};return n}function ft(e){return(t,n,r,i,a,o)=>{let s=G();try{K(s),V(e(t),n,r,i,a,o)}finally{K(s)}}}const pt=Object.freeze([]);function mt(e,t,n){let{children:r}=t;return t.children=r===void 0?pt:Array.isArray(r)?r:[r],t.key??=n,typeof e==`string`?(t[F]=Q,t[Z]=e):t[F]=e,t}function ht(e,t,n){return t.key??=n,typeof e==`string`?(t[F]=Q,t[Z]=e):t[F]=e,t}export{me as ChangeKind,se as Fragment,je as Iterator,Q as Native,at as RefExtension,Ne as Show,k as atomOf,u as bind,ft as component,le as consumerOf,ce as createContext,Pe as derived,b as effect,I as fork,s as getLifecycle,ue as host,H as insert,M as isAtom,mt as jsx,ht as jsxs,Re as listOf,z as mount,V as mountJsx,t as mounted,D as noEffect,ee as peek,ut as peeks,Ce as proxyOf,dt as pyxis,N as read,lt as reads,ze as sync,_ as tick,y as tock,L as track,B as unmount,i as unmounted,R as untrack,ne as update,l as withLifecycle,te as write};
|
|
1
|
+
//#region src/symbols.ts
|
|
2
|
+
const S_ATOM = Symbol.for("pyxis:atom");
|
|
3
|
+
const S_COMPONENT = Symbol.for("pyxis:component");
|
|
4
|
+
const S_TAG_NAME = Symbol.for("pyxis:tagName");
|
|
5
|
+
const S_RUNTIME = Symbol.for("pyxis:runtime");
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/Runtime.ts
|
|
8
|
+
const runtime = globalThis[S_RUNTIME] ??= {
|
|
9
|
+
x: {},
|
|
10
|
+
$extIndex: 0,
|
|
11
|
+
$currentLifecycle: null,
|
|
12
|
+
$currentEffect: null,
|
|
13
|
+
$currentContext: null,
|
|
14
|
+
$currentContextNew: false
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/support/common.ts
|
|
18
|
+
function invoke(callback) {
|
|
19
|
+
return callback.fn(callback.a0, callback.a1, callback.a2);
|
|
20
|
+
}
|
|
21
|
+
function noop() {}
|
|
22
|
+
function rethrow(errors) {
|
|
23
|
+
if (errors) {
|
|
24
|
+
if (errors.length > 1) throw new AggregateError(errors);
|
|
25
|
+
if (errors.length === 1) throw errors[0];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const UNIQUE_VALUE = Object.create(null);
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/data/Dependency.ts
|
|
31
|
+
function bind(lifecycle, target, dependency) {
|
|
32
|
+
link(lifecycle, target, dependency);
|
|
33
|
+
return invoke(dependency);
|
|
34
|
+
}
|
|
35
|
+
function link(lifecycle, target, dep) {
|
|
36
|
+
if (target.$dt) {
|
|
37
|
+
target.$dt.$an = dep;
|
|
38
|
+
dep.$ap = target.$dt;
|
|
39
|
+
} else target.$dh = dep;
|
|
40
|
+
dep.$target = target;
|
|
41
|
+
target.$dt = dep;
|
|
42
|
+
if (lifecycle.$dt) {
|
|
43
|
+
lifecycle.$dt.$ln = dep;
|
|
44
|
+
dep.$lp = lifecycle.$dt;
|
|
45
|
+
} else lifecycle.$dh = dep;
|
|
46
|
+
dep.$lifecycle = lifecycle;
|
|
47
|
+
lifecycle.$dt = dep;
|
|
48
|
+
if (target.$xa && !target.$xn) target.$xn = dep;
|
|
49
|
+
let update;
|
|
50
|
+
do {
|
|
51
|
+
update = target.$notify;
|
|
52
|
+
if (update && update.$se === update.$lifecycle.$scheduler.$epoch) target.$force = true;
|
|
53
|
+
target = target.$upstream;
|
|
54
|
+
} while (target);
|
|
55
|
+
}
|
|
56
|
+
function unlink(dep) {
|
|
57
|
+
const target = dep.$target;
|
|
58
|
+
if (!target) return;
|
|
59
|
+
if (target.$xa && target.$xn === dep) target.$xn = dep.$an;
|
|
60
|
+
if (dep.$ap) dep.$ap.$an = dep.$an;
|
|
61
|
+
else if (target.$dh === dep) target.$dh = dep.$an;
|
|
62
|
+
if (dep.$an) dep.$an.$ap = dep.$ap;
|
|
63
|
+
else if (target.$dt === dep) target.$dt = dep.$ap;
|
|
64
|
+
dep.$target = null;
|
|
65
|
+
dep.$ap = null;
|
|
66
|
+
dep.$an = null;
|
|
67
|
+
const lifecycle = dep.$lifecycle;
|
|
68
|
+
if (dep.$lp) dep.$lp.$ln = dep.$ln;
|
|
69
|
+
else if (lifecycle.$dh === dep) lifecycle.$dh = dep.$ln;
|
|
70
|
+
if (dep.$ln) dep.$ln.$lp = dep.$lp;
|
|
71
|
+
else if (lifecycle.$dt === dep) lifecycle.$dt = dep.$lp;
|
|
72
|
+
dep.$lifecycle = null;
|
|
73
|
+
dep.$lp = null;
|
|
74
|
+
dep.$ln = null;
|
|
75
|
+
}
|
|
76
|
+
function teardown(lifecycle) {
|
|
77
|
+
let dep = lifecycle.$dh;
|
|
78
|
+
let target;
|
|
79
|
+
let next;
|
|
80
|
+
while (dep) {
|
|
81
|
+
target = dep.$target;
|
|
82
|
+
if (target.$xa && target.$xn === dep) target.$xn = dep.$an;
|
|
83
|
+
if (dep.$ap) dep.$ap.$an = dep.$an;
|
|
84
|
+
else if (target.$dh === dep) target.$dh = dep.$an;
|
|
85
|
+
if (dep.$an) dep.$an.$ap = dep.$ap;
|
|
86
|
+
else if (target.$dt === dep) target.$dt = dep.$ap;
|
|
87
|
+
next = dep.$ln;
|
|
88
|
+
dep.$lifecycle = null;
|
|
89
|
+
dep.$target = null;
|
|
90
|
+
dep.$ap = null;
|
|
91
|
+
dep.$an = null;
|
|
92
|
+
dep.$lp = null;
|
|
93
|
+
dep.$ln = null;
|
|
94
|
+
dep = next;
|
|
95
|
+
}
|
|
96
|
+
lifecycle.$dh = null;
|
|
97
|
+
lifecycle.$dt = null;
|
|
98
|
+
lifecycle.$life += 1;
|
|
99
|
+
let callbacks;
|
|
100
|
+
if (callbacks = lifecycle.$onMount) callbacks.length = 0;
|
|
101
|
+
if (callbacks = lifecycle.$onUnmount) callbacks.length = 0;
|
|
102
|
+
}
|
|
103
|
+
function notify(list) {
|
|
104
|
+
list.$xa = true;
|
|
105
|
+
list.$xn = list.$dh;
|
|
106
|
+
let errors;
|
|
107
|
+
let current;
|
|
108
|
+
while (current = list.$xn) {
|
|
109
|
+
list.$xn = current.$an;
|
|
110
|
+
try {
|
|
111
|
+
invoke(current);
|
|
112
|
+
} catch (ex) {
|
|
113
|
+
(errors ??= []).push(ex);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
list.$xa = false;
|
|
117
|
+
list.$xn = null;
|
|
118
|
+
rethrow(errors);
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/Component.ts
|
|
122
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
123
|
+
function component(block) {
|
|
124
|
+
return (props, hParent, hBefore, nUsedParent, nRealParent, isBatch) => {
|
|
125
|
+
const capturedContext = runtime.$currentContext;
|
|
126
|
+
const capturedContextNew = runtime.$currentContextNew;
|
|
127
|
+
try {
|
|
128
|
+
runtime.$currentContextNew = false;
|
|
129
|
+
mountJsx(block(props), hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
130
|
+
} finally {
|
|
131
|
+
runtime.$currentContext = capturedContext;
|
|
132
|
+
runtime.$currentContextNew = capturedContextNew;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/data/Lifecycle.ts
|
|
138
|
+
function mounted(block, lifecycle) {
|
|
139
|
+
lifecycle ??= getLifecycle();
|
|
140
|
+
onceMounted(lifecycle, {
|
|
141
|
+
fn: invokeMountedCallback,
|
|
142
|
+
a0: lifecycle,
|
|
143
|
+
a1: block
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function onceMounted(lifecycle, callback) {
|
|
147
|
+
(lifecycle.$onMount ??= []).push(callback);
|
|
148
|
+
}
|
|
149
|
+
function invokeMountedCallback(lifecycle, block, arg) {
|
|
150
|
+
const life = lifecycle.$life;
|
|
151
|
+
const dispose = block(arg);
|
|
152
|
+
if (dispose) {
|
|
153
|
+
if (lifecycle.$life > life) {
|
|
154
|
+
dispose();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
onceUnmounted(lifecycle, { fn: dispose });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function unmounted(block, lifecycle) {
|
|
161
|
+
onceUnmounted(lifecycle ?? getLifecycle(), { fn: block });
|
|
162
|
+
}
|
|
163
|
+
function onceUnmounted(lifecycle, callback) {
|
|
164
|
+
(lifecycle.$onUnmount ??= []).push(callback);
|
|
165
|
+
}
|
|
166
|
+
function getLifecycle() {
|
|
167
|
+
return runtime.$currentLifecycle;
|
|
168
|
+
}
|
|
169
|
+
function withLifecycle(lifecycle, block, a0, a1, a2) {
|
|
170
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
171
|
+
runtime.$currentLifecycle = lifecycle;
|
|
172
|
+
try {
|
|
173
|
+
return block(a0, a1, a2);
|
|
174
|
+
} finally {
|
|
175
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/data/Scheduler.ts
|
|
180
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
181
|
+
function createScheduler(tick) {
|
|
182
|
+
const effects = [];
|
|
183
|
+
const ticks = [];
|
|
184
|
+
let tocks = [];
|
|
185
|
+
let tocksParked = [];
|
|
186
|
+
let isPending = false;
|
|
187
|
+
const scheduler = {
|
|
188
|
+
$epoch: 1,
|
|
189
|
+
$onEffect: effects,
|
|
190
|
+
$onTick: ticks,
|
|
191
|
+
$onTock: tocks,
|
|
192
|
+
$scheduleTick: () => {
|
|
193
|
+
if (isPending) return;
|
|
194
|
+
isPending = true;
|
|
195
|
+
tick(update);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const update = () => {
|
|
199
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
200
|
+
const epoch = scheduler.$epoch;
|
|
201
|
+
let errors;
|
|
202
|
+
let effectIndex = 0;
|
|
203
|
+
let tickIndex = 0;
|
|
204
|
+
let callback;
|
|
205
|
+
do {
|
|
206
|
+
while (tickIndex < ticks.length) {
|
|
207
|
+
callback = ticks[tickIndex++];
|
|
208
|
+
callback.$se = 0;
|
|
209
|
+
if (callback.$life === callback.$lifecycle.$life) try {
|
|
210
|
+
runtime.$currentLifecycle = callback.$lifecycle;
|
|
211
|
+
invoke(callback);
|
|
212
|
+
} catch (ex) {
|
|
213
|
+
(errors ??= []).push(ex);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (effectIndex < effects.length) {
|
|
217
|
+
callback = effects[effectIndex++];
|
|
218
|
+
callback.$se = 0;
|
|
219
|
+
if (callback.$life === callback.$lifecycle.$life) try {
|
|
220
|
+
runtime.$currentLifecycle = callback.$lifecycle;
|
|
221
|
+
invoke(callback);
|
|
222
|
+
} catch (ex) {
|
|
223
|
+
(errors ??= []).push(ex);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} while (tickIndex < ticks.length || effectIndex < effects.length);
|
|
227
|
+
effects.length = 0;
|
|
228
|
+
ticks.length = 0;
|
|
229
|
+
scheduler.$onTock = tocksParked;
|
|
230
|
+
scheduler.$epoch = epoch + 1;
|
|
231
|
+
const { length } = tocks;
|
|
232
|
+
let tockIndex = 0;
|
|
233
|
+
for (; tockIndex < length; tockIndex += 1) {
|
|
234
|
+
callback = tocks[tockIndex];
|
|
235
|
+
if (callback.$se === epoch) callback.$se = 0;
|
|
236
|
+
if (callback.$life === callback.$lifecycle.$life) try {
|
|
237
|
+
runtime.$currentLifecycle = callback.$lifecycle;
|
|
238
|
+
invoke(callback);
|
|
239
|
+
} catch (ex) {
|
|
240
|
+
(errors ??= []).push(ex);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const tmp = tocksParked;
|
|
244
|
+
tocksParked = tocks;
|
|
245
|
+
tocks = tmp;
|
|
246
|
+
tocksParked.length = 0;
|
|
247
|
+
isPending = false;
|
|
248
|
+
if (ticks.length || tocks.length) scheduler.$scheduleTick();
|
|
249
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
250
|
+
rethrow(errors);
|
|
251
|
+
};
|
|
252
|
+
return scheduler;
|
|
253
|
+
}
|
|
254
|
+
function schedule(lifecycle, queue, callback) {
|
|
255
|
+
callback.$lifecycle = lifecycle;
|
|
256
|
+
callback.$life = lifecycle.$life;
|
|
257
|
+
const scheduler = lifecycle.$scheduler;
|
|
258
|
+
if (callback.$se === scheduler.$epoch) return;
|
|
259
|
+
callback.$se = scheduler.$epoch;
|
|
260
|
+
queue.push(callback);
|
|
261
|
+
scheduler.$scheduleTick();
|
|
262
|
+
}
|
|
263
|
+
function scheduleEffect(lifecycle, callback) {
|
|
264
|
+
schedule(lifecycle, lifecycle.$scheduler.$onEffect, callback);
|
|
265
|
+
}
|
|
266
|
+
function tick(block, lifecycle = getLifecycle()) {
|
|
267
|
+
schedule(lifecycle, lifecycle.$scheduler.$onTick, { fn: block });
|
|
268
|
+
}
|
|
269
|
+
function scheduleTick(lifecycle, callback) {
|
|
270
|
+
schedule(lifecycle, lifecycle.$scheduler.$onTick, callback);
|
|
271
|
+
}
|
|
272
|
+
function tock(block, lifecycle = getLifecycle()) {
|
|
273
|
+
schedule(lifecycle, lifecycle.$scheduler.$onTock, { fn: block });
|
|
274
|
+
}
|
|
275
|
+
function scheduleTock(lifecycle, callback) {
|
|
276
|
+
schedule(lifecycle, lifecycle.$scheduler.$onTock, callback);
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/data/Effect.ts
|
|
280
|
+
function effect(block, lifecycle = getLifecycle()) {
|
|
281
|
+
runEffect({
|
|
282
|
+
$lifecycle: lifecycle,
|
|
283
|
+
$life: lifecycle.$life,
|
|
284
|
+
$block: block,
|
|
285
|
+
$react: scheduleReaction$1,
|
|
286
|
+
$cycle: 0
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function scheduleReaction$1(effect, cycle) {
|
|
290
|
+
if (effect.$cycle > cycle) {
|
|
291
|
+
unlinkEffectDep(effect, this);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
scheduleEffect(effect.$lifecycle, effect.$resolve ??= {
|
|
295
|
+
fn: runEffect,
|
|
296
|
+
a0: effect
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function runEffect(effect) {
|
|
300
|
+
const lifecycle = effect.$lifecycle;
|
|
301
|
+
if (effect.$life !== lifecycle.$life) return;
|
|
302
|
+
teardownEffect(effect);
|
|
303
|
+
if (effect.$life !== lifecycle.$life) return;
|
|
304
|
+
effect.$dispose = resolve(effect);
|
|
305
|
+
if (effect.$life !== lifecycle.$life) {
|
|
306
|
+
teardownEffect(effect);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (!effect.$tracksUnmount && effect.$dispose) {
|
|
310
|
+
effect.$tracksUnmount = true;
|
|
311
|
+
onceUnmounted(lifecycle, {
|
|
312
|
+
fn: teardownEffect,
|
|
313
|
+
a0: effect
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function teardownEffect(effect) {
|
|
318
|
+
const fn = effect.$dispose;
|
|
319
|
+
if (!fn) return;
|
|
320
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
321
|
+
runtime.$currentLifecycle = effect.$lifecycle;
|
|
322
|
+
effect.$dispose = null;
|
|
323
|
+
try {
|
|
324
|
+
fn();
|
|
325
|
+
} finally {
|
|
326
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function resolve(effect) {
|
|
330
|
+
effect.$rc = 0;
|
|
331
|
+
const cycle = effect.$cycle += 1;
|
|
332
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
333
|
+
const prevEffect = runtime.$currentEffect;
|
|
334
|
+
const prevTail = effect.$et;
|
|
335
|
+
runtime.$currentLifecycle = effect.$lifecycle;
|
|
336
|
+
runtime.$currentEffect = effect;
|
|
337
|
+
try {
|
|
338
|
+
return effect.$block();
|
|
339
|
+
} finally {
|
|
340
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
341
|
+
runtime.$currentEffect = prevEffect;
|
|
342
|
+
if (cycle > 1 && effect.$rc > 0 && prevTail) {
|
|
343
|
+
let current = effect.$eh;
|
|
344
|
+
let next;
|
|
345
|
+
while (current) {
|
|
346
|
+
next = current.$en;
|
|
347
|
+
if (current.a1 < cycle) unlinkEffectDep(effect, current);
|
|
348
|
+
if (current === prevTail) break;
|
|
349
|
+
current = next;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function unlinkEffectDep(effect, dep) {
|
|
355
|
+
if (dep.$ep) dep.$ep.$en = dep.$en;
|
|
356
|
+
else if (effect.$eh === dep) effect.$eh = dep.$en;
|
|
357
|
+
if (dep.$en) dep.$en.$ep = dep.$ep;
|
|
358
|
+
else if (effect.$et === dep) effect.$et = dep.$ep;
|
|
359
|
+
dep.$ep = null;
|
|
360
|
+
dep.$en = null;
|
|
361
|
+
effect.$deps?.delete(dep.$target);
|
|
362
|
+
unlink(dep);
|
|
363
|
+
}
|
|
364
|
+
function reportAccess(atom) {
|
|
365
|
+
const currentEffect = runtime.$currentEffect;
|
|
366
|
+
if (!currentEffect || currentEffect.$life !== currentEffect.$lifecycle.$life) return;
|
|
367
|
+
const deps = currentEffect.$deps;
|
|
368
|
+
let dep;
|
|
369
|
+
let count = 0;
|
|
370
|
+
if (deps) dep = deps.get(atom);
|
|
371
|
+
else {
|
|
372
|
+
dep = currentEffect.$eh;
|
|
373
|
+
while (dep) {
|
|
374
|
+
count += 1;
|
|
375
|
+
if (dep.$target === atom) break;
|
|
376
|
+
dep = dep.$en;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (dep) {
|
|
380
|
+
dep.a1 = currentEffect.$cycle;
|
|
381
|
+
if (!dep.$lifecycle) link(currentEffect.$lifecycle, atom, dep);
|
|
382
|
+
} else {
|
|
383
|
+
link(currentEffect.$lifecycle, atom, dep = {
|
|
384
|
+
fn: currentEffect.$react,
|
|
385
|
+
a0: currentEffect,
|
|
386
|
+
a1: currentEffect.$cycle
|
|
387
|
+
});
|
|
388
|
+
if (deps) deps.set(atom, dep);
|
|
389
|
+
else if (count >= 5) {
|
|
390
|
+
const map = currentEffect.$deps = /* @__PURE__ */ new WeakMap();
|
|
391
|
+
let current = currentEffect.$eh;
|
|
392
|
+
do
|
|
393
|
+
map.set(current.$target, current);
|
|
394
|
+
while (current = current.$en);
|
|
395
|
+
map.set(atom, dep);
|
|
396
|
+
}
|
|
397
|
+
if (currentEffect.$et) {
|
|
398
|
+
currentEffect.$et.$en = dep;
|
|
399
|
+
dep.$ep = currentEffect.$et;
|
|
400
|
+
} else currentEffect.$eh = dep;
|
|
401
|
+
currentEffect.$et = dep;
|
|
402
|
+
currentEffect.$rc += 1;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function noEffect(block, a0, a1, a2) {
|
|
406
|
+
const prevEffect = runtime.$currentEffect;
|
|
407
|
+
runtime.$currentEffect = null;
|
|
408
|
+
try {
|
|
409
|
+
return block(a0, a1, a2);
|
|
410
|
+
} finally {
|
|
411
|
+
runtime.$currentEffect = prevEffect;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/data/Atom.ts
|
|
416
|
+
function atomOf(initialValue, lifecycle = getLifecycle()) {
|
|
417
|
+
if (isAtom(initialValue)) initialValue = initialValue.get();
|
|
418
|
+
return {
|
|
419
|
+
[S_ATOM]: true,
|
|
420
|
+
$value: initialValue,
|
|
421
|
+
$tracksValue: true,
|
|
422
|
+
$lifecycle: lifecycle,
|
|
423
|
+
$lastValue: initialValue,
|
|
424
|
+
get: getValue$1,
|
|
425
|
+
set: setValue$1
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function getValue$1() {
|
|
429
|
+
return this.$value;
|
|
430
|
+
}
|
|
431
|
+
function setValue$1(value) {
|
|
432
|
+
if (Object.is(this.$value, value)) return false;
|
|
433
|
+
this.$value = value;
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
function isAtom(input) {
|
|
437
|
+
return input !== null && typeof input === "object" && input[S_ATOM] === true;
|
|
438
|
+
}
|
|
439
|
+
function read(input) {
|
|
440
|
+
if (isAtom(input)) {
|
|
441
|
+
reportAccess(input);
|
|
442
|
+
return input.get();
|
|
443
|
+
}
|
|
444
|
+
return input;
|
|
445
|
+
}
|
|
446
|
+
function peek(input) {
|
|
447
|
+
if (isAtom(input)) return input.get();
|
|
448
|
+
return input;
|
|
449
|
+
}
|
|
450
|
+
function write(input, value, force = false) {
|
|
451
|
+
if (!isAtom(input)) return input;
|
|
452
|
+
if (input.set(value) || force) {
|
|
453
|
+
if (input.$dh) {
|
|
454
|
+
input.$force ||= force;
|
|
455
|
+
scheduleAtomNotification(input);
|
|
456
|
+
} else if (input.$tracksValue) return input.$lastValue = input.get();
|
|
457
|
+
}
|
|
458
|
+
return input.get();
|
|
459
|
+
}
|
|
460
|
+
function update(input, transform, force = false) {
|
|
461
|
+
if (!isAtom(input)) return input;
|
|
462
|
+
const value = transform(input.get());
|
|
463
|
+
if (input.set(value) || force) {
|
|
464
|
+
if (input.$dh) {
|
|
465
|
+
input.$force ||= force;
|
|
466
|
+
scheduleAtomNotification(input);
|
|
467
|
+
} else if (input.$tracksValue) return input.$lastValue = input.get();
|
|
468
|
+
}
|
|
469
|
+
return input.get();
|
|
470
|
+
}
|
|
471
|
+
function scheduleAtomNotification(atom) {
|
|
472
|
+
scheduleTick(atom.$lifecycle, atom.$notify ??= {
|
|
473
|
+
fn: notifyAtomObservers,
|
|
474
|
+
a0: atom
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function notifyAtomObservers(atom) {
|
|
478
|
+
if (atom.$tracksValue) {
|
|
479
|
+
const newValue = atom.get();
|
|
480
|
+
if (!atom.$force && Object.is(atom.$lastValue, newValue)) return;
|
|
481
|
+
atom.$lastValue = newValue;
|
|
482
|
+
}
|
|
483
|
+
atom.$force = false;
|
|
484
|
+
notify(atom);
|
|
485
|
+
}
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/Renderer.ts
|
|
488
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
489
|
+
function createRenderer(adapter, extensions) {
|
|
490
|
+
const hRoot = {
|
|
491
|
+
adapter,
|
|
492
|
+
mounted: true,
|
|
493
|
+
$isGroup: true,
|
|
494
|
+
$scheduler: /* @__PURE__ */ createScheduler(adapter.tick),
|
|
495
|
+
$extensions: extensions,
|
|
496
|
+
$context: null,
|
|
497
|
+
$depth: 0,
|
|
498
|
+
$life: 1,
|
|
499
|
+
$ng: null,
|
|
500
|
+
$ph: null,
|
|
501
|
+
unmount: destroy,
|
|
502
|
+
mount: (nRoot, jsx) => {
|
|
503
|
+
const hGroup = fork(hRoot, null, null);
|
|
504
|
+
try {
|
|
505
|
+
willMount(hGroup, () => {
|
|
506
|
+
const isBatch = !!adapter.batch;
|
|
507
|
+
const nParent = isBatch ? adapter.batch() : nRoot;
|
|
508
|
+
mount(jsx, hGroup, null, nParent, nRoot, isBatch);
|
|
509
|
+
if (isBatch) {
|
|
510
|
+
adapter.insert(nParent, nRoot, null);
|
|
511
|
+
flush(hGroup);
|
|
512
|
+
}
|
|
513
|
+
})();
|
|
514
|
+
return hGroup;
|
|
515
|
+
} catch (ex) {
|
|
516
|
+
destroy(hGroup, [ex]);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
hRoot.$ng = hRoot;
|
|
521
|
+
return hRoot;
|
|
522
|
+
}
|
|
523
|
+
function destroy(hGroup, errors) {
|
|
524
|
+
if (!hGroup.$isUnmounting && !deferUnmount(hGroup, true)) {
|
|
525
|
+
errors = doUnmount(hGroup, errors);
|
|
526
|
+
untrack(hGroup);
|
|
527
|
+
hGroup.$ph = null;
|
|
528
|
+
}
|
|
529
|
+
rethrow(errors);
|
|
530
|
+
}
|
|
531
|
+
function fork(hParent, hBefore = null, context = runtime.$currentContext) {
|
|
532
|
+
const ng = hParent.$ng;
|
|
533
|
+
const hGroup = {
|
|
534
|
+
adapter: ng.adapter,
|
|
535
|
+
mounted: false,
|
|
536
|
+
$isGroup: true,
|
|
537
|
+
$scheduler: ng.$scheduler,
|
|
538
|
+
$extensions: ng.$extensions,
|
|
539
|
+
$context: context,
|
|
540
|
+
$depth: 0,
|
|
541
|
+
$life: 1,
|
|
542
|
+
$ng: null,
|
|
543
|
+
$ph: hParent
|
|
544
|
+
};
|
|
545
|
+
hGroup.$ng = hGroup;
|
|
546
|
+
track(hGroup, hParent, hBefore);
|
|
547
|
+
return hGroup;
|
|
548
|
+
}
|
|
549
|
+
function track(hNode, hParent, hBefore = null) {
|
|
550
|
+
if (hBefore?.$ph === hParent) if (hBefore.$hp) {
|
|
551
|
+
hNode.$hp = hBefore.$hp;
|
|
552
|
+
hNode.$hn = hBefore;
|
|
553
|
+
hBefore.$hp.$hn = hNode;
|
|
554
|
+
hBefore.$hp = hNode;
|
|
555
|
+
} else {
|
|
556
|
+
hNode.$hp = null;
|
|
557
|
+
hNode.$hn = hParent.$hh;
|
|
558
|
+
if (hParent.$hh === hBefore) hBefore.$hp = hNode;
|
|
559
|
+
hParent.$hh = hNode;
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
if (hParent.$ht) {
|
|
563
|
+
hParent.$ht.$hn = hNode;
|
|
564
|
+
hNode.$hp = hParent.$ht;
|
|
565
|
+
} else hParent.$hh = hNode;
|
|
566
|
+
hParent.$ht = hNode;
|
|
567
|
+
}
|
|
568
|
+
hNode.$ph = hParent;
|
|
569
|
+
}
|
|
570
|
+
function untrack(hNode) {
|
|
571
|
+
if (hNode.$hp) hNode.$hp.$hn = hNode.$hn;
|
|
572
|
+
else if (hNode.$ph?.$hh === hNode) hNode.$ph.$hh = hNode.$hn;
|
|
573
|
+
if (hNode.$hn) hNode.$hn.$hp = hNode.$hp;
|
|
574
|
+
else if (hNode.$ph?.$ht === hNode) hNode.$ph.$ht = hNode.$hp;
|
|
575
|
+
hNode.$hp = null;
|
|
576
|
+
hNode.$hn = null;
|
|
577
|
+
}
|
|
578
|
+
function willMount(hGroup, block) {
|
|
579
|
+
return (a0, a1, a2) => {
|
|
580
|
+
const mounts = runtime.$mounts ??= [];
|
|
581
|
+
if (++hGroup.$depth === 1) mounts.push(hGroup);
|
|
582
|
+
let errors;
|
|
583
|
+
try {
|
|
584
|
+
return block(a0, a1, a2);
|
|
585
|
+
} catch (ex) {
|
|
586
|
+
(errors ??= []).push(ex);
|
|
587
|
+
} finally {
|
|
588
|
+
if (--hGroup.$depth === 0) mounts.pop();
|
|
589
|
+
finishMount(errors);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function mount(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
594
|
+
if (hParent.mounted) return;
|
|
595
|
+
const mounts = runtime.$mounts ??= [];
|
|
596
|
+
if (++hParent.$depth === 1) mounts.push(hParent);
|
|
597
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
598
|
+
const prevEffect = runtime.$currentEffect;
|
|
599
|
+
const prevContext = runtime.$currentContext;
|
|
600
|
+
const prevContextNew = runtime.$currentContextNew;
|
|
601
|
+
runtime.$currentLifecycle = hParent;
|
|
602
|
+
runtime.$currentContext = hParent.$context;
|
|
603
|
+
runtime.$currentContextNew = false;
|
|
604
|
+
runtime.$currentEffect = null;
|
|
605
|
+
let errors;
|
|
606
|
+
try {
|
|
607
|
+
mountJsx(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
608
|
+
hParent.$canMount = true;
|
|
609
|
+
if (!isBatch) flush(hParent);
|
|
610
|
+
} catch (ex) {
|
|
611
|
+
(errors ??= []).push(ex);
|
|
612
|
+
}
|
|
613
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
614
|
+
runtime.$currentEffect = prevEffect;
|
|
615
|
+
runtime.$currentContext = prevContext;
|
|
616
|
+
runtime.$currentContextNew = prevContextNew;
|
|
617
|
+
if (--hParent.$depth === 0) mounts.pop();
|
|
618
|
+
if (errors?.length && !deferUnmount(hParent)) errors = doUnmount(hParent, errors);
|
|
619
|
+
finishMount(errors);
|
|
620
|
+
}
|
|
621
|
+
function finishMount(errors) {
|
|
622
|
+
if (!runtime.$mounts.length) {
|
|
623
|
+
const pending = runtime.$unmounts;
|
|
624
|
+
runtime.$unmounts = null;
|
|
625
|
+
if (pending) {
|
|
626
|
+
const { length } = pending;
|
|
627
|
+
let index = 0;
|
|
628
|
+
let request;
|
|
629
|
+
for (; index < length; index += 1) {
|
|
630
|
+
request = pending[index];
|
|
631
|
+
if (request.$life !== request.$group.$life) continue;
|
|
632
|
+
errors = doUnmount(request.$group, errors);
|
|
633
|
+
if (request.$destroy) {
|
|
634
|
+
untrack(request.$group);
|
|
635
|
+
request.$group.$ph = null;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
rethrow(errors);
|
|
641
|
+
}
|
|
642
|
+
function deferUnmount(hGroup, isDestroy = false) {
|
|
643
|
+
const mounts = runtime.$mounts;
|
|
644
|
+
if (!mounts?.length) return false;
|
|
645
|
+
const lifecycle = runtime.$currentLifecycle;
|
|
646
|
+
const { length } = mounts;
|
|
647
|
+
let index = 0;
|
|
648
|
+
let active;
|
|
649
|
+
for (; index < length; index += 1) {
|
|
650
|
+
active = mounts[index];
|
|
651
|
+
if (ancestorContainsNode(hGroup, active) || lifecycle?.$isGroup && ancestorContainsNode(active, lifecycle) && ancestorContainsNode(hGroup, lifecycle)) break;
|
|
652
|
+
}
|
|
653
|
+
if (index === length) return false;
|
|
654
|
+
const pending = runtime.$unmounts ??= [];
|
|
655
|
+
const pendingLength = pending.length;
|
|
656
|
+
let pendingIndex = 0;
|
|
657
|
+
let request;
|
|
658
|
+
for (; pendingIndex < pendingLength; pendingIndex += 1) {
|
|
659
|
+
request = pending[pendingIndex];
|
|
660
|
+
if (request.$group === hGroup && request.$life === hGroup.$life) {
|
|
661
|
+
request.$destroy ||= isDestroy;
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
pending.push({
|
|
666
|
+
$group: hGroup,
|
|
667
|
+
$life: hGroup.$life,
|
|
668
|
+
$destroy: isDestroy
|
|
669
|
+
});
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
function ancestorContainsNode(hAncestor, hNode) {
|
|
673
|
+
while (hNode) {
|
|
674
|
+
if (hNode === hAncestor) return true;
|
|
675
|
+
hNode = hNode.$ph;
|
|
676
|
+
}
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
679
|
+
function flush(hGroup) {
|
|
680
|
+
if (hGroup.$ph?.$ng.mounted !== false) {
|
|
681
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
682
|
+
const prevEffect = runtime.$currentEffect;
|
|
683
|
+
runtime.$currentEffect = null;
|
|
684
|
+
const mounts = runtime.$mounts ??= [];
|
|
685
|
+
if (++hGroup.$depth === 1) mounts.push(hGroup);
|
|
686
|
+
const errors = doFlush(hGroup, void 0);
|
|
687
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
688
|
+
runtime.$currentEffect = prevEffect;
|
|
689
|
+
if (--hGroup.$depth === 0) mounts.pop();
|
|
690
|
+
finishMount(errors);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
function doFlush(hNode, errors) {
|
|
694
|
+
let current = hNode.$hh;
|
|
695
|
+
while (current) {
|
|
696
|
+
errors = doFlush(current, errors);
|
|
697
|
+
current = current.$hn;
|
|
698
|
+
}
|
|
699
|
+
if (hNode.$isGroup && hNode.$canMount && !hNode.mounted) {
|
|
700
|
+
hNode.mounted = true;
|
|
701
|
+
if (hNode.$onMount?.length) {
|
|
702
|
+
const callbacks = hNode.$onMount;
|
|
703
|
+
let index = 0;
|
|
704
|
+
runtime.$currentLifecycle = hNode;
|
|
705
|
+
for (; index < callbacks.length; index += 1) try {
|
|
706
|
+
invoke(callbacks[index]);
|
|
707
|
+
} catch (ex) {
|
|
708
|
+
(errors ??= []).push(ex);
|
|
709
|
+
}
|
|
710
|
+
callbacks.length = 0;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return errors;
|
|
714
|
+
}
|
|
715
|
+
function reinsertNodes(hParent, hBefore, nParent) {
|
|
716
|
+
if (!hParent.mounted) return;
|
|
717
|
+
const { adapter } = hParent;
|
|
718
|
+
const nAnchor = hBefore?.$nn ?? null;
|
|
719
|
+
let current = hParent.$hh;
|
|
720
|
+
while (current) {
|
|
721
|
+
if (current.$isNative) adapter.insert(current.$nn, nParent, nAnchor);
|
|
722
|
+
else reinsertNodes(current, hBefore, nParent);
|
|
723
|
+
current = current.$hn;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function unmount(hGroup, errors) {
|
|
727
|
+
if (deferUnmount(hGroup)) {
|
|
728
|
+
rethrow(errors);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
errors = doUnmount(hGroup, errors);
|
|
732
|
+
rethrow(errors);
|
|
733
|
+
}
|
|
734
|
+
function doUnmount(hGroup, errors) {
|
|
735
|
+
const prevLifecycle = runtime.$currentLifecycle;
|
|
736
|
+
const prevEffect = runtime.$currentEffect;
|
|
737
|
+
runtime.$currentEffect = null;
|
|
738
|
+
errors = unmountNode(hGroup, errors, true);
|
|
739
|
+
runtime.$currentLifecycle = prevLifecycle;
|
|
740
|
+
runtime.$currentEffect = prevEffect;
|
|
741
|
+
return errors;
|
|
742
|
+
}
|
|
743
|
+
function unmountNode(hNode, errors, top) {
|
|
744
|
+
if (hNode.$isUnmounting) return errors;
|
|
745
|
+
hNode.$isUnmounting = true;
|
|
746
|
+
if (hNode.$isGroup) {
|
|
747
|
+
if (hNode.$onUnmount?.length) {
|
|
748
|
+
const callbacks = hNode.$onUnmount;
|
|
749
|
+
let index = 0;
|
|
750
|
+
runtime.$currentLifecycle = hNode;
|
|
751
|
+
for (; index < callbacks.length; index += 1) try {
|
|
752
|
+
invoke(callbacks[index]);
|
|
753
|
+
} catch (ex) {
|
|
754
|
+
(errors ??= []).push(ex);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
teardown(hNode);
|
|
758
|
+
hNode.mounted = false;
|
|
759
|
+
hNode.$canMount = false;
|
|
760
|
+
}
|
|
761
|
+
const { adapter } = hNode.$ng;
|
|
762
|
+
let current = hNode.$hh;
|
|
763
|
+
let next;
|
|
764
|
+
while (current) {
|
|
765
|
+
if (current.$isNative && top) {
|
|
766
|
+
try {
|
|
767
|
+
adapter.remove(current.$nn);
|
|
768
|
+
} catch (ex) {
|
|
769
|
+
(errors ??= []).push(ex);
|
|
770
|
+
}
|
|
771
|
+
errors = unmountNode(current, errors, false);
|
|
772
|
+
} else errors = unmountNode(current, errors, top);
|
|
773
|
+
next = current.$hn;
|
|
774
|
+
current.$hp = null;
|
|
775
|
+
current.$hn = null;
|
|
776
|
+
current.$ph = null;
|
|
777
|
+
current = next;
|
|
778
|
+
}
|
|
779
|
+
hNode.$hh = null;
|
|
780
|
+
hNode.$ht = null;
|
|
781
|
+
hNode.$isUnmounting = false;
|
|
782
|
+
return errors;
|
|
783
|
+
}
|
|
784
|
+
function mountJsx(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
785
|
+
switch (typeof jsx) {
|
|
786
|
+
case "object":
|
|
787
|
+
if (jsx === null) break;
|
|
788
|
+
if (Array.isArray(jsx)) {
|
|
789
|
+
const text = mountJsxArray(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
790
|
+
if (text) mountStaticText(text, hParent, hBefore, nUsedParent, isBatch);
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
if (isAtom(jsx)) mountDynamicText(jsx, hParent, hBefore, nUsedParent, isBatch);
|
|
794
|
+
else jsx[S_COMPONENT]?.(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
795
|
+
break;
|
|
796
|
+
case "string": if (jsx === "") break;
|
|
797
|
+
case "number":
|
|
798
|
+
case "bigint":
|
|
799
|
+
mountStaticText("" + jsx, hParent, hBefore, nUsedParent, isBatch);
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function mountJsxArray(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch, text = "") {
|
|
804
|
+
const { length } = jsx;
|
|
805
|
+
let index = 0;
|
|
806
|
+
let item;
|
|
807
|
+
for (; index < length; index += 1) {
|
|
808
|
+
item = jsx[index];
|
|
809
|
+
switch (typeof item) {
|
|
810
|
+
case "string":
|
|
811
|
+
case "number":
|
|
812
|
+
case "bigint":
|
|
813
|
+
text += item;
|
|
814
|
+
break;
|
|
815
|
+
case "boolean": break;
|
|
816
|
+
default:
|
|
817
|
+
if (item === null || item === void 0) break;
|
|
818
|
+
if (Array.isArray(item)) {
|
|
819
|
+
text = mountJsxArray(item, hParent, hBefore, nUsedParent, nRealParent, isBatch, text);
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
if (text) {
|
|
823
|
+
mountStaticText(text, hParent, hBefore, nUsedParent, isBatch);
|
|
824
|
+
text = "";
|
|
825
|
+
}
|
|
826
|
+
mountJsx(item, hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return text;
|
|
831
|
+
}
|
|
832
|
+
function mountStaticText(text, hParent, hBefore, nUsedParent, isBatch) {
|
|
833
|
+
insert(hParent.$ng.adapter.text(text, null), null, hParent, hBefore, nUsedParent, isBatch);
|
|
834
|
+
}
|
|
835
|
+
function mountDynamicText(atom, hParent, hBefore, nUsedParent, isBatch) {
|
|
836
|
+
insert(bind(hParent.$ng, atom, {
|
|
837
|
+
fn: setBoundText,
|
|
838
|
+
a0: hParent.$ng.adapter,
|
|
839
|
+
a1: null
|
|
840
|
+
}), null, hParent, hBefore, nUsedParent, isBatch);
|
|
841
|
+
}
|
|
842
|
+
function setBoundText(adapter, node) {
|
|
843
|
+
const value = this.$target.get();
|
|
844
|
+
return this.a1 = adapter.text(value === null || value === void 0 || typeof value === "boolean" ? "" : "" + value, node);
|
|
845
|
+
}
|
|
846
|
+
function insert(nNode, children, hParent, hBefore, nUsedParent, isBatch, forceTrack = false) {
|
|
847
|
+
let hNative = hParent;
|
|
848
|
+
if (hNative.$isGroup || forceTrack) track(hNative = {
|
|
849
|
+
$isNative: true,
|
|
850
|
+
$ng: hParent.$ng,
|
|
851
|
+
$nn: nNode,
|
|
852
|
+
$ph: hParent
|
|
853
|
+
}, hParent, hBefore);
|
|
854
|
+
mountJsx(children, hNative, null, nNode, nNode, isBatch);
|
|
855
|
+
hParent.$ng.adapter.insert(nNode, nUsedParent, isBatch ? null : hBefore?.$nn ?? null);
|
|
856
|
+
return hNative === hParent ? null : hNative;
|
|
857
|
+
}
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/component/Fragment.ts
|
|
860
|
+
function Fragment(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
861
|
+
mountJsx(jsx.children, hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
862
|
+
}
|
|
863
|
+
//#endregion
|
|
864
|
+
//#region src/data/ListDelta.ts
|
|
865
|
+
const LC_CHANGE = 1;
|
|
866
|
+
const LC_INSERT = 2;
|
|
867
|
+
const LC_REMOVE = 3;
|
|
868
|
+
const LC_CLEAR = 4;
|
|
869
|
+
function itemChanged({ changes: $changes }, at, oldItem, newItem) {
|
|
870
|
+
const ci = binarySearch($changes, at, latest);
|
|
871
|
+
if (ci < 0) $changes.splice(~ci, 0, {
|
|
872
|
+
kind: 1,
|
|
873
|
+
index: at,
|
|
874
|
+
oldItem,
|
|
875
|
+
newItem
|
|
876
|
+
});
|
|
877
|
+
else {
|
|
878
|
+
const current = $changes[ci];
|
|
879
|
+
switch (current.kind) {
|
|
880
|
+
case 1:
|
|
881
|
+
case 2:
|
|
882
|
+
current.newItem = newItem;
|
|
883
|
+
break;
|
|
884
|
+
case 3:
|
|
885
|
+
$changes.splice(ci + 1, 0, {
|
|
886
|
+
kind: 1,
|
|
887
|
+
index: at,
|
|
888
|
+
oldItem,
|
|
889
|
+
newItem
|
|
890
|
+
});
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
function itemInserted(delta, at, item) {
|
|
896
|
+
const { changes: $changes } = delta;
|
|
897
|
+
let ci = binarySearch($changes, at, earliest);
|
|
898
|
+
if (ci < 0) {
|
|
899
|
+
ci = ~ci;
|
|
900
|
+
$changes.splice(ci, 0, {
|
|
901
|
+
kind: 2,
|
|
902
|
+
index: at,
|
|
903
|
+
newItem: item
|
|
904
|
+
});
|
|
905
|
+
} else {
|
|
906
|
+
const current = $changes[ci];
|
|
907
|
+
switch (current.kind) {
|
|
908
|
+
case 1:
|
|
909
|
+
case 2:
|
|
910
|
+
$changes.splice(ci, 0, {
|
|
911
|
+
kind: 2,
|
|
912
|
+
index: at,
|
|
913
|
+
newItem: item
|
|
914
|
+
});
|
|
915
|
+
break;
|
|
916
|
+
case 3:
|
|
917
|
+
if (Object.is(current.oldItem, item)) $changes.splice(ci--, 1);
|
|
918
|
+
else {
|
|
919
|
+
current.kind = 1;
|
|
920
|
+
current.newItem = item;
|
|
921
|
+
}
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
const { length } = $changes;
|
|
926
|
+
while (++ci < length) $changes[ci].index += 1;
|
|
927
|
+
delta.relSize += 1;
|
|
928
|
+
}
|
|
929
|
+
function itemRemoved(delta, at, item) {
|
|
930
|
+
const { changes: $changes } = delta;
|
|
931
|
+
let ci = binarySearch($changes, at, latest);
|
|
932
|
+
if (ci < 0) {
|
|
933
|
+
ci = ~ci;
|
|
934
|
+
$changes.splice(ci, 0, {
|
|
935
|
+
kind: 3,
|
|
936
|
+
index: at,
|
|
937
|
+
oldItem: item
|
|
938
|
+
});
|
|
939
|
+
} else {
|
|
940
|
+
const current = $changes[ci];
|
|
941
|
+
switch (current.kind) {
|
|
942
|
+
case 1:
|
|
943
|
+
current.kind = 3;
|
|
944
|
+
current.newItem = void 0;
|
|
945
|
+
break;
|
|
946
|
+
case 2:
|
|
947
|
+
$changes.splice(ci--, 1);
|
|
948
|
+
break;
|
|
949
|
+
case 3:
|
|
950
|
+
$changes.splice(++ci, 0, {
|
|
951
|
+
kind: 3,
|
|
952
|
+
index: at,
|
|
953
|
+
oldItem: item
|
|
954
|
+
});
|
|
955
|
+
break;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
const { length } = $changes;
|
|
959
|
+
while (++ci < length) $changes[ci].index -= 1;
|
|
960
|
+
delta.relSize -= 1;
|
|
961
|
+
}
|
|
962
|
+
function listCleared(delta, count) {
|
|
963
|
+
delta.changes.length = 0;
|
|
964
|
+
delta.relSize -= count;
|
|
965
|
+
if (delta.relSize === 0) return;
|
|
966
|
+
delta.changes.push({
|
|
967
|
+
kind: 4,
|
|
968
|
+
index: -1
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
function listSynced(delta, oldState, newState, eq) {
|
|
972
|
+
let index = 0;
|
|
973
|
+
let N = oldState.length;
|
|
974
|
+
let M = newState.length;
|
|
975
|
+
while (index < N && index < M && eq(oldState[index], newState[index])) index += 1;
|
|
976
|
+
if (index === N && index === M) return false;
|
|
977
|
+
while (N > index && M > index && eq(oldState[N - 1], newState[M - 1])) {
|
|
978
|
+
N -= 1;
|
|
979
|
+
M -= 1;
|
|
980
|
+
}
|
|
981
|
+
N -= index;
|
|
982
|
+
M -= index;
|
|
983
|
+
const Z = (Math.min(N, M) + 1) * 2;
|
|
984
|
+
const L = N + M;
|
|
985
|
+
const state = {
|
|
986
|
+
$eq: eq,
|
|
987
|
+
$list0: oldState,
|
|
988
|
+
$list1: newState,
|
|
989
|
+
$index0: index,
|
|
990
|
+
$index1: index,
|
|
991
|
+
$N: N,
|
|
992
|
+
$M: M,
|
|
993
|
+
$Z: Z,
|
|
994
|
+
$c: 0,
|
|
995
|
+
$buffer: new (L <= 255 ? Uint8Array : L <= 65535 ? Uint16Array : Uint32Array)(Z + Z),
|
|
996
|
+
$stack: [],
|
|
997
|
+
$stackTop: 0,
|
|
998
|
+
$pxs: -1,
|
|
999
|
+
$pxe: -1,
|
|
1000
|
+
$pys: -1,
|
|
1001
|
+
$pye: -1,
|
|
1002
|
+
$oxs: -1,
|
|
1003
|
+
$oxe: -1,
|
|
1004
|
+
$oys: -1,
|
|
1005
|
+
$oye: -1
|
|
1006
|
+
};
|
|
1007
|
+
let offset = 0;
|
|
1008
|
+
let hasChanges = false;
|
|
1009
|
+
let rs, re, is, ie, r, i;
|
|
1010
|
+
do {
|
|
1011
|
+
myersDiff(state);
|
|
1012
|
+
if (state.$c === 1) {
|
|
1013
|
+
rs = state.$oxs;
|
|
1014
|
+
re = state.$oxe;
|
|
1015
|
+
is = state.$oys;
|
|
1016
|
+
ie = state.$oye;
|
|
1017
|
+
} else if (state.$pxs >= 0) {
|
|
1018
|
+
rs = state.$pxs;
|
|
1019
|
+
re = state.$pxe;
|
|
1020
|
+
is = state.$pys;
|
|
1021
|
+
ie = state.$pye;
|
|
1022
|
+
} else break;
|
|
1023
|
+
for (r = rs; r < re; r += 1) {
|
|
1024
|
+
itemRemoved(delta, rs + offset, oldState[r]);
|
|
1025
|
+
hasChanges = true;
|
|
1026
|
+
}
|
|
1027
|
+
for (i = is; i < ie; i += 1) {
|
|
1028
|
+
itemInserted(delta, rs + offset, newState[i]);
|
|
1029
|
+
hasChanges = true;
|
|
1030
|
+
offset += 1;
|
|
1031
|
+
}
|
|
1032
|
+
offset -= re - rs;
|
|
1033
|
+
} while (state.$c < 2);
|
|
1034
|
+
return hasChanges;
|
|
1035
|
+
}
|
|
1036
|
+
const latest = (changes, index, mid, _min, max) => {
|
|
1037
|
+
let i = mid;
|
|
1038
|
+
while (++i < max && changes[i].index === index);
|
|
1039
|
+
return i - 1;
|
|
1040
|
+
};
|
|
1041
|
+
const earliest = (changes, index, mid, min, _max) => {
|
|
1042
|
+
let i = mid;
|
|
1043
|
+
while (--i >= min && changes[i].index === index);
|
|
1044
|
+
return i + 1;
|
|
1045
|
+
};
|
|
1046
|
+
function binarySearch(changes, index, bias) {
|
|
1047
|
+
let min = 0;
|
|
1048
|
+
let max = changes.length;
|
|
1049
|
+
let mid;
|
|
1050
|
+
let tmp;
|
|
1051
|
+
while (min < max) {
|
|
1052
|
+
mid = min + max >>> 1;
|
|
1053
|
+
tmp = changes[mid].index;
|
|
1054
|
+
if (index < tmp) max = mid;
|
|
1055
|
+
else if (index > tmp) min = mid + 1;
|
|
1056
|
+
else return bias(changes, index, mid, min, max);
|
|
1057
|
+
}
|
|
1058
|
+
return ~min;
|
|
1059
|
+
}
|
|
1060
|
+
function myersDiff(state) {
|
|
1061
|
+
const { $list0, $list1, $buffer, $stack, $eq } = state;
|
|
1062
|
+
let { $index0, $index1, $N, $M, $Z, $c, $stackTop } = state;
|
|
1063
|
+
let W, L, parity, offsetX, offsetY, z, h, hMax, k, kMin, kMax, gkm, gkp, u, v, x, y, pkm, pkp, sx;
|
|
1064
|
+
while (true) switch ($c) {
|
|
1065
|
+
case 0:
|
|
1066
|
+
Z_block: while ($N > 0 && $M > 0) {
|
|
1067
|
+
W = $N - $M;
|
|
1068
|
+
L = $N + $M;
|
|
1069
|
+
parity = L & 1;
|
|
1070
|
+
offsetX = $index0 + $N - 1;
|
|
1071
|
+
offsetY = $index1 + $M - 1;
|
|
1072
|
+
hMax = (L + parity) / 2;
|
|
1073
|
+
$buffer.fill(0, 0, $Z + $Z);
|
|
1074
|
+
h_loop: for (h = 0; h <= hMax; h += 1) {
|
|
1075
|
+
kMin = 2 * Math.max(0, h - $M) - h;
|
|
1076
|
+
kMax = h - 2 * Math.max(0, h - $N);
|
|
1077
|
+
for (k = kMin; k <= kMax; k += 2) {
|
|
1078
|
+
gkm = $buffer[k - 1 - $Z * Math.floor((k - 1) / $Z)];
|
|
1079
|
+
gkp = $buffer[k + 1 - $Z * Math.floor((k + 1) / $Z)];
|
|
1080
|
+
u = k === -h || k !== h && gkm < gkp ? gkp : gkm + 1;
|
|
1081
|
+
v = u - k;
|
|
1082
|
+
x = u;
|
|
1083
|
+
y = v;
|
|
1084
|
+
while (x < $N && y < $M && $eq($list0[$index0 + x], $list1[$index1 + y])) {
|
|
1085
|
+
x += 1;
|
|
1086
|
+
y += 1;
|
|
1087
|
+
}
|
|
1088
|
+
$buffer[k - $Z * Math.floor(k / $Z)] = x;
|
|
1089
|
+
if (parity === 1 && (z = W - k) >= 1 - h && z < h && x + $buffer[$Z + z - $Z * Math.floor(z / $Z)] >= $N) if (h > 1 || x !== u) {
|
|
1090
|
+
$stack[$stackTop++] = $index0 + x;
|
|
1091
|
+
$stack[$stackTop++] = $index1 + y;
|
|
1092
|
+
$stack[$stackTop++] = $N - x;
|
|
1093
|
+
$stack[$stackTop++] = $M - y;
|
|
1094
|
+
$N = u;
|
|
1095
|
+
$M = v;
|
|
1096
|
+
$Z = 2 * (Math.min($N, $M) + 1);
|
|
1097
|
+
continue Z_block;
|
|
1098
|
+
} else break h_loop;
|
|
1099
|
+
}
|
|
1100
|
+
for (k = kMin; k <= kMax; k += 2) {
|
|
1101
|
+
pkm = $buffer[$Z + k - 1 - $Z * Math.floor((k - 1) / $Z)];
|
|
1102
|
+
pkp = $buffer[$Z + k + 1 - $Z * Math.floor((k + 1) / $Z)];
|
|
1103
|
+
u = k === -h || k !== h && pkm < pkp ? pkp : pkm + 1;
|
|
1104
|
+
v = u - k;
|
|
1105
|
+
x = u;
|
|
1106
|
+
y = v;
|
|
1107
|
+
while (x < $N && y < $M && $eq($list0[offsetX - x], $list1[offsetY - y])) {
|
|
1108
|
+
x += 1;
|
|
1109
|
+
y += 1;
|
|
1110
|
+
}
|
|
1111
|
+
$buffer[$Z + k - $Z * Math.floor(k / $Z)] = x;
|
|
1112
|
+
if (parity === 0 && (z = W - k) >= -h && z <= h && x + $buffer[z - $Z * Math.floor(z / $Z)] >= $N) if (h > 0 || x !== u) {
|
|
1113
|
+
$stack[$stackTop++] = $index0 + $N - u;
|
|
1114
|
+
$stack[$stackTop++] = $index1 + $M - v;
|
|
1115
|
+
$stack[$stackTop++] = u;
|
|
1116
|
+
$stack[$stackTop++] = v;
|
|
1117
|
+
$N = $N - x;
|
|
1118
|
+
$M = $M - y;
|
|
1119
|
+
$Z = 2 * (Math.min($N, $M) + 1);
|
|
1120
|
+
continue Z_block;
|
|
1121
|
+
} else break h_loop;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
if ($N === $M) continue;
|
|
1125
|
+
if ($M > $N) {
|
|
1126
|
+
$index0 += $N;
|
|
1127
|
+
$index1 += $N;
|
|
1128
|
+
$M -= $N;
|
|
1129
|
+
$N = 0;
|
|
1130
|
+
} else {
|
|
1131
|
+
$index0 += $M;
|
|
1132
|
+
$index1 += $M;
|
|
1133
|
+
$N -= $M;
|
|
1134
|
+
$M = 0;
|
|
1135
|
+
}
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
if ($N + $M !== 0) if (state.$pxe === $index0 || state.$pye === $index1) {
|
|
1139
|
+
state.$pxe = $index0 + $N;
|
|
1140
|
+
state.$pye = $index1 + $M;
|
|
1141
|
+
} else {
|
|
1142
|
+
sx = state.$pxs;
|
|
1143
|
+
state.$oxs = state.$pxs;
|
|
1144
|
+
state.$oxe = state.$pxe;
|
|
1145
|
+
state.$oys = state.$pys;
|
|
1146
|
+
state.$oye = state.$pye;
|
|
1147
|
+
state.$pxs = $index0;
|
|
1148
|
+
state.$pxe = $index0 + $N;
|
|
1149
|
+
state.$pys = $index1;
|
|
1150
|
+
state.$pye = $index1 + $M;
|
|
1151
|
+
if (sx >= 0) {
|
|
1152
|
+
state.$index0 = $index0;
|
|
1153
|
+
state.$index1 = $index1;
|
|
1154
|
+
state.$N = $N;
|
|
1155
|
+
state.$M = $M;
|
|
1156
|
+
state.$Z = $Z;
|
|
1157
|
+
state.$stackTop = $stackTop;
|
|
1158
|
+
state.$c = 1;
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
case 1:
|
|
1163
|
+
if ($stackTop === 0) {
|
|
1164
|
+
state.$c = 2;
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
$M = $stack[--$stackTop];
|
|
1168
|
+
$N = $stack[--$stackTop];
|
|
1169
|
+
$index1 = $stack[--$stackTop];
|
|
1170
|
+
$index0 = $stack[--$stackTop];
|
|
1171
|
+
$Z = 2 * (Math.min($N, $M) + 1);
|
|
1172
|
+
$c = 0;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region src/data/ProxyAtom.ts
|
|
1177
|
+
function proxyOf(initialValue, lifecycle = getLifecycle()) {
|
|
1178
|
+
const self = {
|
|
1179
|
+
[S_ATOM]: true,
|
|
1180
|
+
$lifecycle: lifecycle,
|
|
1181
|
+
use
|
|
1182
|
+
};
|
|
1183
|
+
self.use(initialValue, true);
|
|
1184
|
+
return self;
|
|
1185
|
+
}
|
|
1186
|
+
function use(value, isInit = false) {
|
|
1187
|
+
if (value === this) return;
|
|
1188
|
+
const upstream = this.$upstream;
|
|
1189
|
+
if (upstream && upstream === value) return;
|
|
1190
|
+
let shouldNotify = true;
|
|
1191
|
+
if (isAtom(value)) {
|
|
1192
|
+
if (!upstream || isInit) {
|
|
1193
|
+
this.$value = null;
|
|
1194
|
+
this.$tracksValue = false;
|
|
1195
|
+
this.$lastValue = null;
|
|
1196
|
+
this.get = getUpstreamValue$1;
|
|
1197
|
+
this.set = setUpstreamValue;
|
|
1198
|
+
} else unlink(this.$dep);
|
|
1199
|
+
this.$upstream = value;
|
|
1200
|
+
link(this.$lifecycle, value, this.$dep ??= {
|
|
1201
|
+
fn: scheduleAtomNotification,
|
|
1202
|
+
a0: this
|
|
1203
|
+
});
|
|
1204
|
+
} else {
|
|
1205
|
+
if (upstream || isInit) {
|
|
1206
|
+
this.$upstream = null;
|
|
1207
|
+
this.$tracksValue = true;
|
|
1208
|
+
this.$lastValue = UNIQUE_VALUE;
|
|
1209
|
+
this.get = getStaticValue;
|
|
1210
|
+
this.set = setStaticValue;
|
|
1211
|
+
if (!isInit) unlink(this.$dep);
|
|
1212
|
+
} else shouldNotify = !Object.is(this.$value, value);
|
|
1213
|
+
this.$value = value;
|
|
1214
|
+
}
|
|
1215
|
+
if (this.$dh) {
|
|
1216
|
+
if (shouldNotify) scheduleAtomNotification(this);
|
|
1217
|
+
} else if (this.$tracksValue) this.$lastValue = value;
|
|
1218
|
+
}
|
|
1219
|
+
function getUpstreamValue$1() {
|
|
1220
|
+
return this.$upstream.get();
|
|
1221
|
+
}
|
|
1222
|
+
function setUpstreamValue(value) {
|
|
1223
|
+
const atom = this.$upstream;
|
|
1224
|
+
if (atom.set(value) && atom.$dh) scheduleAtomNotification(atom);
|
|
1225
|
+
return false;
|
|
1226
|
+
}
|
|
1227
|
+
function getStaticValue() {
|
|
1228
|
+
return this.$value;
|
|
1229
|
+
}
|
|
1230
|
+
function setStaticValue() {
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
function createProxy(lifecycle, data, keys) {
|
|
1234
|
+
const source = isObject(data) ? data : UNIQUE_VALUE;
|
|
1235
|
+
const proxy = Object.create(null);
|
|
1236
|
+
const { length } = keys;
|
|
1237
|
+
let index = 0;
|
|
1238
|
+
let key;
|
|
1239
|
+
for (; index < length; index += 1) {
|
|
1240
|
+
key = keys[index];
|
|
1241
|
+
proxy[key] = proxyOf(source[key], lifecycle);
|
|
1242
|
+
}
|
|
1243
|
+
proxy.proxied = data;
|
|
1244
|
+
return proxy;
|
|
1245
|
+
}
|
|
1246
|
+
function updateProxy(proxy, data, keys) {
|
|
1247
|
+
const source = isObject(data) ? data : UNIQUE_VALUE;
|
|
1248
|
+
const { length } = keys;
|
|
1249
|
+
proxy.proxied = data;
|
|
1250
|
+
let index = 0;
|
|
1251
|
+
let key;
|
|
1252
|
+
for (; index < length; index += 1) {
|
|
1253
|
+
key = keys[index];
|
|
1254
|
+
proxy[key].use(source[key]);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function isObject(value) {
|
|
1258
|
+
return value !== null && typeof value === "object";
|
|
1259
|
+
}
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region src/support/template.ts
|
|
1262
|
+
function Template(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
1263
|
+
mountJsx(jsx.t?.(jsx.d), hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
1264
|
+
}
|
|
1265
|
+
const REUSED_JSX = { [S_COMPONENT]: Template };
|
|
1266
|
+
function mountTemplate(template, data, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
1267
|
+
REUSED_JSX.t = template;
|
|
1268
|
+
REUSED_JSX.d = data;
|
|
1269
|
+
try {
|
|
1270
|
+
mount(REUSED_JSX, hParent, hBefore, nUsedParent, nRealParent, isBatch);
|
|
1271
|
+
} finally {
|
|
1272
|
+
REUSED_JSX.t = null;
|
|
1273
|
+
REUSED_JSX.d = null;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
//#endregion
|
|
1277
|
+
//#region src/component/Iterator.ts
|
|
1278
|
+
function Iterator(jsx, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
1279
|
+
const source = jsx.source;
|
|
1280
|
+
const proxyKeys = jsx.proxy;
|
|
1281
|
+
const isProxy = proxyKeys !== void 0;
|
|
1282
|
+
const template = jsx.children[0];
|
|
1283
|
+
const hGroup = fork(hParent, hBefore);
|
|
1284
|
+
const { adapter } = hGroup;
|
|
1285
|
+
const shouldBatch = !!adapter.batch;
|
|
1286
|
+
const nListEndMarker = adapter.marker();
|
|
1287
|
+
let renderedItems;
|
|
1288
|
+
let hListEndMarker = null;
|
|
1289
|
+
const renderInitialItems = (initItems, hInitBefore, nInitParent, initIsBatch) => {
|
|
1290
|
+
let nBatchParent = nInitParent;
|
|
1291
|
+
const isLocalBatch = shouldBatch && !initIsBatch && initItems.length > 0;
|
|
1292
|
+
const isAnyBatch = isLocalBatch || initIsBatch;
|
|
1293
|
+
if (isLocalBatch) nBatchParent = adapter.batch();
|
|
1294
|
+
let errors;
|
|
1295
|
+
renderedItems = initItems.map((data) => {
|
|
1296
|
+
const item = createItem(hGroup, hListEndMarker ?? hInitBefore, nBatchParent, isAnyBatch, data, proxyKeys);
|
|
1297
|
+
try {
|
|
1298
|
+
mountTemplate(template, item.$data, item, hInitBefore, nBatchParent, nRealParent, isAnyBatch);
|
|
1299
|
+
} catch (ex) {
|
|
1300
|
+
(errors ??= []).push(ex);
|
|
1301
|
+
}
|
|
1302
|
+
return item;
|
|
1303
|
+
});
|
|
1304
|
+
if (isLocalBatch) {
|
|
1305
|
+
adapter.insert(nBatchParent, nInitParent, hInitBefore?.$nn ?? null);
|
|
1306
|
+
errors = flushItems(renderedItems, 0, renderedItems.length, errors);
|
|
1307
|
+
}
|
|
1308
|
+
rethrow(errors);
|
|
1309
|
+
};
|
|
1310
|
+
source.delta(willMount(hGroup, (delta) => {
|
|
1311
|
+
if (!renderedItems) {
|
|
1312
|
+
renderInitialItems(delta.snapshot, hListEndMarker, nRealParent, false);
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
const { changes, relSize } = delta;
|
|
1316
|
+
const cMax = changes.length;
|
|
1317
|
+
const iMax = renderedItems.length + relSize;
|
|
1318
|
+
let newItems = renderedItems;
|
|
1319
|
+
let errors;
|
|
1320
|
+
let pending;
|
|
1321
|
+
let recycled;
|
|
1322
|
+
let item;
|
|
1323
|
+
let inserted = 0;
|
|
1324
|
+
let ci = 0;
|
|
1325
|
+
let oi = 0;
|
|
1326
|
+
let ni = 0;
|
|
1327
|
+
let change;
|
|
1328
|
+
let ref;
|
|
1329
|
+
let tmp;
|
|
1330
|
+
let isLocalBatch = false;
|
|
1331
|
+
let nBatchParent = nRealParent;
|
|
1332
|
+
let batchStart = 0;
|
|
1333
|
+
for (; ci < cMax; ci += 1) {
|
|
1334
|
+
change = changes[ci];
|
|
1335
|
+
if (newItems === renderedItems) if (change.kind === 1) oi = ni = change.index;
|
|
1336
|
+
else {
|
|
1337
|
+
newItems = new Array(iMax);
|
|
1338
|
+
oi = ni = 0;
|
|
1339
|
+
}
|
|
1340
|
+
while (ni < change.index) newItems[ni++] = renderedItems[oi++];
|
|
1341
|
+
switch (change.kind) {
|
|
1342
|
+
case 1:
|
|
1343
|
+
item = newItems[ni++] = renderedItems[oi++];
|
|
1344
|
+
if (isProxy) updateProxy(item.$data, change.newItem, proxyKeys);
|
|
1345
|
+
else {
|
|
1346
|
+
try {
|
|
1347
|
+
unmount(item);
|
|
1348
|
+
} catch (ex) {
|
|
1349
|
+
(errors ??= []).push(ex);
|
|
1350
|
+
}
|
|
1351
|
+
ref = renderedItems[oi]?.$marker ?? hListEndMarker;
|
|
1352
|
+
try {
|
|
1353
|
+
mountTemplate(template, item.$data = change.newItem, item, ref, nRealParent, nRealParent, false);
|
|
1354
|
+
} catch (ex) {
|
|
1355
|
+
(errors ??= []).push(ex);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
break;
|
|
1359
|
+
case 2:
|
|
1360
|
+
if (!isProxy || inserted < relSize) {
|
|
1361
|
+
ref = renderedItems[oi]?.$marker ?? hListEndMarker;
|
|
1362
|
+
if (!isLocalBatch) {
|
|
1363
|
+
if (shouldBatch) {
|
|
1364
|
+
isLocalBatch = true;
|
|
1365
|
+
batchStart = ni;
|
|
1366
|
+
nBatchParent = adapter.batch();
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
inserted += 1;
|
|
1370
|
+
item = newItems[ni++] = createItem(hGroup, renderedItems[oi]?.$marker ?? hListEndMarker, nBatchParent, isLocalBatch, change.newItem, proxyKeys);
|
|
1371
|
+
try {
|
|
1372
|
+
mountTemplate(template, item.$data, item, ref, nBatchParent, nRealParent, isLocalBatch);
|
|
1373
|
+
} catch (ex) {
|
|
1374
|
+
(errors ??= []).push(ex);
|
|
1375
|
+
}
|
|
1376
|
+
if (isLocalBatch && (inserted >= relSize || !(tmp = changes[ci + 1]) || tmp.kind !== 2 || tmp.index !== ni)) {
|
|
1377
|
+
adapter.insert(nBatchParent, nRealParent, ref.$nn);
|
|
1378
|
+
errors = flushItems(newItems, batchStart, ni, errors);
|
|
1379
|
+
nBatchParent = nRealParent;
|
|
1380
|
+
isLocalBatch = false;
|
|
1381
|
+
}
|
|
1382
|
+
} else {
|
|
1383
|
+
(pending ??= []).push(ci);
|
|
1384
|
+
ni += 1;
|
|
1385
|
+
}
|
|
1386
|
+
break;
|
|
1387
|
+
case 3:
|
|
1388
|
+
item = renderedItems[oi++];
|
|
1389
|
+
if (isProxy) {
|
|
1390
|
+
(recycled ??= []).push(item);
|
|
1391
|
+
untrackItem(item);
|
|
1392
|
+
} else try {
|
|
1393
|
+
destroyItem(item);
|
|
1394
|
+
} catch (ex) {
|
|
1395
|
+
(errors ??= []).push(ex);
|
|
1396
|
+
}
|
|
1397
|
+
break;
|
|
1398
|
+
case 4:
|
|
1399
|
+
if (isProxy) {
|
|
1400
|
+
recycled = renderedItems;
|
|
1401
|
+
recycled.forEach(untrackItem);
|
|
1402
|
+
oi = renderedItems.length;
|
|
1403
|
+
} else while (oi < renderedItems.length) {
|
|
1404
|
+
item = renderedItems[oi++];
|
|
1405
|
+
try {
|
|
1406
|
+
destroyItem(item);
|
|
1407
|
+
} catch (ex) {
|
|
1408
|
+
(errors ??= []).push(ex);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
break;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
if (newItems !== renderedItems) while (ni < iMax) newItems[ni++] = renderedItems[oi++];
|
|
1415
|
+
let pi = pending ? pending.length - 1 : -1;
|
|
1416
|
+
let ri = recycled ? recycled.length - 1 : -1;
|
|
1417
|
+
while (pi >= 0) {
|
|
1418
|
+
tmp = changes[pending[pi--]];
|
|
1419
|
+
item = newItems[tmp.index] = recycled[ri--];
|
|
1420
|
+
updateProxy(item.$data, tmp.newItem, proxyKeys);
|
|
1421
|
+
ref = newItems[tmp.index + 1];
|
|
1422
|
+
track(item.$marker, hGroup, ref?.$marker ?? hListEndMarker);
|
|
1423
|
+
track(item, hGroup, ref?.$marker ?? hListEndMarker);
|
|
1424
|
+
adapter.insert(item.$marker.$nn, nRealParent, ref?.$marker.$nn ?? nListEndMarker);
|
|
1425
|
+
reinsertNodes(item, ref?.$marker ?? hListEndMarker, nRealParent);
|
|
1426
|
+
}
|
|
1427
|
+
while (ri >= 0) {
|
|
1428
|
+
item = recycled[ri--];
|
|
1429
|
+
try {
|
|
1430
|
+
destroyItem(item);
|
|
1431
|
+
} catch (ex) {
|
|
1432
|
+
(errors ??= []).push(ex);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
renderedItems = newItems;
|
|
1436
|
+
rethrow(errors);
|
|
1437
|
+
}), hGroup);
|
|
1438
|
+
if (!source.dirty()) source.stable((snapshot) => {
|
|
1439
|
+
renderInitialItems(snapshot, hBefore, nUsedParent, isBatch);
|
|
1440
|
+
});
|
|
1441
|
+
hListEndMarker = insert(nListEndMarker, null, hGroup, hBefore, nUsedParent, isBatch, true);
|
|
1442
|
+
mount(null, hGroup, hBefore, nUsedParent, nRealParent, isBatch);
|
|
1443
|
+
}
|
|
1444
|
+
function flushItems(items, start, end, errors) {
|
|
1445
|
+
let index = start;
|
|
1446
|
+
for (; index < end; index += 1) try {
|
|
1447
|
+
flush(items[index]);
|
|
1448
|
+
} catch (ex) {
|
|
1449
|
+
(errors ??= []).push(ex);
|
|
1450
|
+
}
|
|
1451
|
+
return errors;
|
|
1452
|
+
}
|
|
1453
|
+
function createItem(hParent, hBefore, nParent, isBatch, data, proxyKeys) {
|
|
1454
|
+
const marker = insert(hParent.adapter.marker(), null, hParent, hBefore, nParent, isBatch, true);
|
|
1455
|
+
const item = fork(hParent, hBefore, hParent.$context);
|
|
1456
|
+
item.$marker = marker;
|
|
1457
|
+
item.$data = proxyKeys !== void 0 ? createProxy(item, data, proxyKeys) : data;
|
|
1458
|
+
return item;
|
|
1459
|
+
}
|
|
1460
|
+
function untrackItem(item) {
|
|
1461
|
+
untrack(item.$marker);
|
|
1462
|
+
untrack(item);
|
|
1463
|
+
}
|
|
1464
|
+
function destroyItem(item) {
|
|
1465
|
+
try {
|
|
1466
|
+
destroy(item);
|
|
1467
|
+
} finally {
|
|
1468
|
+
const marker = item.$marker;
|
|
1469
|
+
item.adapter.remove(marker.$nn);
|
|
1470
|
+
untrack(marker);
|
|
1471
|
+
marker.$ph = null;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
//#endregion
|
|
1475
|
+
//#region src/component/Native.ts
|
|
1476
|
+
function Native(jsx, hParent, hBefore, nUsedParent, _nRealParent, isBatch) {
|
|
1477
|
+
const hGroup = hParent.$ng;
|
|
1478
|
+
const { adapter, $extensions } = hGroup;
|
|
1479
|
+
const nNode = adapter.element(jsx[S_TAG_NAME]);
|
|
1480
|
+
let name;
|
|
1481
|
+
let index;
|
|
1482
|
+
let value;
|
|
1483
|
+
let target;
|
|
1484
|
+
for (name in jsx) {
|
|
1485
|
+
index = name.indexOf(":");
|
|
1486
|
+
value = jsx[name];
|
|
1487
|
+
if (index === 0) {
|
|
1488
|
+
if (target = runtime.x[name]) target.$ext.set(nNode, target.$prop, value, hGroup);
|
|
1489
|
+
} else if (index > 0) $extensions[name.slice(0, index)]?.set(nNode, name.slice(index + 1), value, hGroup);
|
|
1490
|
+
else if (name !== "children") {
|
|
1491
|
+
if (isAtom(value)) {
|
|
1492
|
+
link(hGroup, value, {
|
|
1493
|
+
fn: setBoundProp,
|
|
1494
|
+
a0: adapter,
|
|
1495
|
+
a1: nNode,
|
|
1496
|
+
a2: name
|
|
1497
|
+
});
|
|
1498
|
+
value = value.get();
|
|
1499
|
+
}
|
|
1500
|
+
adapter.set(nNode, name, value);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
insert(nNode, jsx.children, hParent, hBefore, nUsedParent, isBatch);
|
|
1504
|
+
return nNode;
|
|
1505
|
+
}
|
|
1506
|
+
function setBoundProp(adapter, node, prop) {
|
|
1507
|
+
adapter.set(node, prop, this.$target.get());
|
|
1508
|
+
}
|
|
1509
|
+
//#endregion
|
|
1510
|
+
//#region src/component/Show.ts
|
|
1511
|
+
function Show(props, hParent, hBefore, nUsedParent, nRealParent, isBatch) {
|
|
1512
|
+
const when = props.when;
|
|
1513
|
+
if (!isAtom(when) && when === false) return;
|
|
1514
|
+
const { children, data } = props;
|
|
1515
|
+
const proxyKeys = props.proxy;
|
|
1516
|
+
const template = Object.hasOwn(props, "data") ? children[0] : () => children;
|
|
1517
|
+
let dataOrProxy = data;
|
|
1518
|
+
if (proxyKeys) if (isAtom(data)) {
|
|
1519
|
+
dataOrProxy = createProxy(hParent.$ng, data.get(), proxyKeys);
|
|
1520
|
+
link(hParent.$ng, data, {
|
|
1521
|
+
fn: updateShowProxy,
|
|
1522
|
+
a0: dataOrProxy,
|
|
1523
|
+
a1: data,
|
|
1524
|
+
a2: proxyKeys
|
|
1525
|
+
});
|
|
1526
|
+
} else dataOrProxy = createProxy(hParent.$ng, data, proxyKeys);
|
|
1527
|
+
const adapter = hParent.$ng.adapter;
|
|
1528
|
+
const shouldBatch = !!adapter.batch;
|
|
1529
|
+
if (!(isAtom(when) || isAtom(template) || !proxyKeys && isAtom(data))) {
|
|
1530
|
+
const isLocalBatch = shouldBatch && !isBatch;
|
|
1531
|
+
let nBatchParent = nUsedParent;
|
|
1532
|
+
if (isLocalBatch) nBatchParent = adapter.batch();
|
|
1533
|
+
mountJsx(template(dataOrProxy), hParent, hBefore, nBatchParent, nRealParent, isLocalBatch || isBatch);
|
|
1534
|
+
if (isLocalBatch) adapter.insert(nBatchParent, nUsedParent, hBefore?.$nn ?? null);
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
const hGroup = fork(hParent, hBefore);
|
|
1538
|
+
const dispose = () => unmount(hGroup);
|
|
1539
|
+
let hMarker = hBefore;
|
|
1540
|
+
effect(willMount(hGroup, () => {
|
|
1541
|
+
if (read(when) === false) return;
|
|
1542
|
+
const isLocalBatch = shouldBatch && !isBatch;
|
|
1543
|
+
let nBatchParent = nUsedParent;
|
|
1544
|
+
if (isLocalBatch) nBatchParent = adapter.batch();
|
|
1545
|
+
mountTemplate(read(template), read(dataOrProxy), hGroup, hMarker, nBatchParent, nRealParent, isLocalBatch || isBatch);
|
|
1546
|
+
if (isLocalBatch) {
|
|
1547
|
+
adapter.insert(nBatchParent, nUsedParent, hMarker?.$nn ?? null);
|
|
1548
|
+
try {
|
|
1549
|
+
flush(hGroup);
|
|
1550
|
+
} catch (ex) {
|
|
1551
|
+
unmount(hGroup, [ex]);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
return dispose;
|
|
1555
|
+
}), hParent.$ng);
|
|
1556
|
+
hMarker = insert(adapter.marker(), null, hParent, hBefore, nUsedParent, isBatch, true);
|
|
1557
|
+
isBatch = false;
|
|
1558
|
+
nUsedParent = nRealParent;
|
|
1559
|
+
}
|
|
1560
|
+
function updateShowProxy(proxy, source, keys) {
|
|
1561
|
+
updateProxy(proxy, source.get(), keys);
|
|
1562
|
+
}
|
|
1563
|
+
//#endregion
|
|
1564
|
+
//#region src/data/Context.ts
|
|
1565
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1566
|
+
function contextOf() {
|
|
1567
|
+
return { $symbol: Symbol() };
|
|
1568
|
+
}
|
|
1569
|
+
function host(context, defaultValue, lifecycle = getLifecycle()) {
|
|
1570
|
+
if (!runtime.$currentContextNew || !runtime.$currentContext) {
|
|
1571
|
+
runtime.$currentContextNew = true;
|
|
1572
|
+
runtime.$currentContext = { $parent: runtime.$currentContext };
|
|
1573
|
+
}
|
|
1574
|
+
let isUndefined = defaultValue === void 0;
|
|
1575
|
+
const localAtom = {
|
|
1576
|
+
[S_ATOM]: true,
|
|
1577
|
+
$lifecycle: lifecycle,
|
|
1578
|
+
$value: defaultValue,
|
|
1579
|
+
get: getHostedValue,
|
|
1580
|
+
set: setHostedValue
|
|
1581
|
+
};
|
|
1582
|
+
let upstream;
|
|
1583
|
+
if (isUndefined && (upstream = lookupUpstream(context))) {
|
|
1584
|
+
localAtom.get = getUpstreamValue;
|
|
1585
|
+
localAtom.$upstream = upstream;
|
|
1586
|
+
link(lifecycle, upstream, localAtom.$dep = {
|
|
1587
|
+
fn: scheduleAtomNotification,
|
|
1588
|
+
a0: localAtom
|
|
1589
|
+
});
|
|
1590
|
+
} else {
|
|
1591
|
+
localAtom.$tracksValue = true;
|
|
1592
|
+
localAtom.$lastValue = defaultValue;
|
|
1593
|
+
}
|
|
1594
|
+
runtime.$currentContext[context.$symbol] = localAtom;
|
|
1595
|
+
return localAtom;
|
|
1596
|
+
}
|
|
1597
|
+
function contextual(context) {
|
|
1598
|
+
return lookupUpstream(context);
|
|
1599
|
+
}
|
|
1600
|
+
function lookupUpstream(context) {
|
|
1601
|
+
const { $symbol } = context;
|
|
1602
|
+
let ptr = runtime.$currentContext;
|
|
1603
|
+
let atom;
|
|
1604
|
+
while (ptr && !(atom = ptr[$symbol])) ptr = ptr.$parent;
|
|
1605
|
+
return atom;
|
|
1606
|
+
}
|
|
1607
|
+
function getUpstreamValue() {
|
|
1608
|
+
return this.$upstream.get();
|
|
1609
|
+
}
|
|
1610
|
+
function getHostedValue() {
|
|
1611
|
+
return this.$value;
|
|
1612
|
+
}
|
|
1613
|
+
function setHostedValue(value) {
|
|
1614
|
+
let didChange = true;
|
|
1615
|
+
if (this.$upstream) {
|
|
1616
|
+
unlink(this.$dep);
|
|
1617
|
+
this.$upstream = null;
|
|
1618
|
+
this.$dep = null;
|
|
1619
|
+
this.$tracksValue = true;
|
|
1620
|
+
this.$lastValue = UNIQUE_VALUE;
|
|
1621
|
+
this.get = getHostedValue;
|
|
1622
|
+
} else didChange = !Object.is(this.$value, value);
|
|
1623
|
+
this.$value = value;
|
|
1624
|
+
return didChange;
|
|
1625
|
+
}
|
|
1626
|
+
//#endregion
|
|
1627
|
+
//#region src/data/Derivation.ts
|
|
1628
|
+
function derived(block, lifecycle = getLifecycle()) {
|
|
1629
|
+
const atom = {
|
|
1630
|
+
[S_ATOM]: true,
|
|
1631
|
+
$dirty: false,
|
|
1632
|
+
$value: null,
|
|
1633
|
+
$tracksValue: true,
|
|
1634
|
+
$lifecycle: lifecycle,
|
|
1635
|
+
$life: lifecycle.$life,
|
|
1636
|
+
$lastValue: null,
|
|
1637
|
+
$cycle: 0,
|
|
1638
|
+
$block: block,
|
|
1639
|
+
$react: scheduleReaction,
|
|
1640
|
+
get: getValue,
|
|
1641
|
+
set: setValue
|
|
1642
|
+
};
|
|
1643
|
+
const value = resolve(atom);
|
|
1644
|
+
atom.$value = value;
|
|
1645
|
+
atom.$lastValue = value;
|
|
1646
|
+
return atom;
|
|
1647
|
+
}
|
|
1648
|
+
function scheduleReaction(derivation, cycle) {
|
|
1649
|
+
if (derivation.$life !== derivation.$lifecycle.$life || derivation.$cycle > cycle) {
|
|
1650
|
+
unlinkEffectDep(derivation, this);
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
derivation.$dirty = true;
|
|
1654
|
+
scheduleAtomNotification(derivation);
|
|
1655
|
+
}
|
|
1656
|
+
function getValue() {
|
|
1657
|
+
if (this.$dirty && this.$life === this.$lifecycle.$life) {
|
|
1658
|
+
this.$value = resolve(this);
|
|
1659
|
+
this.$dirty = false;
|
|
1660
|
+
}
|
|
1661
|
+
return this.$value;
|
|
1662
|
+
}
|
|
1663
|
+
function setValue() {
|
|
1664
|
+
return false;
|
|
1665
|
+
}
|
|
1666
|
+
//#endregion
|
|
1667
|
+
//#region src/data/List.ts
|
|
1668
|
+
function listOf(source, lifecycle = getLifecycle()) {
|
|
1669
|
+
return {
|
|
1670
|
+
$items: source ? Array.from(source) : [],
|
|
1671
|
+
$lifecycle: lifecycle,
|
|
1672
|
+
$committedDelta: null,
|
|
1673
|
+
$pendingDelta: null,
|
|
1674
|
+
$lock: 0,
|
|
1675
|
+
[Symbol.iterator]: getIterator,
|
|
1676
|
+
size,
|
|
1677
|
+
get,
|
|
1678
|
+
dirty,
|
|
1679
|
+
delta,
|
|
1680
|
+
raw,
|
|
1681
|
+
forEach,
|
|
1682
|
+
stable,
|
|
1683
|
+
set,
|
|
1684
|
+
clear,
|
|
1685
|
+
insertAt,
|
|
1686
|
+
insertFirst,
|
|
1687
|
+
insertLast,
|
|
1688
|
+
remove,
|
|
1689
|
+
removeAt,
|
|
1690
|
+
removeFirst,
|
|
1691
|
+
removeLast
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
function sync(list, source, eq = Object.is) {
|
|
1695
|
+
const oldItems = list.$items;
|
|
1696
|
+
const newItems = Array.from(source);
|
|
1697
|
+
list.$items = newItems;
|
|
1698
|
+
if (!list.$dh && !list.$xa) return;
|
|
1699
|
+
const delta = initDelta(list);
|
|
1700
|
+
if (listSynced(delta, oldItems, newItems, eq)) {
|
|
1701
|
+
list.$pendingDelta = delta;
|
|
1702
|
+
scheduleListNotification(list);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
function size() {
|
|
1706
|
+
reportAccess(this);
|
|
1707
|
+
return this.$items.length;
|
|
1708
|
+
}
|
|
1709
|
+
function get(index) {
|
|
1710
|
+
reportAccess(this);
|
|
1711
|
+
return this.$items[index];
|
|
1712
|
+
}
|
|
1713
|
+
function dirty() {
|
|
1714
|
+
if (this.$xa) return true;
|
|
1715
|
+
const delta = this.$pendingDelta;
|
|
1716
|
+
if (!delta) return false;
|
|
1717
|
+
const pending = this.$notify;
|
|
1718
|
+
return (!pending || pending.$life === pending.$lifecycle.$life) && delta.changes.length > 0;
|
|
1719
|
+
}
|
|
1720
|
+
function delta(block, lifecycle = getLifecycle()) {
|
|
1721
|
+
link(lifecycle, this, {
|
|
1722
|
+
fn: invokeDeltaBlock,
|
|
1723
|
+
a0: this,
|
|
1724
|
+
a1: lifecycle,
|
|
1725
|
+
a2: block
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
function raw() {
|
|
1729
|
+
return this.$items;
|
|
1730
|
+
}
|
|
1731
|
+
function forEach(callback) {
|
|
1732
|
+
reportAccess(this);
|
|
1733
|
+
this.$items.forEach(callback);
|
|
1734
|
+
}
|
|
1735
|
+
function stable(block) {
|
|
1736
|
+
try {
|
|
1737
|
+
this.$lock += 1;
|
|
1738
|
+
return block(this.$items);
|
|
1739
|
+
} finally {
|
|
1740
|
+
this.$lock = Math.max(this.$lock - 1, 0);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
function getIterator() {
|
|
1744
|
+
reportAccess(this);
|
|
1745
|
+
return this.$items[Symbol.iterator]();
|
|
1746
|
+
}
|
|
1747
|
+
function set(index, newItem) {
|
|
1748
|
+
assertIndex(this, index);
|
|
1749
|
+
const oldItem = this.$items[index];
|
|
1750
|
+
if (Object.is(newItem, oldItem)) return;
|
|
1751
|
+
copyOnWrite(this);
|
|
1752
|
+
this.$items[index] = newItem;
|
|
1753
|
+
if (this.$dh || this.$xa) {
|
|
1754
|
+
itemChanged(this.$pendingDelta = initDelta(this), index, oldItem, newItem);
|
|
1755
|
+
scheduleListNotification(this);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
function clear() {
|
|
1759
|
+
const count = this.$items.length;
|
|
1760
|
+
if (this.$lock > 0) {
|
|
1761
|
+
this.$items = [];
|
|
1762
|
+
this.$lock = 0;
|
|
1763
|
+
} else this.$items.length = 0;
|
|
1764
|
+
if (this.$dh || this.$xa) {
|
|
1765
|
+
listCleared(this.$pendingDelta = initDelta(this), count);
|
|
1766
|
+
scheduleListNotification(this);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
function insertAt(index, item) {
|
|
1770
|
+
if (index === this.$items.length) {
|
|
1771
|
+
copyOnWrite(this);
|
|
1772
|
+
this.$items.push(item);
|
|
1773
|
+
} else {
|
|
1774
|
+
assertIndex(this, index);
|
|
1775
|
+
copyOnWrite(this);
|
|
1776
|
+
this.$items.splice(index, 0, item);
|
|
1777
|
+
}
|
|
1778
|
+
if (this.$dh || this.$xa) {
|
|
1779
|
+
itemInserted(this.$pendingDelta = initDelta(this), index, item);
|
|
1780
|
+
scheduleListNotification(this);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
function insertFirst(item) {
|
|
1784
|
+
this.insertAt(0, item);
|
|
1785
|
+
}
|
|
1786
|
+
function insertLast(item) {
|
|
1787
|
+
this.insertAt(this.$items.length, item);
|
|
1788
|
+
}
|
|
1789
|
+
function remove(item) {
|
|
1790
|
+
const index = this.$items.indexOf(item);
|
|
1791
|
+
if (index === -1) return false;
|
|
1792
|
+
this.removeAt(index);
|
|
1793
|
+
return true;
|
|
1794
|
+
}
|
|
1795
|
+
function removeAt(index) {
|
|
1796
|
+
assertIndex(this, index);
|
|
1797
|
+
copyOnWrite(this);
|
|
1798
|
+
const item = this.$items.splice(index, 1)[0];
|
|
1799
|
+
if (this.$dh || this.$xa) {
|
|
1800
|
+
itemRemoved(this.$pendingDelta = initDelta(this), index, item);
|
|
1801
|
+
scheduleListNotification(this);
|
|
1802
|
+
}
|
|
1803
|
+
return item;
|
|
1804
|
+
}
|
|
1805
|
+
function removeFirst() {
|
|
1806
|
+
return this.$items.length > 0 ? this.removeAt(0) : void 0;
|
|
1807
|
+
}
|
|
1808
|
+
function removeLast() {
|
|
1809
|
+
const { length } = this.$items;
|
|
1810
|
+
return length > 0 ? this.removeAt(length - 1) : void 0;
|
|
1811
|
+
}
|
|
1812
|
+
function assertIndex(list, index) {
|
|
1813
|
+
if (!Number.isInteger(index)) throw new TypeError();
|
|
1814
|
+
if (index >= list.$items.length || index < 0) throw new RangeError();
|
|
1815
|
+
}
|
|
1816
|
+
function initDelta(list) {
|
|
1817
|
+
if (list.$pendingDelta) {
|
|
1818
|
+
const pending = list.$notify;
|
|
1819
|
+
if (!pending || pending.$life === pending.$lifecycle.$life) return list.$pendingDelta;
|
|
1820
|
+
}
|
|
1821
|
+
return {
|
|
1822
|
+
changes: [],
|
|
1823
|
+
relSize: 0
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
function copyOnWrite(list) {
|
|
1827
|
+
if (list.$lock > 0) {
|
|
1828
|
+
list.$items = list.$items.slice();
|
|
1829
|
+
list.$lock = 0;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
function scheduleListNotification(list) {
|
|
1833
|
+
scheduleTick(list.$lifecycle, list.$notify ??= {
|
|
1834
|
+
fn: notifyListObservers,
|
|
1835
|
+
a0: list
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
function notifyListObservers(list) {
|
|
1839
|
+
const delta = list.$pendingDelta;
|
|
1840
|
+
list.$pendingDelta = null;
|
|
1841
|
+
if (list.$force || delta.changes.length > 0) {
|
|
1842
|
+
delta.snapshot = list.$items;
|
|
1843
|
+
list.$committedDelta = delta;
|
|
1844
|
+
list.$lock += 1;
|
|
1845
|
+
list.$force = false;
|
|
1846
|
+
try {
|
|
1847
|
+
notify(list);
|
|
1848
|
+
} finally {
|
|
1849
|
+
list.$committedDelta = null;
|
|
1850
|
+
list.$lock = Math.max(list.$lock - 1, 0);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
function invokeDeltaBlock(list, lifecycle, block) {
|
|
1855
|
+
withLifecycle(lifecycle, block, list.$committedDelta);
|
|
1856
|
+
}
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region src/Adapter.ts
|
|
1859
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1860
|
+
function extension(propSetter) {
|
|
1861
|
+
return {
|
|
1862
|
+
$prefix: `:${(++runtime.$extIndex).toString(16)}:`,
|
|
1863
|
+
set: propSetter
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
function ext(extension, extensionProps, targetPropsObject = {}) {
|
|
1867
|
+
const prefix = extension.$prefix;
|
|
1868
|
+
const routing = runtime.x;
|
|
1869
|
+
let prop;
|
|
1870
|
+
let route;
|
|
1871
|
+
for (prop in extensionProps) {
|
|
1872
|
+
route = prefix + prop;
|
|
1873
|
+
routing[route] ??= {
|
|
1874
|
+
$ext: extension,
|
|
1875
|
+
$prop: prop
|
|
1876
|
+
};
|
|
1877
|
+
targetPropsObject[route] = extensionProps[prop];
|
|
1878
|
+
}
|
|
1879
|
+
return targetPropsObject;
|
|
1880
|
+
}
|
|
1881
|
+
//#endregion
|
|
1882
|
+
//#region src/extension/RefExtension.ts
|
|
1883
|
+
const RefExtension = /*@__PURE__*/ extension((node, prop, value, group) => {
|
|
1884
|
+
switch (prop) {
|
|
1885
|
+
case "atom":
|
|
1886
|
+
if (isAtom(value)) {
|
|
1887
|
+
onceMounted(group, {
|
|
1888
|
+
fn: write,
|
|
1889
|
+
a0: value,
|
|
1890
|
+
a1: node
|
|
1891
|
+
});
|
|
1892
|
+
onceUnmounted(group, {
|
|
1893
|
+
fn: write,
|
|
1894
|
+
a0: value,
|
|
1895
|
+
a1: null
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
break;
|
|
1899
|
+
case "call":
|
|
1900
|
+
if (typeof value === "function") onceMounted(group, {
|
|
1901
|
+
fn: invokeMountedCallback,
|
|
1902
|
+
a0: group,
|
|
1903
|
+
a1: value,
|
|
1904
|
+
a2: node
|
|
1905
|
+
});
|
|
1906
|
+
break;
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
//#endregion
|
|
1910
|
+
//#region src/support/atoms.ts
|
|
1911
|
+
function text(strings, ...values) {
|
|
1912
|
+
const { length } = values;
|
|
1913
|
+
return derived(() => {
|
|
1914
|
+
let result = strings[0];
|
|
1915
|
+
let index = 0;
|
|
1916
|
+
let value;
|
|
1917
|
+
while (index < length) {
|
|
1918
|
+
value = read(values[index]);
|
|
1919
|
+
try {
|
|
1920
|
+
value = String(value);
|
|
1921
|
+
} catch {
|
|
1922
|
+
value = "[error]";
|
|
1923
|
+
}
|
|
1924
|
+
result += value + strings[++index];
|
|
1925
|
+
}
|
|
1926
|
+
return result;
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1930
|
+
function writes(input, value, force) {
|
|
1931
|
+
return isAtom(input) ? () => void write(input, value, force) : noop;
|
|
1932
|
+
}
|
|
1933
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1934
|
+
function updates(input, transform, force) {
|
|
1935
|
+
return isAtom(input) ? () => void update(input, transform, force) : noop;
|
|
1936
|
+
}
|
|
1937
|
+
function atomsOf(data, keysOrLifecycle, maybeLifecycle) {
|
|
1938
|
+
let keys;
|
|
1939
|
+
let lifecycle;
|
|
1940
|
+
if (keysOrLifecycle === void 0 || Array.isArray(keysOrLifecycle)) {
|
|
1941
|
+
keys = keysOrLifecycle;
|
|
1942
|
+
lifecycle = maybeLifecycle;
|
|
1943
|
+
} else lifecycle = keysOrLifecycle;
|
|
1944
|
+
lifecycle ??= getLifecycle();
|
|
1945
|
+
const result = Object.create(null);
|
|
1946
|
+
if (keys) {
|
|
1947
|
+
const { length } = keys;
|
|
1948
|
+
let index = 0;
|
|
1949
|
+
let key;
|
|
1950
|
+
for (; index < length; index += 1) {
|
|
1951
|
+
key = keys[index];
|
|
1952
|
+
result[key] = atomOf(data[key], lifecycle);
|
|
1953
|
+
}
|
|
1954
|
+
for (key in data) if (result[key] === void 0) result[key] = data[key];
|
|
1955
|
+
} else {
|
|
1956
|
+
let key;
|
|
1957
|
+
for (key in data) result[key] = atomOf(data[key], lifecycle);
|
|
1958
|
+
}
|
|
1959
|
+
return result;
|
|
1960
|
+
}
|
|
1961
|
+
function assign(store, data, keysOrLifecycle, maybeLifecycle) {
|
|
1962
|
+
let keys;
|
|
1963
|
+
let lifecycle;
|
|
1964
|
+
if (keysOrLifecycle === void 0 || Array.isArray(keysOrLifecycle)) {
|
|
1965
|
+
keys = keysOrLifecycle;
|
|
1966
|
+
lifecycle = maybeLifecycle;
|
|
1967
|
+
} else lifecycle = keysOrLifecycle;
|
|
1968
|
+
if (keys) {
|
|
1969
|
+
const { length } = keys;
|
|
1970
|
+
const visited = Object.create(null);
|
|
1971
|
+
let index = 0;
|
|
1972
|
+
let key;
|
|
1973
|
+
for (; index < length; index += 1) {
|
|
1974
|
+
key = keys[index];
|
|
1975
|
+
write(store[key], peek(data[key]));
|
|
1976
|
+
visited[key] = true;
|
|
1977
|
+
}
|
|
1978
|
+
for (key in data) if (!visited[key]) store[key] = data[key];
|
|
1979
|
+
} else {
|
|
1980
|
+
let key;
|
|
1981
|
+
let atom;
|
|
1982
|
+
for (key in store) {
|
|
1983
|
+
atom = store[key];
|
|
1984
|
+
if (isAtom(atom)) write(atom, peek(data[key]));
|
|
1985
|
+
else store[key] = atomOf(data[key], lifecycle ??= getLifecycle());
|
|
1986
|
+
}
|
|
1987
|
+
for (key in data) if (!Object.hasOwn(store, key)) store[key] = atomOf(data[key], lifecycle ??= getLifecycle());
|
|
1988
|
+
}
|
|
1989
|
+
return store;
|
|
1990
|
+
}
|
|
1991
|
+
//#endregion
|
|
1992
|
+
//#region src/jsx.ts
|
|
1993
|
+
const EMPTY_ARRAY = [];
|
|
1994
|
+
function jsx(componentOrTagName, props, key) {
|
|
1995
|
+
const { children } = props;
|
|
1996
|
+
props.children = children === void 0 ? EMPTY_ARRAY : Array.isArray(children) ? children : [children];
|
|
1997
|
+
props.key ??= key;
|
|
1998
|
+
if (typeof componentOrTagName === "string") {
|
|
1999
|
+
props[S_COMPONENT] = Native;
|
|
2000
|
+
props[S_TAG_NAME] = componentOrTagName;
|
|
2001
|
+
} else props[S_COMPONENT] = componentOrTagName;
|
|
2002
|
+
return props;
|
|
2003
|
+
}
|
|
2004
|
+
function jsxs(componentOrTagName, props, key) {
|
|
2005
|
+
props.key ??= key;
|
|
2006
|
+
if (typeof componentOrTagName === "string") {
|
|
2007
|
+
props[S_COMPONENT] = Native;
|
|
2008
|
+
props[S_TAG_NAME] = componentOrTagName;
|
|
2009
|
+
} else props[S_COMPONENT] = componentOrTagName;
|
|
2010
|
+
return props;
|
|
2011
|
+
}
|
|
2012
|
+
//#endregion
|
|
2013
|
+
//#region src/RendererBuilder.ts
|
|
2014
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
2015
|
+
function renderer(adapter) {
|
|
2016
|
+
const extensions = {};
|
|
2017
|
+
const builder = {
|
|
2018
|
+
create: () => /* @__PURE__ */ createRenderer(adapter, extensions),
|
|
2019
|
+
extend: (extensionKey, extension) => {
|
|
2020
|
+
extensions[extensionKey] = extension;
|
|
2021
|
+
return builder;
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
return builder;
|
|
2025
|
+
}
|
|
2026
|
+
//#endregion
|
|
2027
|
+
export { Fragment, Iterator, LC_CHANGE, LC_CLEAR, LC_INSERT, LC_REMOVE, Native, RefExtension, S_ATOM, S_COMPONENT, S_TAG_NAME, Show, assign, atomOf, atomsOf, bind, component, contextOf, contextual, derived, destroy, effect, ext, extension, flush, fork, getLifecycle, host, insert, invoke, isAtom, jsx, jsxs, link, listOf, mount, mountJsx, mounted, noEffect, onceMounted, onceUnmounted, peek, proxyOf, read, renderer, scheduleTick, scheduleTock, sync, text, tick, tock, track, unlink, unmount, unmounted, untrack, update, updates, willMount, withLifecycle, write, writes };
|
|
2028
|
+
|
|
2
2029
|
//# sourceMappingURL=core.js.map
|