ajo 0.0.25 → 0.1.1
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/ajo.js +122 -0
- package/dist/ajo.umd.cjs +1 -0
- package/package.json +18 -23
- package/readme.md +17 -12
- package/index.cjs +0 -282
- package/index.js +0 -366
- package/index.min.js +0 -1
package/dist/ajo.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var T = (t, e, i) => e in t ? C(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
+
var f = (t, e, i) => (T(t, typeof e != "symbol" ? e + "" : e, i), i);
|
|
4
|
+
const d = Symbol(), w = Symbol(), m = Symbol(), { isArray: g, prototype: { slice: b } } = Array, { assign: v } = Object, z = ({ children: t }) => t, q = function(t, e) {
|
|
5
|
+
const i = { ...e, nodeName: t }, { length: r } = arguments;
|
|
6
|
+
return "children" in i || r < 3 || (i.children = r === 3 ? arguments[2] : b.call(arguments, 2)), i;
|
|
7
|
+
}, E = (t, e, i) => {
|
|
8
|
+
let r = e.firstChild;
|
|
9
|
+
for (t of p(t)) {
|
|
10
|
+
let n = r;
|
|
11
|
+
if (typeof t == "string") {
|
|
12
|
+
for (; n && n.nodeType != 3; )
|
|
13
|
+
n = n.nextSibling;
|
|
14
|
+
n ? n.data != t && (n.data = t) : n = document.createTextNode(t);
|
|
15
|
+
} else {
|
|
16
|
+
const { xmlns: s = i, nodeName: a, is: c, key: l, skip: o, memo: u, ref: x, children: N, ...k } = t;
|
|
17
|
+
for (; n && !(n.localName === a && (n[d] ?? (n[d] = l)) == l); )
|
|
18
|
+
n = n.nextSibling;
|
|
19
|
+
n ?? (n = M(s, a, c, l)), (u == null || A(n[w], n[w] = u)) && (F(k, n), o || E(N, n, s), typeof x == "function" && x(n));
|
|
20
|
+
}
|
|
21
|
+
n === r ? r = r.nextSibling : H(e, n, r);
|
|
22
|
+
}
|
|
23
|
+
for (; r; ) {
|
|
24
|
+
const n = r.nextSibling;
|
|
25
|
+
e.removeChild(r), r = n;
|
|
26
|
+
}
|
|
27
|
+
}, A = (t, e) => g(t) && g(e) ? t.some((i, r) => i !== e[r]) : t !== e, M = (t, e, i, r) => {
|
|
28
|
+
const n = t ? document.createElementNS(t, e, { is: i }) : document.createElement(e, { is: i });
|
|
29
|
+
return n[d] = r, n;
|
|
30
|
+
}, F = (t, e) => {
|
|
31
|
+
const i = e[m] ?? (e[m] = b.call(e.attributes).reduce((r, { name: n, value: s }) => (r[n] = s, r), {}));
|
|
32
|
+
for (const r in { ...i, ...e[m] = t }) {
|
|
33
|
+
const n = t[r];
|
|
34
|
+
n !== i[r] && (r.startsWith("set:") ? e[r.slice(4)] = n : n == null || n === !1 ? e.removeAttribute(r) : e.setAttribute(r, n === !0 ? "" : n));
|
|
35
|
+
}
|
|
36
|
+
}, H = (t, e, i) => {
|
|
37
|
+
if (e.contains(document.activeElement)) {
|
|
38
|
+
const r = e.nextSibling;
|
|
39
|
+
for (; i && i != e; ) {
|
|
40
|
+
const n = i.nextSibling;
|
|
41
|
+
t.insertBefore(i, r), i = n;
|
|
42
|
+
}
|
|
43
|
+
} else
|
|
44
|
+
t.insertBefore(e, i);
|
|
45
|
+
}, p = function* (t, e = { value: "" }, i = !0) {
|
|
46
|
+
for (t of g(t) ? t : [t]) {
|
|
47
|
+
if (t == null || typeof t == "boolean")
|
|
48
|
+
continue;
|
|
49
|
+
const { nodeName: r, ...n } = t, s = typeof r;
|
|
50
|
+
s === "string" ? (e.value && (yield e.value, e.value = ""), yield t) : s === "function" ? yield* p(r(n), e, !1) : g(t) ? yield* p(t, e, !1) : e.value += t;
|
|
51
|
+
}
|
|
52
|
+
i && e.value && (yield e.value);
|
|
53
|
+
};
|
|
54
|
+
let B = 0, h = null, y, S;
|
|
55
|
+
const G = (t, { as: e } = {}) => {
|
|
56
|
+
var n;
|
|
57
|
+
if (((n = t == null ? void 0 : t.constructor) == null ? void 0 : n.name) !== "GeneratorFunction")
|
|
58
|
+
throw new TypeError("fn is not a generator function");
|
|
59
|
+
const i = `host-${B++}`;
|
|
60
|
+
class r extends W(e) {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(...arguments);
|
|
63
|
+
f(this, "generator");
|
|
64
|
+
f(this, "args");
|
|
65
|
+
f(this, "ref");
|
|
66
|
+
}
|
|
67
|
+
disconnectedCallback() {
|
|
68
|
+
this.return();
|
|
69
|
+
}
|
|
70
|
+
refresh() {
|
|
71
|
+
L(this);
|
|
72
|
+
}
|
|
73
|
+
next({ method: c = "next", argument: l } = {}) {
|
|
74
|
+
try {
|
|
75
|
+
const { done: o, value: u } = (this.generator ?? (this.generator = t.call(this, this.args)))[c](l);
|
|
76
|
+
if (o)
|
|
77
|
+
return c !== "return" && this.return(u);
|
|
78
|
+
E(u, this), typeof this.ref == "function" && this.ref(this);
|
|
79
|
+
} catch (o) {
|
|
80
|
+
this.throw(o);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
throw(c) {
|
|
84
|
+
var l;
|
|
85
|
+
for (let o = this.parentNode; o; o = o.parentNode)
|
|
86
|
+
if (typeof ((l = o.generator) == null ? void 0 : l.throw) == "function")
|
|
87
|
+
return o.next({ method: "throw", argument: c });
|
|
88
|
+
throw c;
|
|
89
|
+
}
|
|
90
|
+
return(c) {
|
|
91
|
+
try {
|
|
92
|
+
this.next({ method: "return", argument: c });
|
|
93
|
+
} finally {
|
|
94
|
+
this.generator = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
*[Symbol.iterator]() {
|
|
98
|
+
for (; this.isConnected; )
|
|
99
|
+
yield this.args;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return customElements.define(i, r, { extends: e }), ({ attrs: s = {}, args: a = {}, ref: c, ...l }) => {
|
|
103
|
+
for (const o in l)
|
|
104
|
+
o.startsWith("arg:") ? a[o.slice(4)] = l[o] : (o === "children" ? a : s)[o] = l[o];
|
|
105
|
+
return q(e || i, v(s, { is: e && i, skip: !0, ref: (o) => v(o, { args: a, ref: c }).refresh() }));
|
|
106
|
+
};
|
|
107
|
+
}, L = (t) => {
|
|
108
|
+
(y ?? (y = /* @__PURE__ */ new Set())).add(t), h ?? (h = requestAnimationFrame(() => {
|
|
109
|
+
for (const e of y)
|
|
110
|
+
e.isConnected && e.next();
|
|
111
|
+
y.clear(), h = null;
|
|
112
|
+
}));
|
|
113
|
+
}, W = (t) => {
|
|
114
|
+
let e = (S ?? (S = /* @__PURE__ */ new Map())).get(t);
|
|
115
|
+
return e || (e = document.createElement(t).constructor, e === HTMLUnknownElement && (e = HTMLElement), S.set(t, e)), e;
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
z as Fragment,
|
|
119
|
+
G as component,
|
|
120
|
+
q as h,
|
|
121
|
+
E as render
|
|
122
|
+
};
|
package/dist/ajo.umd.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(s,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(s=typeof globalThis<"u"?globalThis:s||self,l(s.Ajo={}))})(this,function(s){"use strict";var W=Object.defineProperty;var z=(s,l,f)=>l in s?W(s,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):s[l]=f;var p=(s,l,f)=>(z(s,typeof l!="symbol"?l+"":l,f),f);const l=Symbol(),f=Symbol(),y=Symbol(),{isArray:g,prototype:{slice:w}}=Array,{assign:S}=Object,k=({children:t})=>t,b=function(t,e){const o={...e,nodeName:t},{length:i}=arguments;return"children"in o||i<3||(o.children=i===3?arguments[2]:w.call(arguments,2)),o},h=(t,e,o)=>{let i=e.firstChild;for(t of x(t)){let n=i;if(typeof t=="string"){for(;n&&n.nodeType!=3;)n=n.nextSibling;n?n.data!=t&&(n.data=t):n=document.createTextNode(t)}else{const{xmlns:u=o,nodeName:d,is:a,key:c,skip:r,memo:m,ref:N,children:L,...O}=t;for(;n&&!(n.localName===d&&(n[l]??(n[l]=c))==c);)n=n.nextSibling;n??(n=C(u,d,a,c)),(m==null||A(n[f],n[f]=m))&&(M(O,n),r||h(L,n,u),typeof N=="function"&&N(n))}n===i?i=i.nextSibling:j(e,n,i)}for(;i;){const n=i.nextSibling;e.removeChild(i),i=n}},A=(t,e)=>g(t)&&g(e)?t.some((o,i)=>o!==e[i]):t!==e,C=(t,e,o,i)=>{const n=t?document.createElementNS(t,e,{is:o}):document.createElement(e,{is:o});return n[l]=i,n},M=(t,e)=>{const o=e[y]??(e[y]=w.call(e.attributes).reduce((i,{name:n,value:u})=>(i[n]=u,i),{}));for(const i in{...o,...e[y]=t}){const n=t[i];n!==o[i]&&(i.startsWith("set:")?e[i.slice(4)]=n:n==null||n===!1?e.removeAttribute(i):e.setAttribute(i,n===!0?"":n))}},j=(t,e,o)=>{if(e.contains(document.activeElement)){const i=e.nextSibling;for(;o&&o!=e;){const n=o.nextSibling;t.insertBefore(o,i),o=n}}else t.insertBefore(e,o)},x=function*(t,e={value:""},o=!0){for(t of g(t)?t:[t]){if(t==null||typeof t=="boolean")continue;const{nodeName:i,...n}=t,u=typeof i;u==="string"?(e.value&&(yield e.value,e.value=""),yield t):u==="function"?yield*x(i(n),e,!1):g(t)?yield*x(t,e,!1):e.value+=t}o&&e.value&&(yield e.value)};let q=0,E=null,v,T;const F=(t,{as:e}={})=>{var n;if(((n=t==null?void 0:t.constructor)==null?void 0:n.name)!=="GeneratorFunction")throw new TypeError("fn is not a generator function");const o=`host-${q++}`;class i extends B(e){constructor(){super(...arguments);p(this,"generator");p(this,"args");p(this,"ref")}disconnectedCallback(){this.return()}refresh(){H(this)}next({method:a="next",argument:c}={}){try{const{done:r,value:m}=(this.generator??(this.generator=t.call(this,this.args)))[a](c);if(r)return a!=="return"&&this.return(m);h(m,this),typeof this.ref=="function"&&this.ref(this)}catch(r){this.throw(r)}}throw(a){var c;for(let r=this.parentNode;r;r=r.parentNode)if(typeof((c=r.generator)==null?void 0:c.throw)=="function")return r.next({method:"throw",argument:a});throw a}return(a){try{this.next({method:"return",argument:a})}finally{this.generator=null}}*[Symbol.iterator](){for(;this.isConnected;)yield this.args}}return customElements.define(o,i,{extends:e}),({attrs:u={},args:d={},ref:a,...c})=>{for(const r in c)r.startsWith("arg:")?d[r.slice(4)]=c[r]:(r==="children"?d:u)[r]=c[r];return b(e||o,S(u,{is:e&&o,skip:!0,ref:r=>S(r,{args:d,ref:a}).refresh()}))}},H=t=>{(v??(v=new Set)).add(t),E??(E=requestAnimationFrame(()=>{for(const e of v)e.isConnected&&e.next();v.clear(),E=null}))},B=t=>{let e=(T??(T=new Map)).get(t);return e||(e=document.createElement(t).constructor,e===HTMLUnknownElement&&(e=HTMLElement),T.set(t,e)),e};s.Fragment=k,s.component=F,s.h=b,s.render=h,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ajo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "ajo is a JavaScript view library for building user interfaces",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/ajo.umd.cjs",
|
|
10
|
+
"module": "./dist/ajo.js",
|
|
9
11
|
"exports": {
|
|
10
12
|
".": {
|
|
11
|
-
"import": "./
|
|
12
|
-
"require": "./
|
|
13
|
-
"browser": "./index.min.js"
|
|
13
|
+
"import": "./dist/ajo.js",
|
|
14
|
+
"require": "./dist/ajo.umd.cjs"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"jsdom": "^22.1.0",
|
|
19
|
+
"vite": "^4.5.0",
|
|
20
|
+
"vitest": "^0.34.6"
|
|
21
|
+
},
|
|
20
22
|
"keywords": [
|
|
21
23
|
"ui",
|
|
22
24
|
"frontend",
|
|
@@ -24,21 +26,14 @@
|
|
|
24
26
|
"dom",
|
|
25
27
|
"jsx"
|
|
26
28
|
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "npm run build:require && npm run build:browser",
|
|
29
|
-
"build:require": "esbuild --format=cjs --out-extension:.js=.cjs --outdir=. index.js",
|
|
30
|
-
"build:browser": "esbuild --format=iife --out-extension:.js=.min.js --outdir=. --global-name=ajo --minify index.js",
|
|
31
|
-
"release": "npm test && git commit -am \"$npm_package_version\" && git tag $npm_package_version && git push && git push --tags && npm publish",
|
|
32
|
-
"test": "npm run build && uvu"
|
|
33
|
-
},
|
|
34
29
|
"repository": "cristianfalcone/ajo",
|
|
35
30
|
"author": "Cristian Falcone",
|
|
36
31
|
"license": "ISC",
|
|
37
32
|
"bugs": "https://github.com/cristianfalcone/ajo/issues",
|
|
38
33
|
"homepage": "https://github.com/cristianfalcone/ajo#readme",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "vitest --run",
|
|
36
|
+
"build": "vite build",
|
|
37
|
+
"release": "pnpm test && pnpm build && git commit -am \"$npm_package_version\" && git tag $npm_package_version && git push && git push --tags && pnpm publish"
|
|
43
38
|
}
|
|
44
|
-
}
|
|
39
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Ajo
|
|
2
|
+
Ajo is a JavaScript view library for building user interfaces
|
|
3
3
|
|
|
4
4
|
## install
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ ajo is a JavaScript view library for building user interfaces
|
|
|
7
7
|
npm install ajo
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
## render JSX
|
|
10
|
+
## render JSX into DOM
|
|
11
11
|
|
|
12
12
|
```jsx
|
|
13
13
|
/** @jsx h */
|
|
@@ -33,21 +33,26 @@ render(<Greet name="World" />, document.body)
|
|
|
33
33
|
|
|
34
34
|
```jsx
|
|
35
35
|
/** @jsx h */
|
|
36
|
-
import { h,
|
|
36
|
+
import { h, render, component } from 'ajo'
|
|
37
37
|
|
|
38
|
-
const Counter = component(()
|
|
38
|
+
const Counter = component(function* ({ init = 0 }) {
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
let count = init
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const handleClick = () => {
|
|
43
|
+
count++
|
|
44
|
+
this.refresh()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
while (true) yield (
|
|
48
|
+
<button set:onclick={handleClick}>
|
|
49
|
+
Current: {count}
|
|
50
|
+
</button>
|
|
46
51
|
)
|
|
47
52
|
})
|
|
48
53
|
|
|
49
|
-
render(<Counter />, document.body)
|
|
54
|
+
render(<Counter init={5} />, document.body)
|
|
50
55
|
```
|
|
51
56
|
|
|
52
57
|
## acknowledgments
|
|
53
|
-
|
|
58
|
+
Ajo takes heavy inspiration from [Incremental DOM](https://github.com/google/incremental-dom) and [Crank.js](https://github.com/bikeshaving/crank)
|
package/index.cjs
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from2, except, desc) => {
|
|
10
|
-
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from2))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var ajo_exports = {};
|
|
19
|
-
__export(ajo_exports, {
|
|
20
|
-
Fragment: () => Fragment,
|
|
21
|
-
component: () => component,
|
|
22
|
-
h: () => h,
|
|
23
|
-
render: () => render,
|
|
24
|
-
useCallback: () => useCallback,
|
|
25
|
-
useCatch: () => useCatch,
|
|
26
|
-
useEffect: () => useEffect,
|
|
27
|
-
useHost: () => useHost,
|
|
28
|
-
useLayout: () => useLayout,
|
|
29
|
-
useMemo: () => useMemo,
|
|
30
|
-
useReducer: () => useReducer,
|
|
31
|
-
useRef: () => useRef,
|
|
32
|
-
useState: () => useState
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(ajo_exports);
|
|
35
|
-
const Fragment = ({ children }) => children, h = (nodeName, props, ...children) => {
|
|
36
|
-
const { length } = children;
|
|
37
|
-
children = length == 0 ? null : length == 1 ? children[0] : children;
|
|
38
|
-
return { children, ...props, nodeName };
|
|
39
|
-
}, render = (h2, host, ns) => {
|
|
40
|
-
let child = host.firstChild;
|
|
41
|
-
for (h2 of normalize(h2)) {
|
|
42
|
-
let node = child;
|
|
43
|
-
if (h2 instanceof Node)
|
|
44
|
-
node = h2;
|
|
45
|
-
else if (typeof h2 == "string") {
|
|
46
|
-
while (node && node.nodeType != 3)
|
|
47
|
-
node = node.nextSibling;
|
|
48
|
-
node ? node.data != h2 && (node.data = h2) : node = document.createTextNode(h2);
|
|
49
|
-
} else {
|
|
50
|
-
const { xmlns = ns, nodeName, key, ref, memo, children, [FN]: fn, ...props } = h2;
|
|
51
|
-
while (node && !(node.localName == nodeName && is(node.$key ??= key, key)))
|
|
52
|
-
node = node.nextSibling;
|
|
53
|
-
node ??= create(xmlns, nodeName, key);
|
|
54
|
-
if (isObject(ref)) {
|
|
55
|
-
ref.current = node;
|
|
56
|
-
node.$ref = ref;
|
|
57
|
-
}
|
|
58
|
-
if (memo == null || some(node.$deps, node.$deps = memo)) {
|
|
59
|
-
update(props, node);
|
|
60
|
-
isFunction(fn) ? fn(node) : render(children, node, xmlns);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
node == child ? child = child.nextSibling : before(host, node, child);
|
|
64
|
-
}
|
|
65
|
-
while (child) {
|
|
66
|
-
const next = child.nextSibling;
|
|
67
|
-
dispose(child);
|
|
68
|
-
host.removeChild(child);
|
|
69
|
-
child = next;
|
|
70
|
-
}
|
|
71
|
-
}, component = (fn) => ({ nodeName, as, props, key, ref, memo, ...args }) => h(as ?? fn?.as ?? "c-host", {
|
|
72
|
-
...fn?.props,
|
|
73
|
-
...props,
|
|
74
|
-
key,
|
|
75
|
-
ref,
|
|
76
|
-
memo,
|
|
77
|
-
[FN]: (host) => {
|
|
78
|
-
host.$fn = isFunction(fn) ? fn : noop;
|
|
79
|
-
host.$args = { ...fn?.args, ...args };
|
|
80
|
-
schedule(host);
|
|
81
|
-
}
|
|
82
|
-
}), useReducer = (fn, init) => {
|
|
83
|
-
const host = useHost(), hooks = useHooks(), [i, stack] = hooks;
|
|
84
|
-
if (i == stack.length)
|
|
85
|
-
stack[i] = [
|
|
86
|
-
isFunction(init) ? init() : init,
|
|
87
|
-
(value) => {
|
|
88
|
-
const prev = stack[i][0], next = isFunction(value) ? value(prev) : value;
|
|
89
|
-
if (is(prev, stack[i][0] = isFunction(fn) ? fn(prev, next) : next))
|
|
90
|
-
return;
|
|
91
|
-
runMutations(host);
|
|
92
|
-
}
|
|
93
|
-
];
|
|
94
|
-
return stack[hooks[0]++];
|
|
95
|
-
}, useMemo = (fn, deps) => {
|
|
96
|
-
const hooks = useHooks(), [i, stack] = hooks;
|
|
97
|
-
if (i == stack.length || deps == null || some(deps, stack[i][1]))
|
|
98
|
-
stack[i] = [fn(), deps];
|
|
99
|
-
return stack[hooks[0]++][0];
|
|
100
|
-
}, useCatch = (fn) => {
|
|
101
|
-
const host = useHost(), [value, setValue] = useReducer(), hooks = useHooks(), [i, stack] = hooks;
|
|
102
|
-
stack[hooks[0]++] = fn;
|
|
103
|
-
host.$catch ??= (value2) => {
|
|
104
|
-
isFunction(stack[i]) && stack[i](value2);
|
|
105
|
-
setValue(value2);
|
|
106
|
-
};
|
|
107
|
-
return [value, () => setValue()];
|
|
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");
|
|
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) => {
|
|
111
|
-
const node = ns ? document.createElementNS(ns, name) : document.createElement(name);
|
|
112
|
-
return node.$key = key, node;
|
|
113
|
-
}, normalize = function* (h2, buffer = { data: "" }, root = true) {
|
|
114
|
-
let data;
|
|
115
|
-
for (h2 of isArray(h2) ? h2 : [h2]) {
|
|
116
|
-
if (h2 == null || typeof h2 == "boolean")
|
|
117
|
-
continue;
|
|
118
|
-
if (typeof h2.nodeName == "string")
|
|
119
|
-
(data = buffer.data) && (buffer.data = "", yield data), yield h2;
|
|
120
|
-
else if (isFunction(h2.nodeName))
|
|
121
|
-
yield* normalize(h2.nodeName(h2), buffer, false);
|
|
122
|
-
else
|
|
123
|
-
isArray(h2) ? yield* normalize(h2, buffer, false) : buffer.data += h2;
|
|
124
|
-
}
|
|
125
|
-
root && (data = buffer.data) && (yield data);
|
|
126
|
-
}, update = (props, host) => {
|
|
127
|
-
const prev = host.$props ??= host.hasAttributes() ? reduce(host.attributes) : {};
|
|
128
|
-
for (const name in { ...prev, ...host.$props = props }) {
|
|
129
|
-
let value = props[name];
|
|
130
|
-
if (value !== prev[name])
|
|
131
|
-
if (name.startsWith("set:"))
|
|
132
|
-
host[name.slice(4)] = value;
|
|
133
|
-
else if (value == null || value === false)
|
|
134
|
-
host.removeAttribute(name);
|
|
135
|
-
else
|
|
136
|
-
host.setAttribute(name, value === true ? "" : value);
|
|
137
|
-
}
|
|
138
|
-
}, before = (host, node, child) => {
|
|
139
|
-
if (node.contains?.(document.activeElement)) {
|
|
140
|
-
const ref = node.nextSibling;
|
|
141
|
-
while (child && child != node) {
|
|
142
|
-
const next = child.nextSibling;
|
|
143
|
-
host.insertBefore(child, ref);
|
|
144
|
-
child = next;
|
|
145
|
-
}
|
|
146
|
-
} else
|
|
147
|
-
host.insertBefore(node, child);
|
|
148
|
-
}, useHooks = () => current.$hooks ??= [0, []], useFx = (fn, deps, key) => {
|
|
149
|
-
const host = useHost(), hooks = useHooks(), [i, stack] = hooks, init = i == stack.length;
|
|
150
|
-
if (init)
|
|
151
|
-
(host[key] ??= /* @__PURE__ */ new Set()).add(stack[i] = [null, fn, deps]);
|
|
152
|
-
else if (deps == null || some(deps, stack[i][2])) {
|
|
153
|
-
stack[i][1] = fn;
|
|
154
|
-
stack[i][2] = deps;
|
|
155
|
-
}
|
|
156
|
-
hooks[0]++;
|
|
157
|
-
}, schedule = (host) => {
|
|
158
|
-
if (host.$idle)
|
|
159
|
-
return;
|
|
160
|
-
if (globalThis.navigator?.scheduling?.isInputPending()) {
|
|
161
|
-
idleQueue.add(host);
|
|
162
|
-
host.$idle = true;
|
|
163
|
-
idleId ??= requestIdleCallback(runIdle);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
run(host);
|
|
167
|
-
}, run = (host) => {
|
|
168
|
-
if (host.$idle) {
|
|
169
|
-
idleQueue.delete(host);
|
|
170
|
-
host.$idle = false;
|
|
171
|
-
}
|
|
172
|
-
current = host;
|
|
173
|
-
if (current.$hooks)
|
|
174
|
-
current.$hooks[0] = 0;
|
|
175
|
-
try {
|
|
176
|
-
host.$h = host.$fn(host.$args);
|
|
177
|
-
} catch (value) {
|
|
178
|
-
propagate(value, host.parentNode);
|
|
179
|
-
} finally {
|
|
180
|
-
current = null;
|
|
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);
|
|
191
|
-
}
|
|
192
|
-
}, runMutations = (host) => {
|
|
193
|
-
if (host.$runQueued)
|
|
194
|
-
return;
|
|
195
|
-
host.$runQueued = true;
|
|
196
|
-
microtask(() => {
|
|
197
|
-
host.$runQueued = false;
|
|
198
|
-
run(host);
|
|
199
|
-
});
|
|
200
|
-
}, runLayouts = () => {
|
|
201
|
-
layoutId = null;
|
|
202
|
-
for (const host of layoutQueue) {
|
|
203
|
-
layoutQueue.delete(host);
|
|
204
|
-
host.$layoutQueued = false;
|
|
205
|
-
try {
|
|
206
|
-
render(host.$h, host);
|
|
207
|
-
host.$h = null;
|
|
208
|
-
} catch (value) {
|
|
209
|
-
propagate(value, host);
|
|
210
|
-
} finally {
|
|
211
|
-
runFx(host, "$layout");
|
|
212
|
-
effectQueue.add(host);
|
|
213
|
-
host.$effectQueued = true;
|
|
214
|
-
effectId ??= task(runEffects);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}, runEffects = () => {
|
|
218
|
-
effectId = null;
|
|
219
|
-
for (const host of effectQueue) {
|
|
220
|
-
effectQueue.delete(host);
|
|
221
|
-
host.$effectQueued = false;
|
|
222
|
-
runFx(host, "$effect");
|
|
223
|
-
}
|
|
224
|
-
}, runFx = (host, key) => {
|
|
225
|
-
if (host[key])
|
|
226
|
-
for (const fx of host[key]) {
|
|
227
|
-
const [cleanup, setup] = fx;
|
|
228
|
-
if (isFunction(setup)) {
|
|
229
|
-
try {
|
|
230
|
-
if (isFunction(cleanup))
|
|
231
|
-
cleanup();
|
|
232
|
-
fx[0] = setup();
|
|
233
|
-
} catch (value) {
|
|
234
|
-
fx[0] = null;
|
|
235
|
-
propagate(value, host.parentNode);
|
|
236
|
-
} finally {
|
|
237
|
-
fx[1] = null;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}, dispose = (host) => {
|
|
242
|
-
if (host.nodeType != 1)
|
|
243
|
-
return;
|
|
244
|
-
for (const child of host.children)
|
|
245
|
-
dispose(child);
|
|
246
|
-
if (host.$ref)
|
|
247
|
-
host.$ref.current = null;
|
|
248
|
-
if (!host.$fn)
|
|
249
|
-
return;
|
|
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
|
-
}
|
|
262
|
-
for (const key of ["$layout", "$effect"])
|
|
263
|
-
if (host[key]) {
|
|
264
|
-
for (const fx of host[key]) {
|
|
265
|
-
host[key].delete(fx);
|
|
266
|
-
try {
|
|
267
|
-
const [cleanup] = fx;
|
|
268
|
-
isFunction(cleanup) && cleanup();
|
|
269
|
-
} catch (value) {
|
|
270
|
-
propagate(value, host.parentNode);
|
|
271
|
-
} finally {
|
|
272
|
-
fx[0] = fx[1] = null;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}, propagate = (value, host) => {
|
|
277
|
-
for (let fn; host; host = host.parentNode)
|
|
278
|
-
if (isFunction(fn = host.$catch))
|
|
279
|
-
return void fn(value);
|
|
280
|
-
throw value;
|
|
281
|
-
};
|
|
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
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
Fragment = ({ children }) => children,
|
|
4
|
-
|
|
5
|
-
h = (nodeName, props, ...children) => {
|
|
6
|
-
const { length } = children
|
|
7
|
-
children = length == 0 ? null : length == 1 ? children[0] : children
|
|
8
|
-
return { children, ...props, nodeName }
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
render = (h, host, ns) => {
|
|
12
|
-
|
|
13
|
-
let child = host.firstChild
|
|
14
|
-
|
|
15
|
-
for (h of normalize(h)) {
|
|
16
|
-
|
|
17
|
-
let node = child
|
|
18
|
-
|
|
19
|
-
if (h instanceof Node) node = h
|
|
20
|
-
|
|
21
|
-
else if (typeof h == 'string') {
|
|
22
|
-
|
|
23
|
-
while (node && node.nodeType != 3) node = node.nextSibling
|
|
24
|
-
node ? node.data != h && (node.data = h) : node = document.createTextNode(h)
|
|
25
|
-
|
|
26
|
-
} else {
|
|
27
|
-
|
|
28
|
-
const { xmlns = ns, nodeName, key, ref, memo, children, [FN]: fn, ...props } = h
|
|
29
|
-
|
|
30
|
-
while (node && !(node.localName == nodeName && is(node.$key ??= key, key))) node = node.nextSibling
|
|
31
|
-
node ??= create(xmlns, nodeName, key)
|
|
32
|
-
|
|
33
|
-
if (isObject(ref)) {
|
|
34
|
-
ref.current = node
|
|
35
|
-
node.$ref = ref
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (memo == null || some(node.$deps, node.$deps = memo)) {
|
|
39
|
-
update(props, node)
|
|
40
|
-
isFunction(fn) ? fn(node) : render(children, node, xmlns)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
node == child ? child = child.nextSibling : before(host, node, child)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
while (child) {
|
|
48
|
-
const next = child.nextSibling
|
|
49
|
-
dispose(child)
|
|
50
|
-
host.removeChild(child)
|
|
51
|
-
child = next
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
component = fn => ({ nodeName, as, props, key, ref, memo, ...args }) =>
|
|
56
|
-
|
|
57
|
-
h(as ?? fn?.as ?? 'c-host', {
|
|
58
|
-
|
|
59
|
-
...fn?.props, ...props, key, ref, memo, [FN]: host => {
|
|
60
|
-
|
|
61
|
-
host.$fn = isFunction(fn) ? fn : noop
|
|
62
|
-
host.$args = { ...fn?.args, ...args }
|
|
63
|
-
|
|
64
|
-
schedule(host)
|
|
65
|
-
}
|
|
66
|
-
}),
|
|
67
|
-
|
|
68
|
-
useReducer = (fn, init) => {
|
|
69
|
-
|
|
70
|
-
const host = useHost(), hooks = useHooks(), [i, stack] = hooks
|
|
71
|
-
|
|
72
|
-
if (i == stack.length) stack[i] = [
|
|
73
|
-
|
|
74
|
-
isFunction(init) ? init() : init,
|
|
75
|
-
|
|
76
|
-
value => {
|
|
77
|
-
|
|
78
|
-
const prev = stack[i][0], next = isFunction(value) ? value(prev) : value
|
|
79
|
-
|
|
80
|
-
if (is(prev, stack[i][0] = isFunction(fn) ? fn(prev, next) : next)) return
|
|
81
|
-
|
|
82
|
-
runMutations(host)
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
return stack[hooks[0]++]
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
useMemo = (fn, deps) => {
|
|
90
|
-
|
|
91
|
-
const hooks = useHooks(), [i, stack] = hooks
|
|
92
|
-
|
|
93
|
-
if (i == stack.length || deps == null || some(deps, stack[i][1])) stack[i] = [fn(), deps]
|
|
94
|
-
|
|
95
|
-
return stack[hooks[0]++][0]
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
useCatch = fn => {
|
|
99
|
-
|
|
100
|
-
const host = useHost(), [value, setValue] = useReducer(), hooks = useHooks(), [i, stack] = hooks
|
|
101
|
-
|
|
102
|
-
stack[hooks[0]++] = fn
|
|
103
|
-
|
|
104
|
-
host.$catch ??= value => {
|
|
105
|
-
isFunction(stack[i]) && stack[i](value)
|
|
106
|
-
setValue(value)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return [value, () => setValue()]
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
useHost = () => current,
|
|
113
|
-
useState = init => useReducer(null, init),
|
|
114
|
-
|
|
115
|
-
useRef = current => useMemo(() => ({ current }), []),
|
|
116
|
-
useCallback = (fn, deps) => useMemo(() => fn, deps),
|
|
117
|
-
|
|
118
|
-
useLayout = (fn, deps) => useFx(fn, deps, '$layout'),
|
|
119
|
-
useEffect = (fn, deps) => useFx(fn, deps, '$effect')
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
{ isArray, from } = Array, { is } = Object, noop = () => { }, FN = Symbol(),
|
|
124
|
-
|
|
125
|
-
isObject = v => v && typeof v == 'object', isFunction = v => typeof v == 'function',
|
|
126
|
-
|
|
127
|
-
some = (a, b) => (isArray(a) && isArray(b)) ? a.some((v, i) => !is(v, b[i])) : !is(a, b),
|
|
128
|
-
|
|
129
|
-
reduce = v => from(v).reduce(assign, {}), assign = (v, { name, value }) => ((v[name] = value), v),
|
|
130
|
-
|
|
131
|
-
microtask = globalThis.queueMicrotask ?? (fn => fn()), task = globalThis.requestAnimationFrame ?? microtask,
|
|
132
|
-
|
|
133
|
-
create = (ns, name, key) => {
|
|
134
|
-
const node = ns ? document.createElementNS(ns, name) : document.createElement(name)
|
|
135
|
-
return node.$key = key, node
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
normalize = function* (h, buffer = { data: '' }, root = true) {
|
|
139
|
-
|
|
140
|
-
let data
|
|
141
|
-
|
|
142
|
-
for (h of isArray(h) ? h : [h]) {
|
|
143
|
-
if (h == null || typeof h == 'boolean') continue
|
|
144
|
-
if (typeof h.nodeName == 'string') ((data = buffer.data) && (buffer.data = '', yield data)), yield h
|
|
145
|
-
else if (isFunction(h.nodeName)) yield* normalize(h.nodeName(h), buffer, false)
|
|
146
|
-
else isArray(h) ? yield* normalize(h, buffer, false) : buffer.data += h
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
root && (data = buffer.data) && (yield data)
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
update = (props, host) => {
|
|
153
|
-
|
|
154
|
-
const prev = host.$props ??= host.hasAttributes() ? reduce(host.attributes) : {}
|
|
155
|
-
|
|
156
|
-
for (const name in { ...prev, ...(host.$props = props) }) {
|
|
157
|
-
|
|
158
|
-
let value = props[name]
|
|
159
|
-
|
|
160
|
-
if (value !== prev[name])
|
|
161
|
-
if (name.startsWith('set:')) host[name.slice(4)] = value
|
|
162
|
-
else if (value == null || value === false) host.removeAttribute(name)
|
|
163
|
-
else host.setAttribute(name, value === true ? '' : value)
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
before = (host, node, child) => {
|
|
168
|
-
|
|
169
|
-
if (node.contains?.(document.activeElement)) {
|
|
170
|
-
|
|
171
|
-
const ref = node.nextSibling
|
|
172
|
-
|
|
173
|
-
while (child && child != node) {
|
|
174
|
-
const next = child.nextSibling
|
|
175
|
-
host.insertBefore(child, ref)
|
|
176
|
-
child = next
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
} else host.insertBefore(node, child)
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
useHooks = () => current.$hooks ??= [0, []],
|
|
183
|
-
|
|
184
|
-
useFx = (fn, deps, key) => {
|
|
185
|
-
|
|
186
|
-
const host = useHost(), hooks = useHooks(), [i, stack] = hooks, init = i == stack.length
|
|
187
|
-
|
|
188
|
-
if (init) (host[key] ??= new Set).add(stack[i] = [null, fn, deps])
|
|
189
|
-
|
|
190
|
-
else if (deps == null || some(deps, stack[i][2])) {
|
|
191
|
-
stack[i][1] = fn
|
|
192
|
-
stack[i][2] = deps
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
hooks[0]++
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
schedule = host => {
|
|
199
|
-
|
|
200
|
-
if (host.$idle) return
|
|
201
|
-
|
|
202
|
-
if (globalThis.navigator?.scheduling?.isInputPending()) {
|
|
203
|
-
idleQueue.add(host)
|
|
204
|
-
host.$idle = true
|
|
205
|
-
idleId ??= requestIdleCallback(runIdle)
|
|
206
|
-
return
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
run(host)
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
run = host => {
|
|
213
|
-
|
|
214
|
-
if (host.$idle) {
|
|
215
|
-
idleQueue.delete(host)
|
|
216
|
-
host.$idle = false
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
current = host
|
|
220
|
-
|
|
221
|
-
if (current.$hooks) current.$hooks[0] = 0
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
host.$h = host.$fn(host.$args)
|
|
225
|
-
} catch (value) {
|
|
226
|
-
propagate(value, host.parentNode)
|
|
227
|
-
} finally {
|
|
228
|
-
current = null
|
|
229
|
-
layoutQueue.add(host)
|
|
230
|
-
host.$layoutQueued = true
|
|
231
|
-
layoutId ??= task(runLayouts)
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
runIdle = () => {
|
|
236
|
-
|
|
237
|
-
idleId = null
|
|
238
|
-
|
|
239
|
-
for (const host of from(idleQueue)) {
|
|
240
|
-
idleQueue.delete(host)
|
|
241
|
-
host.$idle = false
|
|
242
|
-
schedule(host)
|
|
243
|
-
}
|
|
244
|
-
},
|
|
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
|
-
|
|
257
|
-
runLayouts = () => {
|
|
258
|
-
|
|
259
|
-
layoutId = null
|
|
260
|
-
|
|
261
|
-
for (const host of layoutQueue) {
|
|
262
|
-
|
|
263
|
-
layoutQueue.delete(host)
|
|
264
|
-
host.$layoutQueued = false
|
|
265
|
-
|
|
266
|
-
try {
|
|
267
|
-
render(host.$h, host)
|
|
268
|
-
host.$h = null
|
|
269
|
-
} catch (value) {
|
|
270
|
-
propagate(value, host)
|
|
271
|
-
} finally {
|
|
272
|
-
runFx(host, '$layout')
|
|
273
|
-
effectQueue.add(host)
|
|
274
|
-
host.$effectQueued = true
|
|
275
|
-
effectId ??= task(runEffects)
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
runEffects = () => {
|
|
281
|
-
|
|
282
|
-
effectId = null
|
|
283
|
-
|
|
284
|
-
for (const host of effectQueue) {
|
|
285
|
-
effectQueue.delete(host)
|
|
286
|
-
host.$effectQueued = false
|
|
287
|
-
runFx(host, '$effect')
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
runFx = (host, key) => {
|
|
292
|
-
|
|
293
|
-
if (host[key]) for (const fx of host[key]) {
|
|
294
|
-
|
|
295
|
-
const [cleanup, setup] = fx
|
|
296
|
-
|
|
297
|
-
if (isFunction(setup)) {
|
|
298
|
-
try {
|
|
299
|
-
if (isFunction(cleanup)) cleanup()
|
|
300
|
-
fx[0] = setup()
|
|
301
|
-
} catch (value) {
|
|
302
|
-
fx[0] = null
|
|
303
|
-
propagate(value, host.parentNode)
|
|
304
|
-
} finally {
|
|
305
|
-
fx[1] = null
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
dispose = host => {
|
|
312
|
-
|
|
313
|
-
if (host.nodeType != 1) return
|
|
314
|
-
|
|
315
|
-
for (const child of host.children) dispose(child)
|
|
316
|
-
|
|
317
|
-
if (host.$ref) host.$ref.current = null
|
|
318
|
-
|
|
319
|
-
if (!host.$fn) return
|
|
320
|
-
|
|
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
|
-
}
|
|
335
|
-
|
|
336
|
-
for (const key of ['$layout', '$effect']) if (host[key]) {
|
|
337
|
-
|
|
338
|
-
for (const fx of host[key]) {
|
|
339
|
-
|
|
340
|
-
host[key].delete(fx)
|
|
341
|
-
|
|
342
|
-
try {
|
|
343
|
-
const [cleanup] = fx
|
|
344
|
-
isFunction(cleanup) && cleanup()
|
|
345
|
-
} catch (value) {
|
|
346
|
-
propagate(value, host.parentNode)
|
|
347
|
-
} finally {
|
|
348
|
-
fx[0] = fx[1] = null
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
propagate = (value, host) => {
|
|
355
|
-
for (let fn; host; host = host.parentNode) if (isFunction(fn = host.$catch)) return void fn(value)
|
|
356
|
-
throw value
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
let
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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);})();
|