ajo 0.0.23 → 0.0.24
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/index.cjs +40 -30
- package/index.js +48 -36
- package/index.min.js +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -155,16 +155,19 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
155
155
|
}
|
|
156
156
|
hooks[0]++;
|
|
157
157
|
}, schedule = (host) => {
|
|
158
|
-
if (host.$
|
|
158
|
+
if (host.$idle)
|
|
159
159
|
return;
|
|
160
160
|
if (globalThis.navigator?.scheduling?.isInputPending()) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
idleQueue.add(host);
|
|
162
|
+
host.$idle = true;
|
|
163
|
+
idleId ??= requestIdleCallback(() => {
|
|
164
|
+
idleId = null;
|
|
165
|
+
const queue = from(idleQueue);
|
|
166
|
+
for (const host2 of queue) {
|
|
167
|
+
idleQueue.delete(host2);
|
|
168
|
+
host2.$idle = false;
|
|
169
|
+
schedule(host2);
|
|
170
|
+
}
|
|
168
171
|
});
|
|
169
172
|
return;
|
|
170
173
|
}
|
|
@@ -178,11 +181,9 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
178
181
|
runComponent(host);
|
|
179
182
|
});
|
|
180
183
|
}, runComponent = (host) => {
|
|
181
|
-
if (host.$
|
|
182
|
-
|
|
183
|
-
host.$idleId = null;
|
|
184
|
+
if (host.$idle) {
|
|
185
|
+
idleQueue.delete(host);
|
|
184
186
|
host.$idle = false;
|
|
185
|
-
idleCount--;
|
|
186
187
|
}
|
|
187
188
|
current = host;
|
|
188
189
|
if (current.$hooks)
|
|
@@ -193,18 +194,15 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
193
194
|
propagate(value, host.parentNode);
|
|
194
195
|
} finally {
|
|
195
196
|
current = null;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (--idleCount)
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
layoutsId ??= task(runLayouts);
|
|
197
|
+
layoutQueue.add(host);
|
|
198
|
+
host.$layoutQueued = true;
|
|
199
|
+
layoutId ??= task(runLayouts);
|
|
203
200
|
}
|
|
204
201
|
}, runLayouts = () => {
|
|
205
|
-
|
|
206
|
-
for (const host of
|
|
207
|
-
|
|
202
|
+
layoutId = null;
|
|
203
|
+
for (const host of layoutQueue) {
|
|
204
|
+
layoutQueue.delete(host);
|
|
205
|
+
host.$layoutQueued = false;
|
|
208
206
|
try {
|
|
209
207
|
render(host.$h, host);
|
|
210
208
|
host.$h = null;
|
|
@@ -212,14 +210,16 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
212
210
|
propagate(value, host);
|
|
213
211
|
} finally {
|
|
214
212
|
runFx(host, "$layout");
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
effectQueue.add(host);
|
|
214
|
+
host.$effectQueued = true;
|
|
215
|
+
effectId ??= task(runEffects);
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
218
|
}, runEffects = () => {
|
|
220
|
-
|
|
221
|
-
for (const host of
|
|
222
|
-
|
|
219
|
+
effectId = null;
|
|
220
|
+
for (const host of effectQueue) {
|
|
221
|
+
effectQueue.delete(host);
|
|
222
|
+
host.$effectQueued = false;
|
|
223
223
|
runFx(host, "$effect");
|
|
224
224
|
}
|
|
225
225
|
}, runFx = (host, key) => {
|
|
@@ -248,8 +248,18 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
248
248
|
host.$ref.current = null;
|
|
249
249
|
if (!host.$fn)
|
|
250
250
|
return;
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
if (host.$idle) {
|
|
252
|
+
idleQueue.delete(host);
|
|
253
|
+
host.$idle = false;
|
|
254
|
+
}
|
|
255
|
+
if (host.$layoutQueued) {
|
|
256
|
+
layoutQueue.delete(host);
|
|
257
|
+
host.$layoutQueued = false;
|
|
258
|
+
}
|
|
259
|
+
if (host.$effectQueued) {
|
|
260
|
+
effectQueue.delete(host);
|
|
261
|
+
host.$effectQueued = false;
|
|
262
|
+
}
|
|
253
263
|
for (const key of ["$layout", "$effect"])
|
|
254
264
|
if (host[key]) {
|
|
255
265
|
for (const fx of host[key]) {
|
|
@@ -270,4 +280,4 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
270
280
|
return void fn(value);
|
|
271
281
|
throw value;
|
|
272
282
|
};
|
|
273
|
-
let
|
|
283
|
+
let current = null, layoutQueue = /* @__PURE__ */ new Set(), effectQueue = /* @__PURE__ */ new Set(), idleQueue = /* @__PURE__ */ new Set(), layoutId = null, effectId = null, idleId = null;
|
package/index.js
CHANGED
|
@@ -197,18 +197,21 @@ const
|
|
|
197
197
|
|
|
198
198
|
schedule = host => {
|
|
199
199
|
|
|
200
|
-
if (host.$
|
|
200
|
+
if (host.$idle) return
|
|
201
201
|
|
|
202
202
|
if (globalThis.navigator?.scheduling?.isInputPending()) {
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
idleCount++
|
|
207
|
-
}
|
|
204
|
+
idleQueue.add(host)
|
|
205
|
+
host.$idle = true
|
|
208
206
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
idleId ??= requestIdleCallback(() => {
|
|
208
|
+
idleId = null
|
|
209
|
+
const queue = from(idleQueue)
|
|
210
|
+
for (const host of queue) {
|
|
211
|
+
idleQueue.delete(host)
|
|
212
|
+
host.$idle = false
|
|
213
|
+
schedule(host)
|
|
214
|
+
}
|
|
212
215
|
})
|
|
213
216
|
|
|
214
217
|
return
|
|
@@ -230,11 +233,9 @@ const
|
|
|
230
233
|
|
|
231
234
|
runComponent = host => {
|
|
232
235
|
|
|
233
|
-
if (host.$
|
|
234
|
-
|
|
235
|
-
host.$idleId = null
|
|
236
|
+
if (host.$idle) {
|
|
237
|
+
idleQueue.delete(host)
|
|
236
238
|
host.$idle = false
|
|
237
|
-
idleCount--
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
current = host
|
|
@@ -247,24 +248,20 @@ const
|
|
|
247
248
|
propagate(value, host.parentNode)
|
|
248
249
|
} finally {
|
|
249
250
|
current = null
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
host.$idle = false
|
|
254
|
-
if (--idleCount) return
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
layoutsId ??= task(runLayouts)
|
|
251
|
+
layoutQueue.add(host)
|
|
252
|
+
host.$layoutQueued = true
|
|
253
|
+
layoutId ??= task(runLayouts)
|
|
258
254
|
}
|
|
259
255
|
},
|
|
260
256
|
|
|
261
257
|
runLayouts = () => {
|
|
262
258
|
|
|
263
|
-
|
|
259
|
+
layoutId = null
|
|
264
260
|
|
|
265
|
-
for (const host of
|
|
261
|
+
for (const host of layoutQueue) {
|
|
266
262
|
|
|
267
|
-
|
|
263
|
+
layoutQueue.delete(host)
|
|
264
|
+
host.$layoutQueued = false
|
|
268
265
|
|
|
269
266
|
try {
|
|
270
267
|
render(host.$h, host)
|
|
@@ -273,18 +270,20 @@ const
|
|
|
273
270
|
propagate(value, host)
|
|
274
271
|
} finally {
|
|
275
272
|
runFx(host, '$layout')
|
|
276
|
-
|
|
277
|
-
|
|
273
|
+
effectQueue.add(host)
|
|
274
|
+
host.$effectQueued = true
|
|
275
|
+
effectId ??= task(runEffects)
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
278
|
},
|
|
281
279
|
|
|
282
280
|
runEffects = () => {
|
|
283
281
|
|
|
284
|
-
|
|
282
|
+
effectId = null
|
|
285
283
|
|
|
286
|
-
for (const host of
|
|
287
|
-
|
|
284
|
+
for (const host of effectQueue) {
|
|
285
|
+
effectQueue.delete(host)
|
|
286
|
+
host.$effectQueued = false
|
|
288
287
|
runFx(host, '$effect')
|
|
289
288
|
}
|
|
290
289
|
},
|
|
@@ -319,8 +318,20 @@ const
|
|
|
319
318
|
|
|
320
319
|
if (!host.$fn) return
|
|
321
320
|
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
if (host.$idle) {
|
|
322
|
+
idleQueue.delete(host)
|
|
323
|
+
host.$idle = false
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (host.$layoutQueued) {
|
|
327
|
+
layoutQueue.delete(host)
|
|
328
|
+
host.$layoutQueued = false
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (host.$effectQueued) {
|
|
332
|
+
effectQueue.delete(host)
|
|
333
|
+
host.$effectQueued = false
|
|
334
|
+
}
|
|
324
335
|
|
|
325
336
|
for (const key of ['$layout', '$effect']) if (host[key]) {
|
|
326
337
|
|
|
@@ -346,9 +357,10 @@ const
|
|
|
346
357
|
}
|
|
347
358
|
|
|
348
359
|
let
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
360
|
+
current = null,
|
|
361
|
+
layoutQueue = new Set,
|
|
362
|
+
effectQueue = new Set,
|
|
363
|
+
idleQueue = new Set,
|
|
364
|
+
layoutId = null,
|
|
365
|
+
effectId = null,
|
|
366
|
+
idleId = null
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ajo=(()=>{var
|
|
1
|
+
var ajo=(()=>{var x=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},J=(e,t,n,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of W(t))!D.call(e,l)&&l!==n&&x(e,l,{get:()=>t[l],enumerable:!(u=V(t,l))||u.enumerable});return e};var K=e=>J(x({},"__esModule",{value:!0}),e);var se={};G(se,{Fragment:()=>U,component:()=>X,h:()=>C,render:()=>N,useCallback:()=>h,useCatch:()=>Y,useEffect:()=>te,useHost:()=>p,useLayout:()=>ee,useMemo:()=>Q,useReducer:()=>S,useRef:()=>_,useState:()=>Z});const U=({children:e})=>e,C=(e,t,...n)=>{const{length:u}=n;return n=u==0?null:u==1?n[0]:n,{children:n,...t,nodeName:e}},N=(e,t,n)=>{let u=t.firstChild;for(e of b(e)){let l=u;if(e instanceof Node)l=e;else if(typeof e=="string"){for(;l&&l.nodeType!=3;)l=l.nextSibling;l?l.data!=e&&(l.data=e):l=document.createTextNode(e)}else{const{xmlns:a=n,nodeName:i,key:r,ref:o,memo:q,children:z,[T]:v,...P}=e;for(;l&&!(l.localName==i&&$(l.$key??=r,r));)l=l.nextSibling;l??=ie(a,i,r),ne(o)&&(o.current=l,l.$ref=o),(q==null||w(l.$deps,l.$deps=q))&&(re(P,l),f(v)?v(l):N(z,l,a))}l==u?u=u.nextSibling:fe(t,l,u)}for(;u;){const l=u.nextSibling;L(u),t.removeChild(u),u=l}},X=e=>({nodeName:t,as:n,props:u,key:l,ref:a,memo:i,...r})=>C(n??e?.as??"c-host",{...e?.props,...u,key:l,ref:a,memo:i,[T]:o=>{o.$fn=f(e)?e:le,o.$args={...e?.args,...r},M(o)}}),S=(e,t)=>{const n=p(),u=g(),[l,a]=u;return l==a.length&&(a[l]=[f(t)?t():t,i=>{const r=a[l][0],o=f(i)?i(r):i;$(r,a[l][0]=f(e)?e(r,o):o)||oe(n)}]),a[u[0]++]},Q=(e,t)=>{const n=g(),[u,l]=n;return(u==l.length||t==null||w(t,l[u][1]))&&(l[u]=[e(),t]),l[n[0]++][0]},Y=e=>{const t=p(),[n,u]=S(),l=g(),[a,i]=l;return i[l[0]++]=e,t.$catch??=r=>{f(i[a])&&i[a](r),u(r)},[n,()=>u()]},p=()=>c,Z=e=>S(null,e),_=e=>Q(()=>({current:e}),[]),h=(e,t)=>Q(()=>e,t),ee=(e,t)=>j(e,t,"$layout"),te=(e,t)=>j(e,t,"$effect"),{isArray:s,from:F}=Array,{is:$}=Object,le=()=>{},T=Symbol(),ne=e=>e&&typeof e=="object",f=e=>typeof e=="function",w=(e,t)=>s(e)&&s(t)?e.some((n,u)=>!$(n,t[u])):!$(e,t),ue=e=>F(e).reduce(ae,{}),ae=(e,{name:t,value:n})=>(e[t]=n,e),E=globalThis.queueMicrotask??(e=>e()),I=globalThis.requestAnimationFrame??E,ie=(e,t,n)=>{const u=e?document.createElementNS(e,t):document.createElement(t);return u.$key=n,u},b=function*(e,t={data:""},n=!0){let u;for(e of s(e)?e:[e])e==null||typeof e=="boolean"||(typeof e.nodeName=="string"?((u=t.data)&&(t.data="",yield u),yield e):f(e.nodeName)?yield*b(e.nodeName(e),t,!1):s(e)?yield*b(e,t,!1):t.data+=e);n&&(u=t.data)&&(yield u)},re=(e,t)=>{const n=t.$props??=t.hasAttributes()?ue(t.attributes):{};for(const u in{...n,...t.$props=e}){let l=e[u];l!==n[u]&&(u.startsWith("set:")?t[u.slice(4)]=l:l==null||l===!1?t.removeAttribute(u):t.setAttribute(u,l===!0?"":l))}},fe=(e,t,n)=>{if(t.contains?.(document.activeElement)){const u=t.nextSibling;for(;n&&n!=t;){const l=n.nextSibling;e.insertBefore(n,u),n=l}}else e.insertBefore(t,n)},g=()=>c.$hooks??=[0,[]],j=(e,t,n)=>{const u=p(),l=g(),[a,i]=l;a==i.length?(u[n]??=new Set).add(i[a]=[null,e,t]):(t==null||w(t,i[a][2]))&&(i[a][1]=e,i[a][2]=t),l[0]++},M=e=>{if(!e.$idle){if(globalThis.navigator?.scheduling?.isInputPending()){d.add(e),e.$idle=!0,A??=requestIdleCallback(()=>{A=null;const t=F(d);for(const n of t)d.delete(n),n.$idle=!1,M(n)});return}B(e)}},oe=e=>{e.$queued||(e.$queued=!0,E(()=>{e.$queued=!1,B(e)}))},B=e=>{e.$idle&&(d.delete(e),e.$idle=!1),c=e,c.$hooks&&(c.$hooks[0]=0);try{e.$h=e.$fn(e.$args)}catch(t){k(t,e.parentNode)}finally{c=null,y.add(e),e.$layoutQueued=!0,O??=I(ce)}},ce=()=>{O=null;for(const e of y){y.delete(e),e.$layoutQueued=!1;try{N(e.$h,e),e.$h=null}catch(t){k(t,e)}finally{H(e,"$layout"),m.add(e),e.$effectQueued=!0,R??=I(de)}}},de=()=>{R=null;for(const e of m)m.delete(e),e.$effectQueued=!1,H(e,"$effect")},H=(e,t)=>{if(e[t])for(const n of e[t]){const[u,l]=n;if(f(l))try{f(u)&&u(),n[0]=l()}catch(a){n[0]=null,k(a,e.parentNode)}finally{n[1]=null}}},L=e=>{if(e.nodeType==1){for(const t of e.children)L(t);if(e.$ref&&(e.$ref.current=null),!!e.$fn){e.$idle&&(d.delete(e),e.$idle=!1),e.$layoutQueued&&(y.delete(e),e.$layoutQueued=!1),e.$effectQueued&&(m.delete(e),e.$effectQueued=!1);for(const t of["$layout","$effect"])if(e[t])for(const n of e[t]){e[t].delete(n);try{const[u]=n;f(u)&&u()}catch(u){k(u,e.parentNode)}finally{n[0]=n[1]=null}}}}},k=(e,t)=>{for(let n;t;t=t.parentNode)if(f(n=t.$catch))return void n(e);throw e};let c=null,y=new Set,m=new Set,d=new Set,O=null,R=null,A=null;return K(se);})();
|