ajo 0.0.22 → 0.0.23
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 +35 -16
- package/index.js +47 -17
- package/index.min.js +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -48,14 +48,14 @@ const Fragment = ({ children }) => children, h = (nodeName, props, ...children)
|
|
|
48
48
|
node ? node.data != h2 && (node.data = h2) : node = document.createTextNode(h2);
|
|
49
49
|
} else {
|
|
50
50
|
const { xmlns = ns, nodeName, key, ref, memo, children, [FN]: fn, ...props } = h2;
|
|
51
|
-
while (node && !(node.localName == nodeName && (node.$key ??= key
|
|
51
|
+
while (node && !(node.localName == nodeName && is(node.$key ??= key, key)))
|
|
52
52
|
node = node.nextSibling;
|
|
53
53
|
node ??= create(xmlns, nodeName, key);
|
|
54
54
|
if (isObject(ref)) {
|
|
55
55
|
ref.current = node;
|
|
56
56
|
node.$ref = ref;
|
|
57
57
|
}
|
|
58
|
-
if (memo == null || some(node.$
|
|
58
|
+
if (memo == null || some(node.$deps, node.$deps = memo)) {
|
|
59
59
|
update(props, node);
|
|
60
60
|
isFunction(fn) ? fn(node) : render(children, node, xmlns);
|
|
61
61
|
}
|
|
@@ -64,7 +64,8 @@ const Fragment = ({ children }) => children, h = (nodeName, props, ...children)
|
|
|
64
64
|
}
|
|
65
65
|
while (child) {
|
|
66
66
|
const next = child.nextSibling;
|
|
67
|
-
dispose(
|
|
67
|
+
dispose(child);
|
|
68
|
+
host.removeChild(child);
|
|
68
69
|
child = next;
|
|
69
70
|
}
|
|
70
71
|
}, component = (fn) => ({ nodeName, as, props, key, ref, memo, ...args }) => h(as ?? fn?.as ?? "c-host", {
|
|
@@ -105,8 +106,8 @@ const Fragment = ({ children }) => children, h = (nodeName, props, ...children)
|
|
|
105
106
|
};
|
|
106
107
|
return [value, () => setValue()];
|
|
107
108
|
}, useHost = () => current, useState = (init) => useReducer(null, init), useRef = (current2) => useMemo(() => ({ current: current2 }), []), useCallback = (fn, deps) => useMemo(() => fn, deps), useLayout = (fn, deps) => useFx(fn, deps, "$layout"), useEffect = (fn, deps) => useFx(fn, deps, "$effect");
|
|
108
|
-
const
|
|
109
|
-
}, FN = Symbol(), isObject = (v) => v && typeof v == "object", isFunction = (v) => typeof v == "function", some = (a, b) => isArray(a) && isArray(b) ? a.some((v, i) => !is(v, b[i])) : !is(a, b), reduce = (v) => from(v).reduce(assign, {}), assign = (v, { name, value }) => (v[name] = value, v), create = (ns, name, key) => {
|
|
109
|
+
const { isArray, from } = Array, { is } = Object, noop = () => {
|
|
110
|
+
}, FN = Symbol(), isObject = (v) => v && typeof v == "object", isFunction = (v) => typeof v == "function", some = (a, b) => isArray(a) && isArray(b) ? a.some((v, i) => !is(v, b[i])) : !is(a, b), reduce = (v) => from(v).reduce(assign, {}), assign = (v, { name, value }) => (v[name] = value, v), microtask = globalThis.queueMicrotask ?? ((fn) => fn()), task = globalThis.requestAnimationFrame ?? microtask, create = (ns, name, key) => {
|
|
110
111
|
const node = ns ? document.createElementNS(ns, name) : document.createElement(name);
|
|
111
112
|
return node.$key = key, node;
|
|
112
113
|
}, normalize = function* (h2, buffer = { data: "" }, root = true) {
|
|
@@ -154,11 +155,15 @@ const microtask = globalThis.queueMicrotask ?? ((fn) => fn()), task = globalThis
|
|
|
154
155
|
}
|
|
155
156
|
hooks[0]++;
|
|
156
157
|
}, schedule = (host) => {
|
|
157
|
-
if (host.$
|
|
158
|
+
if (host.$idleId)
|
|
158
159
|
return;
|
|
159
160
|
if (globalThis.navigator?.scheduling?.isInputPending()) {
|
|
160
|
-
host.$idle
|
|
161
|
-
host.$idle =
|
|
161
|
+
if (!host.$idle) {
|
|
162
|
+
host.$idle = true;
|
|
163
|
+
idleCount++;
|
|
164
|
+
}
|
|
165
|
+
host.$idleId = requestIdleCallback(() => {
|
|
166
|
+
host.$idleId = null;
|
|
162
167
|
schedule(host);
|
|
163
168
|
});
|
|
164
169
|
return;
|
|
@@ -173,9 +178,11 @@ const microtask = globalThis.queueMicrotask ?? ((fn) => fn()), task = globalThis
|
|
|
173
178
|
runComponent(host);
|
|
174
179
|
});
|
|
175
180
|
}, runComponent = (host) => {
|
|
176
|
-
if (host.$
|
|
177
|
-
cancelIdleCallback(host.$
|
|
178
|
-
host.$
|
|
181
|
+
if (host.$idleId) {
|
|
182
|
+
cancelIdleCallback(host.$idleId);
|
|
183
|
+
host.$idleId = null;
|
|
184
|
+
host.$idle = false;
|
|
185
|
+
idleCount--;
|
|
179
186
|
}
|
|
180
187
|
current = host;
|
|
181
188
|
if (current.$hooks)
|
|
@@ -187,6 +194,11 @@ const microtask = globalThis.queueMicrotask ?? ((fn) => fn()), task = globalThis
|
|
|
187
194
|
} finally {
|
|
188
195
|
current = null;
|
|
189
196
|
layoutsQueue.add(host);
|
|
197
|
+
if (host.$idle) {
|
|
198
|
+
host.$idle = false;
|
|
199
|
+
if (--idleCount)
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
190
202
|
layoutsId ??= task(runLayouts);
|
|
191
203
|
}
|
|
192
204
|
}, runLayouts = () => {
|
|
@@ -234,16 +246,23 @@ const microtask = globalThis.queueMicrotask ?? ((fn) => fn()), task = globalThis
|
|
|
234
246
|
dispose(child);
|
|
235
247
|
if (host.$ref)
|
|
236
248
|
host.$ref.current = null;
|
|
249
|
+
if (!host.$fn)
|
|
250
|
+
return;
|
|
237
251
|
layoutsQueue.delete(host);
|
|
238
252
|
effectsQueue.delete(host);
|
|
239
253
|
for (const key of ["$layout", "$effect"])
|
|
240
254
|
if (host[key]) {
|
|
241
|
-
for (const fx of host[key])
|
|
255
|
+
for (const fx of host[key]) {
|
|
256
|
+
host[key].delete(fx);
|
|
242
257
|
try {
|
|
243
|
-
|
|
244
|
-
|
|
258
|
+
const [cleanup] = fx;
|
|
259
|
+
isFunction(cleanup) && cleanup();
|
|
260
|
+
} catch (value) {
|
|
261
|
+
propagate(value, host.parentNode);
|
|
262
|
+
} finally {
|
|
263
|
+
fx[0] = fx[1] = null;
|
|
245
264
|
}
|
|
246
|
-
|
|
265
|
+
}
|
|
247
266
|
}
|
|
248
267
|
}, propagate = (value, host) => {
|
|
249
268
|
for (let fn; host; host = host.parentNode)
|
|
@@ -251,4 +270,4 @@ const microtask = globalThis.queueMicrotask ?? ((fn) => fn()), task = globalThis
|
|
|
251
270
|
return void fn(value);
|
|
252
271
|
throw value;
|
|
253
272
|
};
|
|
254
|
-
let
|
|
273
|
+
let idleCount = 0, layoutsQueue = /* @__PURE__ */ new Set(), effectsQueue = /* @__PURE__ */ new Set(), layoutsId = null, effectsId = null, current = null;
|
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export const
|
|
|
27
27
|
|
|
28
28
|
const { xmlns = ns, nodeName, key, ref, memo, children, [FN]: fn, ...props } = h
|
|
29
29
|
|
|
30
|
-
while (node && !(node.localName == nodeName && (node.$key ??= key
|
|
30
|
+
while (node && !(node.localName == nodeName && is(node.$key ??= key, key))) node = node.nextSibling
|
|
31
31
|
node ??= create(xmlns, nodeName, key)
|
|
32
32
|
|
|
33
33
|
if (isObject(ref)) {
|
|
@@ -35,7 +35,7 @@ export const
|
|
|
35
35
|
node.$ref = ref
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (memo == null || some(node.$
|
|
38
|
+
if (memo == null || some(node.$deps, node.$deps = memo)) {
|
|
39
39
|
update(props, node)
|
|
40
40
|
isFunction(fn) ? fn(node) : render(children, node, xmlns)
|
|
41
41
|
}
|
|
@@ -46,7 +46,8 @@ export const
|
|
|
46
46
|
|
|
47
47
|
while (child) {
|
|
48
48
|
const next = child.nextSibling
|
|
49
|
-
dispose(
|
|
49
|
+
dispose(child)
|
|
50
|
+
host.removeChild(child)
|
|
50
51
|
child = next
|
|
51
52
|
}
|
|
52
53
|
},
|
|
@@ -119,11 +120,7 @@ export const
|
|
|
119
120
|
|
|
120
121
|
const
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
task = globalThis.requestAnimationFrame ?? microtask,
|
|
125
|
-
|
|
126
|
-
{ isArray, from } = Array, { is } = Object, noop = () => { }, FN = Symbol(),
|
|
123
|
+
{ isArray, from } = Array, { is } = Object, noop = () => { }, FN = Symbol(),
|
|
127
124
|
|
|
128
125
|
isObject = v => v && typeof v == 'object', isFunction = v => typeof v == 'function',
|
|
129
126
|
|
|
@@ -131,6 +128,8 @@ const
|
|
|
131
128
|
|
|
132
129
|
reduce = v => from(v).reduce(assign, {}), assign = (v, { name, value }) => ((v[name] = value), v),
|
|
133
130
|
|
|
131
|
+
microtask = globalThis.queueMicrotask ?? (fn => fn()), task = globalThis.requestAnimationFrame ?? microtask,
|
|
132
|
+
|
|
134
133
|
create = (ns, name, key) => {
|
|
135
134
|
const node = ns ? document.createElementNS(ns, name) : document.createElement(name)
|
|
136
135
|
return node.$key = key, node
|
|
@@ -198,12 +197,17 @@ const
|
|
|
198
197
|
|
|
199
198
|
schedule = host => {
|
|
200
199
|
|
|
201
|
-
if (host.$
|
|
200
|
+
if (host.$idleId) return
|
|
202
201
|
|
|
203
202
|
if (globalThis.navigator?.scheduling?.isInputPending()) {
|
|
204
203
|
|
|
205
|
-
host.$idle
|
|
206
|
-
host.$idle =
|
|
204
|
+
if (!host.$idle) {
|
|
205
|
+
host.$idle = true
|
|
206
|
+
idleCount++
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
host.$idleId = requestIdleCallback(() => {
|
|
210
|
+
host.$idleId = null
|
|
207
211
|
schedule(host)
|
|
208
212
|
})
|
|
209
213
|
|
|
@@ -226,9 +230,11 @@ const
|
|
|
226
230
|
|
|
227
231
|
runComponent = host => {
|
|
228
232
|
|
|
229
|
-
if (host.$
|
|
230
|
-
cancelIdleCallback(host.$
|
|
231
|
-
host.$
|
|
233
|
+
if (host.$idleId) {
|
|
234
|
+
cancelIdleCallback(host.$idleId)
|
|
235
|
+
host.$idleId = null
|
|
236
|
+
host.$idle = false
|
|
237
|
+
idleCount--
|
|
232
238
|
}
|
|
233
239
|
|
|
234
240
|
current = host
|
|
@@ -242,6 +248,12 @@ const
|
|
|
242
248
|
} finally {
|
|
243
249
|
current = null
|
|
244
250
|
layoutsQueue.add(host)
|
|
251
|
+
|
|
252
|
+
if (host.$idle) {
|
|
253
|
+
host.$idle = false
|
|
254
|
+
if (--idleCount) return
|
|
255
|
+
}
|
|
256
|
+
|
|
245
257
|
layoutsId ??= task(runLayouts)
|
|
246
258
|
}
|
|
247
259
|
},
|
|
@@ -305,14 +317,26 @@ const
|
|
|
305
317
|
|
|
306
318
|
if (host.$ref) host.$ref.current = null
|
|
307
319
|
|
|
320
|
+
if (!host.$fn) return
|
|
321
|
+
|
|
308
322
|
layoutsQueue.delete(host)
|
|
309
323
|
effectsQueue.delete(host)
|
|
310
324
|
|
|
311
325
|
for (const key of ['$layout', '$effect']) if (host[key]) {
|
|
312
326
|
|
|
313
|
-
for (const fx of host[key])
|
|
327
|
+
for (const fx of host[key]) {
|
|
328
|
+
|
|
329
|
+
host[key].delete(fx)
|
|
314
330
|
|
|
315
|
-
|
|
331
|
+
try {
|
|
332
|
+
const [cleanup] = fx
|
|
333
|
+
isFunction(cleanup) && cleanup()
|
|
334
|
+
} catch (value) {
|
|
335
|
+
propagate(value, host.parentNode)
|
|
336
|
+
} finally {
|
|
337
|
+
fx[0] = fx[1] = null
|
|
338
|
+
}
|
|
339
|
+
}
|
|
316
340
|
}
|
|
317
341
|
},
|
|
318
342
|
|
|
@@ -321,4 +345,10 @@ const
|
|
|
321
345
|
throw value
|
|
322
346
|
}
|
|
323
347
|
|
|
324
|
-
let
|
|
348
|
+
let
|
|
349
|
+
idleCount = 0,
|
|
350
|
+
layoutsQueue = new Set,
|
|
351
|
+
effectsQueue = new Set,
|
|
352
|
+
layoutsId = null,
|
|
353
|
+
effectsId = null,
|
|
354
|
+
current = null
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ajo=(()=>{var
|
|
1
|
+
var ajo=(()=>{var k=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var W=(e,n)=>{for(var i in n)k(e,i,{get:n[i],enumerable:!0})},D=(e,n,i,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of P(n))!V.call(e,t)&&t!==i&&k(e,t,{get:()=>n[t],enumerable:!(l=z(n,t))||l.enumerable});return e};var G=e=>D(k({},"__esModule",{value:!0}),e);var se={};W(se,{Fragment:()=>J,component:()=>K,h:()=>q,render:()=>N,useCallback:()=>Z,useCatch:()=>U,useEffect:()=>h,useHost:()=>m,useLayout:()=>_,useMemo:()=>I,useReducer:()=>S,useRef:()=>Y,useState:()=>X});const J=({children:e})=>e,q=(e,n,...i)=>{const{length:l}=i;return i=l==0?null:l==1?i[0]:i,{children:i,...n,nodeName:e}},N=(e,n,i)=>{let l=n.firstChild;for(e of x(e)){let t=l;if(e instanceof Node)t=e;else if(typeof e=="string"){for(;t&&t.nodeType!=3;)t=t.nextSibling;t?t.data!=e&&(t.data=e):t=document.createTextNode(e)}else{const{xmlns:r=i,nodeName:a,key:u,ref:f,memo:C,children:Q,[A]:v,...R}=e;for(;t&&!(t.localName==a&&d(t.$key??=u,u));)t=t.nextSibling;t??=re(r,a,u),te(f)&&(f.current=t,t.$ref=f),(C==null||w(t.$deps,t.$deps=C))&&(ae(R,t),o(v)?v(t):N(Q,t,r))}t==l?l=l.nextSibling:ue(n,t,l)}for(;l;){const t=l.nextSibling;H(l),n.removeChild(l),l=t}},K=e=>({nodeName:n,as:i,props:l,key:t,ref:r,memo:a,...u})=>q(i??e?.as??"c-host",{...e?.props,...l,key:t,ref:r,memo:a,[A]:f=>{f.$fn=o(e)?e:ne,f.$args={...e?.args,...u},j(f)}}),S=(e,n)=>{const i=m(),l=p(),[t,r]=l;return t==r.length&&(r[t]=[o(n)?n():n,a=>{const u=r[t][0],f=o(a)?a(u):a;d(u,r[t][0]=o(e)?e(u,f):f)||oe(i)}]),r[l[0]++]},I=(e,n)=>{const i=p(),[l,t]=i;return(l==t.length||n==null||w(n,t[l][1]))&&(t[l]=[e(),n]),t[i[0]++][0]},U=e=>{const n=m(),[i,l]=S(),t=p(),[r,a]=t;return a[t[0]++]=e,n.$catch??=u=>{o(a[r])&&a[r](u),l(u)},[i,()=>l()]},m=()=>c,X=e=>S(null,e),Y=e=>I(()=>({current:e}),[]),Z=(e,n)=>I(()=>e,n),_=(e,n)=>E(e,n,"$layout"),h=(e,n)=>E(e,n,"$effect"),{isArray:s,from:ee}=Array,{is:d}=Object,ne=()=>{},A=Symbol(),te=e=>e&&typeof e=="object",o=e=>typeof e=="function",w=(e,n)=>s(e)&&s(n)?e.some((i,l)=>!d(i,n[l])):!d(e,n),le=e=>ee(e).reduce(ie,{}),ie=(e,{name:n,value:i})=>(e[n]=i,e),F=globalThis.queueMicrotask??(e=>e()),T=globalThis.requestAnimationFrame??F,re=(e,n,i)=>{const l=e?document.createElementNS(e,n):document.createElement(n);return l.$key=i,l},x=function*(e,n={data:""},i=!0){let l;for(e of s(e)?e:[e])e==null||typeof e=="boolean"||(typeof e.nodeName=="string"?((l=n.data)&&(n.data="",yield l),yield e):o(e.nodeName)?yield*x(e.nodeName(e),n,!1):s(e)?yield*x(e,n,!1):n.data+=e);i&&(l=n.data)&&(yield l)},ae=(e,n)=>{const i=n.$props??=n.hasAttributes()?le(n.attributes):{};for(const l in{...i,...n.$props=e}){let t=e[l];t!==i[l]&&(l.startsWith("set:")?n[l.slice(4)]=t:t==null||t===!1?n.removeAttribute(l):n.setAttribute(l,t===!0?"":t))}},ue=(e,n,i)=>{if(n.contains?.(document.activeElement)){const l=n.nextSibling;for(;i&&i!=n;){const t=i.nextSibling;e.insertBefore(i,l),i=t}}else e.insertBefore(n,i)},p=()=>c.$hooks??=[0,[]],E=(e,n,i)=>{const l=m(),t=p(),[r,a]=t;r==a.length?(l[i]??=new Set).add(a[r]=[null,e,n]):(n==null||w(n,a[r][2]))&&(a[r][1]=e,a[r][2]=n),t[0]++},j=e=>{if(!e.$idleId){if(globalThis.navigator?.scheduling?.isInputPending()){e.$idle||(e.$idle=!0,b++),e.$idleId=requestIdleCallback(()=>{e.$idleId=null,j(e)});return}M(e)}},oe=e=>{e.$queued||(e.$queued=!0,F(()=>{e.$queued=!1,M(e)}))},M=e=>{e.$idleId&&(cancelIdleCallback(e.$idleId),e.$idleId=null,e.$idle=!1,b--),c=e,c.$hooks&&(c.$hooks[0]=0);try{e.$h=e.$fn(e.$args)}catch(n){g(n,e.parentNode)}finally{if(c=null,$.add(e),e.$idle&&(e.$idle=!1,--b))return;L??=T(fe)}},fe=()=>{L=null;for(const e of $){$.delete(e);try{N(e.$h,e),e.$h=null}catch(n){g(n,e)}finally{B(e,"$layout"),y.add(e),O??=T(ce)}}},ce=()=>{O=null;for(const e of y)y.delete(e),B(e,"$effect")},B=(e,n)=>{if(e[n])for(const i of e[n]){const[l,t]=i;if(o(t))try{o(l)&&l(),i[0]=t()}catch(r){i[0]=null,g(r,e.parentNode)}finally{i[1]=null}}},H=e=>{if(e.nodeType==1){for(const n of e.children)H(n);if(e.$ref&&(e.$ref.current=null),!!e.$fn){$.delete(e),y.delete(e);for(const n of["$layout","$effect"])if(e[n])for(const i of e[n]){e[n].delete(i);try{const[l]=i;o(l)&&l()}catch(l){g(l,e.parentNode)}finally{i[0]=i[1]=null}}}}},g=(e,n)=>{for(let i;n;n=n.parentNode)if(o(i=n.$catch))return void i(e);throw e};let b=0,$=new Set,y=new Set,L=null,O=null,c=null;return G(se);})();
|