@elurjs/core 3.6.1 → 3.7.0-beta.0
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/lib/async.cjs +1 -1
- package/dist/lib/async.js +1 -1
- package/dist/lib/component.cjs +1 -2
- package/dist/lib/component.js +2 -66
- package/dist/lib/context.cjs +1 -1
- package/dist/lib/context.js +35 -23
- package/dist/lib/devtools.cjs +1 -1
- package/dist/lib/devtools.js +1 -1
- package/dist/lib/elur/async.cjs +1 -1
- package/dist/lib/elur/async.cjs.map +1 -1
- package/dist/lib/elur/async.js +1 -1
- package/dist/lib/elur/component.cjs +1 -2
- package/dist/lib/elur/component.d.cts +1 -17
- package/dist/lib/elur/component.d.ts +1 -17
- package/dist/lib/elur/component.js +2 -66
- package/dist/lib/elur/context.cjs +1 -1
- package/dist/lib/elur/context.cjs.map +1 -1
- package/dist/lib/elur/context.d.cts +5 -0
- package/dist/lib/elur/context.d.ts +5 -0
- package/dist/lib/elur/context.js +35 -23
- package/dist/lib/elur/context.js.map +1 -1
- package/dist/lib/elur/devtools.cjs +1 -1
- package/dist/lib/elur/devtools.cjs.map +1 -1
- package/dist/lib/elur/devtools.js +1 -1
- package/dist/lib/elur/form.cjs +1 -1
- package/dist/lib/elur/form.cjs.map +1 -1
- package/dist/lib/elur/form.js +1 -1
- package/dist/lib/elur/hydrate/index.cjs +1 -2
- package/dist/lib/elur/hydrate/index.d.cts +1 -13
- package/dist/lib/elur/hydrate/index.d.ts +1 -13
- package/dist/lib/elur/hydrate/index.js +2 -410
- package/dist/lib/elur/lifecycle.cjs +1 -1
- package/dist/lib/elur/lifecycle.cjs.map +1 -1
- package/dist/lib/elur/lifecycle.d.cts +27 -0
- package/dist/lib/elur/lifecycle.d.ts +27 -0
- package/dist/lib/elur/lifecycle.js +4 -0
- package/dist/lib/elur/lifecycle.js.map +1 -1
- package/dist/lib/elur/next/component.d.cts +281 -0
- package/dist/lib/elur/next/component.d.ts +281 -0
- package/dist/lib/elur/next/dom-write.d.cts +18 -0
- package/dist/lib/elur/next/dom-write.d.ts +18 -0
- package/dist/lib/elur/next/hydrate.d.cts +14 -0
- package/dist/lib/elur/next/hydrate.d.ts +14 -0
- package/dist/lib/elur/next/keyed-diff.d.cts +46 -0
- package/dist/lib/elur/next/keyed-diff.d.ts +46 -0
- package/dist/lib/elur/next/mount-helpers.d.cts +25 -0
- package/dist/lib/elur/next/mount-helpers.d.ts +25 -0
- package/dist/lib/elur/next/mount.d.cts +29 -0
- package/dist/lib/elur/next/mount.d.ts +29 -0
- package/dist/lib/elur/next/node-binding.d.cts +6 -0
- package/dist/lib/elur/next/node-binding.d.ts +6 -0
- package/dist/lib/elur/next/reactivity.d.cts +193 -0
- package/dist/lib/elur/next/reactivity.d.ts +193 -0
- package/dist/lib/elur/next-2/component.cjs +2 -0
- package/dist/lib/elur/next-2/component.cjs.map +1 -0
- package/dist/lib/elur/next-2/component.d.cts +283 -0
- package/dist/lib/elur/next-2/component.d.ts +283 -0
- package/dist/lib/elur/next-2/component.js +340 -0
- package/dist/lib/elur/next-2/component.js.map +1 -0
- package/dist/lib/elur/next-2/dom-write.cjs +2 -0
- package/dist/lib/elur/next-2/dom-write.cjs.map +1 -0
- package/dist/lib/elur/next-2/dom-write.d.cts +18 -0
- package/dist/lib/elur/next-2/dom-write.d.ts +18 -0
- package/dist/lib/elur/next-2/dom-write.js +31 -0
- package/dist/lib/elur/next-2/dom-write.js.map +1 -0
- package/dist/lib/elur/next-2/hydrate.cjs +2 -0
- package/dist/lib/elur/next-2/hydrate.cjs.map +1 -0
- package/dist/lib/elur/next-2/hydrate.d.cts +30 -0
- package/dist/lib/elur/next-2/hydrate.d.ts +30 -0
- package/dist/lib/elur/next-2/hydrate.js +449 -0
- package/dist/lib/elur/next-2/hydrate.js.map +1 -0
- package/dist/lib/elur/next-2/keyed-diff.cjs +2 -0
- package/dist/lib/elur/next-2/keyed-diff.cjs.map +1 -0
- package/dist/lib/elur/next-2/keyed-diff.d.cts +79 -0
- package/dist/lib/elur/next-2/keyed-diff.d.ts +79 -0
- package/dist/lib/elur/next-2/keyed-diff.js +208 -0
- package/dist/lib/elur/next-2/keyed-diff.js.map +1 -0
- package/dist/lib/elur/next-2/mount-helpers.cjs +2 -0
- package/dist/lib/elur/next-2/mount-helpers.cjs.map +1 -0
- package/dist/lib/elur/next-2/mount-helpers.d.cts +25 -0
- package/dist/lib/elur/next-2/mount-helpers.d.ts +25 -0
- package/dist/lib/elur/next-2/mount-helpers.js +87 -0
- package/dist/lib/elur/next-2/mount-helpers.js.map +1 -0
- package/dist/lib/elur/next-2/mount.cjs +2 -0
- package/dist/lib/elur/next-2/mount.cjs.map +1 -0
- package/dist/lib/elur/next-2/mount.d.cts +29 -0
- package/dist/lib/elur/next-2/mount.d.ts +29 -0
- package/dist/lib/elur/next-2/mount.js +34 -0
- package/dist/lib/elur/next-2/mount.js.map +1 -0
- package/dist/lib/elur/next-2/node-binding.cjs +2 -0
- package/dist/lib/elur/next-2/node-binding.cjs.map +1 -0
- package/dist/lib/elur/next-2/node-binding.d.cts +6 -0
- package/dist/lib/elur/next-2/node-binding.d.ts +6 -0
- package/dist/lib/elur/next-2/node-binding.js +130 -0
- package/dist/lib/elur/next-2/node-binding.js.map +1 -0
- package/dist/lib/elur/next-2/reactivity.cjs +2 -0
- package/dist/lib/elur/next-2/reactivity.cjs.map +1 -0
- package/dist/lib/elur/next-2/reactivity.d.cts +220 -0
- package/dist/lib/elur/next-2/reactivity.d.ts +220 -0
- package/dist/lib/elur/next-2/reactivity.js +614 -0
- package/dist/lib/elur/next-2/reactivity.js.map +1 -0
- package/dist/lib/elur/next-2/scheduler.cjs +2 -0
- package/dist/lib/elur/next-2/scheduler.cjs.map +1 -0
- package/dist/lib/elur/next-2/scheduler.d.cts +23 -0
- package/dist/lib/elur/next-2/scheduler.d.ts +23 -0
- package/dist/lib/elur/next-2/scheduler.js +26 -0
- package/dist/lib/elur/next-2/scheduler.js.map +1 -0
- package/dist/lib/elur/plugins.cjs +1 -1
- package/dist/lib/elur/plugins.cjs.map +1 -1
- package/dist/lib/elur/plugins.js +1 -1
- package/dist/lib/elur/reactivity.cjs +1 -2
- package/dist/lib/elur/reactivity.d.cts +1 -67
- package/dist/lib/elur/reactivity.d.ts +1 -67
- package/dist/lib/elur/reactivity.js +2 -218
- package/dist/lib/elur/router.cjs +2 -2
- package/dist/lib/elur/router.cjs.map +1 -1
- package/dist/lib/elur/router.js +2 -2
- package/dist/lib/elur/router.js.map +1 -1
- package/dist/lib/elur/server/index.cjs +1 -1
- package/dist/lib/elur/server/index.cjs.map +1 -1
- package/dist/lib/elur/server/index.js +180 -108
- package/dist/lib/elur/server/index.js.map +1 -1
- package/dist/lib/elur/store.cjs +1 -1
- package/dist/lib/elur/store.cjs.map +1 -1
- package/dist/lib/elur/store.js +10 -4
- package/dist/lib/elur/store.js.map +1 -1
- package/dist/lib/elur/template/bindings.cjs +1 -1
- package/dist/lib/elur/template/bindings.cjs.map +1 -1
- package/dist/lib/elur/template/bindings.js +98 -84
- package/dist/lib/elur/template/bindings.js.map +1 -1
- package/dist/lib/elur/template/dom-write.d.cts +1 -5
- package/dist/lib/elur/template/dom-write.d.ts +1 -5
- package/dist/lib/elur/template/error-boundary.cjs +1 -1
- package/dist/lib/elur/template/error-boundary.cjs.map +1 -1
- package/dist/lib/elur/template/error-boundary.js +56 -50
- package/dist/lib/elur/template/error-boundary.js.map +1 -1
- package/dist/lib/elur/template/html.cjs +1 -1
- package/dist/lib/elur/template/html.cjs.map +1 -1
- package/dist/lib/elur/template/html.js +40 -37
- package/dist/lib/elur/template/html.js.map +1 -1
- package/dist/lib/elur/template/index.cjs +1 -1
- package/dist/lib/elur/template/index.d.cts +2 -1
- package/dist/lib/elur/template/index.d.ts +2 -1
- package/dist/lib/elur/template/index.js +13 -12
- package/dist/lib/elur/template/keyed-diff.d.cts +1 -32
- package/dist/lib/elur/template/keyed-diff.d.ts +1 -32
- package/dist/lib/elur/template/keyed.cjs +1 -1
- package/dist/lib/elur/template/keyed.cjs.map +1 -1
- package/dist/lib/elur/template/keyed.d.cts +10 -2
- package/dist/lib/elur/template/keyed.d.ts +10 -2
- package/dist/lib/elur/template/keyed.js +12 -1
- package/dist/lib/elur/template/keyed.js.map +1 -1
- package/dist/lib/elur/template/mount-helpers.d.cts +1 -29
- package/dist/lib/elur/template/mount-helpers.d.ts +1 -29
- package/dist/lib/elur/template/node-binding.d.cts +1 -6
- package/dist/lib/elur/template/node-binding.d.ts +1 -6
- package/dist/lib/elur/template/portal.cjs +1 -1
- package/dist/lib/elur/template/portal.cjs.map +1 -1
- package/dist/lib/elur/template/portal.js +1 -1
- package/dist/lib/elur/template/transitions.cjs +1 -1
- package/dist/lib/elur/template/transitions.cjs.map +1 -1
- package/dist/lib/elur/template/transitions.js +2 -2
- package/dist/lib/elur/template/types.cjs +1 -1
- package/dist/lib/elur/template/types.cjs.map +1 -1
- package/dist/lib/elur/template/types.d.cts +55 -0
- package/dist/lib/elur/template/types.d.ts +55 -0
- package/dist/lib/elur/template/types.js +5 -1
- package/dist/lib/elur/template/types.js.map +1 -1
- package/dist/lib/elur.cjs +1 -1
- package/dist/lib/elur.js +2 -2
- package/dist/lib/form.cjs +1 -1
- package/dist/lib/form.js +1 -1
- package/dist/lib/hydrate.cjs +1 -2
- package/dist/lib/hydrate.js +2 -410
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/lifecycle.cjs +1 -1
- package/dist/lib/lifecycle.js +4 -0
- package/dist/lib/plugins.cjs +1 -1
- package/dist/lib/plugins.js +1 -1
- package/dist/lib/router.cjs +2 -2
- package/dist/lib/router.js +2 -2
- package/dist/lib/server.cjs +1 -1
- package/dist/lib/server.js +180 -108
- package/dist/lib/signals.cjs +1 -2
- package/dist/lib/signals.js +2 -218
- package/dist/lib/store.cjs +1 -1
- package/dist/lib/store.js +10 -4
- package/dist/lib/template.cjs +1 -1
- package/dist/lib/template.js +13 -12
- package/package.json +7 -9
- package/dist/lib/elur/component.cjs.map +0 -1
- package/dist/lib/elur/component.js.map +0 -1
- package/dist/lib/elur/hydrate/index.cjs.map +0 -1
- package/dist/lib/elur/hydrate/index.js.map +0 -1
- package/dist/lib/elur/reactivity.cjs.map +0 -1
- package/dist/lib/elur/reactivity.js.map +0 -1
- package/dist/lib/elur/template/dom-write.cjs +0 -2
- package/dist/lib/elur/template/dom-write.cjs.map +0 -1
- package/dist/lib/elur/template/dom-write.js +0 -16
- package/dist/lib/elur/template/dom-write.js.map +0 -1
- package/dist/lib/elur/template/keyed-diff.cjs +0 -2
- package/dist/lib/elur/template/keyed-diff.cjs.map +0 -1
- package/dist/lib/elur/template/keyed-diff.js +0 -100
- package/dist/lib/elur/template/keyed-diff.js.map +0 -1
- package/dist/lib/elur/template/mount-helpers.cjs +0 -2
- package/dist/lib/elur/template/mount-helpers.cjs.map +0 -1
- package/dist/lib/elur/template/mount-helpers.js +0 -132
- package/dist/lib/elur/template/mount-helpers.js.map +0 -1
- package/dist/lib/elur/template/node-binding.cjs +0 -2
- package/dist/lib/elur/template/node-binding.cjs.map +0 -1
- package/dist/lib/elur/template/node-binding.js +0 -95
- package/dist/lib/elur/template/node-binding.js.map +0 -1
package/dist/lib/async.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./elur/next-2/reactivity.cjs`),t=require(`./elur/template/types.cjs`),n=require(`./lifecycle.cjs`),r=require(`./elur/template/html.cjs`);function i(){return r.html`
|
|
2
2
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
3
3
|
<span class="elur-spinner" style="
|
|
4
4
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
package/dist/lib/async.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { effect as e, signal as t } from "./
|
|
1
|
+
import { effect as e, signal as t } from "./elur/next-2/reactivity.js";
|
|
2
2
|
import { isElurTemplate as n } from "./elur/template/types.js";
|
|
3
3
|
import { ElurComponent as r } from "./lifecycle.js";
|
|
4
4
|
import { html as i } from "./elur/template/html.js";
|
package/dist/lib/component.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
2
|
-
//# sourceMappingURL=component.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./elur/next-2/mount.cjs`);exports.mount=e.mount;
|
package/dist/lib/component.js
CHANGED
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { RouterKey as s, _debugRegisterRouter as c, _debugUnregisterRouter as l } from "./elur/router-registry.js";
|
|
4
|
-
//#region src/elur/component.ts
|
|
5
|
-
function u(e) {
|
|
6
|
-
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
7
|
-
if (!t) throw Error(`[elur] mount: container not found: ${e}`);
|
|
8
|
-
return t;
|
|
9
|
-
}
|
|
10
|
-
function d(d, f, p) {
|
|
11
|
-
if (r(d)) {
|
|
12
|
-
let r = u(f);
|
|
13
|
-
t(d), a();
|
|
14
|
-
let m = () => {}, h = !1;
|
|
15
|
-
try {
|
|
16
|
-
p?.router && (o(s, p.router), c(p.router));
|
|
17
|
-
try {
|
|
18
|
-
d.onInit?.();
|
|
19
|
-
} catch (e) {
|
|
20
|
-
if (d.onError) d.onError(e);
|
|
21
|
-
else throw e;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
m = d.render()._render(r, null);
|
|
25
|
-
} catch (e) {
|
|
26
|
-
if (d.onError) d.onError(e), m = () => {}, h = !0;
|
|
27
|
-
else throw e;
|
|
28
|
-
}
|
|
29
|
-
} finally {
|
|
30
|
-
e(d), i();
|
|
31
|
-
}
|
|
32
|
-
let g;
|
|
33
|
-
if (!h) try {
|
|
34
|
-
let e = d.onMount?.();
|
|
35
|
-
typeof e == "function" && (g = e);
|
|
36
|
-
} catch (e) {
|
|
37
|
-
if (d.onError) d.onError(e);
|
|
38
|
-
else throw e;
|
|
39
|
-
}
|
|
40
|
-
return { unmount() {
|
|
41
|
-
try {
|
|
42
|
-
d.onUnmount?.();
|
|
43
|
-
} catch {}
|
|
44
|
-
try {
|
|
45
|
-
g?.();
|
|
46
|
-
} catch {}
|
|
47
|
-
m(), p?.router && l(p.router), n(d);
|
|
48
|
-
} };
|
|
49
|
-
}
|
|
50
|
-
if (!p?.router) return d.mount(f);
|
|
51
|
-
let m = u(f);
|
|
52
|
-
a();
|
|
53
|
-
let h;
|
|
54
|
-
try {
|
|
55
|
-
o(s, p.router), c(p.router), h = d._render(m, null);
|
|
56
|
-
} finally {
|
|
57
|
-
i();
|
|
58
|
-
}
|
|
59
|
-
return { unmount() {
|
|
60
|
-
h(), l(p.router);
|
|
61
|
-
} };
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { d as mount };
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=component.js.map
|
|
1
|
+
import { mount as e } from "./elur/next-2/mount.js";
|
|
2
|
+
export { e as mount };
|
package/dist/lib/context.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return Symbol(e)}var t=[],n;function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return Symbol(e)}var t=[],n,r=[];function i(){let e=n?.();if(e!==void 0)return e;for(let e of r){let t=e();if(t!==void 0)return t}return t}function a(e){n=e}function o(e){return r.push(e),()=>{let t=r.indexOf(e);t>=0&&r.splice(t,1)}}function s(){return[...i()]}function c(e,t){let n=i(),r=n.splice(0);e.forEach(e=>n.push(e));try{return t()}finally{n.splice(0),r.forEach(e=>n.push(e))}}function l(){i().push(new Map)}function u(){i().pop()}function d(e,t){let n=i(),r=n.splice(0);e.forEach(e=>n.push(e)),n.push(new Map);try{return t()}finally{n.splice(0),r.forEach(e=>n.push(e))}}function f(e,t){let n=i(),r=n[n.length-1];if(!r)throw Error(`[elur] provide() must be called inside onInit() of a ElurComponent.`);r.set(e,t)}function p(e,t){let n=i();for(let t=n.length-1;t>=0;t--)if(n[t].has(e))return n[t].get(e);return t}exports._captureContextSnapshot=s,exports._popComponentContext=u,exports._pushComponentContext=l,exports._pushContextScopeResolver=o,exports._setContextScopeResolver=a,exports._withComponentContext=d,exports._withContextSnapshot=c,exports.createInjectionKey=e,exports.inject=p,exports.provide=f;
|
|
2
2
|
//# sourceMappingURL=context.cjs.map
|
package/dist/lib/context.js
CHANGED
|
@@ -2,51 +2,63 @@
|
|
|
2
2
|
function e(e) {
|
|
3
3
|
return Symbol(e);
|
|
4
4
|
}
|
|
5
|
-
var t = [], n;
|
|
6
|
-
function
|
|
7
|
-
|
|
5
|
+
var t = [], n, r = [];
|
|
6
|
+
function i() {
|
|
7
|
+
let e = n?.();
|
|
8
|
+
if (e !== void 0) return e;
|
|
9
|
+
for (let e of r) {
|
|
10
|
+
let t = e();
|
|
11
|
+
if (t !== void 0) return t;
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
8
14
|
}
|
|
9
|
-
function
|
|
15
|
+
function a(e) {
|
|
10
16
|
n = e;
|
|
11
17
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
18
|
+
function o(e) {
|
|
19
|
+
return r.push(e), () => {
|
|
20
|
+
let t = r.indexOf(e);
|
|
21
|
+
t >= 0 && r.splice(t, 1);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function s() {
|
|
25
|
+
return [...i()];
|
|
14
26
|
}
|
|
15
|
-
function
|
|
16
|
-
let n =
|
|
27
|
+
function c(e, t) {
|
|
28
|
+
let n = i(), r = n.splice(0);
|
|
17
29
|
e.forEach((e) => n.push(e));
|
|
18
30
|
try {
|
|
19
31
|
return t();
|
|
20
32
|
} finally {
|
|
21
|
-
n.splice(0),
|
|
33
|
+
n.splice(0), r.forEach((e) => n.push(e));
|
|
22
34
|
}
|
|
23
35
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
36
|
+
function l() {
|
|
37
|
+
i().push(/* @__PURE__ */ new Map());
|
|
26
38
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
39
|
+
function u() {
|
|
40
|
+
i().pop();
|
|
29
41
|
}
|
|
30
|
-
function
|
|
31
|
-
let n =
|
|
42
|
+
function d(e, t) {
|
|
43
|
+
let n = i(), r = n.splice(0);
|
|
32
44
|
e.forEach((e) => n.push(e)), n.push(/* @__PURE__ */ new Map());
|
|
33
45
|
try {
|
|
34
46
|
return t();
|
|
35
47
|
} finally {
|
|
36
|
-
n.splice(0),
|
|
48
|
+
n.splice(0), r.forEach((e) => n.push(e));
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
|
-
function
|
|
40
|
-
let n =
|
|
41
|
-
if (!
|
|
42
|
-
|
|
51
|
+
function f(e, t) {
|
|
52
|
+
let n = i(), r = n[n.length - 1];
|
|
53
|
+
if (!r) throw Error("[elur] provide() must be called inside onInit() of a ElurComponent.");
|
|
54
|
+
r.set(e, t);
|
|
43
55
|
}
|
|
44
|
-
function
|
|
45
|
-
let n =
|
|
56
|
+
function p(e, t) {
|
|
57
|
+
let n = i();
|
|
46
58
|
for (let t = n.length - 1; t >= 0; t--) if (n[t].has(e)) return n[t].get(e);
|
|
47
59
|
return t;
|
|
48
60
|
}
|
|
49
61
|
//#endregion
|
|
50
|
-
export {
|
|
62
|
+
export { s as _captureContextSnapshot, u as _popComponentContext, l as _pushComponentContext, o as _pushContextScopeResolver, a as _setContextScopeResolver, d as _withComponentContext, c as _withContextSnapshot, e as createInjectionKey, p as inject, f as provide };
|
|
51
63
|
|
|
52
64
|
//# sourceMappingURL=context.js.map
|
package/dist/lib/devtools.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./elur/next-2/reactivity.cjs`),t=require(`./lifecycle.cjs`),n=require(`./router.cjs`);var r={enabled:!1,activeTab:`signals`,renderedTab:null,refreshId:null,root:null,panel:null,content:null,dispose:null,renderKeys:{signals:``,components:``,router:``},scrollMemo:{signals:{top:0,left:0},components:{top:0,left:0},router:{top:0,left:0}}},i=new Set,a=new WeakMap,o=1,s=50,c=new WeakMap,l=new Map,u=[],d=1;function f(e){return typeof WeakRef<`u`?new WeakRef(e):{deref:()=>e}}function p(e){return typeof WeakRef<`u`?new WeakRef(e):{deref:()=>e}}function m(e){e.history.length>s&&e.history.splice(0,e.history.length-s)}function h(e,t){let n=a.get(e);if(n)return m(n),n;let r=Date.now(),s={id:o++,createdAt:r,lastUpdated:r,history:[{at:r,value:t}]};return a.set(e,s),i.add(f(e)),s}function g(){let e=[];for(let t of Array.from(i)){let n=t.deref();if(!n){i.delete(t);continue}let r=a.get(n);if(!r)continue;let o=n._subs?.size??0;e.push({id:r.id,value:n.peek(),subscriberCount:o,createdAt:r.createdAt,lastUpdated:r.lastUpdated,history:r.history.slice()})}return e.sort((e,t)=>t.lastUpdated-e.lastUpdated),e}function _(e){let t=e._debugName;if(t&&t.trim())return t;let n=e.constructor;return n?.name&&n.name.trim()?n.name:`AnonymousComponent`}function v(e){let t=e._slots;return t instanceof Map?Array.from(t.keys()).map(e=>String(e)):[]}function y(e){let t={};for(let n of Object.keys(e)){if(n===`__isElurComponent`||n===`children`||n===`_debugName`||n.startsWith(`_`))continue;let r=e[n];typeof r!=`function`&&(t[n]=r)}return t}function b(e){if(!e)return[];if(e===`*`)return[`*`];let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t)r+=`/`+e,n.push(r);return n.length>0?n:[`/`]}function x(){let e=[];for(let[t,n]of l){let r=n.ref.deref();if(!r){l.delete(t);continue}n.debugName=_(r),n.hasDefaultSlot=r.children!=null,n.slotNames=v(r),n.props=y(r),e.push({id:n.id,parentId:n.parentId,debugName:n.debugName,mountedAt:n.mountedAt,hasDefaultSlot:n.hasDefaultSlot,slotNames:[...n.slotNames],props:{...n.props}})}return e.sort((e,t)=>e.id-t.id),e}function S(e){let t=[e];for(;t.length>0;){let e=t.pop();for(let[n,r]of l)r.parentId===e&&t.push(n);l.delete(e)}}function C(){i.clear(),a=new WeakMap,o=1,c=new WeakMap,l.clear(),u.length=0,d=1}function w(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||e==null)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function T(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\"/g,`"`).replace(/'/g,`'`)}function E(e,t=90){let n=w(e);return n.length<=t?n:n.slice(0,t-1)+`…`}function D(e){if(!e)return`-`;let t=Date.now()-e;return t<1e3?`${t}ms ago`:t<6e4?`${Math.floor(t/1e3)}s ago`:`${Math.floor(t/6e4)}m ago`}function O(e){let t=g(),n=`${t.length}:${t.map(e=>`${e.id}-${e.lastUpdated}-${e.subscriberCount}`).join(`|`)}`;if(r.renderedTab===`signals`&&r.renderKeys.signals===n)return;r.renderKeys.signals=n,r.renderedTab=`signals`;let i=t.map(e=>{let t=w(e.value),n=E(e.value,120);return`<tr data-elur-devtools-signal-id="${e.id}">
|
|
2
2
|
<td style="padding:6px 8px;white-space:nowrap;">${e.id}</td>
|
|
3
3
|
<td style="padding:6px 8px;max-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace, SFMono-Regular, Menlo, monospace;" title="${T(t)}">${T(n)}</td>
|
|
4
4
|
<td>${e.subscriberCount}</td>
|
package/dist/lib/devtools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _setSignalDebugHooks as e } from "./
|
|
1
|
+
import { _setSignalDebugHooks as e } from "./elur/next-2/reactivity.js";
|
|
2
2
|
import { _setComponentDebugHooks as t } from "./lifecycle.js";
|
|
3
3
|
import { _debugGetRouterInternal as n } from "./router.js";
|
|
4
4
|
//#region src/elur/devtools.ts
|
package/dist/lib/elur/async.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./elur/next-2/reactivity.cjs`),t=require(`./elur/template/types.cjs`),n=require(`./lifecycle.cjs`),r=require(`./elur/template/html.cjs`);function i(){return r.html`
|
|
2
2
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
3
3
|
<span class="elur-spinner" style="
|
|
4
4
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.cjs","names":[],"sources":["../../src/elur/async.ts"],"sourcesContent":["import { signal, effect, Signal } from \"./reactivity.js\";\nimport { ElurComponent } from \"./lifecycle.js\";\nimport { type ElurTemplate, html, isElurTemplate } from \"./template/index.js\";\n\n// --- Types ---\n\ntype AsyncState<T> =\n | { status: \"pending\" }\n | { status: \"resolved\"; data: T }\n | { status: \"error\"; error: unknown };\n\nexport interface SuspenseOptions {\n fallback?: ElurTemplate;\n errorFallback?: (err: unknown) => ElurTemplate;\n resetOnRefresh?: boolean;\n invalidate?: Signal<unknown>;\n cacheKey?: string;\n staleTime?: number;\n}\n\n// --- Default fallbacks ---\n\nfunction defaultLoadingFallback(): ElurTemplate {\n return html`\n <span style=\"color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px\">\n <span class=\"elur-spinner\" style=\"\n display:inline-block;width:14px;height:14px;border-radius:50%;\n border:2px solid #38bdf840;border-top-color:#38bdf8;\n animation:elur-spin .7s linear infinite\n \"></span>\n Loading…\n </span>\n <style>@keyframes elur-spin{to{transform:rotate(360deg)}}</style>\n `;\n}\n\nfunction defaultErrorTemplate(err: unknown): ElurTemplate {\n return html`\n <span style=\"color:#f87171;font-size:13px\">\n ⚠ ${err instanceof Error ? err.message : String(err)}\n </span>\n `;\n}\n\n// --- Suspense Cache ---\n\ninterface SuspenseCacheEntry<T = unknown> {\n data?: T;\n fetchedAt: number;\n subscribers: number;\n}\n\nconst _suspenseCache = new Map<string, SuspenseCacheEntry>();\n\nconst DEFAULT_CACHE_TIME = 5 * 60 * 1000;\nlet _suspenseGcTimer: ReturnType<typeof setInterval> | null = null;\nlet _suspenseCacheTime = DEFAULT_CACHE_TIME;\n\nfunction _startSuspenseGC(): void {\n if (_suspenseGcTimer !== null) return;\n _suspenseGcTimer = setInterval(() => {\n const now = Date.now();\n for (const [key, entry] of _suspenseCache) {\n if (entry.subscribers <= 0 && now - entry.fetchedAt > _suspenseCacheTime) {\n _suspenseCache.delete(key);\n }\n }\n if (_suspenseCache.size === 0 && _suspenseGcTimer !== null) {\n clearInterval(_suspenseGcTimer);\n _suspenseGcTimer = null;\n }\n }, 60_000);\n}\n\nfunction _getSuspenseCacheEntry<T>(key: string): SuspenseCacheEntry<T> | undefined {\n const entry = _suspenseCache.get(key);\n if (entry && entry.fetchedAt > 0) return entry as SuspenseCacheEntry<T>;\n return undefined;\n}\n\nfunction _setSuspenseCacheEntry<T>(key: string, data: T): void {\n const existing = _suspenseCache.get(key);\n _suspenseCache.set(key, {\n data,\n fetchedAt: Date.now(),\n subscribers: existing?.subscribers ?? 0,\n });\n _startSuspenseGC();\n}\n\nfunction _subscribeSuspenseCache(key: string): void {\n const entry = _suspenseCache.get(key);\n if (entry) {\n entry.subscribers++;\n } else {\n _suspenseCache.set(key, { fetchedAt: 0, subscribers: 1 } as SuspenseCacheEntry<any>);\n }\n}\n\nfunction _unsubscribeSuspenseCache(key: string): void {\n const entry = _suspenseCache.get(key);\n if (entry) entry.subscribers = Math.max(0, entry.subscribers - 1);\n}\n\nfunction _isSuspenseCacheFresh(key: string, staleTime: number): boolean {\n const entry = _suspenseCache.get(key);\n if (!entry) return false;\n return Date.now() - entry.fetchedAt < staleTime;\n}\n\n// --- suspend() ---\n\n/**\n * Runs an async function and renders based on its state (pending/resolved/error).\n *\n * ```ts\n * const refresh = signal(0);\n * suspend(() => fetchData(), render, { invalidate: refresh });\n * refresh.update(n => n + 1);\n * ```\n */\nexport function suspend<T>(\n asyncFn: () => Promise<T>,\n renderFn: (data: T) => ElurTemplate | ElurComponent,\n options: SuspenseOptions = {}\n): ElurComponent {\n const {\n fallback,\n errorFallback,\n resetOnRefresh = false,\n invalidate,\n cacheKey,\n staleTime = 0,\n } = options;\n\n const resolvedFallback = fallback ?? defaultLoadingFallback();\n const resolvedErrorFallback = errorFallback ?? defaultErrorTemplate;\n\n class SuspendComponent extends ElurComponent {\n private _state: Signal<AsyncState<T>>;\n private _disposeWatcher: (() => void) | undefined;\n\n constructor() {\n super();\n const cached = cacheKey ? _getSuspenseCacheEntry<T>(cacheKey) : undefined;\n\n this._state = signal<AsyncState<T>>(\n cached && cached.data !== undefined\n ? { status: \"resolved\", data: cached.data }\n : { status: \"pending\" }\n );\n }\n\n onMount(): (() => void) | void {\n if (cacheKey) _subscribeSuspenseCache(cacheKey);\n\n const cached = cacheKey ? _getSuspenseCacheEntry<T>(cacheKey) : undefined;\n\n if (cached && _isSuspenseCacheFresh(cacheKey!, staleTime)) {\n // fresh — skip\n } else if (cached) {\n this._fetch();\n } else {\n this._run();\n }\n\n if (invalidate) {\n let first = true;\n this._disposeWatcher = effect(() => {\n invalidate.value;\n if (first) { first = false; return; }\n if (cacheKey) _suspenseCache.delete(cacheKey);\n this._run();\n });\n }\n\n return () => {\n this._disposeWatcher?.();\n if (cacheKey) _unsubscribeSuspenseCache(cacheKey);\n };\n }\n\n private _run(): void {\n if (resetOnRefresh || this._state.peek().status === \"pending\") {\n this._state.value = { status: \"pending\" };\n }\n this._fetch();\n }\n\n private _fetch(): void {\n asyncFn().then(\n (data) => {\n if (cacheKey) _setSuspenseCacheEntry(cacheKey, data);\n this._state.value = { status: \"resolved\", data };\n },\n (err) => { this._state.value = { status: \"error\", error: err }; }\n );\n }\n\n render(): ElurTemplate {\n return html`<div class=\"elur-suspense\" style=\"display:contents\">${() => {\n const s = this._state.value;\n if (s.status === \"pending\") return resolvedFallback;\n if (s.status === \"error\") return resolvedErrorFallback(s.error);\n return renderFn(s.data);\n }}</div>`;\n }\n }\n\n return new SuspendComponent();\n}\n\n// --- lazy() ---\n\nexport interface LazyOptions {\n /** Component selector when the module uses a named export. Defaults to `mod.default`. */\n selector?: (mod: Record<string, unknown>) => new () => ElurComponent;\n /** Template shown while the component is loading. */\n fallback?: ElurTemplate;\n}\n\n/**\n * Wraps a dynamic import for lazy-loading route components.\n * The module is loaded once and cached. Supports both default and named exports.\n */\nexport function lazy(\n importFn: () => Promise<Record<string, unknown>>,\n options?: ElurTemplate | LazyOptions\n): () => ElurComponent {\n const opts: LazyOptions =\n options === undefined || isElurTemplate(options as object)\n ? { fallback: options as ElurTemplate | undefined }\n : (options as LazyOptions);\n\n const selector = opts.selector ?? ((mod) => mod.default as new () => ElurComponent);\n let Cached: (new () => ElurComponent) | null = null;\n\n return (): ElurComponent => {\n if (Cached) return new Cached();\n\n return suspend(\n async () => {\n const mod = await importFn();\n Cached = selector(mod);\n return Cached;\n },\n (Comp) => new Comp(),\n { fallback: opts.fallback }\n );\n };\n}"],"mappings":"8MAsBA,SAAS,GAAuC,CAC5C,MAAO,GAAA,IAAI;;;;;;;;;;MAaf,SAAS,EAAqB,EAA4B,CACtD,MAAO,GAAA,IAAI;;gBAEC,aAAe,MAAQ,EAAI,QAAU,OAAO,EAAI,CAAC;;MAajE,IAAM,EAAiB,IAAI,IAErB,EAAqB,IAAS,IAChC,EAA0D,KAC1D,EAAqB,EAEzB,SAAS,GAAyB,CAC1B,IAAqB,OACzB,EAAmB,gBAAkB,CACjC,IAAM,EAAM,KAAK,KAAK,CACtB,IAAK,GAAM,CAAC,EAAK,KAAU,EACnB,EAAM,aAAe,GAAK,EAAM,EAAM,UAAY,GAClD,EAAe,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\"./reactivity.js\";\nimport { ElurComponent } from \"./lifecycle.js\";\nimport { type ElurTemplate, html, isElurTemplate } from \"./template/index.js\";\n\n// --- Types ---\n\ntype AsyncState<T> =\n | { status: \"pending\" }\n | { status: \"resolved\"; data: T }\n | { status: \"error\"; error: unknown };\n\nexport interface SuspenseOptions {\n fallback?: ElurTemplate;\n errorFallback?: (err: unknown) => ElurTemplate;\n resetOnRefresh?: boolean;\n invalidate?: Signal<unknown>;\n cacheKey?: string;\n staleTime?: number;\n}\n\n// --- Default fallbacks ---\n\nfunction defaultLoadingFallback(): ElurTemplate {\n return html`\n <span style=\"color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px\">\n <span class=\"elur-spinner\" style=\"\n display:inline-block;width:14px;height:14px;border-radius:50%;\n border:2px solid #38bdf840;border-top-color:#38bdf8;\n animation:elur-spin .7s linear infinite\n \"></span>\n Loading…\n </span>\n <style>@keyframes elur-spin{to{transform:rotate(360deg)}}</style>\n `;\n}\n\nfunction defaultErrorTemplate(err: unknown): ElurTemplate {\n return html`\n <span style=\"color:#f87171;font-size:13px\">\n ⚠ ${err instanceof Error ? err.message : String(err)}\n </span>\n `;\n}\n\n// --- Suspense Cache ---\n\ninterface SuspenseCacheEntry<T = unknown> {\n data?: T;\n fetchedAt: number;\n subscribers: number;\n}\n\nconst _suspenseCache = new Map<string, SuspenseCacheEntry>();\n\nconst DEFAULT_CACHE_TIME = 5 * 60 * 1000;\nlet _suspenseGcTimer: ReturnType<typeof setInterval> | null = null;\nlet _suspenseCacheTime = DEFAULT_CACHE_TIME;\n\nfunction _startSuspenseGC(): void {\n if (_suspenseGcTimer !== null) return;\n _suspenseGcTimer = setInterval(() => {\n const now = Date.now();\n for (const [key, entry] of _suspenseCache) {\n if (entry.subscribers <= 0 && now - entry.fetchedAt > _suspenseCacheTime) {\n _suspenseCache.delete(key);\n }\n }\n if (_suspenseCache.size === 0 && _suspenseGcTimer !== null) {\n clearInterval(_suspenseGcTimer);\n _suspenseGcTimer = null;\n }\n }, 60_000);\n}\n\nfunction _getSuspenseCacheEntry<T>(key: string): SuspenseCacheEntry<T> | undefined {\n const entry = _suspenseCache.get(key);\n if (entry && entry.fetchedAt > 0) return entry as SuspenseCacheEntry<T>;\n return undefined;\n}\n\nfunction _setSuspenseCacheEntry<T>(key: string, data: T): void {\n const existing = _suspenseCache.get(key);\n _suspenseCache.set(key, {\n data,\n fetchedAt: Date.now(),\n subscribers: existing?.subscribers ?? 0,\n });\n _startSuspenseGC();\n}\n\nfunction _subscribeSuspenseCache(key: string): void {\n const entry = _suspenseCache.get(key);\n if (entry) {\n entry.subscribers++;\n } else {\n _suspenseCache.set(key, { fetchedAt: 0, subscribers: 1 } as SuspenseCacheEntry<any>);\n }\n}\n\nfunction _unsubscribeSuspenseCache(key: string): void {\n const entry = _suspenseCache.get(key);\n if (entry) entry.subscribers = Math.max(0, entry.subscribers - 1);\n}\n\nfunction _isSuspenseCacheFresh(key: string, staleTime: number): boolean {\n const entry = _suspenseCache.get(key);\n if (!entry) return false;\n return Date.now() - entry.fetchedAt < staleTime;\n}\n\n// --- suspend() ---\n\n/**\n * Runs an async function and renders based on its state (pending/resolved/error).\n *\n * ```ts\n * const refresh = signal(0);\n * suspend(() => fetchData(), render, { invalidate: refresh });\n * refresh.update(n => n + 1);\n * ```\n */\nexport function suspend<T>(\n asyncFn: () => Promise<T>,\n renderFn: (data: T) => ElurTemplate | ElurComponent,\n options: SuspenseOptions = {}\n): ElurComponent {\n const {\n fallback,\n errorFallback,\n resetOnRefresh = false,\n invalidate,\n cacheKey,\n staleTime = 0,\n } = options;\n\n const resolvedFallback = fallback ?? defaultLoadingFallback();\n const resolvedErrorFallback = errorFallback ?? defaultErrorTemplate;\n\n class SuspendComponent extends ElurComponent {\n private _state: Signal<AsyncState<T>>;\n private _disposeWatcher: (() => void) | undefined;\n\n constructor() {\n super();\n const cached = cacheKey ? _getSuspenseCacheEntry<T>(cacheKey) : undefined;\n\n this._state = signal<AsyncState<T>>(\n cached && cached.data !== undefined\n ? { status: \"resolved\", data: cached.data }\n : { status: \"pending\" }\n );\n }\n\n onMount(): (() => void) | void {\n if (cacheKey) _subscribeSuspenseCache(cacheKey);\n\n const cached = cacheKey ? _getSuspenseCacheEntry<T>(cacheKey) : undefined;\n\n if (cached && _isSuspenseCacheFresh(cacheKey!, staleTime)) {\n // fresh — skip\n } else if (cached) {\n this._fetch();\n } else {\n this._run();\n }\n\n if (invalidate) {\n let first = true;\n this._disposeWatcher = effect(() => {\n invalidate.value;\n if (first) { first = false; return; }\n if (cacheKey) _suspenseCache.delete(cacheKey);\n this._run();\n });\n }\n\n return () => {\n this._disposeWatcher?.();\n if (cacheKey) _unsubscribeSuspenseCache(cacheKey);\n };\n }\n\n private _run(): void {\n if (resetOnRefresh || this._state.peek().status === \"pending\") {\n this._state.value = { status: \"pending\" };\n }\n this._fetch();\n }\n\n private _fetch(): void {\n asyncFn().then(\n (data) => {\n if (cacheKey) _setSuspenseCacheEntry(cacheKey, data);\n this._state.value = { status: \"resolved\", data };\n },\n (err) => { this._state.value = { status: \"error\", error: err }; }\n );\n }\n\n render(): ElurTemplate {\n return html`<div class=\"elur-suspense\" style=\"display:contents\">${() => {\n const s = this._state.value;\n if (s.status === \"pending\") return resolvedFallback;\n if (s.status === \"error\") return resolvedErrorFallback(s.error);\n return renderFn(s.data);\n }}</div>`;\n }\n }\n\n return new SuspendComponent();\n}\n\n// --- lazy() ---\n\nexport interface LazyOptions {\n /** Component selector when the module uses a named export. Defaults to `mod.default`. */\n selector?: (mod: Record<string, unknown>) => new () => ElurComponent;\n /** Template shown while the component is loading. */\n fallback?: ElurTemplate;\n}\n\n/**\n * Wraps a dynamic import for lazy-loading route components.\n * The module is loaded once and cached. Supports both default and named exports.\n */\nexport function lazy(\n importFn: () => Promise<Record<string, unknown>>,\n options?: ElurTemplate | LazyOptions\n): () => ElurComponent {\n const opts: LazyOptions =\n options === undefined || isElurTemplate(options as object)\n ? { fallback: options as ElurTemplate | undefined }\n : (options as LazyOptions);\n\n const selector = opts.selector ?? ((mod) => mod.default as new () => ElurComponent);\n let Cached: (new () => ElurComponent) | null = null;\n\n return (): ElurComponent => {\n if (Cached) return new Cached();\n\n return suspend(\n async () => {\n const mod = await importFn();\n Cached = selector(mod);\n return Cached;\n },\n (Comp) => new Comp(),\n { fallback: opts.fallback }\n );\n };\n}"],"mappings":"6NAsBA,SAAS,GAAuC,CAC5C,MAAO,GAAA,IAAI;;;;;;;;;;MAaf,SAAS,EAAqB,EAA4B,CACtD,MAAO,GAAA,IAAI;;gBAEC,aAAe,MAAQ,EAAI,QAAU,OAAO,EAAI,CAAC;;MAajE,IAAM,EAAiB,IAAI,IAErB,EAAqB,IAAS,IAChC,EAA0D,KAC1D,EAAqB,EAEzB,SAAS,GAAyB,CAC1B,IAAqB,OACzB,EAAmB,gBAAkB,CACjC,IAAM,EAAM,KAAK,KAAK,CACtB,IAAK,GAAM,CAAC,EAAK,KAAU,EACnB,EAAM,aAAe,GAAK,EAAM,EAAM,UAAY,GAClD,EAAe,OAAO,EAAI,CAG9B,EAAe,OAAS,GAAK,IAAqB,OAClD,cAAc,EAAiB,CAC/B,EAAmB,OAExB,IAAO,EAGd,SAAS,EAA0B,EAAgD,CAC/E,IAAM,EAAQ,EAAe,IAAI,EAAI,CACrC,GAAI,GAAS,EAAM,UAAY,EAAG,OAAO,EAI7C,SAAS,EAA0B,EAAa,EAAe,CAC3D,IAAM,EAAW,EAAe,IAAI,EAAI,CACxC,EAAe,IAAI,EAAK,CACpB,OACA,UAAW,KAAK,KAAK,CACrB,YAAa,GAAU,aAAe,EACzC,CAAC,CACF,GAAkB,CAGtB,SAAS,EAAwB,EAAmB,CAChD,IAAM,EAAQ,EAAe,IAAI,EAAI,CACjC,EACA,EAAM,cAEN,EAAe,IAAI,EAAK,CAAE,UAAW,EAAG,YAAa,EAAG,CAA4B,CAI5F,SAAS,EAA0B,EAAmB,CAClD,IAAM,EAAQ,EAAe,IAAI,EAAI,CACjC,IAAO,EAAM,Y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AAO,MAAQ,CAAE,OAAQ,QAAS,MAAO,EAAK,EACjE,CAGL,QAAuB,CACnB,MAAO,GAAA,IAAI,2DAA6D,CACpE,IAAM,EAAI,KAAK,OAAO,MAGtB,OAFI,EAAE,SAAW,UAAkB,EAC/B,EAAE,SAAW,QAAgB,EAAsB,EAAE,MAAM,CACxD,EAAS,EAAE,KAAK,EACzB,SAIV,OAAO,IAAI,EAgBf,SAAgB,EACZ,EACA,EACmB,CACnB,IAAM,EACF,IAAY,IAAA,IAAa,EAAA,eAAe,EAAkB,CACpD,CAAE,SAAU,EAAqC,CAChD,EAEL,EAAW,EAAK,WAAc,GAAQ,EAAI,SAC5C,EAA2C,KAE/C,UACQ,EAAe,IAAI,EAEhB,EACH,UAEI,EAAS,EADG,MAAM,GAAU,CACN,CACf,GAEV,GAAS,IAAI,EACd,CAAE,SAAU,EAAK,SAAU,CAC9B"}
|
package/dist/lib/elur/async.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { effect as e, signal as t } from "./
|
|
1
|
+
import { effect as e, signal as t } from "./elur/next-2/reactivity.js";
|
|
2
2
|
import { isElurTemplate as n } from "./elur/template/types.js";
|
|
3
3
|
import { ElurComponent as r } from "./lifecycle.js";
|
|
4
4
|
import { html as i } from "./elur/template/html.js";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
2
|
-
//# sourceMappingURL=component.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./elur/next-2/mount.cjs`);exports.mount=e.mount;
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type ElurComponent } from "./lifecycle.js";
|
|
3
|
-
import type { Router } from "./router.js";
|
|
4
|
-
export interface MountOptions {
|
|
5
|
-
router?: Router;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Mounts a ElurTemplate or ElurComponent into the DOM.
|
|
9
|
-
*
|
|
10
|
-
* mount(Counter(), "#app"); // ElurTemplate (function component)
|
|
11
|
-
* mount(new Timer(), "#app"); // ElurComponent (class with lifecycle)
|
|
12
|
-
*
|
|
13
|
-
* @param component ElurTemplate (result of html``) or a ElurComponent instance.
|
|
14
|
-
* @param container CSS selector or HTMLElement to mount into.
|
|
15
|
-
* @returns { unmount() } — disposes effects and removes DOM.
|
|
16
|
-
*/
|
|
17
|
-
export declare function mount(component: ElurTemplate | ElurComponent, container: Element | string, options?: MountOptions): ElurMountHandle;
|
|
1
|
+
export * from "./next-2/mount.js";
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type ElurComponent } from "./lifecycle.js";
|
|
3
|
-
import type { Router } from "./router.js";
|
|
4
|
-
export interface MountOptions {
|
|
5
|
-
router?: Router;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Mounts a ElurTemplate or ElurComponent into the DOM.
|
|
9
|
-
*
|
|
10
|
-
* mount(Counter(), "#app"); // ElurTemplate (function component)
|
|
11
|
-
* mount(new Timer(), "#app"); // ElurComponent (class with lifecycle)
|
|
12
|
-
*
|
|
13
|
-
* @param component ElurTemplate (result of html``) or a ElurComponent instance.
|
|
14
|
-
* @param container CSS selector or HTMLElement to mount into.
|
|
15
|
-
* @returns { unmount() } — disposes effects and removes DOM.
|
|
16
|
-
*/
|
|
17
|
-
export declare function mount(component: ElurTemplate | ElurComponent, container: Element | string, options?: MountOptions): ElurMountHandle;
|
|
1
|
+
export * from "./next-2/mount.js";
|
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { RouterKey as s, _debugRegisterRouter as c, _debugUnregisterRouter as l } from "./elur/router-registry.js";
|
|
4
|
-
//#region src/elur/component.ts
|
|
5
|
-
function u(e) {
|
|
6
|
-
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
7
|
-
if (!t) throw Error(`[elur] mount: container not found: ${e}`);
|
|
8
|
-
return t;
|
|
9
|
-
}
|
|
10
|
-
function d(d, f, p) {
|
|
11
|
-
if (r(d)) {
|
|
12
|
-
let r = u(f);
|
|
13
|
-
t(d), a();
|
|
14
|
-
let m = () => {}, h = !1;
|
|
15
|
-
try {
|
|
16
|
-
p?.router && (o(s, p.router), c(p.router));
|
|
17
|
-
try {
|
|
18
|
-
d.onInit?.();
|
|
19
|
-
} catch (e) {
|
|
20
|
-
if (d.onError) d.onError(e);
|
|
21
|
-
else throw e;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
m = d.render()._render(r, null);
|
|
25
|
-
} catch (e) {
|
|
26
|
-
if (d.onError) d.onError(e), m = () => {}, h = !0;
|
|
27
|
-
else throw e;
|
|
28
|
-
}
|
|
29
|
-
} finally {
|
|
30
|
-
e(d), i();
|
|
31
|
-
}
|
|
32
|
-
let g;
|
|
33
|
-
if (!h) try {
|
|
34
|
-
let e = d.onMount?.();
|
|
35
|
-
typeof e == "function" && (g = e);
|
|
36
|
-
} catch (e) {
|
|
37
|
-
if (d.onError) d.onError(e);
|
|
38
|
-
else throw e;
|
|
39
|
-
}
|
|
40
|
-
return { unmount() {
|
|
41
|
-
try {
|
|
42
|
-
d.onUnmount?.();
|
|
43
|
-
} catch {}
|
|
44
|
-
try {
|
|
45
|
-
g?.();
|
|
46
|
-
} catch {}
|
|
47
|
-
m(), p?.router && l(p.router), n(d);
|
|
48
|
-
} };
|
|
49
|
-
}
|
|
50
|
-
if (!p?.router) return d.mount(f);
|
|
51
|
-
let m = u(f);
|
|
52
|
-
a();
|
|
53
|
-
let h;
|
|
54
|
-
try {
|
|
55
|
-
o(s, p.router), c(p.router), h = d._render(m, null);
|
|
56
|
-
} finally {
|
|
57
|
-
i();
|
|
58
|
-
}
|
|
59
|
-
return { unmount() {
|
|
60
|
-
h(), l(p.router);
|
|
61
|
-
} };
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { d as mount };
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=component.js.map
|
|
1
|
+
import { mount as e } from "./elur/next-2/mount.js";
|
|
2
|
+
export { e as mount };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return Symbol(e)}var t=[],n;function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return Symbol(e)}var t=[],n,r=[];function i(){let e=n?.();if(e!==void 0)return e;for(let e of r){let t=e();if(t!==void 0)return t}return t}function a(e){n=e}function o(e){return r.push(e),()=>{let t=r.indexOf(e);t>=0&&r.splice(t,1)}}function s(){return[...i()]}function c(e,t){let n=i(),r=n.splice(0);e.forEach(e=>n.push(e));try{return t()}finally{n.splice(0),r.forEach(e=>n.push(e))}}function l(){i().push(new Map)}function u(){i().pop()}function d(e,t){let n=i(),r=n.splice(0);e.forEach(e=>n.push(e)),n.push(new Map);try{return t()}finally{n.splice(0),r.forEach(e=>n.push(e))}}function f(e,t){let n=i(),r=n[n.length-1];if(!r)throw Error(`[elur] provide() must be called inside onInit() of a ElurComponent.`);r.set(e,t)}function p(e,t){let n=i();for(let t=n.length-1;t>=0;t--)if(n[t].has(e))return n[t].get(e);return t}exports._captureContextSnapshot=s,exports._popComponentContext=u,exports._pushComponentContext=l,exports._pushContextScopeResolver=o,exports._setContextScopeResolver=a,exports._withComponentContext=d,exports._withContextSnapshot=c,exports.createInjectionKey=e,exports.inject=p,exports.provide=f;
|
|
2
2
|
//# sourceMappingURL=context.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.cjs","names":[],"sources":["../../src/elur/context.ts"],"sourcesContent":["// --- Public types ---\n\n/** Typed key for provide/inject. Generic `T` enforces type safety between provider and consumer. */\nexport type InjectionKey<T> = symbol & { readonly __elurType?: T };\n\n/** Creates a unique typed InjectionKey. */\nexport function createInjectionKey<T>(description?: string): InjectionKey<T> {\n return Symbol(description) as InjectionKey<T>;\n}\n\n// --- Internal stack ---\n\n/** Stack of provide maps, one per active component in the render tree. */\nconst _stack: Map<unknown, unknown>[] = [];\nlet
|
|
1
|
+
{"version":3,"file":"context.cjs","names":[],"sources":["../../src/elur/context.ts"],"sourcesContent":["// --- Public types ---\n\n/** Typed key for provide/inject. Generic `T` enforces type safety between provider and consumer. */\nexport type InjectionKey<T> = symbol & { readonly __elurType?: T };\n\n/** Creates a unique typed InjectionKey. */\nexport function createInjectionKey<T>(description?: string): InjectionKey<T> {\n return Symbol(description) as InjectionKey<T>;\n}\n\n// --- Internal stack ---\n\n/** Stack of provide maps, one per active component in the render tree. */\nconst _stack: Map<unknown, unknown>[] = [];\n// Resolver primario (set) + secundarios (push): el primario se consulta\n// primero — p.ej. SSR por AsyncLocalStorage — y los secundarios sólo si\n// aquél devuelve undefined (p.ej. contexto por instancia en next/). Así el\n// resultado no depende del orden de importación de los módulos.\nlet _primaryResolver: (() => Map<unknown, unknown>[] | undefined) | undefined;\nconst _scopeResolvers: (() => Map<unknown, unknown>[] | undefined)[] = [];\n\nfunction currentStack(): Map<unknown, unknown>[] {\n const primary = _primaryResolver?.();\n if (primary !== undefined) return primary;\n for (const r of _scopeResolvers) {\n const frames = r();\n if (frames !== undefined) return frames;\n }\n return _stack;\n}\n\nexport function _setContextScopeResolver(\n resolver: (() => Map<unknown, unknown>[] | undefined) | undefined,\n): void {\n _primaryResolver = resolver;\n}\n\n/**\n * @internal — añade un resolver secundario consultado sólo si el primario\n * devuelve undefined. Devuelve una función para quitarlo.\n */\nexport function _pushContextScopeResolver(\n resolver: () => Map<unknown, unknown>[] | undefined,\n): () => void {\n _scopeResolvers.push(resolver);\n return () => {\n const i = _scopeResolvers.indexOf(resolver);\n if (i >= 0) _scopeResolvers.splice(i, 1);\n };\n}\n\n/** @internal — returns a copy of the stack for capturing in effect closures. */\nexport function _captureContextSnapshot(): Map<unknown, unknown>[] {\n return [...currentStack()];\n}\n\nexport function _withContextSnapshot<T>(\n snapshot: Map<unknown, unknown>[],\n fn: () => T,\n): T {\n const stack = currentStack();\n const saved = stack.splice(0);\n snapshot.forEach((entry) => stack.push(entry));\n try {\n return fn();\n } finally {\n stack.splice(0);\n saved.forEach((entry) => stack.push(entry));\n }\n}\n\n/** @internal — pushes an empty context for a new component (static render). */\nexport function _pushComponentContext(): void {\n currentStack().push(new Map());\n}\n\n/** @internal — pops the current component context (static render). */\nexport function _popComponentContext(): void {\n currentStack().pop();\n}\n\n/**\n * @internal — executes `fn` with `parentSnapshot` as ancestors and a fresh\n * empty context on top, then restores the previous stack.\n */\nexport function _withComponentContext<T>(\n parentSnapshot: Map<unknown, unknown>[],\n fn: () => T\n): T {\n const stack = currentStack();\n const saved = stack.splice(0);\n parentSnapshot.forEach(m => stack.push(m));\n stack.push(new Map());\n try {\n return fn();\n } finally {\n stack.splice(0);\n saved.forEach(m => stack.push(m));\n }\n}\n\n// --- Public API ---\n\n/**\n * Registers a value so descendant components can retrieve it via `inject()`.\n * Must be called inside `onInit()` of a ElurComponent.\n */\nexport function provide<T>(\n key: InjectionKey<T> | string | symbol,\n value: T\n): void {\n const stack = currentStack();\n const top = stack[stack.length - 1];\n if (!top) {\n throw new Error(\n \"[elur] provide() must be called inside onInit() of a ElurComponent.\"\n );\n }\n top.set(key, value);\n}\n\n/**\n * Retrieves a value provided by an ancestor component.\n * Searches child-to-parent; returns `undefined` if the key was not provided.\n */\nexport function inject<T>(\n key: InjectionKey<T> | string | symbol,\n defaultValue?: T\n): T | undefined {\n const stack = currentStack();\n for (let i = stack.length - 1; i >= 0; i--) {\n if (stack[i].has(key)) {\n return stack[i].get(key) as T;\n }\n }\n return defaultValue;\n}\n"],"mappings":"mEAMA,SAAgB,EAAsB,EAAuC,CACzE,OAAO,OAAO,EAAY,CAM9B,IAAM,EAAkC,EAAE,CAKtC,EACE,EAAiE,EAAE,CAEzE,SAAS,GAAwC,CAC7C,IAAM,EAAU,KAAoB,CACpC,GAAI,IAAY,IAAA,GAAW,OAAO,EAClC,IAAK,IAAM,KAAK,EAAiB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jB,OAAO,EAAM,GAAG,IAAI,EAAI,CAGhC,OAAO"}
|
|
@@ -5,6 +5,11 @@ export type InjectionKey<T> = symbol & {
|
|
|
5
5
|
/** Creates a unique typed InjectionKey. */
|
|
6
6
|
export declare function createInjectionKey<T>(description?: string): InjectionKey<T>;
|
|
7
7
|
export declare function _setContextScopeResolver(resolver: (() => Map<unknown, unknown>[] | undefined) | undefined): void;
|
|
8
|
+
/**
|
|
9
|
+
* @internal — añade un resolver secundario consultado sólo si el primario
|
|
10
|
+
* devuelve undefined. Devuelve una función para quitarlo.
|
|
11
|
+
*/
|
|
12
|
+
export declare function _pushContextScopeResolver(resolver: () => Map<unknown, unknown>[] | undefined): () => void;
|
|
8
13
|
/** @internal — returns a copy of the stack for capturing in effect closures. */
|
|
9
14
|
export declare function _captureContextSnapshot(): Map<unknown, unknown>[];
|
|
10
15
|
export declare function _withContextSnapshot<T>(snapshot: Map<unknown, unknown>[], fn: () => T): T;
|
|
@@ -5,6 +5,11 @@ export type InjectionKey<T> = symbol & {
|
|
|
5
5
|
/** Creates a unique typed InjectionKey. */
|
|
6
6
|
export declare function createInjectionKey<T>(description?: string): InjectionKey<T>;
|
|
7
7
|
export declare function _setContextScopeResolver(resolver: (() => Map<unknown, unknown>[] | undefined) | undefined): void;
|
|
8
|
+
/**
|
|
9
|
+
* @internal — añade un resolver secundario consultado sólo si el primario
|
|
10
|
+
* devuelve undefined. Devuelve una función para quitarlo.
|
|
11
|
+
*/
|
|
12
|
+
export declare function _pushContextScopeResolver(resolver: () => Map<unknown, unknown>[] | undefined): () => void;
|
|
8
13
|
/** @internal — returns a copy of the stack for capturing in effect closures. */
|
|
9
14
|
export declare function _captureContextSnapshot(): Map<unknown, unknown>[];
|
|
10
15
|
export declare function _withContextSnapshot<T>(snapshot: Map<unknown, unknown>[], fn: () => T): T;
|
package/dist/lib/elur/context.js
CHANGED
|
@@ -2,51 +2,63 @@
|
|
|
2
2
|
function e(e) {
|
|
3
3
|
return Symbol(e);
|
|
4
4
|
}
|
|
5
|
-
var t = [], n;
|
|
6
|
-
function
|
|
7
|
-
|
|
5
|
+
var t = [], n, r = [];
|
|
6
|
+
function i() {
|
|
7
|
+
let e = n?.();
|
|
8
|
+
if (e !== void 0) return e;
|
|
9
|
+
for (let e of r) {
|
|
10
|
+
let t = e();
|
|
11
|
+
if (t !== void 0) return t;
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
8
14
|
}
|
|
9
|
-
function
|
|
15
|
+
function a(e) {
|
|
10
16
|
n = e;
|
|
11
17
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
18
|
+
function o(e) {
|
|
19
|
+
return r.push(e), () => {
|
|
20
|
+
let t = r.indexOf(e);
|
|
21
|
+
t >= 0 && r.splice(t, 1);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function s() {
|
|
25
|
+
return [...i()];
|
|
14
26
|
}
|
|
15
|
-
function
|
|
16
|
-
let n =
|
|
27
|
+
function c(e, t) {
|
|
28
|
+
let n = i(), r = n.splice(0);
|
|
17
29
|
e.forEach((e) => n.push(e));
|
|
18
30
|
try {
|
|
19
31
|
return t();
|
|
20
32
|
} finally {
|
|
21
|
-
n.splice(0),
|
|
33
|
+
n.splice(0), r.forEach((e) => n.push(e));
|
|
22
34
|
}
|
|
23
35
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
36
|
+
function l() {
|
|
37
|
+
i().push(/* @__PURE__ */ new Map());
|
|
26
38
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
39
|
+
function u() {
|
|
40
|
+
i().pop();
|
|
29
41
|
}
|
|
30
|
-
function
|
|
31
|
-
let n =
|
|
42
|
+
function d(e, t) {
|
|
43
|
+
let n = i(), r = n.splice(0);
|
|
32
44
|
e.forEach((e) => n.push(e)), n.push(/* @__PURE__ */ new Map());
|
|
33
45
|
try {
|
|
34
46
|
return t();
|
|
35
47
|
} finally {
|
|
36
|
-
n.splice(0),
|
|
48
|
+
n.splice(0), r.forEach((e) => n.push(e));
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
|
-
function
|
|
40
|
-
let n =
|
|
41
|
-
if (!
|
|
42
|
-
|
|
51
|
+
function f(e, t) {
|
|
52
|
+
let n = i(), r = n[n.length - 1];
|
|
53
|
+
if (!r) throw Error("[elur] provide() must be called inside onInit() of a ElurComponent.");
|
|
54
|
+
r.set(e, t);
|
|
43
55
|
}
|
|
44
|
-
function
|
|
45
|
-
let n =
|
|
56
|
+
function p(e, t) {
|
|
57
|
+
let n = i();
|
|
46
58
|
for (let t = n.length - 1; t >= 0; t--) if (n[t].has(e)) return n[t].get(e);
|
|
47
59
|
return t;
|
|
48
60
|
}
|
|
49
61
|
//#endregion
|
|
50
|
-
export {
|
|
62
|
+
export { s as _captureContextSnapshot, u as _popComponentContext, l as _pushComponentContext, o as _pushContextScopeResolver, a as _setContextScopeResolver, d as _withComponentContext, c as _withContextSnapshot, e as createInjectionKey, p as inject, f as provide };
|
|
51
63
|
|
|
52
64
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../src/elur/context.ts"],"sourcesContent":["// --- Public types ---\n\n/** Typed key for provide/inject. Generic `T` enforces type safety between provider and consumer. */\nexport type InjectionKey<T> = symbol & { readonly __elurType?: T };\n\n/** Creates a unique typed InjectionKey. */\nexport function createInjectionKey<T>(description?: string): InjectionKey<T> {\n return Symbol(description) as InjectionKey<T>;\n}\n\n// --- Internal stack ---\n\n/** Stack of provide maps, one per active component in the render tree. */\nconst _stack: Map<unknown, unknown>[] = [];\nlet
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../src/elur/context.ts"],"sourcesContent":["// --- Public types ---\n\n/** Typed key for provide/inject. Generic `T` enforces type safety between provider and consumer. */\nexport type InjectionKey<T> = symbol & { readonly __elurType?: T };\n\n/** Creates a unique typed InjectionKey. */\nexport function createInjectionKey<T>(description?: string): InjectionKey<T> {\n return Symbol(description) as InjectionKey<T>;\n}\n\n// --- Internal stack ---\n\n/** Stack of provide maps, one per active component in the render tree. */\nconst _stack: Map<unknown, unknown>[] = [];\n// Resolver primario (set) + secundarios (push): el primario se consulta\n// primero — p.ej. SSR por AsyncLocalStorage — y los secundarios sólo si\n// aquél devuelve undefined (p.ej. contexto por instancia en next/). Así el\n// resultado no depende del orden de importación de los módulos.\nlet _primaryResolver: (() => Map<unknown, unknown>[] | undefined) | undefined;\nconst _scopeResolvers: (() => Map<unknown, unknown>[] | undefined)[] = [];\n\nfunction currentStack(): Map<unknown, unknown>[] {\n const primary = _primaryResolver?.();\n if (primary !== undefined) return primary;\n for (const r of _scopeResolvers) {\n const frames = r();\n if (frames !== undefined) return frames;\n }\n return _stack;\n}\n\nexport function _setContextScopeResolver(\n resolver: (() => Map<unknown, unknown>[] | undefined) | undefined,\n): void {\n _primaryResolver = resolver;\n}\n\n/**\n * @internal — añade un resolver secundario consultado sólo si el primario\n * devuelve undefined. Devuelve una función para quitarlo.\n */\nexport function _pushContextScopeResolver(\n resolver: () => Map<unknown, unknown>[] | undefined,\n): () => void {\n _scopeResolvers.push(resolver);\n return () => {\n const i = _scopeResolvers.indexOf(resolver);\n if (i >= 0) _scopeResolvers.splice(i, 1);\n };\n}\n\n/** @internal — returns a copy of the stack for capturing in effect closures. */\nexport function _captureContextSnapshot(): Map<unknown, unknown>[] {\n return [...currentStack()];\n}\n\nexport function _withContextSnapshot<T>(\n snapshot: Map<unknown, unknown>[],\n fn: () => T,\n): T {\n const stack = currentStack();\n const saved = stack.splice(0);\n snapshot.forEach((entry) => stack.push(entry));\n try {\n return fn();\n } finally {\n stack.splice(0);\n saved.forEach((entry) => stack.push(entry));\n }\n}\n\n/** @internal — pushes an empty context for a new component (static render). */\nexport function _pushComponentContext(): void {\n currentStack().push(new Map());\n}\n\n/** @internal — pops the current component context (static render). */\nexport function _popComponentContext(): void {\n currentStack().pop();\n}\n\n/**\n * @internal — executes `fn` with `parentSnapshot` as ancestors and a fresh\n * empty context on top, then restores the previous stack.\n */\nexport function _withComponentContext<T>(\n parentSnapshot: Map<unknown, unknown>[],\n fn: () => T\n): T {\n const stack = currentStack();\n const saved = stack.splice(0);\n parentSnapshot.forEach(m => stack.push(m));\n stack.push(new Map());\n try {\n return fn();\n } finally {\n stack.splice(0);\n saved.forEach(m => stack.push(m));\n }\n}\n\n// --- Public API ---\n\n/**\n * Registers a value so descendant components can retrieve it via `inject()`.\n * Must be called inside `onInit()` of a ElurComponent.\n */\nexport function provide<T>(\n key: InjectionKey<T> | string | symbol,\n value: T\n): void {\n const stack = currentStack();\n const top = stack[stack.length - 1];\n if (!top) {\n throw new Error(\n \"[elur] provide() must be called inside onInit() of a ElurComponent.\"\n );\n }\n top.set(key, value);\n}\n\n/**\n * Retrieves a value provided by an ancestor component.\n * Searches child-to-parent; returns `undefined` if the key was not provided.\n */\nexport function inject<T>(\n key: InjectionKey<T> | string | symbol,\n defaultValue?: T\n): T | undefined {\n const stack = currentStack();\n for (let i = stack.length - 1; i >= 0; i--) {\n if (stack[i].has(key)) {\n return stack[i].get(key) as T;\n }\n }\n return defaultValue;\n}\n"],"mappings":";AAMA,SAAgB,EAAsB,GAAuC;AACzE,QAAO,OAAO,EAAY;;AAM9B,IAAM,IAAkC,EAAE,EAKtC,GACE,IAAiE,EAAE;AAEzE,SAAS,IAAwC;CAC7C,IAAM,IAAU,KAAoB;AACpC,KAAI,MAAY,KAAA,EAAW,QAAO;AAClC,MAAK,IAAM,KAAK,GAAiB;EAC7B,IAAM,IAAS,GAAG;AAClB,MAAI,MAAW,KAAA,EAAW,QAAO;;AAErC,QAAO;;AAGX,SAAgB,EACZ,GACI;AACJ,KAAmB;;AAOvB,SAAgB,EACZ,GACU;AAEV,QADA,EAAgB,KAAK,EAAS,QACjB;EACT,IAAM,IAAI,EAAgB,QAAQ,EAAS;AAC3C,EAAI,KAAK,KAAG,EAAgB,OAAO,GAAG,EAAE;;;AAKhD,SAAgB,IAAmD;AAC/D,QAAO,CAAC,GAAG,GAAc,CAAC;;AAG9B,SAAgB,EACZ,GACA,GACC;CACD,IAAM,IAAQ,GAAc,EACtB,IAAQ,EAAM,OAAO,EAAE;AAC7B,GAAS,SAAS,MAAU,EAAM,KAAK,EAAM,CAAC;AAC9C,KAAI;AACA,SAAO,GAAI;WACL;AAEN,EADA,EAAM,OAAO,EAAE,EACf,EAAM,SAAS,MAAU,EAAM,KAAK,EAAM,CAAC;;;AAKnD,SAAgB,IAA8B;AAC1C,IAAc,CAAC,qBAAK,IAAI,KAAK,CAAC;;AAIlC,SAAgB,IAA6B;AACzC,IAAc,CAAC,KAAK;;AAOxB,SAAgB,EACZ,GACA,GACC;CACD,IAAM,IAAQ,GAAc,EACtB,IAAQ,EAAM,OAAO,EAAE;AAE7B,CADA,EAAe,SAAQ,MAAK,EAAM,KAAK,EAAE,CAAC,EAC1C,EAAM,qBAAK,IAAI,KAAK,CAAC;AACrB,KAAI;AACA,SAAO,GAAI;WACL;AAEN,EADA,EAAM,OAAO,EAAE,EACf,EAAM,SAAQ,MAAK,EAAM,KAAK,EAAE,CAAC;;;AAUzC,SAAgB,EACZ,GACA,GACI;CACJ,IAAM,IAAQ,GAAc,EACtB,IAAM,EAAM,EAAM,SAAS;AACjC,KAAI,CAAC,EACD,OAAU,MACN,sEACH;AAEL,GAAI,IAAI,GAAK,EAAM;;AAOvB,SAAgB,EACZ,GACA,GACa;CACb,IAAM,IAAQ,GAAc;AAC5B,MAAK,IAAI,IAAI,EAAM,SAAS,GAAG,KAAK,GAAG,IACnC,KAAI,EAAM,GAAG,IAAI,EAAI,CACjB,QAAO,EAAM,GAAG,IAAI,EAAI;AAGhC,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./elur/next-2/reactivity.cjs`),t=require(`./lifecycle.cjs`),n=require(`./router.cjs`);var r={enabled:!1,activeTab:`signals`,renderedTab:null,refreshId:null,root:null,panel:null,content:null,dispose:null,renderKeys:{signals:``,components:``,router:``},scrollMemo:{signals:{top:0,left:0},components:{top:0,left:0},router:{top:0,left:0}}},i=new Set,a=new WeakMap,o=1,s=50,c=new WeakMap,l=new Map,u=[],d=1;function f(e){return typeof WeakRef<`u`?new WeakRef(e):{deref:()=>e}}function p(e){return typeof WeakRef<`u`?new WeakRef(e):{deref:()=>e}}function m(e){e.history.length>s&&e.history.splice(0,e.history.length-s)}function h(e,t){let n=a.get(e);if(n)return m(n),n;let r=Date.now(),s={id:o++,createdAt:r,lastUpdated:r,history:[{at:r,value:t}]};return a.set(e,s),i.add(f(e)),s}function g(){let e=[];for(let t of Array.from(i)){let n=t.deref();if(!n){i.delete(t);continue}let r=a.get(n);if(!r)continue;let o=n._subs?.size??0;e.push({id:r.id,value:n.peek(),subscriberCount:o,createdAt:r.createdAt,lastUpdated:r.lastUpdated,history:r.history.slice()})}return e.sort((e,t)=>t.lastUpdated-e.lastUpdated),e}function _(e){let t=e._debugName;if(t&&t.trim())return t;let n=e.constructor;return n?.name&&n.name.trim()?n.name:`AnonymousComponent`}function v(e){let t=e._slots;return t instanceof Map?Array.from(t.keys()).map(e=>String(e)):[]}function y(e){let t={};for(let n of Object.keys(e)){if(n===`__isElurComponent`||n===`children`||n===`_debugName`||n.startsWith(`_`))continue;let r=e[n];typeof r!=`function`&&(t[n]=r)}return t}function b(e){if(!e)return[];if(e===`*`)return[`*`];let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t)r+=`/`+e,n.push(r);return n.length>0?n:[`/`]}function x(){let e=[];for(let[t,n]of l){let r=n.ref.deref();if(!r){l.delete(t);continue}n.debugName=_(r),n.hasDefaultSlot=r.children!=null,n.slotNames=v(r),n.props=y(r),e.push({id:n.id,parentId:n.parentId,debugName:n.debugName,mountedAt:n.mountedAt,hasDefaultSlot:n.hasDefaultSlot,slotNames:[...n.slotNames],props:{...n.props}})}return e.sort((e,t)=>e.id-t.id),e}function S(e){let t=[e];for(;t.length>0;){let e=t.pop();for(let[n,r]of l)r.parentId===e&&t.push(n);l.delete(e)}}function C(){i.clear(),a=new WeakMap,o=1,c=new WeakMap,l.clear(),u.length=0,d=1}function w(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||e==null)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function T(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\"/g,`"`).replace(/'/g,`'`)}function E(e,t=90){let n=w(e);return n.length<=t?n:n.slice(0,t-1)+`…`}function D(e){if(!e)return`-`;let t=Date.now()-e;return t<1e3?`${t}ms ago`:t<6e4?`${Math.floor(t/1e3)}s ago`:`${Math.floor(t/6e4)}m ago`}function O(e){let t=g(),n=`${t.length}:${t.map(e=>`${e.id}-${e.lastUpdated}-${e.subscriberCount}`).join(`|`)}`;if(r.renderedTab===`signals`&&r.renderKeys.signals===n)return;r.renderKeys.signals=n,r.renderedTab=`signals`;let i=t.map(e=>{let t=w(e.value),n=E(e.value,120);return`<tr data-elur-devtools-signal-id="${e.id}">
|
|
2
2
|
<td style="padding:6px 8px;white-space:nowrap;">${e.id}</td>
|
|
3
3
|
<td style="padding:6px 8px;max-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace, SFMono-Regular, Menlo, monospace;" title="${T(t)}">${T(n)}</td>
|
|
4
4
|
<td>${e.subscriberCount}</td>
|