@elurjs/core 3.5.1 → 3.6.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/lib/component.cjs +1 -1
- package/dist/lib/component.js +1 -1
- package/dist/lib/elur/component.cjs +1 -1
- package/dist/lib/elur/component.cjs.map +1 -1
- package/dist/lib/elur/component.d.cts +1 -1
- package/dist/lib/elur/component.d.ts +1 -1
- package/dist/lib/elur/component.js +1 -1
- package/dist/lib/elur/component.js.map +1 -1
- package/dist/lib/elur/lifecycle.cjs +1 -1
- package/dist/lib/elur/lifecycle.cjs.map +1 -1
- package/dist/lib/elur/lifecycle.d.cts +6 -0
- package/dist/lib/elur/lifecycle.d.ts +6 -0
- package/dist/lib/elur/lifecycle.js +40 -7
- package/dist/lib/elur/lifecycle.js.map +1 -1
- package/dist/lib/elur/reactivity.cjs +1 -1
- package/dist/lib/elur/reactivity.cjs.map +1 -1
- package/dist/lib/elur/reactivity.d.cts +7 -0
- package/dist/lib/elur/reactivity.d.ts +7 -0
- package/dist/lib/elur/reactivity.js +52 -22
- package/dist/lib/elur/reactivity.js.map +1 -1
- package/dist/lib/elur/router-registry.cjs +2 -0
- package/dist/lib/elur/router-registry.cjs.map +1 -0
- package/dist/lib/elur/router-registry.d.cts +14 -0
- package/dist/lib/elur/router-registry.d.ts +14 -0
- package/dist/lib/elur/router-registry.js +15 -0
- package/dist/lib/elur/router-registry.js.map +1 -0
- package/dist/lib/elur/router.cjs +3 -3
- package/dist/lib/elur/router.cjs.map +1 -1
- package/dist/lib/elur/router.d.cts +2 -5
- package/dist/lib/elur/router.d.ts +2 -5
- package/dist/lib/elur/router.js +159 -166
- package/dist/lib/elur/router.js.map +1 -1
- package/dist/lib/elur.cjs +1 -1
- package/dist/lib/elur.js +6 -5
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.js +6 -5
- package/dist/lib/lifecycle.cjs +1 -1
- package/dist/lib/lifecycle.js +40 -7
- package/dist/lib/router.cjs +3 -3
- package/dist/lib/router.js +159 -166
- package/dist/lib/signals.cjs +1 -1
- package/dist/lib/signals.js +52 -22
- package/package.json +12 -1
package/dist/lib/component.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lifecycle.cjs`),t=require(`./context.cjs`),n=require(`./router.cjs`);function r(e){let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw Error(`[elur] mount: container not found: ${e}`);return t}function i(i,a,o){if(e.isElurComponent(i)){let s=r(a);e._debugComponentMountStart(i),t._pushComponentContext();let c=()=>{},l=!1;try{o?.router&&(t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router));try{i.onInit?.()}catch(e){if(i.onError)i.onError(e);else throw e}try{c=i.render()._render(s,null)}catch(e){if(i.onError)i.onError(e),c=()=>{},l=!0;else throw e}}finally{e._debugComponentMountEnd(i),t._popComponentContext()}let u;if(!l)try{let e=i.onMount?.();typeof e==`function`&&(u=e)}catch(e){if(i.onError)i.onError(e);else throw e}return{unmount(){try{i.onUnmount?.()}catch{}try{u?.()}catch{}c(),o?.router&&n._debugUnregisterRouter(o.router),e._debugComponentUnmount(i)}}}if(!o?.router)return i.mount(a);let s=r(a);t._pushComponentContext();let c;try{t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router),c=i._render(s,null)}finally{t._popComponentContext()}return{unmount(){c(),n._debugUnregisterRouter(o.router)}}}exports.mount=i;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lifecycle.cjs`),t=require(`./context.cjs`),n=require(`./elur/router-registry.cjs`);function r(e){let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw Error(`[elur] mount: container not found: ${e}`);return t}function i(i,a,o){if(e.isElurComponent(i)){let s=r(a);e._debugComponentMountStart(i),t._pushComponentContext();let c=()=>{},l=!1;try{o?.router&&(t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router));try{i.onInit?.()}catch(e){if(i.onError)i.onError(e);else throw e}try{c=i.render()._render(s,null)}catch(e){if(i.onError)i.onError(e),c=()=>{},l=!0;else throw e}}finally{e._debugComponentMountEnd(i),t._popComponentContext()}let u;if(!l)try{let e=i.onMount?.();typeof e==`function`&&(u=e)}catch(e){if(i.onError)i.onError(e);else throw e}return{unmount(){try{i.onUnmount?.()}catch{}try{u?.()}catch{}c(),o?.router&&n._debugUnregisterRouter(o.router),e._debugComponentUnmount(i)}}}if(!o?.router)return i.mount(a);let s=r(a);t._pushComponentContext();let c;try{t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router),c=i._render(s,null)}finally{t._popComponentContext()}return{unmount(){c(),n._debugUnregisterRouter(o.router)}}}exports.mount=i;
|
|
2
2
|
//# sourceMappingURL=component.cjs.map
|
package/dist/lib/component.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _debugComponentMountEnd as e, _debugComponentMountStart as t, _debugComponentUnmount as n, isElurComponent as r } from "./lifecycle.js";
|
|
2
2
|
import { _popComponentContext as i, _pushComponentContext as a, provide as o } from "./context.js";
|
|
3
|
-
import { RouterKey as s, _debugRegisterRouter as c, _debugUnregisterRouter as l } from "./router.js";
|
|
3
|
+
import { RouterKey as s, _debugRegisterRouter as c, _debugUnregisterRouter as l } from "./elur/router-registry.js";
|
|
4
4
|
//#region src/elur/component.ts
|
|
5
5
|
function u(e) {
|
|
6
6
|
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lifecycle.cjs`),t=require(`./context.cjs`),n=require(`./router.cjs`);function r(e){let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw Error(`[elur] mount: container not found: ${e}`);return t}function i(i,a,o){if(e.isElurComponent(i)){let s=r(a);e._debugComponentMountStart(i),t._pushComponentContext();let c=()=>{},l=!1;try{o?.router&&(t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router));try{i.onInit?.()}catch(e){if(i.onError)i.onError(e);else throw e}try{c=i.render()._render(s,null)}catch(e){if(i.onError)i.onError(e),c=()=>{},l=!0;else throw e}}finally{e._debugComponentMountEnd(i),t._popComponentContext()}let u;if(!l)try{let e=i.onMount?.();typeof e==`function`&&(u=e)}catch(e){if(i.onError)i.onError(e);else throw e}return{unmount(){try{i.onUnmount?.()}catch{}try{u?.()}catch{}c(),o?.router&&n._debugUnregisterRouter(o.router),e._debugComponentUnmount(i)}}}if(!o?.router)return i.mount(a);let s=r(a);t._pushComponentContext();let c;try{t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router),c=i._render(s,null)}finally{t._popComponentContext()}return{unmount(){c(),n._debugUnregisterRouter(o.router)}}}exports.mount=i;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lifecycle.cjs`),t=require(`./context.cjs`),n=require(`./elur/router-registry.cjs`);function r(e){let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw Error(`[elur] mount: container not found: ${e}`);return t}function i(i,a,o){if(e.isElurComponent(i)){let s=r(a);e._debugComponentMountStart(i),t._pushComponentContext();let c=()=>{},l=!1;try{o?.router&&(t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router));try{i.onInit?.()}catch(e){if(i.onError)i.onError(e);else throw e}try{c=i.render()._render(s,null)}catch(e){if(i.onError)i.onError(e),c=()=>{},l=!0;else throw e}}finally{e._debugComponentMountEnd(i),t._popComponentContext()}let u;if(!l)try{let e=i.onMount?.();typeof e==`function`&&(u=e)}catch(e){if(i.onError)i.onError(e);else throw e}return{unmount(){try{i.onUnmount?.()}catch{}try{u?.()}catch{}c(),o?.router&&n._debugUnregisterRouter(o.router),e._debugComponentUnmount(i)}}}if(!o?.router)return i.mount(a);let s=r(a);t._pushComponentContext();let c;try{t.provide(n.RouterKey,o.router),n._debugRegisterRouter(o.router),c=i._render(s,null)}finally{t._popComponentContext()}return{unmount(){c(),n._debugUnregisterRouter(o.router)}}}exports.mount=i;
|
|
2
2
|
//# sourceMappingURL=component.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.cjs","names":[],"sources":["../../src/elur/component.ts"],"sourcesContent":["import type { ElurTemplate, ElurMountHandle } from \"./template/index.js\";\nimport {\n isElurComponent,\n _debugComponentMountStart,\n _debugComponentMountEnd,\n _debugComponentUnmount,\n type ElurComponent,\n} from \"./lifecycle.js\";\nimport { _pushComponentContext, _popComponentContext, provide } from \"./context.js\";\nimport { RouterKey,
|
|
1
|
+
{"version":3,"file":"component.cjs","names":[],"sources":["../../src/elur/component.ts"],"sourcesContent":["import type { ElurTemplate, ElurMountHandle } from \"./template/index.js\";\nimport {\n isElurComponent,\n _debugComponentMountStart,\n _debugComponentMountEnd,\n _debugComponentUnmount,\n type ElurComponent,\n} from \"./lifecycle.js\";\nimport { _pushComponentContext, _popComponentContext, provide } from \"./context.js\";\nimport { RouterKey, _debugRegisterRouter, _debugUnregisterRouter } from \"./router-registry.js\";\nimport type { Router } from \"./router.js\";\n\nexport interface MountOptions {\n router?: Router;\n}\n\nfunction _resolveContainer(container: Element | string): Element {\n const el =\n typeof container === \"string\"\n ? (document.querySelector(container) as Element)\n : container;\n if (!el) {\n throw new Error(`[elur] mount: container not found: ${container}`);\n }\n return el;\n}\n\n/**\n * Mounts a ElurTemplate or ElurComponent into the DOM.\n *\n * mount(Counter(), \"#app\"); // ElurTemplate (function component)\n * mount(new Timer(), \"#app\"); // ElurComponent (class with lifecycle)\n *\n * @param component ElurTemplate (result of html``) or a ElurComponent instance.\n * @param container CSS selector or HTMLElement to mount into.\n * @returns { unmount() } — disposes effects and removes DOM.\n */\nexport function mount(\n component: ElurTemplate | ElurComponent,\n container: Element | string,\n options?: MountOptions\n): ElurMountHandle {\n if (isElurComponent(component)) {\n const el = _resolveContainer(container);\n\n _debugComponentMountStart(component);\n _pushComponentContext();\n let cleanup: () => void = () => { };\n let renderFailed = false;\n try {\n if (options?.router) {\n provide(RouterKey, options.router);\n _debugRegisterRouter(options.router);\n }\n try { component.onInit?.(); } catch (e) { if (component.onError) component.onError(e); else throw e; }\n try {\n cleanup = component.render()._render(el, null);\n } catch (e) {\n if (component.onError) {\n component.onError(e);\n cleanup = () => { };\n renderFailed = true;\n } else {\n throw e;\n }\n }\n } finally {\n _debugComponentMountEnd(component);\n _popComponentContext();\n }\n\n let mountCleanup: (() => void) | undefined;\n if (!renderFailed) {\n try {\n const ret = component.onMount?.();\n if (typeof ret === \"function\") mountCleanup = ret;\n } catch (e) {\n if (component.onError) component.onError(e);\n else throw e;\n }\n }\n\n return {\n unmount() {\n try { component.onUnmount?.(); } catch { /* ignore */ }\n try { mountCleanup?.(); } catch { /* ignore */ }\n cleanup();\n if (options?.router) _debugUnregisterRouter(options.router);\n _debugComponentUnmount(component);\n },\n };\n }\n\n if (!options?.router) {\n // ElurTemplate: delegar al método .mount() interno\n return (component as ElurTemplate).mount(container);\n }\n\n // For template roots, create a context frame so elurRouter()/inject() can resolve.\n const el = _resolveContainer(container);\n _pushComponentContext();\n let cleanup: () => void;\n try {\n provide(RouterKey, options.router);\n _debugRegisterRouter(options.router);\n cleanup = (component as ElurTemplate)._render(el, null);\n } finally {\n _popComponentContext();\n }\n\n return {\n unmount() {\n cleanup();\n _debugUnregisterRouter(options.router!);\n },\n };\n}\n"],"mappings":"yKAgBA,SAAS,EAAkB,EAAsC,CAC7D,IAAM,EACF,OAAO,GAAc,SACd,SAAS,cAAc,EAAU,CAClC,EACV,GAAI,CAAC,EACD,MAAU,MAAM,sCAAsC,IAAY,CAEtE,OAAO,EAaX,SAAgB,EACZ,EACA,EACA,EACe,CACf,GAAI,EAAA,gBAAgB,EAAU,CAAE,CAC5B,IAAM,EAAK,EAAkB,EAAU,CAEvC,EAAA,0BAA0B,EAAU,CACpC,EAAA,uBAAuB,CACvB,IAAI,MAA4B,GAC5B,EAAe,GACnB,GAAI,CACI,GAAS,SACT,EAAA,QAAQ,EAAA,UAAW,EAAQ,OAAO,CAClC,EAAA,qBAAqB,EAAQ,OAAO,EAExC,GAAI,CAAE,EAAU,UAAU,OAAW,EAAG,CAAE,GAAI,EAAU,QAAS,EAAU,QAAQ,EAAE,MAAO,MAAM,EAClG,GAAI,CACA,EAAU,EAAU,QAAQ,CAAC,QAAQ,EAAI,KAAK,OACzC,EAAG,CACR,GAAI,EAAU,QACV,EAAU,QAAQ,EAAE,CACpB,MAAgB,GAChB,EAAe,QAEf,MAAM,UAGR,CACN,EAAA,wBAAwB,EAAU,CAClC,EAAA,sBAAsB,CAG1B,IAAI,EACJ,GAAI,CAAC,EACD,GAAI,CACA,IAAM,EAAM,EAAU,WAAW,CAC7B,OAAO,GAAQ,aAAY,EAAe,SACzC,EAAG,CACR,GAAI,EAAU,QAAS,EAAU,QAAQ,EAAE,MACtC,MAAM,EAInB,MAAO,CACH,SAAU,CACN,GAAI,CAAE,EAAU,aAAa,MAAU,EACvC,GAAI,CAAE,KAAgB,MAAU,EAChC,GAAS,CACL,GAAS,QAAQ,EAAA,uBAAuB,EAAQ,OAAO,CAC3D,EAAA,uBAAuB,EAAU,EAExC,CAGL,GAAI,CAAC,GAAS,OAEV,OAAQ,EAA2B,MAAM,EAAU,CAIvD,IAAM,EAAK,EAAkB,EAAU,CACvC,EAAA,uBAAuB,CACvB,IAAI,EACJ,GAAI,CACA,EAAA,QAAQ,EAAA,UAAW,EAAQ,OAAO,CAClC,EAAA,qBAAqB,EAAQ,OAAO,CACpC,EAAW,EAA2B,QAAQ,EAAI,KAAK,QACjD,CACN,EAAA,sBAAsB,CAG1B,MAAO,CACH,SAAU,CACN,GAAS,CACT,EAAA,uBAAuB,EAAQ,OAAQ,EAE9C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ElurTemplate, ElurMountHandle } from "./template/index.js";
|
|
2
2
|
import { type ElurComponent } from "./lifecycle.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { Router } from "./router.js";
|
|
4
4
|
export interface MountOptions {
|
|
5
5
|
router?: Router;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ElurTemplate, ElurMountHandle } from "./template/index.js";
|
|
2
2
|
import { type ElurComponent } from "./lifecycle.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { Router } from "./router.js";
|
|
4
4
|
export interface MountOptions {
|
|
5
5
|
router?: Router;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _debugComponentMountEnd as e, _debugComponentMountStart as t, _debugComponentUnmount as n, isElurComponent as r } from "./lifecycle.js";
|
|
2
2
|
import { _popComponentContext as i, _pushComponentContext as a, provide as o } from "./context.js";
|
|
3
|
-
import { RouterKey as s, _debugRegisterRouter as c, _debugUnregisterRouter as l } from "./router.js";
|
|
3
|
+
import { RouterKey as s, _debugRegisterRouter as c, _debugUnregisterRouter as l } from "./elur/router-registry.js";
|
|
4
4
|
//#region src/elur/component.ts
|
|
5
5
|
function u(e) {
|
|
6
6
|
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","names":[],"sources":["../../src/elur/component.ts"],"sourcesContent":["import type { ElurTemplate, ElurMountHandle } from \"./template/index.js\";\nimport {\n isElurComponent,\n _debugComponentMountStart,\n _debugComponentMountEnd,\n _debugComponentUnmount,\n type ElurComponent,\n} from \"./lifecycle.js\";\nimport { _pushComponentContext, _popComponentContext, provide } from \"./context.js\";\nimport { RouterKey,
|
|
1
|
+
{"version":3,"file":"component.js","names":[],"sources":["../../src/elur/component.ts"],"sourcesContent":["import type { ElurTemplate, ElurMountHandle } from \"./template/index.js\";\nimport {\n isElurComponent,\n _debugComponentMountStart,\n _debugComponentMountEnd,\n _debugComponentUnmount,\n type ElurComponent,\n} from \"./lifecycle.js\";\nimport { _pushComponentContext, _popComponentContext, provide } from \"./context.js\";\nimport { RouterKey, _debugRegisterRouter, _debugUnregisterRouter } from \"./router-registry.js\";\nimport type { Router } from \"./router.js\";\n\nexport interface MountOptions {\n router?: Router;\n}\n\nfunction _resolveContainer(container: Element | string): Element {\n const el =\n typeof container === \"string\"\n ? (document.querySelector(container) as Element)\n : container;\n if (!el) {\n throw new Error(`[elur] mount: container not found: ${container}`);\n }\n return el;\n}\n\n/**\n * Mounts a ElurTemplate or ElurComponent into the DOM.\n *\n * mount(Counter(), \"#app\"); // ElurTemplate (function component)\n * mount(new Timer(), \"#app\"); // ElurComponent (class with lifecycle)\n *\n * @param component ElurTemplate (result of html``) or a ElurComponent instance.\n * @param container CSS selector or HTMLElement to mount into.\n * @returns { unmount() } — disposes effects and removes DOM.\n */\nexport function mount(\n component: ElurTemplate | ElurComponent,\n container: Element | string,\n options?: MountOptions\n): ElurMountHandle {\n if (isElurComponent(component)) {\n const el = _resolveContainer(container);\n\n _debugComponentMountStart(component);\n _pushComponentContext();\n let cleanup: () => void = () => { };\n let renderFailed = false;\n try {\n if (options?.router) {\n provide(RouterKey, options.router);\n _debugRegisterRouter(options.router);\n }\n try { component.onInit?.(); } catch (e) { if (component.onError) component.onError(e); else throw e; }\n try {\n cleanup = component.render()._render(el, null);\n } catch (e) {\n if (component.onError) {\n component.onError(e);\n cleanup = () => { };\n renderFailed = true;\n } else {\n throw e;\n }\n }\n } finally {\n _debugComponentMountEnd(component);\n _popComponentContext();\n }\n\n let mountCleanup: (() => void) | undefined;\n if (!renderFailed) {\n try {\n const ret = component.onMount?.();\n if (typeof ret === \"function\") mountCleanup = ret;\n } catch (e) {\n if (component.onError) component.onError(e);\n else throw e;\n }\n }\n\n return {\n unmount() {\n try { component.onUnmount?.(); } catch { /* ignore */ }\n try { mountCleanup?.(); } catch { /* ignore */ }\n cleanup();\n if (options?.router) _debugUnregisterRouter(options.router);\n _debugComponentUnmount(component);\n },\n };\n }\n\n if (!options?.router) {\n // ElurTemplate: delegar al método .mount() interno\n return (component as ElurTemplate).mount(container);\n }\n\n // For template roots, create a context frame so elurRouter()/inject() can resolve.\n const el = _resolveContainer(container);\n _pushComponentContext();\n let cleanup: () => void;\n try {\n provide(RouterKey, options.router);\n _debugRegisterRouter(options.router);\n cleanup = (component as ElurTemplate)._render(el, null);\n } finally {\n _popComponentContext();\n }\n\n return {\n unmount() {\n cleanup();\n _debugUnregisterRouter(options.router!);\n },\n };\n}\n"],"mappings":";;;;AAgBA,SAAS,EAAkB,GAAsC;CAC7D,IAAM,IACF,OAAO,KAAc,WACd,SAAS,cAAc,EAAU,GAClC;AACV,KAAI,CAAC,EACD,OAAU,MAAM,sCAAsC,IAAY;AAEtE,QAAO;;AAaX,SAAgB,EACZ,GACA,GACA,GACe;AACf,KAAI,EAAgB,EAAU,EAAE;EAC5B,IAAM,IAAK,EAAkB,EAAU;AAGvC,EADA,EAA0B,EAAU,EACpC,GAAuB;EACvB,IAAI,UAA4B,IAC5B,IAAe;AACnB,MAAI;AACA,GAAI,GAAS,WACT,EAAQ,GAAW,EAAQ,OAAO,EAClC,EAAqB,EAAQ,OAAO;AAExC,OAAI;AAAE,MAAU,UAAU;YAAW,GAAG;AAAE,QAAI,EAAU,QAAS,GAAU,QAAQ,EAAE;QAAO,OAAM;;AAClG,OAAI;AACA,QAAU,EAAU,QAAQ,CAAC,QAAQ,GAAI,KAAK;YACzC,GAAG;AACR,QAAI,EAAU,QAGV,CAFA,EAAU,QAAQ,EAAE,EACpB,UAAgB,IAChB,IAAe;QAEf,OAAM;;YAGR;AAEN,GADA,EAAwB,EAAU,EAClC,GAAsB;;EAG1B,IAAI;AACJ,MAAI,CAAC,EACD,KAAI;GACA,IAAM,IAAM,EAAU,WAAW;AACjC,GAAI,OAAO,KAAQ,eAAY,IAAe;WACzC,GAAG;AACR,OAAI,EAAU,QAAS,GAAU,QAAQ,EAAE;OACtC,OAAM;;AAInB,SAAO,EACH,UAAU;AACN,OAAI;AAAE,MAAU,aAAa;WAAU;AACvC,OAAI;AAAE,SAAgB;WAAU;AAGhC,GAFA,GAAS,EACL,GAAS,UAAQ,EAAuB,EAAQ,OAAO,EAC3D,EAAuB,EAAU;KAExC;;AAGL,KAAI,CAAC,GAAS,OAEV,QAAQ,EAA2B,MAAM,EAAU;CAIvD,IAAM,IAAK,EAAkB,EAAU;AACvC,IAAuB;CACvB,IAAI;AACJ,KAAI;AAGA,EAFA,EAAQ,GAAW,EAAQ,OAAO,EAClC,EAAqB,EAAQ,OAAO,EACpC,IAAW,EAA2B,QAAQ,GAAI,KAAK;WACjD;AACN,KAAsB;;AAG1B,QAAO,EACH,UAAU;AAEN,EADA,GAAS,EACT,EAAuB,EAAQ,OAAQ;IAE9C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{__isElurComponent=!0;children;_debugName;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}setDebugName(e){return this._debugName=e,this}};function t(e){return typeof e==`object`&&!!e&&e.__isElurComponent===!0}var n=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{__isElurComponent=!0;children;_debugName;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}setDebugName(e){return this._debugName=e,this}};function t(e){return typeof e==`object`&&!!e&&e.__isElurComponent===!0}var n=Symbol.for(`@elurjs/core/reactivity-state`);function r(){let e=globalThis,t=e[n];return t||(t={},e[n]=t),t}function i(e){let t=e.componentDebugHookSet;if(!t||t.size===0){e.componentDebugHooks=null;return}if(t.size===1){e.componentDebugHooks=t.values().next().value??null;return}e.componentDebugHooks={onMountStart(e){for(let n of t)n.onMountStart?.(e)},onMountEnd(e){for(let n of t)n.onMountEnd?.(e)},onUnmount(e){for(let n of t)n.onUnmount?.(e)}}}function a(e){let t=r(),n=new Set;e&&n.add(e),t.componentDebugHookSet=n,i(t)}function o(e){let t=r(),n=t.componentDebugHookSet;return n||(n=new Set,t.componentDebugHooks&&n.add(t.componentDebugHooks),t.componentDebugHookSet=n),n.add(e),i(t),()=>{n.delete(e),i(t)}}function s(e){r().componentDebugHooks?.onMountStart?.(e)}function c(e){r().componentDebugHooks?.onMountEnd?.(e)}function l(e){r().componentDebugHooks?.onUnmount?.(e)}exports.ElurComponent=e,exports._addComponentDebugHooks=o,exports._debugComponentMountEnd=c,exports._debugComponentMountStart=s,exports._debugComponentUnmount=l,exports._setComponentDebugHooks=a,exports.isElurComponent=t;
|
|
2
2
|
//# sourceMappingURL=lifecycle.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.cjs","names":[],"sources":["../../src/elur/lifecycle.ts"],"sourcesContent":["import type { ElurTemplate } from \"./template/index.js\";\n\n// --- ElurChildren ---\n\n/** Valid child content for components. */\nexport type ElurChildren =\n | ElurTemplate\n | ElurComponent\n | Array<ElurTemplate | ElurComponent>\n | null\n | undefined;\n\n// --- ElurComponent ---\n\n/** Base class for components with lifecycle hooks. */\nexport abstract class ElurComponent {\n /** @internal */\n readonly __isElurComponent = true as const;\n\n /** Default slot — child content injected by the parent. */\n children?: ElurChildren;\n\n /** Optional label used by devtools. Falls back to class name. */\n _debugName?: string;\n\n /** @internal */\n private _slots = new Map<string, ElurChildren>();\n\n /** Sets the default slot content. Returns `this` for chaining. */\n setChildren(content: ElurChildren): this {\n this.children = content;\n return this;\n }\n\n /** Sets a named slot. Returns `this` for chaining. */\n setSlot(name: string, content: ElurChildren): this {\n this._slots.set(name, content);\n return this;\n }\n\n /** Returns content for a named slot. */\n slot(name: string): ElurChildren {\n return this._slots.get(name);\n }\n\n /** Sets an explicit devtools display name. Returns `this` for chaining. */\n setDebugName(name: string): this {\n this._debugName = name;\n return this;\n }\n\n /** Returns the component template. Called once on mount; updates happen via signals. */\n abstract render(): ElurTemplate;\n\n /** Called before `render()` — no DOM yet. Errors are caught by `onError` if present. */\n onInit?(): void;\n\n /** Server-only lifecycle hook. Runs during SSR after `onInit()`; never on the client. */\n onServerRender?(): void;\n\n /** Called after DOM insertion. May return a cleanup function. */\n onMount?(): (() => void) | void;\n\n /** Called before DOM removal. */\n onUnmount?(): void;\n\n /** Catches errors thrown in `onInit` and `onMount`. */\n onError?(err: unknown): void;\n}\n\n// --- Type guard ---\n\n/** @internal */\nexport function isElurComponent(v: unknown): v is ElurComponent {\n return (\n v != null &&\n typeof v === \"object\" &&\n (v as Record<string, unknown>).__isElurComponent === true\n );\n}\n\n// --- Devtools component tracking (internal) ---\n\nexport interface _ComponentDebugHooks {\n onMountStart?: (inst: ElurComponent) => void;\n onMountEnd?: (inst: ElurComponent) => void;\n onUnmount?: (inst: ElurComponent) => void;\n}\n\
|
|
1
|
+
{"version":3,"file":"lifecycle.cjs","names":[],"sources":["../../src/elur/lifecycle.ts"],"sourcesContent":["import type { ElurTemplate } from \"./template/index.js\";\n\n// --- ElurChildren ---\n\n/** Valid child content for components. */\nexport type ElurChildren =\n | ElurTemplate\n | ElurComponent\n | Array<ElurTemplate | ElurComponent>\n | null\n | undefined;\n\n// --- ElurComponent ---\n\n/** Base class for components with lifecycle hooks. */\nexport abstract class ElurComponent {\n /** @internal */\n readonly __isElurComponent = true as const;\n\n /** Default slot — child content injected by the parent. */\n children?: ElurChildren;\n\n /** Optional label used by devtools. Falls back to class name. */\n _debugName?: string;\n\n /** @internal */\n private _slots = new Map<string, ElurChildren>();\n\n /** Sets the default slot content. Returns `this` for chaining. */\n setChildren(content: ElurChildren): this {\n this.children = content;\n return this;\n }\n\n /** Sets a named slot. Returns `this` for chaining. */\n setSlot(name: string, content: ElurChildren): this {\n this._slots.set(name, content);\n return this;\n }\n\n /** Returns content for a named slot. */\n slot(name: string): ElurChildren {\n return this._slots.get(name);\n }\n\n /** Sets an explicit devtools display name. Returns `this` for chaining. */\n setDebugName(name: string): this {\n this._debugName = name;\n return this;\n }\n\n /** Returns the component template. Called once on mount; updates happen via signals. */\n abstract render(): ElurTemplate;\n\n /** Called before `render()` — no DOM yet. Errors are caught by `onError` if present. */\n onInit?(): void;\n\n /** Server-only lifecycle hook. Runs during SSR after `onInit()`; never on the client. */\n onServerRender?(): void;\n\n /** Called after DOM insertion. May return a cleanup function. */\n onMount?(): (() => void) | void;\n\n /** Called before DOM removal. */\n onUnmount?(): void;\n\n /** Catches errors thrown in `onInit` and `onMount`. */\n onError?(err: unknown): void;\n}\n\n// --- Type guard ---\n\n/** @internal */\nexport function isElurComponent(v: unknown): v is ElurComponent {\n return (\n v != null &&\n typeof v === \"object\" &&\n (v as Record<string, unknown>).__isElurComponent === true\n );\n}\n\n// --- Devtools component tracking (internal) ---\n\nexport interface _ComponentDebugHooks {\n onMountStart?: (inst: ElurComponent) => void;\n onMountEnd?: (inst: ElurComponent) => void;\n onUnmount?: (inst: ElurComponent) => void;\n}\n\n/**\n * The registry lives in the shared reactivity global state\n * (`Symbol.for(\"@elurjs/core/reactivity-state\")`) rather than in module-local\n * state, so hooks work even when the package ends up duplicated in a bundle.\n */\ninterface _ComponentHookState {\n componentDebugHooks?: _ComponentDebugHooks | null;\n componentDebugHookSet?: Set<_ComponentDebugHooks>;\n}\n\nconst _reactivityStateKey = Symbol.for(\"@elurjs/core/reactivity-state\");\n\nfunction _hookState(): _ComponentHookState {\n const g = globalThis as Record<PropertyKey, unknown>;\n let state = g[_reactivityStateKey] as _ComponentHookState | undefined;\n if (!state) {\n // reactivity.ts merges its defaults into this object when it loads.\n state = {};\n g[_reactivityStateKey] = state;\n }\n return state;\n}\n\n/** Single dispatcher on the hot path; the set is only for bookkeeping. */\nfunction _syncComponentDebugHooks(state: _ComponentHookState): void {\n const set = state.componentDebugHookSet;\n if (!set || set.size === 0) {\n state.componentDebugHooks = null;\n return;\n }\n if (set.size === 1) {\n state.componentDebugHooks = set.values().next().value ?? null;\n return;\n }\n state.componentDebugHooks = {\n onMountStart(inst) {\n for (const hooks of set) hooks.onMountStart?.(inst);\n },\n onMountEnd(inst) {\n for (const hooks of set) hooks.onMountEnd?.(inst);\n },\n onUnmount(inst) {\n for (const hooks of set) hooks.onUnmount?.(inst);\n },\n };\n}\n\nexport function _setComponentDebugHooks(hooks: _ComponentDebugHooks | null): void {\n const state = _hookState();\n const set = new Set<_ComponentDebugHooks>();\n if (hooks) set.add(hooks);\n state.componentDebugHookSet = set;\n _syncComponentDebugHooks(state);\n}\n\n/**\n * @internal — Adds a component debug hook subscriber WITHOUT replacing\n * existing ones (unlike `_setComponentDebugHooks`). Returns an unsubscribe\n * function. Zero cost when no subscribers are registered.\n */\nexport function _addComponentDebugHooks(hooks: _ComponentDebugHooks): () => void {\n const state = _hookState();\n let set = state.componentDebugHookSet;\n if (!set) {\n set = new Set<_ComponentDebugHooks>();\n if (state.componentDebugHooks) set.add(state.componentDebugHooks);\n state.componentDebugHookSet = set;\n }\n set.add(hooks);\n _syncComponentDebugHooks(state);\n return () => {\n set.delete(hooks);\n _syncComponentDebugHooks(state);\n };\n}\n\nexport function _debugComponentMountStart(inst: ElurComponent): void {\n _hookState().componentDebugHooks?.onMountStart?.(inst);\n}\n\nexport function _debugComponentMountEnd(inst: ElurComponent): void {\n _hookState().componentDebugHooks?.onMountEnd?.(inst);\n}\n\nexport function _debugComponentUnmount(inst: ElurComponent): void {\n _hookState().componentDebugHooks?.onUnmount?.(inst);\n}\n"],"mappings":"mEAeA,IAAsB,EAAtB,KAAoC,CAEhC,kBAA6B,GAG7B,SAGA,WAGA,OAAiB,IAAI,IAGrB,YAAY,EAA6B,CAErC,MADA,MAAK,SAAW,EACT,KAIX,QAAQ,EAAc,EAA6B,CAE/C,OADA,KAAK,OAAO,IAAI,EAAM,EAAQ,CACvB,KAIX,KAAK,EAA4B,CAC7B,OAAO,KAAK,OAAO,IAAI,EAAK,CAIhC,aAAa,EAAoB,CAE7B,MADA,MAAK,WAAa,EACX,OAyBf,SAAgB,EAAgB,EAAgC,CAC5D,OAEI,OAAO,GAAM,YADb,GAEC,EAA8B,oBAAsB,GAsB7D,IAAM,EAAsB,OAAO,IAAI,gCAAgC,CAEvE,SAAS,GAAkC,CACvC,IAAM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|
|
42
42
|
export declare function _setComponentDebugHooks(hooks: _ComponentDebugHooks | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* @internal — Adds a component debug hook subscriber WITHOUT replacing
|
|
45
|
+
* existing ones (unlike `_setComponentDebugHooks`). Returns an unsubscribe
|
|
46
|
+
* function. Zero cost when no subscribers are registered.
|
|
47
|
+
*/
|
|
48
|
+
export declare function _addComponentDebugHooks(hooks: _ComponentDebugHooks): () => void;
|
|
43
49
|
export declare function _debugComponentMountStart(inst: ElurComponent): void;
|
|
44
50
|
export declare function _debugComponentMountEnd(inst: ElurComponent): void;
|
|
45
51
|
export declare function _debugComponentUnmount(inst: ElurComponent): void;
|
|
@@ -40,6 +40,12 @@ export interface _ComponentDebugHooks {
|
|
|
40
40
|
onUnmount?: (inst: ElurComponent) => void;
|
|
41
41
|
}
|
|
42
42
|
export declare function _setComponentDebugHooks(hooks: _ComponentDebugHooks | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* @internal — Adds a component debug hook subscriber WITHOUT replacing
|
|
45
|
+
* existing ones (unlike `_setComponentDebugHooks`). Returns an unsubscribe
|
|
46
|
+
* function. Zero cost when no subscribers are registered.
|
|
47
|
+
*/
|
|
48
|
+
export declare function _addComponentDebugHooks(hooks: _ComponentDebugHooks): () => void;
|
|
43
49
|
export declare function _debugComponentMountStart(inst: ElurComponent): void;
|
|
44
50
|
export declare function _debugComponentMountEnd(inst: ElurComponent): void;
|
|
45
51
|
export declare function _debugComponentUnmount(inst: ElurComponent): void;
|
|
@@ -20,20 +20,53 @@ var e = class {
|
|
|
20
20
|
function t(e) {
|
|
21
21
|
return typeof e == "object" && !!e && e.__isElurComponent === !0;
|
|
22
22
|
}
|
|
23
|
-
var n =
|
|
24
|
-
function r(
|
|
25
|
-
|
|
23
|
+
var n = Symbol.for("@elurjs/core/reactivity-state");
|
|
24
|
+
function r() {
|
|
25
|
+
let e = globalThis, t = e[n];
|
|
26
|
+
return t || (t = {}, e[n] = t), t;
|
|
26
27
|
}
|
|
27
28
|
function i(e) {
|
|
28
|
-
|
|
29
|
+
let t = e.componentDebugHookSet;
|
|
30
|
+
if (!t || t.size === 0) {
|
|
31
|
+
e.componentDebugHooks = null;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (t.size === 1) {
|
|
35
|
+
e.componentDebugHooks = t.values().next().value ?? null;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
e.componentDebugHooks = {
|
|
39
|
+
onMountStart(e) {
|
|
40
|
+
for (let n of t) n.onMountStart?.(e);
|
|
41
|
+
},
|
|
42
|
+
onMountEnd(e) {
|
|
43
|
+
for (let n of t) n.onMountEnd?.(e);
|
|
44
|
+
},
|
|
45
|
+
onUnmount(e) {
|
|
46
|
+
for (let n of t) n.onUnmount?.(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
29
49
|
}
|
|
30
50
|
function a(e) {
|
|
31
|
-
n
|
|
51
|
+
let t = r(), n = /* @__PURE__ */ new Set();
|
|
52
|
+
e && n.add(e), t.componentDebugHookSet = n, i(t);
|
|
32
53
|
}
|
|
33
54
|
function o(e) {
|
|
34
|
-
|
|
55
|
+
let t = r(), n = t.componentDebugHookSet;
|
|
56
|
+
return n || (n = /* @__PURE__ */ new Set(), t.componentDebugHooks && n.add(t.componentDebugHooks), t.componentDebugHookSet = n), n.add(e), i(t), () => {
|
|
57
|
+
n.delete(e), i(t);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function s(e) {
|
|
61
|
+
r().componentDebugHooks?.onMountStart?.(e);
|
|
62
|
+
}
|
|
63
|
+
function c(e) {
|
|
64
|
+
r().componentDebugHooks?.onMountEnd?.(e);
|
|
65
|
+
}
|
|
66
|
+
function l(e) {
|
|
67
|
+
r().componentDebugHooks?.onUnmount?.(e);
|
|
35
68
|
}
|
|
36
69
|
//#endregion
|
|
37
|
-
export { e as ElurComponent,
|
|
70
|
+
export { e as ElurComponent, o as _addComponentDebugHooks, c as _debugComponentMountEnd, s as _debugComponentMountStart, l as _debugComponentUnmount, a as _setComponentDebugHooks, t as isElurComponent };
|
|
38
71
|
|
|
39
72
|
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","names":[],"sources":["../../src/elur/lifecycle.ts"],"sourcesContent":["import type { ElurTemplate } from \"./template/index.js\";\n\n// --- ElurChildren ---\n\n/** Valid child content for components. */\nexport type ElurChildren =\n | ElurTemplate\n | ElurComponent\n | Array<ElurTemplate | ElurComponent>\n | null\n | undefined;\n\n// --- ElurComponent ---\n\n/** Base class for components with lifecycle hooks. */\nexport abstract class ElurComponent {\n /** @internal */\n readonly __isElurComponent = true as const;\n\n /** Default slot — child content injected by the parent. */\n children?: ElurChildren;\n\n /** Optional label used by devtools. Falls back to class name. */\n _debugName?: string;\n\n /** @internal */\n private _slots = new Map<string, ElurChildren>();\n\n /** Sets the default slot content. Returns `this` for chaining. */\n setChildren(content: ElurChildren): this {\n this.children = content;\n return this;\n }\n\n /** Sets a named slot. Returns `this` for chaining. */\n setSlot(name: string, content: ElurChildren): this {\n this._slots.set(name, content);\n return this;\n }\n\n /** Returns content for a named slot. */\n slot(name: string): ElurChildren {\n return this._slots.get(name);\n }\n\n /** Sets an explicit devtools display name. Returns `this` for chaining. */\n setDebugName(name: string): this {\n this._debugName = name;\n return this;\n }\n\n /** Returns the component template. Called once on mount; updates happen via signals. */\n abstract render(): ElurTemplate;\n\n /** Called before `render()` — no DOM yet. Errors are caught by `onError` if present. */\n onInit?(): void;\n\n /** Server-only lifecycle hook. Runs during SSR after `onInit()`; never on the client. */\n onServerRender?(): void;\n\n /** Called after DOM insertion. May return a cleanup function. */\n onMount?(): (() => void) | void;\n\n /** Called before DOM removal. */\n onUnmount?(): void;\n\n /** Catches errors thrown in `onInit` and `onMount`. */\n onError?(err: unknown): void;\n}\n\n// --- Type guard ---\n\n/** @internal */\nexport function isElurComponent(v: unknown): v is ElurComponent {\n return (\n v != null &&\n typeof v === \"object\" &&\n (v as Record<string, unknown>).__isElurComponent === true\n );\n}\n\n// --- Devtools component tracking (internal) ---\n\nexport interface _ComponentDebugHooks {\n onMountStart?: (inst: ElurComponent) => void;\n onMountEnd?: (inst: ElurComponent) => void;\n onUnmount?: (inst: ElurComponent) => void;\n}\n\
|
|
1
|
+
{"version":3,"file":"lifecycle.js","names":[],"sources":["../../src/elur/lifecycle.ts"],"sourcesContent":["import type { ElurTemplate } from \"./template/index.js\";\n\n// --- ElurChildren ---\n\n/** Valid child content for components. */\nexport type ElurChildren =\n | ElurTemplate\n | ElurComponent\n | Array<ElurTemplate | ElurComponent>\n | null\n | undefined;\n\n// --- ElurComponent ---\n\n/** Base class for components with lifecycle hooks. */\nexport abstract class ElurComponent {\n /** @internal */\n readonly __isElurComponent = true as const;\n\n /** Default slot — child content injected by the parent. */\n children?: ElurChildren;\n\n /** Optional label used by devtools. Falls back to class name. */\n _debugName?: string;\n\n /** @internal */\n private _slots = new Map<string, ElurChildren>();\n\n /** Sets the default slot content. Returns `this` for chaining. */\n setChildren(content: ElurChildren): this {\n this.children = content;\n return this;\n }\n\n /** Sets a named slot. Returns `this` for chaining. */\n setSlot(name: string, content: ElurChildren): this {\n this._slots.set(name, content);\n return this;\n }\n\n /** Returns content for a named slot. */\n slot(name: string): ElurChildren {\n return this._slots.get(name);\n }\n\n /** Sets an explicit devtools display name. Returns `this` for chaining. */\n setDebugName(name: string): this {\n this._debugName = name;\n return this;\n }\n\n /** Returns the component template. Called once on mount; updates happen via signals. */\n abstract render(): ElurTemplate;\n\n /** Called before `render()` — no DOM yet. Errors are caught by `onError` if present. */\n onInit?(): void;\n\n /** Server-only lifecycle hook. Runs during SSR after `onInit()`; never on the client. */\n onServerRender?(): void;\n\n /** Called after DOM insertion. May return a cleanup function. */\n onMount?(): (() => void) | void;\n\n /** Called before DOM removal. */\n onUnmount?(): void;\n\n /** Catches errors thrown in `onInit` and `onMount`. */\n onError?(err: unknown): void;\n}\n\n// --- Type guard ---\n\n/** @internal */\nexport function isElurComponent(v: unknown): v is ElurComponent {\n return (\n v != null &&\n typeof v === \"object\" &&\n (v as Record<string, unknown>).__isElurComponent === true\n );\n}\n\n// --- Devtools component tracking (internal) ---\n\nexport interface _ComponentDebugHooks {\n onMountStart?: (inst: ElurComponent) => void;\n onMountEnd?: (inst: ElurComponent) => void;\n onUnmount?: (inst: ElurComponent) => void;\n}\n\n/**\n * The registry lives in the shared reactivity global state\n * (`Symbol.for(\"@elurjs/core/reactivity-state\")`) rather than in module-local\n * state, so hooks work even when the package ends up duplicated in a bundle.\n */\ninterface _ComponentHookState {\n componentDebugHooks?: _ComponentDebugHooks | null;\n componentDebugHookSet?: Set<_ComponentDebugHooks>;\n}\n\nconst _reactivityStateKey = Symbol.for(\"@elurjs/core/reactivity-state\");\n\nfunction _hookState(): _ComponentHookState {\n const g = globalThis as Record<PropertyKey, unknown>;\n let state = g[_reactivityStateKey] as _ComponentHookState | undefined;\n if (!state) {\n // reactivity.ts merges its defaults into this object when it loads.\n state = {};\n g[_reactivityStateKey] = state;\n }\n return state;\n}\n\n/** Single dispatcher on the hot path; the set is only for bookkeeping. */\nfunction _syncComponentDebugHooks(state: _ComponentHookState): void {\n const set = state.componentDebugHookSet;\n if (!set || set.size === 0) {\n state.componentDebugHooks = null;\n return;\n }\n if (set.size === 1) {\n state.componentDebugHooks = set.values().next().value ?? null;\n return;\n }\n state.componentDebugHooks = {\n onMountStart(inst) {\n for (const hooks of set) hooks.onMountStart?.(inst);\n },\n onMountEnd(inst) {\n for (const hooks of set) hooks.onMountEnd?.(inst);\n },\n onUnmount(inst) {\n for (const hooks of set) hooks.onUnmount?.(inst);\n },\n };\n}\n\nexport function _setComponentDebugHooks(hooks: _ComponentDebugHooks | null): void {\n const state = _hookState();\n const set = new Set<_ComponentDebugHooks>();\n if (hooks) set.add(hooks);\n state.componentDebugHookSet = set;\n _syncComponentDebugHooks(state);\n}\n\n/**\n * @internal — Adds a component debug hook subscriber WITHOUT replacing\n * existing ones (unlike `_setComponentDebugHooks`). Returns an unsubscribe\n * function. Zero cost when no subscribers are registered.\n */\nexport function _addComponentDebugHooks(hooks: _ComponentDebugHooks): () => void {\n const state = _hookState();\n let set = state.componentDebugHookSet;\n if (!set) {\n set = new Set<_ComponentDebugHooks>();\n if (state.componentDebugHooks) set.add(state.componentDebugHooks);\n state.componentDebugHookSet = set;\n }\n set.add(hooks);\n _syncComponentDebugHooks(state);\n return () => {\n set.delete(hooks);\n _syncComponentDebugHooks(state);\n };\n}\n\nexport function _debugComponentMountStart(inst: ElurComponent): void {\n _hookState().componentDebugHooks?.onMountStart?.(inst);\n}\n\nexport function _debugComponentMountEnd(inst: ElurComponent): void {\n _hookState().componentDebugHooks?.onMountEnd?.(inst);\n}\n\nexport function _debugComponentUnmount(inst: ElurComponent): void {\n _hookState().componentDebugHooks?.onUnmount?.(inst);\n}\n"],"mappings":";AAeA,IAAsB,IAAtB,MAAoC;CAEhC,oBAA6B;CAG7B;CAGA;CAGA,yBAAiB,IAAI,KAA2B;CAGhD,YAAY,GAA6B;AAErC,SADA,KAAK,WAAW,GACT;;CAIX,QAAQ,GAAc,GAA6B;AAE/C,SADA,KAAK,OAAO,IAAI,GAAM,EAAQ,EACvB;;CAIX,KAAK,GAA4B;AAC7B,SAAO,KAAK,OAAO,IAAI,EAAK;;CAIhC,aAAa,GAAoB;AAE7B,SADA,KAAK,aAAa,GACX;;;AAyBf,SAAgB,EAAgB,GAAgC;AAC5D,QAEI,OAAO,KAAM,cADb,KAEC,EAA8B,sBAAsB;;AAsB7D,IAAM,IAAsB,OAAO,IAAI,gCAAgC;AAEvE,SAAS,IAAkC;CACvC,IAAM,IAAI,YACN,IAAQ,EAAE;AAMd,QALK,MAED,IAAQ,EAAE,EACV,EAAE,KAAuB,IAEtB;;AAIX,SAAS,EAAyB,GAAkC;CAChE,IAAM,IAAM,EAAM;AAClB,KAAI,CAAC,KAAO,EAAI,SAAS,GAAG;AACxB,IAAM,sBAAsB;AAC5B;;AAEJ,KAAI,EAAI,SAAS,GAAG;AAChB,IAAM,sBAAsB,EAAI,QAAQ,CAAC,MAAM,CAAC,SAAS;AACzD;;AAEJ,GAAM,sBAAsB;EACxB,aAAa,GAAM;AACf,QAAK,IAAM,KAAS,EAAK,GAAM,eAAe,EAAK;;EAEvD,WAAW,GAAM;AACb,QAAK,IAAM,KAAS,EAAK,GAAM,aAAa,EAAK;;EAErD,UAAU,GAAM;AACZ,QAAK,IAAM,KAAS,EAAK,GAAM,YAAY,EAAK;;EAEvD;;AAGL,SAAgB,EAAwB,GAA0C;CAC9E,IAAM,IAAQ,GAAY,EACpB,oBAAM,IAAI,KAA2B;AAG3C,CAFI,KAAO,EAAI,IAAI,EAAM,EACzB,EAAM,wBAAwB,GAC9B,EAAyB,EAAM;;AAQnC,SAAgB,EAAwB,GAAyC;CAC7E,IAAM,IAAQ,GAAY,EACtB,IAAM,EAAM;AAQhB,QAPK,MACD,oBAAM,IAAI,KAA2B,EACjC,EAAM,uBAAqB,EAAI,IAAI,EAAM,oBAAoB,EACjE,EAAM,wBAAwB,IAElC,EAAI,IAAI,EAAM,EACd,EAAyB,EAAM,QAClB;AAET,EADA,EAAI,OAAO,EAAM,EACjB,EAAyB,EAAM;;;AAIvC,SAAgB,EAA0B,GAA2B;AACjE,IAAY,CAAC,qBAAqB,eAAe,EAAK;;AAG1D,SAAgB,EAAwB,GAA2B;AAC/D,IAAY,CAAC,qBAAqB,aAAa,EAAK;;AAGxD,SAAgB,EAAuB,GAA2B;AAC9D,IAAY,CAAC,qBAAqB,YAAY,EAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(){return{ctxPool:[],ctxStack:[],activeEffect:null,activeDeps:null,activeErrorHandler:null,errorHandlerStack:[],batchLevel:0,pendingEffectsSet:new Set,pendingEffectsArr:[],effectDepth:0,notifyBuf:[],notifyBase:0,signalDebugHooks:null}}var t=Symbol.for(`@elurjs/core/reactivity-state`),n=globalThis,r=(()=>{let r=n[t];if(r)
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(){return{ctxPool:[],ctxStack:[],activeEffect:null,activeDeps:null,activeErrorHandler:null,errorHandlerStack:[],batchLevel:0,pendingEffectsSet:new Set,pendingEffectsArr:[],effectDepth:0,notifyBuf:[],notifyBase:0,signalDebugHooks:null}}var t=Symbol.for(`@elurjs/core/reactivity-state`),n=globalThis,r=(()=>{let r=n[t];if(r){let t=e(),n=r;for(let e of Object.keys(t))e in n||(n[e]=t[e]);return r}let i=e();return n[t]=i,i})();function i(e){r.errorHandlerStack.push(r.activeErrorHandler),r.activeErrorHandler=e}function a(){r.activeErrorHandler=r.errorHandlerStack.pop()??null}var o=100,s=64,c=16,l=32;function u(){let e=r.signalDebugHookSet;if(!e||e.size===0){r.signalDebugHooks=null;return}if(e.size===1){r.signalDebugHooks=e.values().next().value??null;return}r.signalDebugHooks={onCreate(t,n){for(let r of e)r.onCreate?.(t,n)},onWrite(t,n){for(let r of e)r.onWrite?.(t,n)}}}function d(e){let t=new Set;e&&t.add(e),r.signalDebugHookSet=t,u()}function f(e){let t=r.signalDebugHookSet;return t||(t=new Set,r.signalDebugHooks&&t.add(r.signalDebugHooks),r.signalDebugHookSet=t),t.add(e),u(),()=>{t.delete(e),u()}}function p(){return r.notifyBuf.length}var m=class{_value;_subs=new Set;constructor(e){this._value=e,r.signalDebugHooks?.onCreate?.(this,e)}get value(){return r.activeEffect&&(this._subs.add(r.activeEffect),r.activeDeps?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,r.signalDebugHooks?.onWrite?.(this,e),this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(r.batchLevel>0){for(let e of this._subs)r.pendingEffectsSet.has(e)||(r.pendingEffectsSet.add(e),r.pendingEffectsArr.push(e));return}let e=r.notifyBase,t=0;for(let n of this._subs)r.notifyBuf[e+ t++]=n;r.notifyBase=e+t;try{for(let n=0;n<t;n++){let t=r.notifyBuf[e+n];r.notifyBuf[e+n]=null,t?.()}}finally{r.notifyBase=e,e===0&&r.notifyBuf.length>s&&t<c&&(r.notifyBuf.length=l)}}dispose(){this._subs.clear()}};function h(e){return new m(e)}function g(e){let t=!1,n,i=new Set,a=new Set,s=r.activeErrorHandler,c=()=>{if(t)return;typeof n==`function`&&n();let l=i;i=a,a=l,a.clear();let u=r.ctxPool.length>0?r.ctxPool.pop():{effect:null,deps:null};if(u.effect=r.activeEffect,u.deps=r.activeDeps,r.ctxStack.push(u),r.activeEffect=c,r.activeDeps=a,r.effectDepth++,r.effectDepth>o){r.effectDepth=0;let e=r.ctxStack.pop();throw r.activeEffect=e.effect,r.activeDeps=e.deps,e.effect=null,e.deps=null,r.ctxPool.push(e),Error(`[elur] Maximum effect re-execution depth exceeded (possible infinite loop).`)}try{n=e()}catch(e){if(s)s(e);else throw e}finally{r.effectDepth--;let e=r.ctxStack.pop();r.activeEffect=e.effect,r.activeDeps=e.deps,e.effect=null,e.deps=null,r.ctxPool.push(e);for(let e of i)a.has(e)||e._removeSub(c)}};return c(),()=>{t=!0,typeof n==`function`&&n();for(let e of a)e._removeSub(c);a.clear(),i.clear()}}var _=Symbol(`elur-computed-uninitialized`);function v(e,t=Object.is){let n=new m(_),r=null,i=!1,a=!1,o=()=>{i||a||(i=!0,b(()=>{r=g(()=>{let r=e(),i=n.peek();(i===_||!t(r,i))&&(n.value=r)})}))},s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n),`value`);if(!s?.get||!s?.set)throw Error(`[elur] Internal error: Signal.value descriptor not found.`);Object.defineProperty(n,`value`,{get(){return o(),s.get.call(this)},set(e){s.set.call(this,e)},configurable:!0});let c=n.dispose;return n.dispose=()=>{a=!0,r?.(),r=null,c.call(n)},n}function y(e){r.batchLevel++;try{e()}finally{if(r.batchLevel--,r.batchLevel===0&&r.pendingEffectsArr.length>0){let e=r.pendingEffectsArr.length;for(let t=0;t<e;t++)r.pendingEffectsArr[t]();r.pendingEffectsArr.length=0,r.pendingEffectsSet.clear()}}}function b(e){let t=r.activeEffect,n=r.activeDeps;r.activeEffect=null,r.activeDeps=null;try{return e()}finally{r.activeEffect=t,r.activeDeps=n}}function x(e,t,n={}){let{immediate:r=!1,once:i=!1}=n,a=e instanceof m?()=>e.value:e,o,s=!0,c=!1,l=g(()=>{let e=a();if(s){if(s=!1,r&&!c){let n=e;b(()=>t(n,void 0)),i&&(c=!0,Promise.resolve().then(l))}o=e;return}if(!c){let n=e,r=o;o=e,b(()=>t(n,r)),i&&(c=!0,Promise.resolve().then(l))}});return()=>{c=!0,l()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}exports.Signal=m,exports._addSignalDebugHooks=f,exports._getNotifyBufSize=p,exports._popErrorHandler=a,exports._pushErrorHandler=i,exports._setSignalDebugHooks=d,exports.batch=y,exports.computed=v,exports.effect=g,exports.nextTick=S,exports.signal=h,exports.untrack=b,exports.watch=x;
|
|
2
2
|
//# sourceMappingURL=signals.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.cjs","names":[],"sources":["../../src/elur/reactivity.ts"],"sourcesContent":["// --- Dependency tracking ---\n\ninterface _EffectCtx {\n effect: (() => void) | null;\n deps: Set<Signal<any>> | null;\n}\n\ninterface _ReactivityGlobalState {\n ctxPool: _EffectCtx[];\n ctxStack: _EffectCtx[];\n activeEffect: (() => void) | null;\n activeDeps: Set<Signal<any>> | null;\n activeErrorHandler: ((err: unknown) => void) | null;\n errorHandlerStack: (((err: unknown) => void) | null)[];\n batchLevel: number;\n pendingEffectsSet: Set<() => void>;\n pendingEffectsArr: (() => void)[];\n effectDepth: number;\n notifyBuf: ((() => void) | null)[];\n notifyBase: number;\n signalDebugHooks: _SignalDebugHooks | null;\n}\n\nfunction _createReactivityState(): _ReactivityGlobalState {\n return {\n ctxPool: [],\n ctxStack: [],\n activeEffect: null,\n activeDeps: null,\n activeErrorHandler: null,\n errorHandlerStack: [],\n batchLevel: 0,\n pendingEffectsSet: new Set<() => void>(),\n pendingEffectsArr: [],\n effectDepth: 0,\n notifyBuf: [],\n notifyBase: 0,\n signalDebugHooks: null,\n };\n}\n\nconst _reactivityStateKey = Symbol.for(\"@elurjs/core/reactivity-state\");\nconst _globalObj = globalThis as Record<PropertyKey, unknown>;\nconst _state = (() => {\n const existing = _globalObj[_reactivityStateKey] as _ReactivityGlobalState | undefined;\n if (existing) return existing;\n const created = _createReactivityState();\n _globalObj[_reactivityStateKey] = created;\n return created;\n})();\n\n// --- Error boundary support ---\n\n/**\n * @internal — Register an error boundary handler. All `effect()` calls made\n * synchronously while this handler is active will capture it. When those\n * effects re-run and throw, the captured handler is invoked.\n */\nexport function _pushErrorHandler(h: (err: unknown) => void): void {\n _state.errorHandlerStack.push(_state.activeErrorHandler);\n _state.activeErrorHandler = h;\n}\n\n/** @internal — Restore the previous error boundary handler. */\nexport function _popErrorHandler(): void {\n _state.activeErrorHandler = _state.errorHandlerStack.pop() ?? null;\n}\n\n// --- Batching ---\n\n/**\n * Guards against synchronous effect re-entrancy.\n *\n * Effects re-run synchronously when a signal they depend on changes. If an\n * effect writes to a signal it also reads, this creates a synchronous loop.\n * The guard below caps re-execution at MAX_EFFECT_DEPTH (100) iterations and\n * throws an error to prevent stack overflow.\n *\n * Throwing is deliberate: when the guard fires, the reactive graph is in an\n * inconsistent state — the effect partially executed, dependencies may be\n * stale, and continuing could produce incorrect UI. Throwing surfaces the\n * bug immediately instead of silently degrading.\n *\n * To avoid re-entrancy:\n * 1. Use `computed()` for derived state — computed signals cache their result\n * and only recompute when dependencies change. They never write to other\n * signals, so they can't loop.\n * 2. Use `watch()` for side effects — watch callbacks receive the new value;\n * if you need to update other signals, do it inside `batch()` to coalesce\n * notifications.\n * 3. Never write to a signal you read in the same effect — this is the direct\n * cause of re-entrancy. If you need to transform a value, use `computed()`\n * instead.\n * 4. Use `batch()` to group writes — batched writes flush once at the end,\n * preventing intermediate re-runs.\n */\n\nconst MAX_EFFECT_DEPTH = 100;\nconst _NOTIFY_SHRINK_TRIGGER = 64;\nconst _NOTIFY_LOW_USAGE = 16;\nconst _NOTIFY_SHRINK_TO = 32;\n\nexport interface _SignalDebugHooks {\n onCreate?: (signal: Signal<any>, initialValue: unknown) => void;\n onWrite?: (signal: Signal<any>, value: unknown) => void;\n}\n\nexport function _setSignalDebugHooks(hooks: _SignalDebugHooks | null): void {\n _state.signalDebugHooks = hooks;\n}\n\n/** @internal — notify buffer capacity, exposed for tests. */\nexport function _getNotifyBufSize(): number {\n return _state.notifyBuf.length;\n}\n\n// --- Signal ---\n\nexport class Signal<T> {\n private _value: T;\n private _subs = new Set<() => void>();\n\n constructor(initialValue: T) {\n this._value = initialValue;\n _state.signalDebugHooks?.onCreate?.(this, initialValue);\n }\n\n /** Read the current value. Subscribes the active effect if one exists. */\n get value(): T {\n if (_state.activeEffect) {\n this._subs.add(_state.activeEffect);\n _state.activeDeps?.add(this);\n }\n return this._value;\n }\n\n /** Write a new value. Notifies subscribers when the value changes. */\n set value(newValue: T) {\n if (Object.is(this._value, newValue)) return;\n this._value = newValue;\n _state.signalDebugHooks?.onWrite?.(this, newValue);\n this._notify();\n }\n\n /** Mutate the value via a updater function. */\n update(fn: (current: T) => T): void {\n this.value = fn(this._value);\n }\n\n /** Read without subscribing the active effect. */\n peek(): T {\n return this._value;\n }\n\n /** @internal */\n _removeSub(sub: () => void): void {\n this._subs.delete(sub);\n }\n\n private _notify(): void {\n if (_state.batchLevel > 0) {\n for (const s of this._subs) {\n if (!_state.pendingEffectsSet.has(s)) {\n _state.pendingEffectsSet.add(s);\n _state.pendingEffectsArr.push(s);\n }\n }\n return;\n }\n const base = _state.notifyBase;\n let len = 0;\n for (const s of this._subs) _state.notifyBuf[base + len++] = s;\n _state.notifyBase = base + len;\n try {\n for (let i = 0; i < len; i++) {\n const fn = _state.notifyBuf[base + i];\n _state.notifyBuf[base + i] = null!;\n fn?.();\n }\n } finally {\n _state.notifyBase = base;\n // Shrink oversized notify buffer after a low-usage top-level flush.\n if (\n base === 0 &&\n _state.notifyBuf.length > _NOTIFY_SHRINK_TRIGGER &&\n len < _NOTIFY_LOW_USAGE\n ) {\n _state.notifyBuf.length = _NOTIFY_SHRINK_TO;\n }\n }\n }\n\n dispose(): void {\n this._subs.clear();\n }\n}\n\n// --- Factories ---\n\nexport function signal<T>(initialValue: T): Signal<T> {\n return new Signal(initialValue);\n}\n\n/**\n * Runs `fn` and re-runs it whenever any signal read inside changes.\n * Returns a dispose function to tear down the effect.\n * If `fn` returns a function, it is called as cleanup before each re-run\n * and on disposal.\n */\nexport function effect(fn: () => void | (() => void)): () => void {\n let disposed = false;\n let cleanup: (() => void) | void;\n\n // Opt: Double buffering para evitar crear `new Set()` en cada ejecución\n let deps = new Set<Signal<any>>();\n let newDeps = new Set<Signal<any>>();\n\n const capturedErrorHandler = _state.activeErrorHandler;\n\n const execute = () => {\n if (disposed) return;\n if (typeof cleanup === \"function\") cleanup();\n\n // Intercambiamos los buffers. 'deps' ahora tiene los viejos, 'newDeps' está limpio para recolectar.\n const temp = deps;\n deps = newDeps;\n newDeps = temp;\n newDeps.clear();\n\n const ctx = _state.ctxPool.length > 0 ? _state.ctxPool.pop()! : { effect: null, deps: null };\n ctx.effect = _state.activeEffect;\n ctx.deps = _state.activeDeps;\n _state.ctxStack.push(ctx);\n _state.activeEffect = execute;\n _state.activeDeps = newDeps;\n\n _state.effectDepth++;\n if (_state.effectDepth > MAX_EFFECT_DEPTH) {\n _state.effectDepth = 0;\n // Restaurar desde el stack unificado\n const restored = _state.ctxStack.pop()!;\n _state.activeEffect = restored.effect;\n _state.activeDeps = restored.deps;\n restored.effect = null;\n restored.deps = null;\n _state.ctxPool.push(restored);\n throw new Error(\n \"[elur] Maximum effect re-execution depth exceeded (possible infinite loop).\"\n );\n }\n\n try {\n cleanup = fn();\n } catch (err) {\n if (capturedErrorHandler) {\n capturedErrorHandler(err);\n } else {\n throw err;\n }\n } finally {\n _state.effectDepth--;\n const restored = _state.ctxStack.pop()!;\n _state.activeEffect = restored.effect;\n _state.activeDeps = restored.deps;\n restored.effect = null; // limpiar referencias para GC\n restored.deps = null;\n _state.ctxPool.push(restored); // devolver al pool para reutilizar\n\n\n // Cleanup phase: Desuscribirse de señales que estaban en 'deps' pero NO en 'newDeps'\n for (const oldDep of deps) {\n if (!newDeps.has(oldDep)) {\n oldDep._removeSub(execute);\n }\n }\n }\n };\n\n execute();\n\n return () => {\n disposed = true;\n if (typeof cleanup === \"function\") cleanup();\n // Al desechar, usamos newDeps porque es el que quedó activo después del último execute\n for (const dep of newDeps) {\n dep._removeSub(execute);\n }\n newDeps.clear();\n deps.clear();\n };\n}\n\n/** Derived signal that recalculates when its dependencies change. */\nconst _computedSentinel = Symbol(\"elur-computed-uninitialized\");\n\nexport function computed<T>(\n fn: () => T,\n equals: (a: T, b: T) => boolean = Object.is,\n): Signal<T> & { dispose(): void } {\n const s = new Signal<T | typeof _computedSentinel>(_computedSentinel);\n let disposeEffect: (() => void) | null = null;\n let initialized = false;\n let disposed = false;\n\n const ensureInitialized = () => {\n if (initialized || disposed) return;\n initialized = true;\n // Important: initialize untracked so first computed evaluation does not\n // accidentally subscribe the currently running external effect.\n untrack(() => {\n disposeEffect = effect(() => {\n const next = fn();\n const prev = s.peek();\n // The first computed value must always be written; afterwards use\n // the supplied equality comparator (defaults to Object.is).\n if (prev === _computedSentinel || !equals(next, prev)) {\n s.value = next;\n }\n });\n });\n };\n\n const signalProto = Object.getPrototypeOf(s) as Signal<T>;\n const valueDescriptor = Object.getOwnPropertyDescriptor(signalProto, \"value\");\n if (!valueDescriptor?.get || !valueDescriptor?.set) {\n throw new Error(\"[elur] Internal error: Signal.value descriptor not found.\");\n }\n\n Object.defineProperty(s, \"value\", {\n get() {\n ensureInitialized();\n return valueDescriptor.get!.call(this) as T;\n },\n set(v: T) {\n valueDescriptor.set!.call(this, v);\n },\n configurable: true,\n });\n\n const originalDispose = s.dispose;\n\n s.dispose = () => {\n disposed = true;\n disposeEffect?.();\n disposeEffect = null;\n originalDispose.call(s); // Opt: Evitar el uso lento de .bind()\n };\n return s as Signal<T> & { dispose(): void };\n}\n\n/** Groups multiple signal writes so effects flush once at the end. */\nexport function batch(fn: () => void): void {\n _state.batchLevel++;\n try {\n fn();\n } finally {\n _state.batchLevel--;\n if (_state.batchLevel === 0 && _state.pendingEffectsArr.length > 0) {\n const len = _state.pendingEffectsArr.length;\n for (let i = 0; i < len; i++) _state.pendingEffectsArr[i]();\n _state.pendingEffectsArr.length = 0; // reset O(1) sin GC — key del cambio\n _state.pendingEffectsSet.clear();\n }\n }\n}\n\n/** Executes `fn` without subscribing to any signals read inside it. */\nexport function untrack<T>(fn: () => T): T {\n const prevEffect = _state.activeEffect;\n const prevDeps = _state.activeDeps;\n _state.activeEffect = null;\n _state.activeDeps = null;\n try {\n return fn();\n } finally {\n _state.activeEffect = prevEffect;\n _state.activeDeps = prevDeps;\n }\n}\n\n// --- watch ---\n\nexport interface WatchOptions {\n /** Fire the callback immediately with the current value. Default: `false`. */\n immediate?: boolean;\n /** Automatically dispose after the first callback invocation. Default: `false`. */\n once?: boolean;\n}\n\n/**\n * Watches a reactive source and calls `callback(newValue, oldValue)` on each change.\n * Accepts a Signal or a getter function. Returns a dispose function.\n */\nexport function watch<T>(\n source: Signal<T> | (() => T),\n callback: (newValue: T, oldValue: T | undefined) => void,\n options: WatchOptions = {}\n): () => void {\n const { immediate = false, once = false } = options;\n\n const getter: () => T =\n source instanceof Signal ? () => source.value : source;\n\n let oldValue: T | undefined;\n let isFirst = true;\n let disposed = false;\n\n const dispose = effect(() => {\n const newValue = getter();\n\n if (isFirst) {\n isFirst = false;\n if (immediate && !disposed) {\n const snap = newValue;\n untrack(() => callback(snap, undefined));\n if (once) { disposed = true; Promise.resolve().then(dispose); }\n }\n oldValue = newValue;\n return;\n }\n\n if (!disposed) {\n const snap = newValue;\n const prev = oldValue;\n oldValue = newValue;\n untrack(() => callback(snap, prev));\n if (once) { disposed = true; Promise.resolve().then(dispose); }\n }\n });\n\n return () => {\n disposed = true;\n dispose();\n };\n}\n\n// --- nextTick ---\n\n/** Returns a promise that resolves on the next microtask. Accepts an optional callback. */\nexport function nextTick(fn?: () => void): Promise<void> {\n return fn ? Promise.resolve().then(fn) : Promise.resolve();\n}"],"mappings":"mEAuBA,SAAS,GAAiD,CACtD,MAAO,CACH,QAAS,EAAE,CACX,SAAU,EAAE,CACZ,aAAc,KACd,WAAY,KACZ,mBAAoB,KACpB,kBAAmB,EAAE,CACrB,WAAY,EACZ,kBAAmB,IAAI,IACvB,kBAAmB,EAAE,CACrB,YAAa,EACb,UAAW,EAAE,CACb,WAAY,EACZ,iBAAkB,KACrB,CAGL,IAAM,EAAsB,OAAO,IAAI,gCAAgC,CACjE,EAAa,WACb,OAAgB,CAClB,IAAM,EAAW,EAAW,GAC5B,GAAI,EAAU,OAAO,EACrB,IAAM,EAAU,GAAwB,CAExC,MADA,GAAW,GAAuB,EAC3B,KACP,CASJ,SAAgB,EAAkB,EAAiC,CAC/D,EAAO,kBAAkB,KAAK,EAAO,mBAAmB,CACxD,EAAO,mBAAqB,EAIhC,SAAgB,GAAyB,CACrC,EAAO,mBAAqB,EAAO,kBAAkB,KAAK,EAAI,KAgClE,IAAM,EAAmB,IACnB,EAAyB,GACzB,EAAoB,GACpB,EAAoB,GAO1B,SAAgB,EAAqB,EAAuC,CACxE,EAAO,iBAAmB,EAI9B,SAAgB,GAA4B,CACxC,OAAO,EAAO,UAAU,OAK5B,IAAa,EAAb,KAAuB,CACnB,OACA,MAAgB,IAAI,IAEpB,YAAY,EAAiB,CACzB,KAAK,OAAS,EACd,EAAO,kBAAkB,WAAW,KAAM,EAAa,CAI3D,IAAI,OAAW,CAKX,OAJI,EAAO,eACP,KAAK,MAAM,IAAI,EAAO,aAAa,CACnC,EAAO,YAAY,IAAI,KAAK,EAEzB,KAAK,OAIhB,IAAI,MAAM,EAAa,CACf,OAAO,GAAG,KAAK,OAAQ,EAAS,GACpC,KAAK,OAAS,EACd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AAM,EAAK,CAAC,CAC/B,IAAQ,EAAW,GAAM,QAAQ,SAAS,CAAC,KAAK,EAAQ,IAElE,CAEF,UAAa,CACT,EAAW,GACX,GAAS,EAOjB,SAAgB,EAAS,EAAgC,CACrD,OAAO,EAAK,QAAQ,SAAS,CAAC,KAAK,EAAG,CAAG,QAAQ,SAAS"}
|
|
1
|
+
{"version":3,"file":"signals.cjs","names":[],"sources":["../../src/elur/reactivity.ts"],"sourcesContent":["// --- Dependency tracking ---\n\ninterface _EffectCtx {\n effect: (() => void) | null;\n deps: Set<Signal<any>> | null;\n}\n\ninterface _ReactivityGlobalState {\n ctxPool: _EffectCtx[];\n ctxStack: _EffectCtx[];\n activeEffect: (() => void) | null;\n activeDeps: Set<Signal<any>> | null;\n activeErrorHandler: ((err: unknown) => void) | null;\n errorHandlerStack: (((err: unknown) => void) | null)[];\n batchLevel: number;\n pendingEffectsSet: Set<() => void>;\n pendingEffectsArr: (() => void)[];\n effectDepth: number;\n notifyBuf: ((() => void) | null)[];\n notifyBase: number;\n signalDebugHooks: _SignalDebugHooks | null;\n /**\n * @internal Multi-subscriber registry backing `signalDebugHooks`.\n * The hot path always reads the single `signalDebugHooks` object; this\n * set only exists so devtools-style consumers can coexist.\n */\n signalDebugHookSet?: Set<_SignalDebugHooks>;\n /**\n * @internal Component debug hooks live here (not module-local) so they\n * work across duplicated module instances. Managed by lifecycle.ts.\n */\n componentDebugHooks?: {\n onMountStart?: (inst: unknown) => void;\n onMountEnd?: (inst: unknown) => void;\n onUnmount?: (inst: unknown) => void;\n } | null;\n /** @internal Multi-subscriber registry backing `componentDebugHooks`. */\n componentDebugHookSet?: Set<NonNullable<_ReactivityGlobalState[\"componentDebugHooks\"]>>;\n}\n\nfunction _createReactivityState(): _ReactivityGlobalState {\n return {\n ctxPool: [],\n ctxStack: [],\n activeEffect: null,\n activeDeps: null,\n activeErrorHandler: null,\n errorHandlerStack: [],\n batchLevel: 0,\n pendingEffectsSet: new Set<() => void>(),\n pendingEffectsArr: [],\n effectDepth: 0,\n notifyBuf: [],\n notifyBase: 0,\n signalDebugHooks: null,\n };\n}\n\nconst _reactivityStateKey = Symbol.for(\"@elurjs/core/reactivity-state\");\nconst _globalObj = globalThis as Record<PropertyKey, unknown>;\nconst _state = (() => {\n const existing = _globalObj[_reactivityStateKey] as _ReactivityGlobalState | undefined;\n if (existing) {\n // Another module may have pre-created the state object with only a\n // subset of fields (e.g. lifecycle.ts registering component hooks\n // before this module evaluated). Fill in any missing defaults.\n const defaults = _createReactivityState() as unknown as Record<string, unknown>;\n const target = existing as unknown as Record<string, unknown>;\n for (const key of Object.keys(defaults)) {\n if (!(key in target)) target[key] = defaults[key];\n }\n return existing;\n }\n const created = _createReactivityState();\n _globalObj[_reactivityStateKey] = created;\n return created;\n})();\n\n// --- Error boundary support ---\n\n/**\n * @internal — Register an error boundary handler. All `effect()` calls made\n * synchronously while this handler is active will capture it. When those\n * effects re-run and throw, the captured handler is invoked.\n */\nexport function _pushErrorHandler(h: (err: unknown) => void): void {\n _state.errorHandlerStack.push(_state.activeErrorHandler);\n _state.activeErrorHandler = h;\n}\n\n/** @internal — Restore the previous error boundary handler. */\nexport function _popErrorHandler(): void {\n _state.activeErrorHandler = _state.errorHandlerStack.pop() ?? null;\n}\n\n// --- Batching ---\n\n/**\n * Guards against synchronous effect re-entrancy.\n *\n * Effects re-run synchronously when a signal they depend on changes. If an\n * effect writes to a signal it also reads, this creates a synchronous loop.\n * The guard below caps re-execution at MAX_EFFECT_DEPTH (100) iterations and\n * throws an error to prevent stack overflow.\n *\n * Throwing is deliberate: when the guard fires, the reactive graph is in an\n * inconsistent state — the effect partially executed, dependencies may be\n * stale, and continuing could produce incorrect UI. Throwing surfaces the\n * bug immediately instead of silently degrading.\n *\n * To avoid re-entrancy:\n * 1. Use `computed()` for derived state — computed signals cache their result\n * and only recompute when dependencies change. They never write to other\n * signals, so they can't loop.\n * 2. Use `watch()` for side effects — watch callbacks receive the new value;\n * if you need to update other signals, do it inside `batch()` to coalesce\n * notifications.\n * 3. Never write to a signal you read in the same effect — this is the direct\n * cause of re-entrancy. If you need to transform a value, use `computed()`\n * instead.\n * 4. Use `batch()` to group writes — batched writes flush once at the end,\n * preventing intermediate re-runs.\n */\n\nconst MAX_EFFECT_DEPTH = 100;\nconst _NOTIFY_SHRINK_TRIGGER = 64;\nconst _NOTIFY_LOW_USAGE = 16;\nconst _NOTIFY_SHRINK_TO = 32;\n\nexport interface _SignalDebugHooks {\n onCreate?: (signal: Signal<any>, initialValue: unknown) => void;\n onWrite?: (signal: Signal<any>, value: unknown) => void;\n}\n\n/**\n * Keeps `signalDebugHooks` as a single object on the hot path. Only when\n * more than one subscriber is registered do we install a dispatcher.\n */\nfunction _syncSignalDebugHooks(): void {\n const set = _state.signalDebugHookSet;\n if (!set || set.size === 0) {\n _state.signalDebugHooks = null;\n return;\n }\n if (set.size === 1) {\n _state.signalDebugHooks = set.values().next().value ?? null;\n return;\n }\n _state.signalDebugHooks = {\n onCreate(signal, initialValue) {\n for (const hooks of set) hooks.onCreate?.(signal, initialValue);\n },\n onWrite(signal, value) {\n for (const hooks of set) hooks.onWrite?.(signal, value);\n },\n };\n}\n\nexport function _setSignalDebugHooks(hooks: _SignalDebugHooks | null): void {\n const set = new Set<_SignalDebugHooks>();\n if (hooks) set.add(hooks);\n _state.signalDebugHookSet = set;\n _syncSignalDebugHooks();\n}\n\n/**\n * @internal — Adds a debug hook subscriber WITHOUT replacing existing ones\n * (unlike `_setSignalDebugHooks`). Returns an unsubscribe function.\n * Zero cost when no subscribers are registered: the setter keeps reading a\n * single `signalDebugHooks` object.\n */\nexport function _addSignalDebugHooks(hooks: _SignalDebugHooks): () => void {\n let set = _state.signalDebugHookSet;\n if (!set) {\n set = new Set<_SignalDebugHooks>();\n if (_state.signalDebugHooks) set.add(_state.signalDebugHooks);\n _state.signalDebugHookSet = set;\n }\n set.add(hooks);\n _syncSignalDebugHooks();\n return () => {\n set.delete(hooks);\n _syncSignalDebugHooks();\n };\n}\n\n/** @internal — notify buffer capacity, exposed for tests. */\nexport function _getNotifyBufSize(): number {\n return _state.notifyBuf.length;\n}\n\n// --- Signal ---\n\nexport class Signal<T> {\n private _value: T;\n private _subs = new Set<() => void>();\n\n constructor(initialValue: T) {\n this._value = initialValue;\n _state.signalDebugHooks?.onCreate?.(this, initialValue);\n }\n\n /** Read the current value. Subscribes the active effect if one exists. */\n get value(): T {\n if (_state.activeEffect) {\n this._subs.add(_state.activeEffect);\n _state.activeDeps?.add(this);\n }\n return this._value;\n }\n\n /** Write a new value. Notifies subscribers when the value changes. */\n set value(newValue: T) {\n if (Object.is(this._value, newValue)) return;\n this._value = newValue;\n _state.signalDebugHooks?.onWrite?.(this, newValue);\n this._notify();\n }\n\n /** Mutate the value via a updater function. */\n update(fn: (current: T) => T): void {\n this.value = fn(this._value);\n }\n\n /** Read without subscribing the active effect. */\n peek(): T {\n return this._value;\n }\n\n /** @internal */\n _removeSub(sub: () => void): void {\n this._subs.delete(sub);\n }\n\n private _notify(): void {\n if (_state.batchLevel > 0) {\n for (const s of this._subs) {\n if (!_state.pendingEffectsSet.has(s)) {\n _state.pendingEffectsSet.add(s);\n _state.pendingEffectsArr.push(s);\n }\n }\n return;\n }\n const base = _state.notifyBase;\n let len = 0;\n for (const s of this._subs) _state.notifyBuf[base + len++] = s;\n _state.notifyBase = base + len;\n try {\n for (let i = 0; i < len; i++) {\n const fn = _state.notifyBuf[base + i];\n _state.notifyBuf[base + i] = null!;\n fn?.();\n }\n } finally {\n _state.notifyBase = base;\n // Shrink oversized notify buffer after a low-usage top-level flush.\n if (\n base === 0 &&\n _state.notifyBuf.length > _NOTIFY_SHRINK_TRIGGER &&\n len < _NOTIFY_LOW_USAGE\n ) {\n _state.notifyBuf.length = _NOTIFY_SHRINK_TO;\n }\n }\n }\n\n dispose(): void {\n this._subs.clear();\n }\n}\n\n// --- Factories ---\n\nexport function signal<T>(initialValue: T): Signal<T> {\n return new Signal(initialValue);\n}\n\n/**\n * Runs `fn` and re-runs it whenever any signal read inside changes.\n * Returns a dispose function to tear down the effect.\n * If `fn` returns a function, it is called as cleanup before each re-run\n * and on disposal.\n */\nexport function effect(fn: () => void | (() => void)): () => void {\n let disposed = false;\n let cleanup: (() => void) | void;\n\n // Opt: Double buffering para evitar crear `new Set()` en cada ejecución\n let deps = new Set<Signal<any>>();\n let newDeps = new Set<Signal<any>>();\n\n const capturedErrorHandler = _state.activeErrorHandler;\n\n const execute = () => {\n if (disposed) return;\n if (typeof cleanup === \"function\") cleanup();\n\n // Intercambiamos los buffers. 'deps' ahora tiene los viejos, 'newDeps' está limpio para recolectar.\n const temp = deps;\n deps = newDeps;\n newDeps = temp;\n newDeps.clear();\n\n const ctx = _state.ctxPool.length > 0 ? _state.ctxPool.pop()! : { effect: null, deps: null };\n ctx.effect = _state.activeEffect;\n ctx.deps = _state.activeDeps;\n _state.ctxStack.push(ctx);\n _state.activeEffect = execute;\n _state.activeDeps = newDeps;\n\n _state.effectDepth++;\n if (_state.effectDepth > MAX_EFFECT_DEPTH) {\n _state.effectDepth = 0;\n // Restaurar desde el stack unificado\n const restored = _state.ctxStack.pop()!;\n _state.activeEffect = restored.effect;\n _state.activeDeps = restored.deps;\n restored.effect = null;\n restored.deps = null;\n _state.ctxPool.push(restored);\n throw new Error(\n \"[elur] Maximum effect re-execution depth exceeded (possible infinite loop).\"\n );\n }\n\n try {\n cleanup = fn();\n } catch (err) {\n if (capturedErrorHandler) {\n capturedErrorHandler(err);\n } else {\n throw err;\n }\n } finally {\n _state.effectDepth--;\n const restored = _state.ctxStack.pop()!;\n _state.activeEffect = restored.effect;\n _state.activeDeps = restored.deps;\n restored.effect = null; // limpiar referencias para GC\n restored.deps = null;\n _state.ctxPool.push(restored); // devolver al pool para reutilizar\n\n\n // Cleanup phase: Desuscribirse de señales que estaban en 'deps' pero NO en 'newDeps'\n for (const oldDep of deps) {\n if (!newDeps.has(oldDep)) {\n oldDep._removeSub(execute);\n }\n }\n }\n };\n\n execute();\n\n return () => {\n disposed = true;\n if (typeof cleanup === \"function\") cleanup();\n // Al desechar, usamos newDeps porque es el que quedó activo después del último execute\n for (const dep of newDeps) {\n dep._removeSub(execute);\n }\n newDeps.clear();\n deps.clear();\n };\n}\n\n/** Derived signal that recalculates when its dependencies change. */\nconst _computedSentinel = Symbol(\"elur-computed-uninitialized\");\n\nexport function computed<T>(\n fn: () => T,\n equals: (a: T, b: T) => boolean = Object.is,\n): Signal<T> & { dispose(): void } {\n const s = new Signal<T | typeof _computedSentinel>(_computedSentinel);\n let disposeEffect: (() => void) | null = null;\n let initialized = false;\n let disposed = false;\n\n const ensureInitialized = () => {\n if (initialized || disposed) return;\n initialized = true;\n // Important: initialize untracked so first computed evaluation does not\n // accidentally subscribe the currently running external effect.\n untrack(() => {\n disposeEffect = effect(() => {\n const next = fn();\n const prev = s.peek();\n // The first computed value must always be written; afterwards use\n // the supplied equality comparator (defaults to Object.is).\n if (prev === _computedSentinel || !equals(next, prev)) {\n s.value = next;\n }\n });\n });\n };\n\n const signalProto = Object.getPrototypeOf(s) as Signal<T>;\n const valueDescriptor = Object.getOwnPropertyDescriptor(signalProto, \"value\");\n if (!valueDescriptor?.get || !valueDescriptor?.set) {\n throw new Error(\"[elur] Internal error: Signal.value descriptor not found.\");\n }\n\n Object.defineProperty(s, \"value\", {\n get() {\n ensureInitialized();\n return valueDescriptor.get!.call(this) as T;\n },\n set(v: T) {\n valueDescriptor.set!.call(this, v);\n },\n configurable: true,\n });\n\n const originalDispose = s.dispose;\n\n s.dispose = () => {\n disposed = true;\n disposeEffect?.();\n disposeEffect = null;\n originalDispose.call(s); // Opt: Evitar el uso lento de .bind()\n };\n return s as Signal<T> & { dispose(): void };\n}\n\n/** Groups multiple signal writes so effects flush once at the end. */\nexport function batch(fn: () => void): void {\n _state.batchLevel++;\n try {\n fn();\n } finally {\n _state.batchLevel--;\n if (_state.batchLevel === 0 && _state.pendingEffectsArr.length > 0) {\n const len = _state.pendingEffectsArr.length;\n for (let i = 0; i < len; i++) _state.pendingEffectsArr[i]();\n _state.pendingEffectsArr.length = 0; // reset O(1) sin GC — key del cambio\n _state.pendingEffectsSet.clear();\n }\n }\n}\n\n/** Executes `fn` without subscribing to any signals read inside it. */\nexport function untrack<T>(fn: () => T): T {\n const prevEffect = _state.activeEffect;\n const prevDeps = _state.activeDeps;\n _state.activeEffect = null;\n _state.activeDeps = null;\n try {\n return fn();\n } finally {\n _state.activeEffect = prevEffect;\n _state.activeDeps = prevDeps;\n }\n}\n\n// --- watch ---\n\nexport interface WatchOptions {\n /** Fire the callback immediately with the current value. Default: `false`. */\n immediate?: boolean;\n /** Automatically dispose after the first callback invocation. Default: `false`. */\n once?: boolean;\n}\n\n/**\n * Watches a reactive source and calls `callback(newValue, oldValue)` on each change.\n * Accepts a Signal or a getter function. Returns a dispose function.\n */\nexport function watch<T>(\n source: Signal<T> | (() => T),\n callback: (newValue: T, oldValue: T | undefined) => void,\n options: WatchOptions = {}\n): () => void {\n const { immediate = false, once = false } = options;\n\n const getter: () => T =\n source instanceof Signal ? () => source.value : source;\n\n let oldValue: T | undefined;\n let isFirst = true;\n let disposed = false;\n\n const dispose = effect(() => {\n const newValue = getter();\n\n if (isFirst) {\n isFirst = false;\n if (immediate && !disposed) {\n const snap = newValue;\n untrack(() => callback(snap, undefined));\n if (once) { disposed = true; Promise.resolve().then(dispose); }\n }\n oldValue = newValue;\n return;\n }\n\n if (!disposed) {\n const snap = newValue;\n const prev = oldValue;\n oldValue = newValue;\n untrack(() => callback(snap, prev));\n if (once) { disposed = true; Promise.resolve().then(dispose); }\n }\n });\n\n return () => {\n disposed = true;\n dispose();\n };\n}\n\n// --- nextTick ---\n\n/** Returns a promise that resolves on the next microtask. Accepts an optional callback. */\nexport function nextTick(fn?: () => void): Promise<void> {\n return fn ? Promise.resolve().then(fn) : Promise.resolve();\n}"],"mappings":"mEAwCA,SAAS,GAAiD,CACtD,MAAO,CACH,QAAS,EAAE,CACX,SAAU,EAAE,CACZ,aAAc,KACd,WAAY,KACZ,mB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,KACpB,GAAI,CACA,OAAO,GAAI,QACL,CACN,EAAO,aAAe,EACtB,EAAO,WAAa,GAiB5B,SAAgB,EACZ,EACA,EACA,EAAwB,EAAE,CAChB,CACV,GAAM,CAAE,YAAY,GAAO,OAAO,IAAU,EAEtC,EACF,aAAkB,MAAe,EAAO,MAAQ,EAEhD,EACA,EAAU,GACV,EAAW,GAET,EAAU,MAAa,CACzB,IAAM,EAAW,GAAQ,CAEzB,GAAI,EAAS,CAET,GADA,EAAU,GACN,GAAa,CAAC,EAAU,CACxB,IAAM,EAAO,EACb,MAAc,EAAS,EAAM,IAAA,GAAU,CAAC,CACpC,IAAQ,EAAW,GAAM,QAAQ,SAAS,CAAC,KAAK,EAAQ,EAEhE,EAAW,EACX,OAGJ,GAAI,CAAC,EAAU,CACX,IAAM,EAAO,EACP,EAAO,EACb,EAAW,EACX,MAAc,EAAS,EAAM,EAAK,CAAC,CAC/B,IAAQ,EAAW,GAAM,QAAQ,SAAS,CAAC,KAAK,EAAQ,IAElE,CAEF,UAAa,CACT,EAAW,GACX,GAAS,EAOjB,SAAgB,EAAS,EAAgC,CACrD,OAAO,EAAK,QAAQ,SAAS,CAAC,KAAK,EAAG,CAAG,QAAQ,SAAS"}
|
|
@@ -11,6 +11,13 @@ export interface _SignalDebugHooks {
|
|
|
11
11
|
onWrite?: (signal: Signal<any>, value: unknown) => void;
|
|
12
12
|
}
|
|
13
13
|
export declare function _setSignalDebugHooks(hooks: _SignalDebugHooks | null): void;
|
|
14
|
+
/**
|
|
15
|
+
* @internal — Adds a debug hook subscriber WITHOUT replacing existing ones
|
|
16
|
+
* (unlike `_setSignalDebugHooks`). Returns an unsubscribe function.
|
|
17
|
+
* Zero cost when no subscribers are registered: the setter keeps reading a
|
|
18
|
+
* single `signalDebugHooks` object.
|
|
19
|
+
*/
|
|
20
|
+
export declare function _addSignalDebugHooks(hooks: _SignalDebugHooks): () => void;
|
|
14
21
|
/** @internal — notify buffer capacity, exposed for tests. */
|
|
15
22
|
export declare function _getNotifyBufSize(): number;
|
|
16
23
|
export declare class Signal<T> {
|
|
@@ -11,6 +11,13 @@ export interface _SignalDebugHooks {
|
|
|
11
11
|
onWrite?: (signal: Signal<any>, value: unknown) => void;
|
|
12
12
|
}
|
|
13
13
|
export declare function _setSignalDebugHooks(hooks: _SignalDebugHooks | null): void;
|
|
14
|
+
/**
|
|
15
|
+
* @internal — Adds a debug hook subscriber WITHOUT replacing existing ones
|
|
16
|
+
* (unlike `_setSignalDebugHooks`). Returns an unsubscribe function.
|
|
17
|
+
* Zero cost when no subscribers are registered: the setter keeps reading a
|
|
18
|
+
* single `signalDebugHooks` object.
|
|
19
|
+
*/
|
|
20
|
+
export declare function _addSignalDebugHooks(hooks: _SignalDebugHooks): () => void;
|
|
14
21
|
/** @internal — notify buffer capacity, exposed for tests. */
|
|
15
22
|
export declare function _getNotifyBufSize(): number;
|
|
16
23
|
export declare class Signal<T> {
|
|
@@ -18,7 +18,11 @@ function e() {
|
|
|
18
18
|
}
|
|
19
19
|
var t = Symbol.for("@elurjs/core/reactivity-state"), n = globalThis, r = (() => {
|
|
20
20
|
let r = n[t];
|
|
21
|
-
if (r)
|
|
21
|
+
if (r) {
|
|
22
|
+
let t = e(), n = r;
|
|
23
|
+
for (let e of Object.keys(t)) e in n || (n[e] = t[e]);
|
|
24
|
+
return r;
|
|
25
|
+
}
|
|
22
26
|
let i = e();
|
|
23
27
|
return n[t] = i, i;
|
|
24
28
|
})();
|
|
@@ -29,13 +33,39 @@ function a() {
|
|
|
29
33
|
r.activeErrorHandler = r.errorHandlerStack.pop() ?? null;
|
|
30
34
|
}
|
|
31
35
|
var o = 100, s = 64, c = 16, l = 32;
|
|
32
|
-
function u(
|
|
33
|
-
|
|
36
|
+
function u() {
|
|
37
|
+
let e = r.signalDebugHookSet;
|
|
38
|
+
if (!e || e.size === 0) {
|
|
39
|
+
r.signalDebugHooks = null;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (e.size === 1) {
|
|
43
|
+
r.signalDebugHooks = e.values().next().value ?? null;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
r.signalDebugHooks = {
|
|
47
|
+
onCreate(t, n) {
|
|
48
|
+
for (let r of e) r.onCreate?.(t, n);
|
|
49
|
+
},
|
|
50
|
+
onWrite(t, n) {
|
|
51
|
+
for (let r of e) r.onWrite?.(t, n);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
34
54
|
}
|
|
35
|
-
function d() {
|
|
55
|
+
function d(e) {
|
|
56
|
+
let t = /* @__PURE__ */ new Set();
|
|
57
|
+
e && t.add(e), r.signalDebugHookSet = t, u();
|
|
58
|
+
}
|
|
59
|
+
function f(e) {
|
|
60
|
+
let t = r.signalDebugHookSet;
|
|
61
|
+
return t || (t = /* @__PURE__ */ new Set(), r.signalDebugHooks && t.add(r.signalDebugHooks), r.signalDebugHookSet = t), t.add(e), u(), () => {
|
|
62
|
+
t.delete(e), u();
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function p() {
|
|
36
66
|
return r.notifyBuf.length;
|
|
37
67
|
}
|
|
38
|
-
var
|
|
68
|
+
var m = class {
|
|
39
69
|
_value;
|
|
40
70
|
_subs = /* @__PURE__ */ new Set();
|
|
41
71
|
constructor(e) {
|
|
@@ -77,10 +107,10 @@ var f = class {
|
|
|
77
107
|
this._subs.clear();
|
|
78
108
|
}
|
|
79
109
|
};
|
|
80
|
-
function
|
|
81
|
-
return new
|
|
110
|
+
function h(e) {
|
|
111
|
+
return new m(e);
|
|
82
112
|
}
|
|
83
|
-
function
|
|
113
|
+
function g(e) {
|
|
84
114
|
let t = !1, n, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), s = r.activeErrorHandler, c = () => {
|
|
85
115
|
if (t) return;
|
|
86
116
|
typeof n == "function" && n();
|
|
@@ -113,13 +143,13 @@ function m(e) {
|
|
|
113
143
|
a.clear(), i.clear();
|
|
114
144
|
};
|
|
115
145
|
}
|
|
116
|
-
var
|
|
117
|
-
function
|
|
118
|
-
let n = new
|
|
119
|
-
i || a || (i = !0,
|
|
120
|
-
r =
|
|
146
|
+
var _ = Symbol("elur-computed-uninitialized");
|
|
147
|
+
function v(e, t = Object.is) {
|
|
148
|
+
let n = new m(_), r = null, i = !1, a = !1, o = () => {
|
|
149
|
+
i || a || (i = !0, b(() => {
|
|
150
|
+
r = g(() => {
|
|
121
151
|
let r = e(), i = n.peek();
|
|
122
|
-
(i ===
|
|
152
|
+
(i === _ || !t(r, i)) && (n.value = r);
|
|
123
153
|
});
|
|
124
154
|
}));
|
|
125
155
|
}, s = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n), "value");
|
|
@@ -138,7 +168,7 @@ function g(e, t = Object.is) {
|
|
|
138
168
|
a = !0, r?.(), r = null, c.call(n);
|
|
139
169
|
}, n;
|
|
140
170
|
}
|
|
141
|
-
function
|
|
171
|
+
function y(e) {
|
|
142
172
|
r.batchLevel++;
|
|
143
173
|
try {
|
|
144
174
|
e();
|
|
@@ -150,7 +180,7 @@ function _(e) {
|
|
|
150
180
|
}
|
|
151
181
|
}
|
|
152
182
|
}
|
|
153
|
-
function
|
|
183
|
+
function b(e) {
|
|
154
184
|
let t = r.activeEffect, n = r.activeDeps;
|
|
155
185
|
r.activeEffect = null, r.activeDeps = null;
|
|
156
186
|
try {
|
|
@@ -159,30 +189,30 @@ function v(e) {
|
|
|
159
189
|
r.activeEffect = t, r.activeDeps = n;
|
|
160
190
|
}
|
|
161
191
|
}
|
|
162
|
-
function
|
|
163
|
-
let { immediate: r = !1, once: i = !1 } = n, a = e instanceof
|
|
192
|
+
function x(e, t, n = {}) {
|
|
193
|
+
let { immediate: r = !1, once: i = !1 } = n, a = e instanceof m ? () => e.value : e, o, s = !0, c = !1, l = g(() => {
|
|
164
194
|
let e = a();
|
|
165
195
|
if (s) {
|
|
166
196
|
if (s = !1, r && !c) {
|
|
167
197
|
let n = e;
|
|
168
|
-
|
|
198
|
+
b(() => t(n, void 0)), i && (c = !0, Promise.resolve().then(l));
|
|
169
199
|
}
|
|
170
200
|
o = e;
|
|
171
201
|
return;
|
|
172
202
|
}
|
|
173
203
|
if (!c) {
|
|
174
204
|
let n = e, r = o;
|
|
175
|
-
o = e,
|
|
205
|
+
o = e, b(() => t(n, r)), i && (c = !0, Promise.resolve().then(l));
|
|
176
206
|
}
|
|
177
207
|
});
|
|
178
208
|
return () => {
|
|
179
209
|
c = !0, l();
|
|
180
210
|
};
|
|
181
211
|
}
|
|
182
|
-
function
|
|
212
|
+
function S(e) {
|
|
183
213
|
return e ? Promise.resolve().then(e) : Promise.resolve();
|
|
184
214
|
}
|
|
185
215
|
//#endregion
|
|
186
|
-
export {
|
|
216
|
+
export { m as Signal, f as _addSignalDebugHooks, p as _getNotifyBufSize, a as _popErrorHandler, i as _pushErrorHandler, d as _setSignalDebugHooks, y as batch, v as computed, g as effect, S as nextTick, h as signal, b as untrack, x as watch };
|
|
187
217
|
|
|
188
218
|
//# sourceMappingURL=signals.js.map
|