ajo 0.0.23 → 0.0.25
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 +50 -41
- package/index.js +63 -51
- package/index.min.js +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -155,34 +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
|
-
host.$idleId = requestIdleCallback(() => {
|
|
166
|
-
host.$idleId = null;
|
|
167
|
-
schedule(host);
|
|
168
|
-
});
|
|
161
|
+
idleQueue.add(host);
|
|
162
|
+
host.$idle = true;
|
|
163
|
+
idleId ??= requestIdleCallback(runIdle);
|
|
169
164
|
return;
|
|
170
165
|
}
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
if (host.$
|
|
174
|
-
|
|
175
|
-
host.$queued = true;
|
|
176
|
-
microtask(() => {
|
|
177
|
-
host.$queued = false;
|
|
178
|
-
runComponent(host);
|
|
179
|
-
});
|
|
180
|
-
}, runComponent = (host) => {
|
|
181
|
-
if (host.$idleId) {
|
|
182
|
-
cancelIdleCallback(host.$idleId);
|
|
183
|
-
host.$idleId = null;
|
|
166
|
+
run(host);
|
|
167
|
+
}, run = (host) => {
|
|
168
|
+
if (host.$idle) {
|
|
169
|
+
idleQueue.delete(host);
|
|
184
170
|
host.$idle = false;
|
|
185
|
-
idleCount--;
|
|
186
171
|
}
|
|
187
172
|
current = host;
|
|
188
173
|
if (current.$hooks)
|
|
@@ -193,18 +178,30 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
193
178
|
propagate(value, host.parentNode);
|
|
194
179
|
} finally {
|
|
195
180
|
current = null;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
181
|
+
layoutQueue.add(host);
|
|
182
|
+
host.$layoutQueued = true;
|
|
183
|
+
layoutId ??= task(runLayouts);
|
|
184
|
+
}
|
|
185
|
+
}, runIdle = () => {
|
|
186
|
+
idleId = null;
|
|
187
|
+
for (const host of from(idleQueue)) {
|
|
188
|
+
idleQueue.delete(host);
|
|
189
|
+
host.$idle = false;
|
|
190
|
+
schedule(host);
|
|
203
191
|
}
|
|
192
|
+
}, runMutations = (host) => {
|
|
193
|
+
if (host.$runQueued)
|
|
194
|
+
return;
|
|
195
|
+
host.$runQueued = true;
|
|
196
|
+
microtask(() => {
|
|
197
|
+
host.$runQueued = false;
|
|
198
|
+
run(host);
|
|
199
|
+
});
|
|
204
200
|
}, runLayouts = () => {
|
|
205
|
-
|
|
206
|
-
for (const host of
|
|
207
|
-
|
|
201
|
+
layoutId = null;
|
|
202
|
+
for (const host of layoutQueue) {
|
|
203
|
+
layoutQueue.delete(host);
|
|
204
|
+
host.$layoutQueued = false;
|
|
208
205
|
try {
|
|
209
206
|
render(host.$h, host);
|
|
210
207
|
host.$h = null;
|
|
@@ -212,14 +209,16 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
212
209
|
propagate(value, host);
|
|
213
210
|
} finally {
|
|
214
211
|
runFx(host, "$layout");
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
effectQueue.add(host);
|
|
213
|
+
host.$effectQueued = true;
|
|
214
|
+
effectId ??= task(runEffects);
|
|
217
215
|
}
|
|
218
216
|
}
|
|
219
217
|
}, runEffects = () => {
|
|
220
|
-
|
|
221
|
-
for (const host of
|
|
222
|
-
|
|
218
|
+
effectId = null;
|
|
219
|
+
for (const host of effectQueue) {
|
|
220
|
+
effectQueue.delete(host);
|
|
221
|
+
host.$effectQueued = false;
|
|
223
222
|
runFx(host, "$effect");
|
|
224
223
|
}
|
|
225
224
|
}, runFx = (host, key) => {
|
|
@@ -248,8 +247,18 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
248
247
|
host.$ref.current = null;
|
|
249
248
|
if (!host.$fn)
|
|
250
249
|
return;
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
if (host.$idle) {
|
|
251
|
+
idleQueue.delete(host);
|
|
252
|
+
host.$idle = false;
|
|
253
|
+
}
|
|
254
|
+
if (host.$layoutQueued) {
|
|
255
|
+
layoutQueue.delete(host);
|
|
256
|
+
host.$layoutQueued = false;
|
|
257
|
+
}
|
|
258
|
+
if (host.$effectQueued) {
|
|
259
|
+
effectQueue.delete(host);
|
|
260
|
+
host.$effectQueued = false;
|
|
261
|
+
}
|
|
253
262
|
for (const key of ["$layout", "$effect"])
|
|
254
263
|
if (host[key]) {
|
|
255
264
|
for (const fx of host[key]) {
|
|
@@ -270,4 +279,4 @@ const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
|
270
279
|
return void fn(value);
|
|
271
280
|
throw value;
|
|
272
281
|
};
|
|
273
|
-
let
|
|
282
|
+
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,44 +197,23 @@ 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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
idleCount++
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
host.$idleId = requestIdleCallback(() => {
|
|
210
|
-
host.$idleId = null
|
|
211
|
-
schedule(host)
|
|
212
|
-
})
|
|
213
|
-
|
|
203
|
+
idleQueue.add(host)
|
|
204
|
+
host.$idle = true
|
|
205
|
+
idleId ??= requestIdleCallback(runIdle)
|
|
214
206
|
return
|
|
215
207
|
}
|
|
216
208
|
|
|
217
|
-
|
|
209
|
+
run(host)
|
|
218
210
|
},
|
|
219
211
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (host.$queued) return
|
|
212
|
+
run = host => {
|
|
223
213
|
|
|
224
|
-
host.$
|
|
225
|
-
|
|
226
|
-
host.$queued = false
|
|
227
|
-
runComponent(host)
|
|
228
|
-
})
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
runComponent = host => {
|
|
232
|
-
|
|
233
|
-
if (host.$idleId) {
|
|
234
|
-
cancelIdleCallback(host.$idleId)
|
|
235
|
-
host.$idleId = null
|
|
214
|
+
if (host.$idle) {
|
|
215
|
+
idleQueue.delete(host)
|
|
236
216
|
host.$idle = false
|
|
237
|
-
idleCount--
|
|
238
217
|
}
|
|
239
218
|
|
|
240
219
|
current = host
|
|
@@ -247,24 +226,42 @@ const
|
|
|
247
226
|
propagate(value, host.parentNode)
|
|
248
227
|
} finally {
|
|
249
228
|
current = null
|
|
250
|
-
|
|
229
|
+
layoutQueue.add(host)
|
|
230
|
+
host.$layoutQueued = true
|
|
231
|
+
layoutId ??= task(runLayouts)
|
|
232
|
+
}
|
|
233
|
+
},
|
|
251
234
|
|
|
252
|
-
|
|
253
|
-
host.$idle = false
|
|
254
|
-
if (--idleCount) return
|
|
255
|
-
}
|
|
235
|
+
runIdle = () => {
|
|
256
236
|
|
|
257
|
-
|
|
237
|
+
idleId = null
|
|
238
|
+
|
|
239
|
+
for (const host of from(idleQueue)) {
|
|
240
|
+
idleQueue.delete(host)
|
|
241
|
+
host.$idle = false
|
|
242
|
+
schedule(host)
|
|
258
243
|
}
|
|
259
244
|
},
|
|
260
245
|
|
|
246
|
+
runMutations = host => {
|
|
247
|
+
|
|
248
|
+
if (host.$runQueued) return
|
|
249
|
+
|
|
250
|
+
host.$runQueued = true
|
|
251
|
+
microtask(() => {
|
|
252
|
+
host.$runQueued = false
|
|
253
|
+
run(host)
|
|
254
|
+
})
|
|
255
|
+
},
|
|
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 u in t)x(e,u,{get:t[u],enumerable:!0})},J=(e,t,u,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of W(t))!D.call(e,l)&&l!==u&&x(e,l,{get:()=>t[l],enumerable:!(n=V(t,l))||n.enumerable});return e};var K=e=>J(x({},"__esModule",{value:!0}),e);var $e={};G($e,{Fragment:()=>U,component:()=>X,h:()=>F,render:()=>N,useCallback:()=>h,useCatch:()=>Y,useEffect:()=>te,useHost:()=>p,useLayout:()=>ee,useMemo:()=>S,useReducer:()=>Q,useRef:()=>_,useState:()=>Z});const U=({children:e})=>e,F=(e,t,...u)=>{const{length:n}=u;return u=n==0?null:n==1?u[0]:u,{children:u,...t,nodeName:e}},N=(e,t,u)=>{let n=t.firstChild;for(e of b(e)){let l=n;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=u,nodeName:r,key:i,ref:o,memo:v,children:z,[T]:A,...P}=e;for(;l&&!(l.localName==r&&$(l.$key??=i,i));)l=l.nextSibling;l??=re(a,r,i),ne(o)&&(o.current=l,l.$ref=o),(v==null||w(l.$deps,l.$deps=v))&&(ie(P,l),f(A)?A(l):N(z,l,a))}l==n?n=n.nextSibling:fe(t,l,n)}for(;n;){const l=n.nextSibling;H(n),t.removeChild(n),n=l}},X=e=>({nodeName:t,as:u,props:n,key:l,ref:a,memo:r,...i})=>F(u??e?.as??"c-host",{...e?.props,...n,key:l,ref:a,memo:r,[T]:o=>{o.$fn=f(e)?e:le,o.$args={...e?.args,...i},q(o)}}),Q=(e,t)=>{const u=p(),n=g(),[l,a]=n;return l==a.length&&(a[l]=[f(t)?t():t,r=>{const i=a[l][0],o=f(r)?r(i):r;$(i,a[l][0]=f(e)?e(i,o):o)||ce(u)}]),a[n[0]++]},S=(e,t)=>{const u=g(),[n,l]=u;return(n==l.length||t==null||w(t,l[n][1]))&&(l[n]=[e(),t]),l[u[0]++][0]},Y=e=>{const t=p(),[u,n]=Q(),l=g(),[a,r]=l;return r[l[0]++]=e,t.$catch??=i=>{f(r[a])&&r[a](i),n(i)},[u,()=>n()]},p=()=>c,Z=e=>Q(null,e),_=e=>S(()=>({current:e}),[]),h=(e,t)=>S(()=>e,t),ee=(e,t)=>j(e,t,"$layout"),te=(e,t)=>j(e,t,"$effect"),{isArray:s,from:I}=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((u,n)=>!$(u,t[n])):!$(e,t),ue=e=>I(e).reduce(ae,{}),ae=(e,{name:t,value:u})=>(e[t]=u,e),C=globalThis.queueMicrotask??(e=>e()),E=globalThis.requestAnimationFrame??C,re=(e,t,u)=>{const n=e?document.createElementNS(e,t):document.createElement(t);return n.$key=u,n},b=function*(e,t={data:""},u=!0){let n;for(e of s(e)?e:[e])e==null||typeof e=="boolean"||(typeof e.nodeName=="string"?((n=t.data)&&(t.data="",yield n),yield e):f(e.nodeName)?yield*b(e.nodeName(e),t,!1):s(e)?yield*b(e,t,!1):t.data+=e);u&&(n=t.data)&&(yield n)},ie=(e,t)=>{const u=t.$props??=t.hasAttributes()?ue(t.attributes):{};for(const n in{...u,...t.$props=e}){let l=e[n];l!==u[n]&&(n.startsWith("set:")?t[n.slice(4)]=l:l==null||l===!1?t.removeAttribute(n):t.setAttribute(n,l===!0?"":l))}},fe=(e,t,u)=>{if(t.contains?.(document.activeElement)){const n=t.nextSibling;for(;u&&u!=t;){const l=u.nextSibling;e.insertBefore(u,n),u=l}}else e.insertBefore(t,u)},g=()=>c.$hooks??=[0,[]],j=(e,t,u)=>{const n=p(),l=g(),[a,r]=l;a==r.length?(n[u]??=new Set).add(r[a]=[null,e,t]):(t==null||w(t,r[a][2]))&&(r[a][1]=e,r[a][2]=t),l[0]++},q=e=>{if(!e.$idle){if(globalThis.navigator?.scheduling?.isInputPending()){d.add(e),e.$idle=!0,R??=requestIdleCallback(oe);return}M(e)}},M=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,L??=E(de)}},oe=()=>{R=null;for(const e of I(d))d.delete(e),e.$idle=!1,q(e)},ce=e=>{e.$runQueued||(e.$runQueued=!0,C(()=>{e.$runQueued=!1,M(e)}))},de=()=>{L=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{B(e,"$layout"),m.add(e),e.$effectQueued=!0,O??=E(se)}}},se=()=>{O=null;for(const e of m)m.delete(e),e.$effectQueued=!1,B(e,"$effect")},B=(e,t)=>{if(e[t])for(const u of e[t]){const[n,l]=u;if(f(l))try{f(n)&&n(),u[0]=l()}catch(a){u[0]=null,k(a,e.parentNode)}finally{u[1]=null}}},H=e=>{if(e.nodeType==1){for(const t of e.children)H(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 u of e[t]){e[t].delete(u);try{const[n]=u;f(n)&&n()}catch(n){k(n,e.parentNode)}finally{u[0]=u[1]=null}}}}},k=(e,t)=>{for(let u;t;t=t.parentNode)if(f(u=t.$catch))return void u(e);throw e};let c=null,y=new Set,m=new Set,d=new Set,L=null,O=null,R=null;return K($e);})();
|