@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.
Files changed (213) hide show
  1. package/dist/lib/async.cjs +1 -1
  2. package/dist/lib/async.js +1 -1
  3. package/dist/lib/component.cjs +1 -2
  4. package/dist/lib/component.js +2 -66
  5. package/dist/lib/context.cjs +1 -1
  6. package/dist/lib/context.js +35 -23
  7. package/dist/lib/devtools.cjs +1 -1
  8. package/dist/lib/devtools.js +1 -1
  9. package/dist/lib/elur/async.cjs +1 -1
  10. package/dist/lib/elur/async.cjs.map +1 -1
  11. package/dist/lib/elur/async.js +1 -1
  12. package/dist/lib/elur/component.cjs +1 -2
  13. package/dist/lib/elur/component.d.cts +1 -17
  14. package/dist/lib/elur/component.d.ts +1 -17
  15. package/dist/lib/elur/component.js +2 -66
  16. package/dist/lib/elur/context.cjs +1 -1
  17. package/dist/lib/elur/context.cjs.map +1 -1
  18. package/dist/lib/elur/context.d.cts +5 -0
  19. package/dist/lib/elur/context.d.ts +5 -0
  20. package/dist/lib/elur/context.js +35 -23
  21. package/dist/lib/elur/context.js.map +1 -1
  22. package/dist/lib/elur/devtools.cjs +1 -1
  23. package/dist/lib/elur/devtools.cjs.map +1 -1
  24. package/dist/lib/elur/devtools.js +1 -1
  25. package/dist/lib/elur/form.cjs +1 -1
  26. package/dist/lib/elur/form.cjs.map +1 -1
  27. package/dist/lib/elur/form.js +1 -1
  28. package/dist/lib/elur/hydrate/index.cjs +1 -2
  29. package/dist/lib/elur/hydrate/index.d.cts +1 -13
  30. package/dist/lib/elur/hydrate/index.d.ts +1 -13
  31. package/dist/lib/elur/hydrate/index.js +2 -410
  32. package/dist/lib/elur/lifecycle.cjs +1 -1
  33. package/dist/lib/elur/lifecycle.cjs.map +1 -1
  34. package/dist/lib/elur/lifecycle.d.cts +27 -0
  35. package/dist/lib/elur/lifecycle.d.ts +27 -0
  36. package/dist/lib/elur/lifecycle.js +4 -0
  37. package/dist/lib/elur/lifecycle.js.map +1 -1
  38. package/dist/lib/elur/next/component.d.cts +281 -0
  39. package/dist/lib/elur/next/component.d.ts +281 -0
  40. package/dist/lib/elur/next/dom-write.d.cts +18 -0
  41. package/dist/lib/elur/next/dom-write.d.ts +18 -0
  42. package/dist/lib/elur/next/hydrate.d.cts +14 -0
  43. package/dist/lib/elur/next/hydrate.d.ts +14 -0
  44. package/dist/lib/elur/next/keyed-diff.d.cts +46 -0
  45. package/dist/lib/elur/next/keyed-diff.d.ts +46 -0
  46. package/dist/lib/elur/next/mount-helpers.d.cts +25 -0
  47. package/dist/lib/elur/next/mount-helpers.d.ts +25 -0
  48. package/dist/lib/elur/next/mount.d.cts +29 -0
  49. package/dist/lib/elur/next/mount.d.ts +29 -0
  50. package/dist/lib/elur/next/node-binding.d.cts +6 -0
  51. package/dist/lib/elur/next/node-binding.d.ts +6 -0
  52. package/dist/lib/elur/next/reactivity.d.cts +193 -0
  53. package/dist/lib/elur/next/reactivity.d.ts +193 -0
  54. package/dist/lib/elur/next-2/component.cjs +2 -0
  55. package/dist/lib/elur/next-2/component.cjs.map +1 -0
  56. package/dist/lib/elur/next-2/component.d.cts +283 -0
  57. package/dist/lib/elur/next-2/component.d.ts +283 -0
  58. package/dist/lib/elur/next-2/component.js +340 -0
  59. package/dist/lib/elur/next-2/component.js.map +1 -0
  60. package/dist/lib/elur/next-2/dom-write.cjs +2 -0
  61. package/dist/lib/elur/next-2/dom-write.cjs.map +1 -0
  62. package/dist/lib/elur/next-2/dom-write.d.cts +18 -0
  63. package/dist/lib/elur/next-2/dom-write.d.ts +18 -0
  64. package/dist/lib/elur/next-2/dom-write.js +31 -0
  65. package/dist/lib/elur/next-2/dom-write.js.map +1 -0
  66. package/dist/lib/elur/next-2/hydrate.cjs +2 -0
  67. package/dist/lib/elur/next-2/hydrate.cjs.map +1 -0
  68. package/dist/lib/elur/next-2/hydrate.d.cts +30 -0
  69. package/dist/lib/elur/next-2/hydrate.d.ts +30 -0
  70. package/dist/lib/elur/next-2/hydrate.js +449 -0
  71. package/dist/lib/elur/next-2/hydrate.js.map +1 -0
  72. package/dist/lib/elur/next-2/keyed-diff.cjs +2 -0
  73. package/dist/lib/elur/next-2/keyed-diff.cjs.map +1 -0
  74. package/dist/lib/elur/next-2/keyed-diff.d.cts +79 -0
  75. package/dist/lib/elur/next-2/keyed-diff.d.ts +79 -0
  76. package/dist/lib/elur/next-2/keyed-diff.js +208 -0
  77. package/dist/lib/elur/next-2/keyed-diff.js.map +1 -0
  78. package/dist/lib/elur/next-2/mount-helpers.cjs +2 -0
  79. package/dist/lib/elur/next-2/mount-helpers.cjs.map +1 -0
  80. package/dist/lib/elur/next-2/mount-helpers.d.cts +25 -0
  81. package/dist/lib/elur/next-2/mount-helpers.d.ts +25 -0
  82. package/dist/lib/elur/next-2/mount-helpers.js +87 -0
  83. package/dist/lib/elur/next-2/mount-helpers.js.map +1 -0
  84. package/dist/lib/elur/next-2/mount.cjs +2 -0
  85. package/dist/lib/elur/next-2/mount.cjs.map +1 -0
  86. package/dist/lib/elur/next-2/mount.d.cts +29 -0
  87. package/dist/lib/elur/next-2/mount.d.ts +29 -0
  88. package/dist/lib/elur/next-2/mount.js +34 -0
  89. package/dist/lib/elur/next-2/mount.js.map +1 -0
  90. package/dist/lib/elur/next-2/node-binding.cjs +2 -0
  91. package/dist/lib/elur/next-2/node-binding.cjs.map +1 -0
  92. package/dist/lib/elur/next-2/node-binding.d.cts +6 -0
  93. package/dist/lib/elur/next-2/node-binding.d.ts +6 -0
  94. package/dist/lib/elur/next-2/node-binding.js +130 -0
  95. package/dist/lib/elur/next-2/node-binding.js.map +1 -0
  96. package/dist/lib/elur/next-2/reactivity.cjs +2 -0
  97. package/dist/lib/elur/next-2/reactivity.cjs.map +1 -0
  98. package/dist/lib/elur/next-2/reactivity.d.cts +220 -0
  99. package/dist/lib/elur/next-2/reactivity.d.ts +220 -0
  100. package/dist/lib/elur/next-2/reactivity.js +614 -0
  101. package/dist/lib/elur/next-2/reactivity.js.map +1 -0
  102. package/dist/lib/elur/next-2/scheduler.cjs +2 -0
  103. package/dist/lib/elur/next-2/scheduler.cjs.map +1 -0
  104. package/dist/lib/elur/next-2/scheduler.d.cts +23 -0
  105. package/dist/lib/elur/next-2/scheduler.d.ts +23 -0
  106. package/dist/lib/elur/next-2/scheduler.js +26 -0
  107. package/dist/lib/elur/next-2/scheduler.js.map +1 -0
  108. package/dist/lib/elur/plugins.cjs +1 -1
  109. package/dist/lib/elur/plugins.cjs.map +1 -1
  110. package/dist/lib/elur/plugins.js +1 -1
  111. package/dist/lib/elur/reactivity.cjs +1 -2
  112. package/dist/lib/elur/reactivity.d.cts +1 -67
  113. package/dist/lib/elur/reactivity.d.ts +1 -67
  114. package/dist/lib/elur/reactivity.js +2 -218
  115. package/dist/lib/elur/router.cjs +2 -2
  116. package/dist/lib/elur/router.cjs.map +1 -1
  117. package/dist/lib/elur/router.js +2 -2
  118. package/dist/lib/elur/router.js.map +1 -1
  119. package/dist/lib/elur/server/index.cjs +1 -1
  120. package/dist/lib/elur/server/index.cjs.map +1 -1
  121. package/dist/lib/elur/server/index.js +180 -108
  122. package/dist/lib/elur/server/index.js.map +1 -1
  123. package/dist/lib/elur/store.cjs +1 -1
  124. package/dist/lib/elur/store.cjs.map +1 -1
  125. package/dist/lib/elur/store.js +10 -4
  126. package/dist/lib/elur/store.js.map +1 -1
  127. package/dist/lib/elur/template/bindings.cjs +1 -1
  128. package/dist/lib/elur/template/bindings.cjs.map +1 -1
  129. package/dist/lib/elur/template/bindings.js +98 -84
  130. package/dist/lib/elur/template/bindings.js.map +1 -1
  131. package/dist/lib/elur/template/dom-write.d.cts +1 -5
  132. package/dist/lib/elur/template/dom-write.d.ts +1 -5
  133. package/dist/lib/elur/template/error-boundary.cjs +1 -1
  134. package/dist/lib/elur/template/error-boundary.cjs.map +1 -1
  135. package/dist/lib/elur/template/error-boundary.js +56 -50
  136. package/dist/lib/elur/template/error-boundary.js.map +1 -1
  137. package/dist/lib/elur/template/html.cjs +1 -1
  138. package/dist/lib/elur/template/html.cjs.map +1 -1
  139. package/dist/lib/elur/template/html.js +40 -37
  140. package/dist/lib/elur/template/html.js.map +1 -1
  141. package/dist/lib/elur/template/index.cjs +1 -1
  142. package/dist/lib/elur/template/index.d.cts +2 -1
  143. package/dist/lib/elur/template/index.d.ts +2 -1
  144. package/dist/lib/elur/template/index.js +13 -12
  145. package/dist/lib/elur/template/keyed-diff.d.cts +1 -32
  146. package/dist/lib/elur/template/keyed-diff.d.ts +1 -32
  147. package/dist/lib/elur/template/keyed.cjs +1 -1
  148. package/dist/lib/elur/template/keyed.cjs.map +1 -1
  149. package/dist/lib/elur/template/keyed.d.cts +10 -2
  150. package/dist/lib/elur/template/keyed.d.ts +10 -2
  151. package/dist/lib/elur/template/keyed.js +12 -1
  152. package/dist/lib/elur/template/keyed.js.map +1 -1
  153. package/dist/lib/elur/template/mount-helpers.d.cts +1 -29
  154. package/dist/lib/elur/template/mount-helpers.d.ts +1 -29
  155. package/dist/lib/elur/template/node-binding.d.cts +1 -6
  156. package/dist/lib/elur/template/node-binding.d.ts +1 -6
  157. package/dist/lib/elur/template/portal.cjs +1 -1
  158. package/dist/lib/elur/template/portal.cjs.map +1 -1
  159. package/dist/lib/elur/template/portal.js +1 -1
  160. package/dist/lib/elur/template/transitions.cjs +1 -1
  161. package/dist/lib/elur/template/transitions.cjs.map +1 -1
  162. package/dist/lib/elur/template/transitions.js +2 -2
  163. package/dist/lib/elur/template/types.cjs +1 -1
  164. package/dist/lib/elur/template/types.cjs.map +1 -1
  165. package/dist/lib/elur/template/types.d.cts +55 -0
  166. package/dist/lib/elur/template/types.d.ts +55 -0
  167. package/dist/lib/elur/template/types.js +5 -1
  168. package/dist/lib/elur/template/types.js.map +1 -1
  169. package/dist/lib/elur.cjs +1 -1
  170. package/dist/lib/elur.js +2 -2
  171. package/dist/lib/form.cjs +1 -1
  172. package/dist/lib/form.js +1 -1
  173. package/dist/lib/hydrate.cjs +1 -2
  174. package/dist/lib/hydrate.js +2 -410
  175. package/dist/lib/index.cjs +1 -1
  176. package/dist/lib/index.js +2 -2
  177. package/dist/lib/lifecycle.cjs +1 -1
  178. package/dist/lib/lifecycle.js +4 -0
  179. package/dist/lib/plugins.cjs +1 -1
  180. package/dist/lib/plugins.js +1 -1
  181. package/dist/lib/router.cjs +2 -2
  182. package/dist/lib/router.js +2 -2
  183. package/dist/lib/server.cjs +1 -1
  184. package/dist/lib/server.js +180 -108
  185. package/dist/lib/signals.cjs +1 -2
  186. package/dist/lib/signals.js +2 -218
  187. package/dist/lib/store.cjs +1 -1
  188. package/dist/lib/store.js +10 -4
  189. package/dist/lib/template.cjs +1 -1
  190. package/dist/lib/template.js +13 -12
  191. package/package.json +7 -9
  192. package/dist/lib/elur/component.cjs.map +0 -1
  193. package/dist/lib/elur/component.js.map +0 -1
  194. package/dist/lib/elur/hydrate/index.cjs.map +0 -1
  195. package/dist/lib/elur/hydrate/index.js.map +0 -1
  196. package/dist/lib/elur/reactivity.cjs.map +0 -1
  197. package/dist/lib/elur/reactivity.js.map +0 -1
  198. package/dist/lib/elur/template/dom-write.cjs +0 -2
  199. package/dist/lib/elur/template/dom-write.cjs.map +0 -1
  200. package/dist/lib/elur/template/dom-write.js +0 -16
  201. package/dist/lib/elur/template/dom-write.js.map +0 -1
  202. package/dist/lib/elur/template/keyed-diff.cjs +0 -2
  203. package/dist/lib/elur/template/keyed-diff.cjs.map +0 -1
  204. package/dist/lib/elur/template/keyed-diff.js +0 -100
  205. package/dist/lib/elur/template/keyed-diff.js.map +0 -1
  206. package/dist/lib/elur/template/mount-helpers.cjs +0 -2
  207. package/dist/lib/elur/template/mount-helpers.cjs.map +0 -1
  208. package/dist/lib/elur/template/mount-helpers.js +0 -132
  209. package/dist/lib/elur/template/mount-helpers.js.map +0 -1
  210. package/dist/lib/elur/template/node-binding.cjs +0 -2
  211. package/dist/lib/elur/template/node-binding.cjs.map +0 -1
  212. package/dist/lib/elur/template/node-binding.js +0 -95
  213. package/dist/lib/elur/template/node-binding.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","names":[],"sources":["../../../../src/elur/next-2/component.ts"],"sourcesContent":["/**\n * Elur \"next\" — kernel unificado de componentes (experimental).\n *\n * Implementa A.6–A.9 del PLAN_TECNICO_ELUR_NEXT sobre el ownership de\n * `./reactivity.ts`:\n * - Una sola `ComponentInstance` para clases y funciones (adaptadores).\n * - Máquina de estados (A.7): created → initializing → rendering →\n * pending-mount → mounted → disposing → disposed (o failed).\n * - Mount transaccional (A.9): cualquier fallo dispara rollback —\n * cleanups registrados, owner reactivo disposed, DOM insertado removido.\n * - `unmount()` idempotente (A.2.10).\n * - `onMount` corre DESPUÉS del commit DOM (A.2.9).\n * - Todo lo creado en setup/render pertenece al owner de la instancia y\n * muere con unmount (A.2.1 — no más effects huérfanos).\n *\n * Las invocaciones implementan `ELUR_RENDER_PROTOCOL.mountDom`, así el\n * renderer existente las monta sin saber que son componentes.\n */\n\nimport {\n getOwner,\n runWithOwner,\n signal,\n Owner,\n Signal,\n type Disposable,\n type OwnerLike,\n} from \"./reactivity.js\";\nimport {\n isElurComponent,\n _debugComponentMountStart,\n _debugComponentMountEnd,\n _debugComponentUnmount,\n type ElurComponent,\n type ComponentController,\n} from \"../lifecycle.js\";\nimport {\n ELUR_RENDER_PROTOCOL,\n isElurTemplate,\n type DomProtocolContext,\n} from \"../template/types.js\";\nimport {\n _pushComponentContext,\n _popComponentContext,\n _withComponentContext,\n _pushContextScopeResolver,\n} from \"../context.js\";\n\n// --- Máquina de estados (A.7) -------------------------------------------------\n\nexport type ComponentState =\n | \"created\"\n | \"initializing\"\n | \"rendering\"\n | \"pending-mount\"\n | \"mounted\"\n | \"deactivated\"\n | \"disposing\"\n | \"disposed\"\n | \"failed\";\n\n// --- Hooks --------------------------------------------------------------------\n\n// --- A.16: error boundaries ----------------------------------------------------\n\n/** Fase del lifecycle donde ocurrió el error. */\nexport type ErrorPhase =\n | \"setup\"\n | \"init\"\n | \"render\"\n | \"hydrate\"\n | \"mount\"\n | \"effect\"\n | \"activate\"\n | \"deactivate\"\n | \"cleanup\"\n | \"unmount\";\n\n/** Información estructurada del error (A.16). */\nexport interface ComponentErrorInfo {\n phase: ErrorPhase;\n /** Instancia donde ocurrió el error (no la boundary que lo maneja). */\n component: ComponentInstance;\n cause: unknown;\n}\n\n/** Resolución de una boundary (A.16). */\nexport type ErrorResolution =\n | { handled: false }\n | { handled: true; fallback?: Renderable }\n | { handled: true; retry: true };\n\nexport interface ComponentHooks {\n /** Tras el commit DOM. Puede devolver cleanup (corre en unmount). */\n onMount?: () => (() => void) | void;\n /** Antes de remover el DOM. */\n onUnmount?: () => void;\n /**\n * Boundary de errores (A.16): recibe info estructurada; el error burbujea\n * por la cadena de instancias hasta una boundary que devuelva handled.\n * `void` = manejado sin más.\n */\n onError?: (info: ComponentErrorInfo) => ErrorResolution | void;\n /** A.17: tras setup durante SSR — nunca en cliente. */\n onServerRender?: () => void;\n}\n\n/** Contexto que recibe el setup de un componente funcional. */\nexport interface SetupCtx {\n onMount(fn: () => (() => void) | void): void;\n onUnmount(fn: () => void): void;\n onError(fn: (info: ComponentErrorInfo) => ErrorResolution | void): void;\n /** A.17: hook server-side — corre tras setup durante SSR, nunca en cliente. */\n onServerRender(fn: () => void): void;\n /** Owner de la instancia — para runWithOwner/getOwner manual. */\n readonly owner: OwnerLike;\n /** Señal interna de una prop (A.13) — para acceso reactivo explícito. */\n propSignal<K extends string>(key: K): Signal<unknown> | undefined;\n /**\n * A.14: renderiza el contenido de un slot (lazy — corre el render del\n * slot bajo el owner del padre que lo declaró). `\"default\"` por defecto.\n */\n slot(name?: string): unknown;\n /** A.14: slots declarados en la invocación. */\n readonly slots: Record<string, Slot> | undefined;\n}\n\n// --- Renderable ---------------------------------------------------------------\n\ninterface RenderableValue {\n _render(parent: Node, before: Node | null): () => void;\n}\n\nfunction asRenderable(v: unknown): RenderableValue | null {\n if (isElurTemplate(v)) return v as unknown as RenderableValue;\n return null;\n}\n\n// --- A.14: Slots (lazy, marcados) --------------------------------------------------\n\n/** Renderable común: cualquier cosa montable en un binding. */\nexport type Renderable =\n | ElurComponent\n | ComponentInvocation<unknown>\n | Slot\n | { _render(parent: Node, before: Node | null): () => void }\n | string\n | number\n | bigint\n | false\n | null\n | undefined\n | Renderable[];\n\n/**\n * Slot lazy y marcado (A.14): el contenido se renderiza bajo el owner del\n * padre que LO DECLARÓ (contexto léxico), aunque se monte dentro del\n * componente consumidor.\n */\nexport interface Slot {\n readonly __isElurSlot: true;\n /** Owner capturado en el punto de declaración (contexto léxico). */\n readonly owner: OwnerLike | null;\n render(): unknown;\n}\n\nexport function slot(render: () => unknown): Slot {\n return { __isElurSlot: true, owner: getOwner(), render };\n}\n\nexport function isElurSlot(v: unknown): v is Slot {\n return (\n v != null &&\n typeof v === \"object\" &&\n (v as { __isElurSlot?: boolean }).__isElurSlot === true\n );\n}\n\n// --- ComponentInstance ----------------------------------------------------------\n\nlet nextInstanceId = 1;\n\nexport class ComponentInstance implements Disposable {\n readonly id = nextInstanceId++;\n readonly kind: \"class\" | \"function\";\n state: ComponentState = \"created\";\n /** Owner reactivo de la instancia — todo lo creado dentro muere con él. */\n readonly owner = new Owner();\n /** Instancia padre (owner activo cuando se creó esta instancia). */\n parent: ComponentInstance | null = null;\n hooks: ComponentHooks = {};\n renderable: RenderableValue | null = null;\n /** A.12: frame de provide/inject propio de la instancia — permanente. */\n readonly context = new Map<unknown, unknown>();\n\n private _inst: ElurComponent | null = null;\n private _invocation: ComponentInvocation<any> | null = null;\n private _renderCleanup: (() => void) | null = null;\n private _mountCleanups: (() => void)[] | null = null;\n /** A.13: señales internas por prop + objeto live pasado al setup. */\n private _propSignals: Map<string, Signal<unknown>> | null = null;\n private _liveProps: Record<string, unknown> | null = null;\n /** A.16: fase actual del lifecycle — para el ComponentErrorInfo. */\n private _phase: ErrorPhase = \"setup\";\n /** A.16: posición de montaje — para renderizar fallback de boundary. */\n private _mountParent: Node | null = null;\n private _mountBefore: Node | null = null;\n /** A.3.8: nodos DOM de la instancia — para detach/attach. */\n private _domNodes: Node[] | null = null;\n /** A.21: controllers de ciclo de vida (Lit-style). */\n private _controllers: ComponentController[] | null = null;\n\n constructor(source: ElurComponent | ComponentInvocation<any>) {\n if (isElurComponent(source)) {\n this.kind = \"class\";\n this._inst = source;\n } else {\n this.kind = \"function\";\n this._invocation = source;\n }\n // A.16: errores de effects/computeds de la instancia burbujean aquí.\n this.owner.onOwnerError = (err) =>\n reportError(this, { phase: \"effect\", component: this, cause: err })\n .handled;\n }\n\n /**\n * Mount transaccional (A.9). Cualquier fase que falle → rollback completo:\n * owner disposed, cleanups corridos, DOM insertado removido, state=failed.\n *\n * Opciones:\n * - `ctxSnapshot`: contexto capturado en el punto de declaración\n * (mounts dentro de effects dinámicos heredan provide/inject).\n * - `deferOnMount`: recibe una función `fire()` que corre onMount; el\n * caller decide cuándo invocarla (fragments aún no insertados).\n */\n mount(\n parent: Node,\n before: Node | null,\n opts?: {\n ctxSnapshot?: Map<unknown, unknown>[];\n deferOnMount?: (fire: () => void) => void;\n /** Valores a proveer en el frame de contexto de la instancia (A.12). */\n provides?: Iterable<readonly [unknown, unknown]>;\n /**\n * A.14: owner del declarante — para contenido de slots, el owner padre\n * es el del padre que declaró el contenido, no el del punto de montaje.\n */\n declOwner?: OwnerLike | null;\n },\n ): void {\n if (this.state !== \"created\") {\n throw new Error(\n `[elur-next] ComponentInstance.mount(): estado inválido \"${this.state}\" (una instancia montada no puede montarse otra vez).`,\n );\n }\n ownerToInstance.set(this.owner, this);\n ownerToContext.set(this.owner, this.context);\n this._resolveParent();\n // A.12: el owner de la instancia se cuelga del owner activo en el punto\n // de declaración — así la cadena de owners reproduce el árbol de\n // componentes y provide/inject resuelven por instancias.\n this.owner.parent = opts?.declOwner !== undefined ? opts.declOwner : getOwner();\n if (opts?.provides) {\n for (const [k, v] of opts.provides) this.context.set(k, v);\n }\n this._mountParent = parent;\n this._mountBefore = before;\n\n // A.2.4: debug events sólo para funcionales — las clases ya emiten por\n // mount-helpers; emitir aquí duplicaría. El payload es la\n // ComponentInstance (id/kind/state/parent en el árbol).\n const isFunctional = !isElurComponent(this._inst);\n const dbg = this as unknown as ElurComponent;\n if (isFunctional) _debugComponentMountStart(dbg);\n\n // A.3.8: índice donde empieza el DOM de la instancia — para capturar el\n // rango de nodos tras _render y poder detach/attach después.\n const startIndex = before\n ? Array.prototype.indexOf.call(parent.childNodes, before)\n : parent.childNodes.length;\n\n try {\n // --- initializing + rendering + pending-mount, TODO bajo el mismo\n // frame de contexto: los hijos montados durante _render heredan el\n // provide de esta instancia (como en la impl actual).\n this.state = \"initializing\";\n runWithOwner(this.owner, () =>\n this._withScope(opts?.ctxSnapshot, () => {\n this._initBody();\n // A.21: controllers de la clase + programáticos — hostInit dentro\n // del frame para que lo que creen quede poseído por la instancia.\n if (this._inst?._controllers) {\n for (const c of this._inst._controllers) this.addController(c);\n }\n if (this._controllers) {\n for (const c of this._controllers) c.hostInit?.();\n }\n // pending-mount: activar bindings + insertar DOM, aún dentro del\n // frame de contexto para que los hijos hereden provide/inject.\n this._phase = \"mount\";\n this.state = \"pending-mount\";\n this._renderCleanup = this.renderable!._render(parent, before);\n // A.3.8: capturar los nodos insertados entre startIndex y `before`.\n const endIndex = before\n ? Array.prototype.indexOf.call(parent.childNodes, before)\n : parent.childNodes.length;\n this._domNodes = Array.prototype.slice.call(\n parent.childNodes,\n startIndex,\n endIndex,\n ) as Node[];\n }),\n );\n\n // --- commit ---\n this.state = \"mounted\";\n\n // onMount DESPUÉS del commit DOM (A.2.9) — inmediato o diferido por\n // el caller (fragments que aún no están en el documento).\n const fire = () => this._runOnMount();\n if (opts?.deferOnMount) opts.deferOnMount(fire);\n else fire();\n } catch (err) {\n this._rollback();\n const res = reportError(this, {\n phase: this._phase,\n component: this,\n cause: err,\n });\n if (!res.handled) throw err;\n if (\"retry\" in res && res.retry) {\n // Una sola reintento — instancia fresca (el owner viejo está\n // disposed); un segundo fallo se propaga igual.\n new ComponentInstance(this._inst ?? this._invocation!).mount(\n parent,\n before,\n opts,\n );\n } else if (\"fallback\" in res && res.fallback !== undefined) {\n this._renderFallback(res.fallback, parent, before);\n }\n } finally {\n // A.3.3/A.2.4: mountEnd balanceado — se emite haya éxito, rollback,\n // retry o fallback, para que el tooling pueda emparejar start/end.\n if (isFunctional) _debugComponentMountEnd(dbg);\n }\n }\n\n /** A.21: registra un controller — sus hooks corren bajo este owner. */\n addController(c: ComponentController): void {\n (this._controllers ??= []).push(c);\n }\n\n /**\n * A.3.8: saca el DOM de la instancia SIN disponer nada — effects, signals\n * y contexto siguen vivos (página cached, Suspense, transición). No-op si\n * no está montado.\n */\n detach(): void {\n if (this.state !== \"mounted\" || !this._domNodes) return;\n const frag = document.createDocumentFragment();\n for (const n of this._domNodes) frag.appendChild(n);\n this.state = \"deactivated\";\n // A.21: hostDeactivate — signals/effects del controller siguen vivos.\n if (this._controllers) {\n runWithOwner(this.owner, () => {\n for (const c of this._controllers!) c.hostDeactivate?.();\n });\n }\n }\n\n /**\n * A.3.8: reinserta el DOM de una instancia detached en la posición original\n * (o en parent/before dados). No-op si no está deactivated.\n */\n attach(parent?: Node, before?: Node | null): void {\n if (this.state !== \"deactivated\" || !this._domNodes) return;\n const p = parent ?? this._mountParent;\n const b = before !== undefined ? before : this._mountBefore;\n if (!p) return;\n for (const n of this._domNodes) p.insertBefore(n, b);\n this.state = \"mounted\";\n // A.21: hostActivate — la instancia volvió al DOM.\n if (this._controllers) {\n runWithOwner(this.owner, () => {\n for (const c of this._controllers!) c.hostActivate?.();\n });\n }\n }\n\n /** Idempotente (A.2.10): disponer dos veces es seguro. */\n unmount(): void {\n if (this.state === \"created\") return; // nunca montado\n if (this.state === \"disposing\" || this.state === \"disposed\") return;\n if (this.state === \"failed\") {\n this.state = \"disposed\";\n return;\n }\n // A.3.8: unmount de una instancia detached dispone igual — el cleanup\n // del renderable remueve los nodos de su padre actual (el fragment).\n if (this.state === \"deactivated\") this._domNodes = null;\n this.state = \"disposing\";\n // A.2.4: mismo criterio — sólo funcionales (las clases emiten por\n // mount-helpers).\n if (!isElurComponent(this._inst)) {\n _debugComponentUnmount(this as unknown as ElurComponent);\n }\n try {\n // A.12: bajo el owner → inject() resuelve dentro de onUnmount también.\n runWithOwner(this.owner, () => {\n this.hooks.onUnmount?.call(this._inst ?? undefined);\n this._inst?.onUnmount?.();\n // A.21: hostUnmount antes del disposal del owner.\n if (this._controllers) {\n for (const c of this._controllers) c.hostUnmount?.();\n }\n });\n } catch (err) {\n // A.16: errores de unmount no abortan el disposal pero se reportan.\n this._reportSwallowed(err, \"unmount\");\n }\n if (this._mountCleanups) {\n for (const fn of this._mountCleanups) {\n try {\n fn();\n } catch (err) {\n // A.3.4/A.16: cleanup errors continúan el teardown, pero se reportan.\n this._reportSwallowed(err, \"cleanup\");\n }\n }\n this._mountCleanups = null;\n }\n // Owner primero (mata effects/computeds/cleanups de la instancia),\n // luego el cleanup del renderable (remueve DOM + cleanup propio).\n this.owner.dispose();\n try {\n this._renderCleanup?.();\n } finally {\n this._renderCleanup = null;\n this.state = \"disposed\";\n }\n }\n\n dispose(): void {\n this.unmount();\n }\n\n /** @internal — corre onMount una vez; no-op si ya no está montado. */\n _runOnMount(): void {\n if (this.state !== \"mounted\") return;\n try {\n // A.12: bajo el owner → inject() dentro de onMount resuelve por la\n // cadena de instancias (contexto permanente, no sólo durante render).\n const mountRet = runWithOwner(this.owner, () => {\n const r =\n this.kind === \"class\" ? this._inst!.onMount?.() : this.hooks.onMount?.();\n // A.21\n if (this._controllers) {\n for (const c of this._controllers) c.hostMounted?.();\n }\n return r;\n });\n if (typeof mountRet === \"function\") {\n (this._mountCleanups ??= []).push(mountRet);\n }\n } catch (err) {\n // A.16: onMount falla → rollback completo + boundary (+fallback).\n this._rollback();\n const res = reportError(this, {\n phase: \"mount\",\n component: this,\n cause: err,\n });\n if (!res.handled) throw err;\n if (\"fallback\" in res && res.fallback !== undefined) {\n this._renderFallback(res.fallback, this._mountParent!, this._mountBefore);\n }\n }\n }\n\n /**\n * @internal A.16: intenta manejar el error con el boundary propio.\n * `null` = este nodo no tiene boundary — seguir subiendo.\n */\n _handleError(info: ComponentErrorInfo): ErrorResolution | null {\n if (this.kind === \"function\" && this.hooks.onError) {\n const r = this.hooks.onError(info);\n if (r === undefined) return { handled: true };\n return r;\n }\n if (this.kind === \"class\" && this._inst?.onError) {\n this._inst.onError(info.cause);\n return { handled: true };\n }\n return null;\n }\n\n /** A.16: errores de teardown — se reportan a la cadena; si nadie los maneja quedan registrados. */\n private _reportSwallowed(err: unknown, phase: ErrorPhase): void {\n const res = reportError(this, { phase, component: this, cause: err });\n if (!res.handled) console.error(\"[elur-next] error en \" + phase + \":\", err);\n }\n\n /** A.16: renderiza el fallback de una boundary en la posición del componente. */\n private _renderFallback(\n fallback: Renderable,\n parent: Node,\n before: Node | null,\n ): void {\n const r = asRenderable(fallback);\n if (r) r._render(parent, before);\n else if (typeof fallback === \"string\" || typeof fallback === \"number\") {\n parent.insertBefore(document.createTextNode(String(fallback)), before);\n } else if (Array.isArray(fallback)) {\n for (const f of fallback) this._renderFallback(f, parent, before);\n }\n // ComponentInvocation / ElurComponent se montan por el camino normal.\n else if (fallback) {\n new ComponentInstance(fallback as ComponentInvocation<unknown>).mount(\n parent,\n before,\n );\n }\n }\n\n /** Camina la cadena de owners hasta la instancia registrada más cercana. */\n private _resolveParent(): void {\n let o = getOwner();\n while (o) {\n const inst = ownerToInstance.get(o);\n if (inst) {\n this.parent = inst;\n return;\n }\n o = o.parent;\n }\n }\n\n private _rollback(): void {\n // Cancelar hooks pendientes + cleanups + owner + hijos + DOM insertado.\n this.owner.dispose();\n try {\n this._renderCleanup?.();\n } finally {\n this._renderCleanup = null;\n this.state = \"failed\";\n }\n }\n\n private _makeSetupCtx(): SetupCtx {\n const inst = this;\n return {\n owner: this.owner,\n onMount(fn) {\n inst.hooks.onMount = fn;\n },\n onUnmount(fn) {\n inst.hooks.onUnmount = fn;\n },\n onError(fn) {\n inst.hooks.onError = fn;\n },\n onServerRender(fn) {\n inst.hooks.onServerRender = fn;\n },\n propSignal(key) {\n return inst._propSignals?.get(key);\n },\n slots: this._invocation?.slots,\n // Devuelve el Slot marcado — el renderer lo desenvuelve bajo el owner\n // del declarante (contexto léxico, A.14).\n slot(name = \"default\") {\n return inst._invocation?.slots?.[name];\n },\n };\n }\n\n /** Fases initializing+rendering: setup/onInit + render → this.renderable. */\n private _initBody(): void {\n if (this.kind === \"class\") {\n const inst = this._inst!;\n this._phase = \"init\";\n inst.onInit?.();\n this._phase = \"render\";\n this.state = \"rendering\";\n this.renderable = asRenderable(inst.render());\n } else {\n const inv = this._invocation!;\n const ctx = this._makeSetupCtx();\n this._phase = \"setup\";\n this.state = \"rendering\";\n // A.13: LiveProps — getters readonly sobre signals internas.\n // Leer props.x dentro de un binding/effect registra dependencia.\n this.renderable = asRenderable(\n inv.definition.setup(this._initProps(inv.props), ctx),\n );\n }\n if (!this.renderable) {\n throw new Error(\n `[elur-next] El componente #${this.id} no produjo un template renderizable.`,\n );\n }\n }\n\n /** Corre `body` dentro del frame de contexto (snapshot o frame nuevo). */\n private _withScope(\n ctxSnapshot: Map<unknown, unknown>[] | undefined,\n body: () => void,\n ): void {\n if (ctxSnapshot) {\n _withComponentContext(ctxSnapshot, body);\n } else {\n _pushComponentContext();\n try {\n body();\n } finally {\n _popComponentContext();\n }\n }\n }\n\n /**\n * A.18 — hidratación: setup/onInit + render una sola vez, luego adopta el\n * DOM SSR via ctx.render (que activa bindings dentro del owner de la\n * instancia). En mismatch: rollback de la activación + remount por el mismo\n * kernel REUSANDO el renderable — setup/onInit no se duplica.\n */\n _hydrate(ctx: {\n parent: Node;\n bounds: { start: Comment; end: Comment } | null;\n render(value: unknown): unknown;\n /** \"throw\" propaga el mismatch en vez de remontar (HydrateOptions). */\n mismatch?: \"throw\" | \"warn-remount\" | \"remount\";\n }): void {\n if (this.state !== \"created\") {\n throw new Error(`[elur-next] _hydrate(): estado inválido \"${this.state}\".`);\n }\n ownerToInstance.set(this.owner, this);\n ownerToContext.set(this.owner, this.context);\n this._resolveParent();\n this.owner.parent = getOwner();\n try {\n this.state = \"initializing\";\n let hydrateCleanup: unknown;\n runWithOwner(this.owner, () =>\n this._withScope(undefined, () => {\n this._initBody();\n this.state = \"pending-mount\";\n hydrateCleanup = ctx.render(this.renderable);\n }),\n );\n this._renderCleanup =\n typeof hydrateCleanup === \"function\" ? (hydrateCleanup as () => void) : null;\n this.state = \"mounted\";\n this._runOnMount();\n } catch (error) {\n if (ctx.mismatch === \"throw\") throw error;\n if (ctx.mismatch !== \"remount\") {\n console.warn(\"[elur] Hydration mismatch en componente; remounting:\", error);\n }\n // Mismatch SSR → rollback de la activación y remount por el kernel,\n // reutilizando this.renderable (onInit/setup ya corrieron — A.18).\n this.owner.dispose();\n const retry = this.renderable;\n this.state = \"initializing\";\n runWithOwner(this.owner, () =>\n this._withScope(undefined, () => {\n if (!retry) this._initBody();\n this.state = \"pending-mount\";\n this._renderCleanup = this.renderable!._render(\n ctx.parent,\n ctx.bounds?.end ?? null,\n );\n }),\n );\n this.state = \"mounted\";\n this._runOnMount();\n }\n }\n\n /**\n * A.17 — SSR: setup/onInit + onServerRender + serializar el renderable.\n * NO corre onMount/onUnmount; el owner server-side se dispone al final\n * (mata effects/computeds creados en setup).\n */\n async _renderServer(sctx: {\n markers?: boolean;\n render(value: unknown, options?: { markers?: boolean }): string | Promise<string>;\n }): Promise<string> {\n this.state = \"initializing\";\n ownerToInstance.set(this.owner, this);\n ownerToContext.set(this.owner, this.context);\n this._resolveParent();\n this.owner.parent = getOwner();\n runWithOwner(this.owner, () =>\n this._withScope(undefined, () => {\n this._initBody();\n if (this.kind === \"class\") this._inst!.onServerRender?.();\n else this.hooks.onServerRender?.();\n }),\n );\n try {\n return await sctx.render(this.renderable, { markers: sctx.markers });\n } finally {\n // Disposal server-side: cleanups + hijos reactivos, sin lifecycle DOM.\n this.owner.dispose();\n this.state = \"disposed\";\n }\n }\n\n /**\n * A.13 — crea el objeto LiveProps: propiedades readonly respaldadas por\n * signals. OJO: destructurar props en setup crea snapshots no reactivos.\n */\n private _initProps(props: unknown): Record<string, unknown> {\n this._propSignals = new Map();\n this._liveProps = {};\n if (props != null && typeof props === \"object\") {\n for (const [key, value] of Object.entries(props)) {\n if (key === \"key\") continue; // la key es identidad, no prop reactiva\n const sig = signal(value);\n this._propSignals.set(key, sig);\n Object.defineProperty(this._liveProps, key, {\n enumerable: true,\n get: () => sig.value,\n });\n }\n }\n return this._liveProps;\n }\n\n /**\n * A.13/A.15 — true si `inv` es la misma definición con la misma key:\n * entonces el runtime debe actualizar props, no recrear el setup.\n */\n matches(inv: ComponentInvocation<any>): boolean {\n if (this.kind !== \"function\" || !this._invocation) return false;\n const keyOf = (p: unknown) =>\n p != null && typeof p === \"object\"\n ? (p as Record<string, unknown>).key\n : undefined;\n return (\n inv.definition === this._invocation.definition &&\n keyOf(inv.props) === keyOf(this._invocation.props)\n );\n }\n\n /**\n * A.13 — actualiza props sin recrear setup: escribe cada signal de prop.\n * Props nuevas se añaden; props desaparecidas quedan en undefined.\n */\n updateProps(props: unknown): void {\n if (!this._propSignals || !this._liveProps) return;\n const seen = new Set<string>();\n if (props != null && typeof props === \"object\") {\n for (const [key, value] of Object.entries(props)) {\n if (key === \"key\") continue;\n seen.add(key);\n const sig = this._propSignals.get(key);\n if (sig) {\n sig.value = value;\n } else {\n const s = signal(value);\n this._propSignals.set(key, s);\n Object.defineProperty(this._liveProps, key, {\n enumerable: true,\n get: () => s.value,\n });\n }\n }\n }\n for (const key of this._propSignals.keys()) {\n if (!seen.has(key)) this._propSignals.get(key)!.value = undefined;\n }\n }\n}\n\n/**\n * A.16: burbujeo de errores por la cadena de instancias (padres reales del\n * árbol de componentes). Devuelve la primera resolución manejada; si nadie\n * maneja el error, `{ handled: false }` y el caller decide (re-lanzar o\n * registrar).\n */\nexport function reportError(\n from: ComponentInstance,\n info: ComponentErrorInfo,\n): ErrorResolution {\n let cur: ComponentInstance | null = from;\n while (cur) {\n const r = cur._handleError(info);\n if (r !== null) return r;\n cur = cur.parent;\n }\n return { handled: false };\n}\n\n// --- Adaptador de clase ---------------------------------------------------------\n\n/** Envuelve un ElurComponent de clase en el kernel unificado. */\nexport function adaptClassComponent(inst: ElurComponent): ComponentInstance {\n const ci = new ComponentInstance(inst);\n // Los hooks de clase se leen de la instancia en mount/unmount directamente\n // (onInit/onMount/onUnmount/onError) — no necesitan registro por ctx.\n return ci;\n}\n\n// --- Componentes funcionales (A.5) ------------------------------------------------\n\nexport interface ComponentDefinition<P> {\n (props?: P, slots?: Record<string, Slot>): ComponentInvocation<P>;\n readonly setup: (props: P | undefined, ctx: SetupCtx) => unknown;\n readonly _isComponentDefinition: true;\n}\n\n/** Invocación marcada: `Counter({ initial: 10 })` NO ejecuta setup — monta después. */\nexport class ComponentInvocation<P> {\n readonly [ELUR_RENDER_PROTOCOL] = {\n mountDom: (ctx: DomProtocolContext): (() => void) => {\n const inst = new ComponentInstance(this as ComponentInvocation<any>);\n // mount() resuelve `parent` caminando la cadena de owners — bajo el\n // swap, el caller corre dentro del owner del componente padre.\n inst.mount(ctx.parent, ctx.before);\n return () => inst.unmount();\n },\n // A.17 — SSR: setup + onServerRender + serialización; sin lifecycle DOM.\n renderServer: (sctx: {\n markers?: boolean;\n render(value: unknown, options?: { markers?: boolean }): string | Promise<string>;\n }): Promise<string> => {\n const inst = new ComponentInstance(this as ComponentInvocation<any>);\n return inst._renderServer(sctx);\n },\n // A.18 — hidratación: setup una vez + adopta DOM SSR; mismatch → remount\n // por el kernel reusando el renderable.\n hydrateDom: (ctx: {\n parent: Node;\n bounds: { start: Comment; end: Comment } | null;\n render(value: unknown): unknown;\n }): (() => void) => {\n const inst = new ComponentInstance(this as ComponentInvocation<any>);\n inst._hydrate(ctx);\n return () => inst.unmount();\n },\n };\n\n readonly definition: ComponentDefinition<P>;\n readonly props: P | undefined;\n /** A.14: slots declarados en la llamada — `Card(props, { default: slot(...) })`. */\n readonly slots: Record<string, Slot> | undefined;\n\n constructor(\n definition: ComponentDefinition<P>,\n props: P | undefined,\n slots?: Record<string, Slot>,\n ) {\n this.definition = definition;\n this.props = props;\n this.slots = slots;\n }\n}\n\nexport function isComponentInvocation(v: unknown): v is ComponentInvocation<any> {\n return v instanceof ComponentInvocation;\n}\n\n/** Owner → instancia, para localizar el padre al montar una invocación. */\nconst ownerToInstance = new WeakMap<OwnerLike, ComponentInstance>();\n/** Owner → frame de contexto (instancias o roots de mount con provides). */\nconst ownerToContext = new WeakMap<OwnerLike, Map<unknown, unknown>>();\n\n/**\n * @internal — registra un frame de contexto para un owner raíz (mount de\n * template con router, roots de app, etc).\n */\nexport function _registerContextOwner(\n owner: OwnerLike,\n context: Map<unknown, unknown>,\n): void {\n ownerToContext.set(owner, context);\n}\n\n// --- A.12: contexto permanente por instancia -----------------------------------\n//\n// El modelo actual usa un stack global empujado durante init/render — por eso\n// provide/inject fallan fuera de esas fases (A.3.6). Aquí el contexto ES de la\n// instancia: un Map propio por ComponentInstance, resuelto caminando la cadena\n// de owners activa. inject() funciona en setup, effects, onMount y callbacks —\n// el árbol de owners reproduce el árbol de componentes permanentemente.\n// Si no hay instancia en la cadena → undefined → el resolver cae al stack\n// global (misma semántica: provide fuera de componente lanza error).\n\n// Resolver secundario: el primario (server/index, ALS) gana durante SSR;\n// éste se consulta cuando aquél devuelve undefined (lado cliente).\n_pushContextScopeResolver(() => {\n const frames: Map<unknown, unknown>[] = [];\n let o: OwnerLike | null = getOwner();\n while (o) {\n const ctx = ownerToContext.get(o);\n if (ctx) frames.push(ctx);\n o = o.parent;\n }\n if (frames.length === 0) return undefined;\n frames.reverse(); // cadena innermost→outermost → stack outermost→innermost\n return frames;\n});\n\n/**\n * Define un componente funcional de primera clase (A.5):\n * `Counter(props)` retorna una invocación marcada; el runtime ejecuta el\n * setup cuando monta la invocación.\n */\nexport function defineComponent<P = Record<string, never>>(\n setup: (props: P | undefined, ctx: SetupCtx) => unknown,\n): ComponentDefinition<P> {\n const def = ((props?: P, slots?: Record<string, Slot>) =>\n new ComponentInvocation<P>(\n def as ComponentDefinition<P>,\n props,\n slots,\n )) as ComponentDefinition<P>;\n (def as { setup: unknown }).setup = setup;\n (def as { _isComponentDefinition: boolean })._isComponentDefinition = true;\n return def;\n}\n\n// --- Mount de alto nivel ------------------------------------------------------------\n\n/**\n * Monta un componente (clase o invocación funcional) en `container` y\n * devuelve el handle con `unmount()`. Todo el árbol reactivo muere con el\n * unmount — sin fugas de effects/computeds.\n */\nexport function mountComponent(\n value: ElurComponent | ComponentInvocation<any>,\n container: Element,\n): { unmount(): void; instance: ComponentInstance } {\n const inst = new ComponentInstance(value);\n inst.mount(container, null);\n return { unmount: () => inst.unmount(), instance: inst };\n}\n"],"mappings":";;;;;AAqIA,SAAS,EAAa,GAAoC;AAExD,QADI,EAAe,EAAE,GAAS,IACvB;;AAmCT,SAAgB,EAAW,GAAuB;AAChD,QAEE,OAAO,KAAM,cADb,KAEC,EAAiC,iBAAiB;;AAMvD,IAAI,IAAiB,GAER,IAAb,MAAa,EAAwC;CACnD,KAAc;CACd;CACA,QAAwB;CAExB,QAAiB,IAAI,GAAO;CAE5B,SAAmC;CACnC,QAAwB,EAAE;CAC1B,aAAqC;CAErC,0BAAmB,IAAI,KAAuB;CAE9C,QAAsC;CACtC,cAAuD;CACvD,iBAA8C;CAC9C,iBAAgD;CAEhD,eAA4D;CAC5D,aAAqD;CAErD,SAA6B;CAE7B,eAAoC;CACpC,eAAoC;CAEpC,YAAmC;CAEnC,eAAqD;CAErD,YAAY,GAAkD;AAS5D,EARI,EAAgB,EAAO,IACzB,KAAK,OAAO,SACZ,KAAK,QAAQ,MAEb,KAAK,OAAO,YACZ,KAAK,cAAc,IAGrB,KAAK,MAAM,gBAAgB,MACzB,EAAY,MAAM;GAAE,OAAO;GAAU,WAAW;GAAM,OAAO;GAAK,CAAC,CAChE;;CAaP,MACE,GACA,GACA,GAWM;AACN,MAAI,KAAK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E,UADA,EAAK,SAAS,EAAI,QACL,EAAK,SAAS;;EAE9B;CAED;CACA;CAEA;CAEA,YACE,GACA,GACA,GACA;AAGA,EAFA,KAAK,aAAa,GAClB,KAAK,QAAQ,GACb,KAAK,QAAQ;;;AAIjB,SAAgB,EAAsB,GAA2C;AAC/E,QAAO,aAAa;;AAItB,IAAM,oBAAkB,IAAI,SAAuC,EAE7D,oBAAiB,IAAI,SAA2C;AAMtE,SAAgB,EACd,GACA,GACM;AACN,GAAe,IAAI,GAAO,EAAQ;;AAepC,QAAgC;CAC9B,IAAM,IAAkC,EAAE,EACtC,IAAsB,GAAU;AACpC,QAAO,IAAG;EACR,IAAM,IAAM,EAAe,IAAI,EAAE;AAEjC,EADI,KAAK,EAAO,KAAK,EAAI,EACzB,IAAI,EAAE;;AAEJ,OAAO,WAAW,EAEtB,QADA,EAAO,SAAS,EACT;EACP"}
@@ -0,0 +1,2 @@
1
+ var e=new Map,t=!1;function n(t,n,r){e.set(t,{id:t,kind:n,write:r}),i()}function r(t){e.set(t,{id:t,kind:`custom`,write:t}),i()}function i(){t||(t=!0,queueMicrotask(()=>{let n=[...e.values()];e.clear(),t=!1;for(let e of n)try{e.write()}catch(t){console.error(`[Elur] Error in DOM write task (${e.kind}):`,t)}}))}exports.queueDOMWrite=r,exports.queueDomWrite=n;
2
+ //# sourceMappingURL=dom-write.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-write.cjs","names":[],"sources":["../../../../src/elur/next-2/dom-write.ts"],"sourcesContent":["// =============================================================================\n// --- next/ — cola DOM tipada (B.11) ---\n// Fork de ../template/dom-write.ts: misma superficie (`queueDOMWrite`), pero la\n// cola es tipada y hace last-write-wins por binding id — varios writes al mismo\n// binding en un microtask sólo ejecutan el último. La API tipada\n// `queueDomWrite(id, kind, write)` es la que el compiler usará para writers\n// directos (C.17); `queueDOMWrite(task)` queda como compat (id = identidad del\n// closure, misma deduplicación que la impl actual).\n// =============================================================================\n\nexport type DomWriteKind = \"text\" | \"attr\" | \"prop\" | \"class\" | \"style\" | \"custom\";\n\nexport interface DomWrite {\n /** Identidad del binding — dos writes con el mismo id colapsan (último gana). */\n id: unknown;\n kind: DomWriteKind;\n write: () => void;\n}\n\nconst _domWriteQueue = new Map<unknown, DomWrite>();\nlet _isDomWriteScheduled = false;\n\n/**\n * Cola tipada: `id` identifica el binding. Si el mismo binding escribe varias\n * veces antes del flush, sólo corre la última escritura — Map.set reemplaza el\n * valor conservando la posición de inserción.\n */\nexport function queueDomWrite(id: unknown, kind: DomWriteKind, write: () => void): void {\n _domWriteQueue.set(id, { id, kind, write });\n _schedule();\n}\n\n/**\n * Compat con la API actual: deduplica por identidad del closure\n * (comportamiento idéntico a la impl estable).\n */\nexport function queueDOMWrite(task: () => void): void {\n _domWriteQueue.set(task, { id: task, kind: \"custom\", write: task });\n _schedule();\n}\n\nfunction _schedule(): void {\n if (_isDomWriteScheduled) return;\n _isDomWriteScheduled = true;\n queueMicrotask(() => {\n const items = [..._domWriteQueue.values()];\n _domWriteQueue.clear();\n _isDomWriteScheduled = false;\n for (const item of items) {\n try {\n item.write();\n } catch (e) {\n // Evitamos que un error rompa el hilo entero\n console.error(`[Elur] Error in DOM write task (${item.kind}):`, e);\n }\n }\n });\n}\n"],"mappings":"AAmBA,IAAM,EAAiB,IAAI,IACvB,EAAuB,GAO3B,SAAgB,EAAc,EAAa,EAAoB,EAAyB,CACtF,EAAe,IAAI,EAAI,CAAE,KAAI,OAAM,QAAO,CAAC,CAC3C,GAAW,CAOb,SAAgB,EAAc,EAAwB,CACpD,EAAe,IAAI,EAAM,CAAE,GAAI,EAAM,KAAM,SAAU,MAAO,EAAM,CAAC,CACnE,GAAW,CAGb,SAAS,GAAkB,CACrB,IACJ,EAAuB,GACvB,mBAAqB,CACnB,IAAM,EAAQ,CAAC,GAAG,EAAe,QAAQ,CAAC,CAC1C,EAAe,OAAO,CACtB,EAAuB,GACvB,IAAK,IAAM,KAAQ,EACjB,GAAI,CACF,EAAK,OAAO,OACL,EAAG,CAEV,QAAQ,MAAM,mCAAmC,EAAK,KAAK,IAAK,EAAE,GAGtE"}
@@ -0,0 +1,18 @@
1
+ export type DomWriteKind = "text" | "attr" | "prop" | "class" | "style" | "custom";
2
+ export interface DomWrite {
3
+ /** Identidad del binding — dos writes con el mismo id colapsan (último gana). */
4
+ id: unknown;
5
+ kind: DomWriteKind;
6
+ write: () => void;
7
+ }
8
+ /**
9
+ * Cola tipada: `id` identifica el binding. Si el mismo binding escribe varias
10
+ * veces antes del flush, sólo corre la última escritura — Map.set reemplaza el
11
+ * valor conservando la posición de inserción.
12
+ */
13
+ export declare function queueDomWrite(id: unknown, kind: DomWriteKind, write: () => void): void;
14
+ /**
15
+ * Compat con la API actual: deduplica por identidad del closure
16
+ * (comportamiento idéntico a la impl estable).
17
+ */
18
+ export declare function queueDOMWrite(task: () => void): void;
@@ -0,0 +1,18 @@
1
+ export type DomWriteKind = "text" | "attr" | "prop" | "class" | "style" | "custom";
2
+ export interface DomWrite {
3
+ /** Identidad del binding — dos writes con el mismo id colapsan (último gana). */
4
+ id: unknown;
5
+ kind: DomWriteKind;
6
+ write: () => void;
7
+ }
8
+ /**
9
+ * Cola tipada: `id` identifica el binding. Si el mismo binding escribe varias
10
+ * veces antes del flush, sólo corre la última escritura — Map.set reemplaza el
11
+ * valor conservando la posición de inserción.
12
+ */
13
+ export declare function queueDomWrite(id: unknown, kind: DomWriteKind, write: () => void): void;
14
+ /**
15
+ * Compat con la API actual: deduplica por identidad del closure
16
+ * (comportamiento idéntico a la impl estable).
17
+ */
18
+ export declare function queueDOMWrite(task: () => void): void;
@@ -0,0 +1,31 @@
1
+ //#region src/elur/next-2/dom-write.ts
2
+ var e = /* @__PURE__ */ new Map(), t = !1;
3
+ function n(t, n, r) {
4
+ e.set(t, {
5
+ id: t,
6
+ kind: n,
7
+ write: r
8
+ }), i();
9
+ }
10
+ function r(t) {
11
+ e.set(t, {
12
+ id: t,
13
+ kind: "custom",
14
+ write: t
15
+ }), i();
16
+ }
17
+ function i() {
18
+ t || (t = !0, queueMicrotask(() => {
19
+ let n = [...e.values()];
20
+ e.clear(), t = !1;
21
+ for (let e of n) try {
22
+ e.write();
23
+ } catch (t) {
24
+ console.error(`[Elur] Error in DOM write task (${e.kind}):`, t);
25
+ }
26
+ }));
27
+ }
28
+ //#endregion
29
+ export { r as queueDOMWrite, n as queueDomWrite };
30
+
31
+ //# sourceMappingURL=dom-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-write.js","names":[],"sources":["../../../../src/elur/next-2/dom-write.ts"],"sourcesContent":["// =============================================================================\n// --- next/ — cola DOM tipada (B.11) ---\n// Fork de ../template/dom-write.ts: misma superficie (`queueDOMWrite`), pero la\n// cola es tipada y hace last-write-wins por binding id — varios writes al mismo\n// binding en un microtask sólo ejecutan el último. La API tipada\n// `queueDomWrite(id, kind, write)` es la que el compiler usará para writers\n// directos (C.17); `queueDOMWrite(task)` queda como compat (id = identidad del\n// closure, misma deduplicación que la impl actual).\n// =============================================================================\n\nexport type DomWriteKind = \"text\" | \"attr\" | \"prop\" | \"class\" | \"style\" | \"custom\";\n\nexport interface DomWrite {\n /** Identidad del binding — dos writes con el mismo id colapsan (último gana). */\n id: unknown;\n kind: DomWriteKind;\n write: () => void;\n}\n\nconst _domWriteQueue = new Map<unknown, DomWrite>();\nlet _isDomWriteScheduled = false;\n\n/**\n * Cola tipada: `id` identifica el binding. Si el mismo binding escribe varias\n * veces antes del flush, sólo corre la última escritura — Map.set reemplaza el\n * valor conservando la posición de inserción.\n */\nexport function queueDomWrite(id: unknown, kind: DomWriteKind, write: () => void): void {\n _domWriteQueue.set(id, { id, kind, write });\n _schedule();\n}\n\n/**\n * Compat con la API actual: deduplica por identidad del closure\n * (comportamiento idéntico a la impl estable).\n */\nexport function queueDOMWrite(task: () => void): void {\n _domWriteQueue.set(task, { id: task, kind: \"custom\", write: task });\n _schedule();\n}\n\nfunction _schedule(): void {\n if (_isDomWriteScheduled) return;\n _isDomWriteScheduled = true;\n queueMicrotask(() => {\n const items = [..._domWriteQueue.values()];\n _domWriteQueue.clear();\n _isDomWriteScheduled = false;\n for (const item of items) {\n try {\n item.write();\n } catch (e) {\n // Evitamos que un error rompa el hilo entero\n console.error(`[Elur] Error in DOM write task (${item.kind}):`, e);\n }\n }\n });\n}\n"],"mappings":";AAmBA,IAAM,oBAAiB,IAAI,KAAwB,EAC/C,IAAuB;AAO3B,SAAgB,EAAc,GAAa,GAAoB,GAAyB;AAEtF,CADA,EAAe,IAAI,GAAI;EAAE;EAAI;EAAM;EAAO,CAAC,EAC3C,GAAW;;AAOb,SAAgB,EAAc,GAAwB;AAEpD,CADA,EAAe,IAAI,GAAM;EAAE,IAAI;EAAM,MAAM;EAAU,OAAO;EAAM,CAAC,EACnE,GAAW;;AAGb,SAAS,IAAkB;AACrB,OACJ,IAAuB,IACvB,qBAAqB;EACnB,IAAM,IAAQ,CAAC,GAAG,EAAe,QAAQ,CAAC;AAE1C,EADA,EAAe,OAAO,EACtB,IAAuB;AACvB,OAAK,IAAM,KAAQ,EACjB,KAAI;AACF,KAAK,OAAO;WACL,GAAG;AAEV,WAAQ,MAAM,mCAAmC,EAAK,KAAK,KAAK,EAAE;;GAGtE"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./reactivity.cjs`),t=require(`../template/types.cjs`),n=require(`../../lifecycle.cjs`),r=require(`../../context.cjs`),i=require(`./component.cjs`),a=require(`./mount-helpers.cjs`),o=require(`../template/keyed.cjs`),s=require(`./keyed-diff.cjs`),c=require(`../template/sanitize.cjs`),l=require(`../template/bindings.cjs`);function u(e,r,o={}){try{if(i.isComponentInvocation(e)){let n=new i.ComponentInstance(e);return n._hydrate({parent:r,bounds:null,mismatch:o.mismatch,render:e=>{if(t.isElurTemplate(e)){let n=e[t.ELUR_TEMPLATE_DESCRIPTOR];return n||T(o,-1,`descriptor`,`Component template has no hydration descriptor`),f(n,r,o)}return e?._render?.(r,null)}}),{unmount:()=>n.unmount()}}if(n.isElurComponent(e))return d(e,r,o);let a=e[t.ELUR_TEMPLATE_DESCRIPTOR];return a||T(o,-1,`descriptor`,`Template has no hydration descriptor`),{unmount:f(a,r,o)}}catch(t){if(o.mismatch===`throw`)throw t;if(o.mismatch!==`remount`&&console.warn(`[elur] Hydration mismatch; remounting root:`,t),r.replaceChildren(),i.isComponentInvocation(e)){let t=new i.ComponentInstance(e);return t.mount(r,null),{unmount:()=>t.unmount()}}return{unmount:n.isElurComponent(e)?a._mountComponent(e,r,null):e._render(r,null)}}}function d(e,n,i){r._pushComponentContext();let a=()=>{};try{try{e.onInit?.()}catch(t){if(e.onError)e.onError(t);else throw t}let r=e.render()[t.ELUR_TEMPLATE_DESCRIPTOR];r||T(i,-1,`descriptor`,`Component template has no hydration descriptor`),a=f(r,n,i)}finally{r._popComponentContext()}let o=e.onMount?.();return{unmount(){e.onUnmount?.(),typeof o==`function`&&o(),a()}}}function f(e,t,n,r){if(e.hydrate){let i=e.hydrate(t,e.values,n,r);return typeof i==`function`?i:()=>{}}let i=p(t,r),a=[];for(let t=0;t<e.contexts.length;t++){let r=e.contexts[t],o=e.values[t];if(r.type===`event`){let e=i.events.get(t);e||T(n,t,`event`,`Missing event marker ${t}`),e.removeAttribute(`data-elur-e-${t}`),a.push(g(e,r.eventName,r.modifiers,o));continue}if(r.type===`attr`){let e=i.attributes.get(t);e||T(n,t,`attribute`,`Missing attribute marker ${t}`),e.removeAttribute(`data-elur-a-${t}`),a.push(_(e,r.attrName,r.url===!0,o));continue}let s=i.nodes.get(t);s||T(n,t,`node`,`Missing node marker ${t}`);let c=v(s,o,n,i.keyed.get(t),i.arrayItems.get(t));c&&a.push(c)}return()=>{for(let e=a.length-1;e>=0;e--)a[e]()}}function p(e,t){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=[],l=[],u=[],d=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),f;for(;f=d.nextNode();){if(t&&!h(f,t))continue;if(f.nodeType===Node.COMMENT_NODE){let e=f,t=/^elur-(\d+)$/.exec(e.data);if(t){let n=Number(t[1]);c.length===0&&r.set(n,e),c.push(n);continue}let i=/^elur-end-(\d+)$/.exec(e.data);if(i){let t=Number(i[1]);if(c.pop()===t&&c.length===0){let i=r.get(t);i&&n.set(t,{start:i,end:e})}continue}let a=/^elur-ki:(.+)$/.exec(e.data);if(a){let t=a[1];l.length===0&&c.length===1?l.push({start:e,serializedKey:t,parentIndex:c[c.length-1]}):l.push({start:e,serializedKey:t,parentIndex:-1});continue}if(e.data===`elur-ke`){let t=l.pop();if(t){if(t.parentIndex>=0){let n=o.get(t.parentIndex)??[];n.push({start:t.start,end:e,serializedKey:t.serializedKey}),o.set(t.parentIndex,n)}}else throw Error(`[elur] Hydration marker mismatch: orphan keyed end marker (elur-ke)`);continue}if(e.data===`elur-ai`){u.length===0&&c.length===1?u.push({start:e,parentIndex:c[c.length-1]}):u.push({start:e,parentIndex:-1});continue}if(e.data===`elur-aiend`){let t=u.pop();if(t&&t.parentIndex>=0){let n=s.get(t.parentIndex)??[];n.push({start:t.start,end:e}),s.set(t.parentIndex,n)}continue}continue}if(c.length>0)continue;let e=f;for(let t of Array.from(e.attributes)){let n=/^data-elur-e-(\d+)$/.exec(t.name);n&&a.set(Number(n[1]),e);let r=/^data-elur-a-(\d+)$/.exec(t.name);r&&i.set(Number(r[1]),e)}}return{nodes:n,attributes:i,events:a,keyed:o,arrayItems:s}}function m(e,t,n,r,i){return v(e,t,n??{},r,i)}function h(e,t){let n=document.createRange();return n.setStartAfter(t.start),n.setEndBefore(t.end),n.intersectsNode(e)}function g(e,t,n,r){if(typeof r!=`function`)throw TypeError(`Event "${t}" requires a function`);let i=r;if(l.isDelegableEvent(t)&&!n.includes(`capture`)&&!n.includes(`once`)&&document.body.contains(e))return l.activateDelegatedEvent(e,t,n,i);let a={once:n.includes(`once`),capture:n.includes(`capture`),passive:n.includes(`passive`)},o=e=>{n.includes(`prevent`)&&e.preventDefault(),n.includes(`stop`)&&e.stopPropagation(),!(n.includes(`self`)&&e.target!==e.currentTarget)&&i(e)};return e.addEventListener(t,o,a),()=>e.removeEventListener(t,o,a)}function _(n,r,i,a){if(r===`ref`){let e=a;return e.el=n,()=>{e.el=null}}let o=(r===`value`||r===`checked`||r===`selected`)&&r in n,s=!0,l=!1,u=e=>{if(o)if(!s)n[r]=e??``;else{let t=n[r];if(String(t)!==String(e??``)&&!l){l=!0;let e=r===`checked`||r===`selected`?`change`:`input`;queueMicrotask(()=>{l=!1,n.dispatchEvent(new Event(e,{bubbles:!0}))})}}else if(e==null||e===!1)n.removeAttribute(r);else{let t=i?c.sanitizeUrl(String(e)):String(e);n.setAttribute(r,t)}s=!1};return t.isDerivedBinding(a)&&(a=a.get),a instanceof e.Signal?e._bindSignal(a,u):typeof a==`function`?e.effect(()=>u(a())):(u(a),()=>{})}function v(n,i,a,o,c){if(t.isDerivedBinding(i)&&(i=i.get),i instanceof e.Signal){let t=C(n);t||(t=document.createTextNode(``),n.end.parentNode.insertBefore(t,n.end));let r=t;return e._bindSignal(i,e=>{r.nodeValue=e==null||e===!1?``:String(e)})}if(typeof i!=`function`)return y(n,i,a,o,c);let l=!0,u,d=C(n),f=null,p=r._captureContextSnapshot(),m=s.createKeyedMount(p),h=e=>{console.warn(`[elur] repeat(): duplicate key "${e}". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`)},g=e.effect(()=>{let e=i();if(t.isKeyedList(e)){if(l&&!f){let t=b(e,o,a);f={state:t.state,prevOrder:t.prevOrder},u=t.cleanup,s.reconcileKeyedList({zoneStart:n.start,anchor:n.end,state:f.state,prevOrder:f.prevOrder,list:e,mount:m,ctxSnapshot:p,onDuplicateKey:h}),d=null,l=!1;return}f||(u?.(),w(n),f={state:new Map,prevOrder:[]},u=()=>{for(let e of f.state.values())e.cleanup()}),s.reconcileKeyedList({zoneStart:n.start,anchor:n.end,state:f.state,prevOrder:f.prevOrder,list:e,mount:m,ctxSnapshot:p,onDuplicateKey:h}),d=null,l=!1;return}f&&(u?.(),w(n),f=null,u=void 0),typeof e==`string`||typeof e==`number`||typeof e==`bigint`?d?d.nodeValue!==String(e)&&(d.nodeValue=String(e)):(d=document.createTextNode(String(e)),n.end.parentNode.insertBefore(d,n.end)):l?u=y(n,e,a,o,c):(u?.(),w(n),u=S(n,e),d=C(n)),l=!1});return()=>{g(),u?.()}}function y(e,i,a,o,c){if(t.isKeyedList(i)){let t=r._captureContextSnapshot(),n=b(i,o,a);return s.reconcileKeyedList({zoneStart:e.start,anchor:e.end,state:n.state,prevOrder:n.prevOrder,list:i,mount:s.createKeyedMount(t),ctxSnapshot:t,onDuplicateKey:e=>{console.warn(`[elur] repeat(): duplicate key "${e}". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`)}}),n.cleanup}if(Array.isArray(i)){let t=[],n=c!==void 0&&c.length>0;for(let r=0;r<i.length;r++){let o=i[r],s=c?.[r];if(n&&s){let e=y(s,o,a);e&&t.push(e)}else if(n){let n=S(e,o);n&&t.push(n)}else{let n=y(e,o,a);n&&t.push(n)}}return t.length?()=>{for(let e=t.length-1;e>=0;e--)t[e]()}:void 0}if(t.isElurTemplate(i)){let n=i[t.ELUR_TEMPLATE_DESCRIPTOR];return n||T(a,-1,`descriptor`,`Nested template has no hydration descriptor`),f(n,e.start.parentNode,a,e)}if(n.isElurComponent(i)){r._pushComponentContext();let n;try{try{i.onInit?.()}catch(e){if(i.onError)i.onError(e);else throw e}let r=i.render()[t.ELUR_TEMPLATE_DESCRIPTOR];r||T(a,-1,`descriptor`,`Nested component has no hydration descriptor`);let o=f(r,e.start.parentNode,a,e),s=i.onMount?.();n=()=>{i.onUnmount?.(),typeof s==`function`&&s(),o()}}finally{r._popComponentContext()}return n}if(typeof i==`object`&&i){let n=i[t.ELUR_RENDER_PROTOCOL];if(n?.hydrateDom)return n.hydrateDom({parent:e.start.parentNode,bounds:e,context:a.context,render:t=>y(e,t,a)})??void 0}}function b(t,n,r){let i=new Map,a=[];if(!n||n.length===0)return{state:i,prevOrder:a,cleanup:()=>{}};let s=new Map;for(let e=0;e<t.items.length;e++){let n=o.normalizeRepeatKey(t.keyFn(t.items[e],e),e),r=o.serializeRepeatKey(n);s.has(r)&&console.warn(`[elur] repeat(): duplicate client key "${n}" during hydration. Keys must be unique; entries after the first leak.`),s.set(r,e)}for(let c of n){let n=s.get(c.serializedKey);if(n===void 0){x(c);continue}let l=t.items[n],u=o.normalizeRepeatKey(t.keyFn(l,n),n);if(o.serializeRepeatKey(u)!==c.serializedKey&&console.warn(`[elur] repeat(): hydration key mismatch at index ${n} (${o.deserializeRepeatKey(c.serializedKey)} != ${u}). The SSR item is adopted by position.`),i.has(u)){console.warn(`[elur] repeat(): duplicate key "${u}" during hydration; removing duplicate SSR node.`),x(c);continue}let d=t.renderFn(l,n),f,p=e.createRoot(e=>(f=y({start:c.start,end:c.end},d,r),e));i.set(u,{start:c.start,end:c.end,cleanup:()=>{f?.(),p()},item:l}),a.push(u)}return{state:i,prevOrder:a,cleanup:()=>{for(let e of i.values())e.cleanup()}}}function x(e){let t=e.start.nextSibling;for(;t&&t!==e.end;){let e=t.nextSibling;t.parentNode?.removeChild(t),t=e}e.start.parentNode?.removeChild(e.start),e.end.parentNode?.removeChild(e.end)}function S(e,r){if(r==null||r===!1||r===!0)return;if(Array.isArray(r)){let t=[];for(let n of r){let r=S(e,n);r&&t.push(r)}return t.length?()=>{for(let e=t.length-1;e>=0;e--)t[e]()}:void 0}if(t.isElurTemplate(r))return r._render(e.end.parentNode,e.end);if(n.isElurComponent(r))return r.render()._render(e.end.parentNode,e.end);let i=document.createTextNode(String(r));return e.end.parentNode.insertBefore(i,e.end),()=>i.parentNode?.removeChild(i)}function C(e){let t=e.start.nextSibling;for(;t&&t!==e.end;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.nextSibling}return null}function w(e){let t=e.start.nextSibling;for(;t&&t!==e.end;){let e=t.nextSibling;t.parentNode?.removeChild(t),t=e}}function T(e,t,n,r){let i={index:t,kind:n,message:r};e.onMismatch?.(i);let a=Error(`[elur] Hydration marker mismatch: ${r}`);throw Object.assign(a,{mismatch:i}),a}exports._hydrateNodeRange=m,exports.hydrate=u;
2
+ //# sourceMappingURL=hydrate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate.cjs","names":[],"sources":["../../../../src/elur/next-2/hydrate.ts"],"sourcesContent":["import { _captureContextSnapshot, _popComponentContext, _pushComponentContext } from \"../context.js\";\nimport { isElurComponent, type ElurComponent } from \"../lifecycle.js\";\nimport { effect, createRoot, Signal, _bindSignal } from \"./reactivity.js\";\nimport { isDerivedBinding } from \"../template/types.js\";\nimport {\n ComponentInstance,\n isComponentInvocation,\n type ComponentInvocation,\n} from \"./component.js\";\nimport { sanitizeUrl } from \"../template/sanitize.js\";\nimport { activateDelegatedEvent, isDelegableEvent } from \"../template/bindings.js\";\nimport {\n isKeyedList,\n isElurTemplate,\n ELUR_RENDER_PROTOCOL,\n ELUR_TEMPLATE_DESCRIPTOR,\n type KEntry,\n type ElurMountHandle,\n type ElurRef,\n type ElurTemplate,\n type TemplateDescriptor,\n} from \"../template/types.js\";\nimport {\n deserializeRepeatKey,\n normalizeRepeatKey,\n serializeRepeatKey,\n type RepeatKey,\n} from \"../template/keyed.js\";\nimport { createKeyedMount, reconcileKeyedList } from \"./keyed-diff.js\";\nimport { _mountComponent } from \"./mount-helpers.js\";\n\nexport interface HydrateOptions {\n mismatch?: \"throw\" | \"warn-remount\" | \"remount\";\n onMismatch?: (error: HydrationMismatch) => void;\n context?: unknown;\n}\n\nexport interface HydrationMismatch {\n index: number;\n kind: \"node\" | \"attribute\" | \"event\" | \"descriptor\" | \"keyed\";\n message: string;\n}\n\ninterface MarkerRange {\n start: Comment;\n end: Comment;\n}\n\ninterface KeyedMarkerRange {\n start: Comment;\n end: Comment;\n serializedKey: string;\n}\n\ninterface ScannedMarkers {\n nodes: Map<number, MarkerRange>;\n attributes: Map<number, Element>;\n events: Map<number, Element>;\n keyed: Map<number, KeyedMarkerRange[]>;\n arrayItems: Map<number, MarkerRange[]>;\n}\n\nexport function hydrate(\n value: ElurTemplate | ElurComponent | ComponentInvocation<any>,\n container: Element,\n options: HydrateOptions = {},\n): ElurMountHandle {\n try {\n // A.18 — componentes funcionales: setup una vez + adoptar DOM SSR;\n // mismatch → el kernel remonta reusando el renderable.\n if (isComponentInvocation(value)) {\n const inst = new ComponentInstance(value);\n inst._hydrate({\n parent: container,\n bounds: null,\n mismatch: options.mismatch,\n render: (nested) => {\n if (isElurTemplate(nested)) {\n const d = nested[ELUR_TEMPLATE_DESCRIPTOR];\n if (!d) {\n throwMismatch(options, -1, \"descriptor\", \"Component template has no hydration descriptor\");\n }\n return hydrateDescriptor(d!, container, options);\n }\n return (nested as { _render?: (p: Node, b: Node | null) => () => void })\n ?._render?.(container, null);\n },\n });\n return { unmount: () => inst.unmount() };\n }\n if (isElurComponent(value)) return hydrateComponent(value, container, options);\n const descriptor = value[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Template has no hydration descriptor\");\n const cleanup = hydrateDescriptor(descriptor!, container, options);\n return { unmount: cleanup };\n } catch (error) {\n if (options.mismatch === \"throw\") throw error;\n if (options.mismatch !== \"remount\") console.warn(\"[elur] Hydration mismatch; remounting root:\", error);\n container.replaceChildren();\n if (isComponentInvocation(value)) {\n // A.18 — remount root por el kernel tras mismatch top-level.\n const inst = new ComponentInstance(value);\n inst.mount(container, null);\n return { unmount: () => inst.unmount() };\n }\n const cleanup = isElurComponent(value)\n ? _mountComponent(value, container, null)\n : value._render(container, null);\n return { unmount: cleanup };\n }\n}\n\nfunction hydrateComponent(\n component: ElurComponent,\n container: Element,\n options: HydrateOptions,\n): ElurMountHandle {\n _pushComponentContext();\n let cleanup = () => { };\n try {\n try {\n component.onInit?.();\n } catch (error) {\n if (component.onError) component.onError(error);\n else throw error;\n }\n const template = component.render();\n const descriptor = template[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Component template has no hydration descriptor\");\n cleanup = hydrateDescriptor(descriptor!, container, options);\n } finally {\n _popComponentContext();\n }\n const mountCleanup = component.onMount?.();\n return {\n unmount() {\n component.onUnmount?.();\n if (typeof mountCleanup === \"function\") mountCleanup();\n cleanup();\n },\n };\n}\n\nfunction hydrateDescriptor(\n descriptor: TemplateDescriptor,\n root: ParentNode,\n options: HydrateOptions,\n bounds?: MarkerRange,\n): () => void {\n // C.13: descriptor compilado — activación por posición, sin scan global.\n if (descriptor.hydrate) {\n const cleanup = descriptor.hydrate(root, descriptor.values, options, bounds);\n return typeof cleanup === \"function\" ? cleanup : () => { };\n }\n const markers = scanMarkers(root, bounds);\n const cleanups: Array<() => void> = [];\n\n for (let index = 0; index < descriptor.contexts.length; index++) {\n const context = descriptor.contexts[index];\n const value = descriptor.values[index];\n if (context.type === \"event\") {\n const element = markers.events.get(index);\n if (!element) throwMismatch(options, index, \"event\", `Missing event marker ${index}`);\n element!.removeAttribute(`data-elur-e-${index}`);\n cleanups.push(activateEvent(element!, context.eventName, context.modifiers, value));\n continue;\n }\n if (context.type === \"attr\") {\n const element = markers.attributes.get(index);\n if (!element) throwMismatch(options, index, \"attribute\", `Missing attribute marker ${index}`);\n element!.removeAttribute(`data-elur-a-${index}`);\n cleanups.push(activateAttribute(element!, context.attrName, context.url === true, value));\n continue;\n }\n\n const range = markers.nodes.get(index);\n if (!range) throwMismatch(options, index, \"node\", `Missing node marker ${index}`);\n const cleanup = activateNode(range!, value, options, markers.keyed.get(index), markers.arrayItems.get(index));\n if (cleanup) cleanups.push(cleanup);\n }\n\n return () => {\n for (let index = cleanups.length - 1; index >= 0; index--) cleanups[index]();\n };\n}\n\nfunction scanMarkers(root: ParentNode, bounds?: MarkerRange): ScannedMarkers {\n const nodes = new Map<number, MarkerRange>();\n const starts = new Map<number, Comment>();\n const attributes = new Map<number, Element>();\n const events = new Map<number, Element>();\n const keyed = new Map<number, KeyedMarkerRange[]>();\n const arrayItems = new Map<number, MarkerRange[]>();\n const stack: number[] = [];\n const keyedStack: Array<{ start: Comment; serializedKey: string; parentIndex: number }> = [];\n const arrayStack: Array<{ start: Comment; parentIndex: number }> = [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT);\n let current: Node | null;\n\n while ((current = walker.nextNode())) {\n if (bounds && !isInsideRange(current, bounds)) continue;\n if (current.nodeType === Node.COMMENT_NODE) {\n const comment = current as Comment;\n const startMatch = /^elur-(\\d+)$/.exec(comment.data);\n if (startMatch) {\n const index = Number(startMatch[1]);\n if (stack.length === 0) starts.set(index, comment);\n stack.push(index);\n continue;\n }\n const endMatch = /^elur-end-(\\d+)$/.exec(comment.data);\n if (endMatch) {\n const index = Number(endMatch[1]);\n const active = stack.pop();\n if (active === index && stack.length === 0) {\n const start = starts.get(index);\n if (start) nodes.set(index, { start, end: comment });\n }\n continue;\n }\n const keyedStartMatch = /^elur-ki:(.+)$/.exec(comment.data);\n if (keyedStartMatch) {\n const serializedKey = keyedStartMatch[1];\n if (keyedStack.length === 0 && stack.length === 1) {\n keyedStack.push({ start: comment, serializedKey, parentIndex: stack[stack.length - 1] });\n } else {\n keyedStack.push({ start: comment, serializedKey, parentIndex: -1 });\n }\n continue;\n }\n if (comment.data === \"elur-ke\") {\n const active = keyedStack.pop();\n if (active) {\n if (active.parentIndex >= 0) {\n const list = keyed.get(active.parentIndex) ?? [];\n list.push({ start: active.start, end: comment, serializedKey: active.serializedKey });\n keyed.set(active.parentIndex, list);\n }\n } else {\n throw new Error(\"[elur] Hydration marker mismatch: orphan keyed end marker (elur-ke)\");\n }\n continue;\n }\n if (comment.data === \"elur-ai\") {\n if (arrayStack.length === 0 && stack.length === 1) {\n arrayStack.push({ start: comment, parentIndex: stack[stack.length - 1] });\n } else {\n arrayStack.push({ start: comment, parentIndex: -1 });\n }\n continue;\n }\n if (comment.data === \"elur-aiend\") {\n const active = arrayStack.pop();\n if (active && active.parentIndex >= 0) {\n const list = arrayItems.get(active.parentIndex) ?? [];\n list.push({ start: active.start, end: comment });\n arrayItems.set(active.parentIndex, list);\n }\n continue;\n }\n continue;\n }\n if (stack.length > 0) continue;\n const element = current as Element;\n for (const attribute of Array.from(element.attributes)) {\n const eventMatch = /^data-elur-e-(\\d+)$/.exec(attribute.name);\n if (eventMatch) events.set(Number(eventMatch[1]), element);\n const attributeMatch = /^data-elur-a-(\\d+)$/.exec(attribute.name);\n if (attributeMatch) attributes.set(Number(attributeMatch[1]), element);\n }\n }\n\n return { nodes, attributes, events, keyed, arrayItems };\n}\n\n/**\n * @internal — C.13: activación de un binding de nodo durante hidratación\n * compilada. El runtime del plugin localiza los markers por posición y\n * delega aquí — misma semántica que el path de markers globales.\n */\nexport function _hydrateNodeRange(\n range: { start: Comment; end: Comment },\n value: unknown,\n options?: HydrateOptions,\n keyedItems?: Array<{ start: Comment; end: Comment; serializedKey: string }>,\n arrayItems?: Array<{ start: Comment; end: Comment }>,\n): (() => void) | undefined {\n return activateNode(range, value, options ?? {}, keyedItems, arrayItems);\n}\n\nfunction isInsideRange(node: Node, range: MarkerRange): boolean {\n const domRange = document.createRange();\n domRange.setStartAfter(range.start);\n domRange.setEndBefore(range.end);\n return domRange.intersectsNode(node);\n}\n\nfunction activateEvent(\n element: Element,\n eventName: string,\n modifiers: readonly string[],\n value: unknown,\n): () => void {\n if (typeof value !== \"function\") throw new TypeError(`Event \"${eventName}\" requires a function`);\n const rawHandler = value as EventListener;\n\n // Use global delegation for delegable events without capture/once mods,\n // matching the mount-time behavior in bindings.ts. The element must be\n // connected to the document for delegation to work (events bubble to\n // document where the delegated listener is registered).\n const canDelegate =\n isDelegableEvent(eventName) &&\n !modifiers.includes(\"capture\") &&\n !modifiers.includes(\"once\") &&\n document.body.contains(element);\n\n if (canDelegate) {\n return activateDelegatedEvent(element, eventName, modifiers, rawHandler);\n }\n\n // Non-delegable events or disconnected elements: use addEventListener directly.\n const options: AddEventListenerOptions = {\n once: modifiers.includes(\"once\"),\n capture: modifiers.includes(\"capture\"),\n passive: modifiers.includes(\"passive\"),\n };\n const listener = (event: Event) => {\n if (modifiers.includes(\"prevent\")) event.preventDefault();\n if (modifiers.includes(\"stop\")) event.stopPropagation();\n if (modifiers.includes(\"self\") && event.target !== event.currentTarget) return;\n rawHandler(event);\n };\n element.addEventListener(eventName, listener, options);\n return () => element.removeEventListener(eventName, listener, options);\n}\n\nfunction activateAttribute(\n element: Element,\n name: string,\n url: boolean,\n value: unknown,\n): () => void {\n if (name === \"ref\") {\n const reference = value as ElurRef<Element>;\n reference.el = element;\n return () => { reference.el = null; };\n }\n\n const isProperty = (name === \"value\" || name === \"checked\" || name === \"selected\") && name in element;\n let firstRun = true;\n let pendingSync = false;\n const update = (resolved: unknown) => {\n if (isProperty) {\n if (!firstRun) {\n (element as any)[name] = resolved ?? \"\";\n } else {\n // Interaction before hydration: the DOM may hold a value the\n // user (or a hydration race with lazy island directives like\n // \"visible\") wrote before the binding activated. The DOM is\n // authoritative; keep it and propagate it to reactive model\n // sources once every handler is attached (microtask) so a\n // late @input/@change listener picks up the real value.\n const current = (element as any)[name];\n const model = resolved ?? \"\";\n if (String(current) !== String(model) && !pendingSync) {\n pendingSync = true;\n const eventName = name === \"checked\" || name === \"selected\" ? \"change\" : \"input\";\n queueMicrotask(() => {\n pendingSync = false;\n element.dispatchEvent(new Event(eventName, { bubbles: true }));\n });\n }\n }\n } else if (resolved === null || resolved === undefined || resolved === false) {\n element.removeAttribute(name);\n } else {\n const serialized = url ? sanitizeUrl(String(resolved)) : String(resolved);\n element.setAttribute(name, serialized);\n }\n firstRun = false;\n };\n\n // C.7 T2: desenvolver el pack derivado a getter — el effect trackea las\n // deps dinámicamente (semántica idéntica al path genérico).\n if (isDerivedBinding(value)) value = value.get;\n if (value instanceof Signal) {\n // C.6 T1: binding directo — la primera escritura pasa por el mismo\n // path firstRun (el DOM es autoritativo para props interactivos).\n return _bindSignal(value, update);\n }\n if (typeof value === \"function\") {\n return effect(() => update((value as () => unknown)()));\n }\n update(value);\n return () => { };\n}\n\nfunction activateNode(\n range: MarkerRange,\n value: unknown,\n options: HydrateOptions,\n keyedItems?: KeyedMarkerRange[],\n arrayItems?: MarkerRange[],\n): (() => void) | undefined {\n // C.7 T2: desenvolver el pack derivado a getter — cae en el path de\n // function con tracking dinámico.\n if (isDerivedBinding(value)) value = value.get;\n // C.6 T1: el valor ES la señal — adoptar el text node SSR y suscribirlo\n // directo (sin effect ni getter). Si no hay text node, crearlo.\n if (value instanceof Signal) {\n let sigText = findTextNode(range);\n if (!sigText) {\n sigText = document.createTextNode(\"\");\n range.end.parentNode!.insertBefore(sigText, range.end);\n }\n const node = sigText;\n return _bindSignal(value, (v) => {\n node.nodeValue = v == null || v === false ? \"\" : String(v);\n });\n }\n\n if (typeof value !== \"function\") return hydrateNodeValue(range, value, options, keyedItems, arrayItems);\n\n let firstRun = true;\n let nestedCleanup: (() => void) | undefined;\n let textNode = findTextNode(range);\n let keyed: { state: Map<RepeatKey, KEntry>; prevOrder: RepeatKey[] } | null = null;\n const ctxSnapshot = _captureContextSnapshot();\n const keyedMount = createKeyedMount(ctxSnapshot);\n\n const warnDuplicate = (key: RepeatKey) => {\n console.warn(`[elur] repeat(): duplicate key \"${key}\". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);\n };\n\n const dispose = effect(() => {\n const resolved = (value as () => unknown)();\n\n if (isKeyedList(resolved)) {\n if (firstRun && !keyed) {\n // First resolution is a keyed list: adopt the SSR markers when\n // present. Afterwards we converge with the current model, which\n // handles count/ordering drift without recreating surviving nodes.\n const adopted = adoptKeyedRange(resolved, keyedItems, options);\n keyed = { state: adopted.state, prevOrder: adopted.prevOrder };\n nestedCleanup = adopted.cleanup;\n reconcileKeyedList({\n zoneStart: range.start,\n anchor: range.end,\n state: keyed.state,\n prevOrder: keyed.prevOrder,\n list: resolved,\n mount: keyedMount,\n ctxSnapshot,\n onDuplicateKey: warnDuplicate,\n });\n textNode = null;\n firstRun = false;\n return;\n }\n if (!keyed) {\n // The binding became keyed after another value: the SSR markers\n // were already consumed (or never existed), so mount fresh.\n nestedCleanup?.();\n clearRange(range);\n keyed = { state: new Map(), prevOrder: [] };\n nestedCleanup = () => {\n for (const entry of keyed!.state.values()) entry.cleanup();\n };\n }\n reconcileKeyedList({\n zoneStart: range.start,\n anchor: range.end,\n state: keyed.state,\n prevOrder: keyed.prevOrder,\n list: resolved,\n mount: keyedMount,\n ctxSnapshot,\n onDuplicateKey: warnDuplicate,\n });\n textNode = null;\n firstRun = false;\n return;\n }\n\n // Non-keyed value: tear down any keyed zone first.\n if (keyed) {\n nestedCleanup?.();\n clearRange(range);\n keyed = null;\n nestedCleanup = undefined;\n }\n\n if (typeof resolved === \"string\" || typeof resolved === \"number\" || typeof resolved === \"bigint\") {\n if (!textNode) {\n textNode = document.createTextNode(String(resolved));\n range.end.parentNode!.insertBefore(textNode, range.end);\n } else if (textNode.nodeValue !== String(resolved)) {\n textNode.nodeValue = String(resolved);\n }\n } else if (firstRun) {\n nestedCleanup = hydrateNodeValue(range, resolved, options, keyedItems, arrayItems);\n } else {\n nestedCleanup?.();\n clearRange(range);\n nestedCleanup = mountNodeValue(range, resolved);\n textNode = findTextNode(range);\n }\n firstRun = false;\n });\n\n return () => {\n dispose();\n nestedCleanup?.();\n };\n}\n\nfunction hydrateNodeValue(\n range: MarkerRange,\n value: unknown,\n options: HydrateOptions,\n keyedItems?: KeyedMarkerRange[],\n arrayItems?: MarkerRange[],\n): (() => void) | undefined {\n if (isKeyedList(value)) {\n const ctxSnapshot = _captureContextSnapshot();\n const adopted = adoptKeyedRange(value, keyedItems, options);\n reconcileKeyedList({\n zoneStart: range.start,\n anchor: range.end,\n state: adopted.state,\n prevOrder: adopted.prevOrder,\n list: value,\n mount: createKeyedMount(ctxSnapshot),\n ctxSnapshot,\n onDuplicateKey: (key) => {\n console.warn(`[elur] repeat(): duplicate key \"${key}\". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);\n },\n });\n return adopted.cleanup;\n }\n if (Array.isArray(value)) {\n const cleanups: Array<() => void> = [];\n const hasMarkers = arrayItems !== undefined && arrayItems.length > 0;\n for (let index = 0; index < value.length; index++) {\n const item = value[index];\n const itemBounds = arrayItems?.[index];\n if (hasMarkers && itemBounds) {\n // Hydrate each item within its own SSR-delimited range so\n // repeated marker indices across items never collide.\n const cleanup = hydrateNodeValue(itemBounds, item, options);\n if (cleanup) cleanups.push(cleanup);\n } else if (hasMarkers) {\n // Client item with no SSR slot: mount it fresh at the end.\n const cleanup = mountNodeValue(range, item);\n if (cleanup) cleanups.push(cleanup);\n } else {\n const cleanup = hydrateNodeValue(range, item, options);\n if (cleanup) cleanups.push(cleanup);\n }\n }\n return cleanups.length ? () => { for (let i = cleanups.length - 1; i >= 0; i--) cleanups[i](); } : undefined;\n }\n if (isElurTemplate(value)) {\n const descriptor = value[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Nested template has no hydration descriptor\");\n return hydrateDescriptor(descriptor!, range.start.parentNode as ParentNode, options, range);\n }\n if (isElurComponent(value)) {\n _pushComponentContext();\n let result: (() => void) | undefined;\n try {\n try {\n value.onInit?.();\n } catch (error) {\n if (value.onError) value.onError(error);\n else throw error;\n }\n const template = value.render();\n const descriptor = template[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Nested component has no hydration descriptor\");\n const cleanup = hydrateDescriptor(descriptor!, range.start.parentNode as ParentNode, options, range);\n const mountCleanup = value.onMount?.();\n result = () => {\n value.onUnmount?.();\n if (typeof mountCleanup === \"function\") mountCleanup();\n cleanup();\n };\n } finally {\n _popComponentContext();\n }\n return result;\n }\n if (value != null && typeof value === \"object\") {\n const protocol = (value as Record<PropertyKey, unknown>)[ELUR_RENDER_PROTOCOL] as\n | { hydrateDom?: (ctx: import(\"../template/types.js\").HydrationProtocolContext) => (() => void) | void }\n | undefined;\n if (protocol?.hydrateDom) {\n return protocol.hydrateDom({\n parent: range.start.parentNode!,\n bounds: range,\n context: options.context,\n render: (nested) => hydrateNodeValue(range, nested, options),\n }) ?? undefined;\n }\n }\n return undefined;\n}\n\nfunction adoptKeyedRange(\n list: import(\"../template/types.js\").KeyedList,\n keyedItems: KeyedMarkerRange[] | undefined,\n options: HydrateOptions,\n): { state: Map<RepeatKey, KEntry>; prevOrder: RepeatKey[]; cleanup: () => void } {\n const state = new Map<RepeatKey, KEntry>();\n const prevOrder: RepeatKey[] = [];\n\n if (!keyedItems || keyedItems.length === 0) {\n return { state, prevOrder, cleanup: () => { } };\n }\n\n const clientByKey = new Map<string, number>();\n for (let j = 0; j < list.items.length; j++) {\n const key = normalizeRepeatKey(list.keyFn(list.items[j], j), j);\n const serialized = serializeRepeatKey(key);\n if (clientByKey.has(serialized)) {\n console.warn(\n `[elur] repeat(): duplicate client key \"${key}\" during hydration. ` +\n \"Keys must be unique; entries after the first leak.\",\n );\n }\n clientByKey.set(serialized, j);\n }\n\n for (const marker of keyedItems) {\n const clientIndex = clientByKey.get(marker.serializedKey);\n if (clientIndex === undefined) {\n // SSR item not present in the client model → remove its DOM.\n removeKeyedMarker(marker);\n continue;\n }\n const item = list.items[clientIndex];\n const key = normalizeRepeatKey(list.keyFn(item, clientIndex), clientIndex);\n if (serializeRepeatKey(key) !== marker.serializedKey) {\n console.warn(\n `[elur] repeat(): hydration key mismatch at index ${clientIndex} ` +\n `(${deserializeRepeatKey(marker.serializedKey)} != ${key}). The SSR item is adopted by position.`,\n );\n }\n if (state.has(key)) {\n console.warn(`[elur] repeat(): duplicate key \"${key}\" during hydration; removing duplicate SSR node.`);\n removeKeyedMarker(marker);\n continue;\n }\n const rendered = list.renderFn(item, clientIndex);\n // next/: bindings del item bajo su propio owner — sobreviven a\n // re-evals del effect de la lista y mueren con entry.cleanup().\n let inner: (() => void) | undefined;\n const disposeOwner = createRoot((dispose) => {\n inner = hydrateNodeValue(\n { start: marker.start, end: marker.end },\n rendered,\n options,\n );\n return dispose;\n });\n const cleanup = () => { inner?.(); disposeOwner(); };\n // C.16.1: guardar el item — reconcileKeyedList lo usa para detectar\n // \"misma key, objeto nuevo\" y remontar. Sin él, el primer update\n // remontaría los nodos SSR adoptados (pérdida de identidad).\n state.set(key, { start: marker.start, end: marker.end, cleanup, item } as KEntry);\n prevOrder.push(key);\n }\n\n return {\n state,\n prevOrder,\n cleanup: () => {\n for (const entry of state.values()) entry.cleanup();\n },\n };\n}\n\nfunction removeKeyedMarker(marker: KeyedMarkerRange): void {\n let node: Node | null = marker.start.nextSibling;\n while (node && node !== marker.end) {\n const next = node.nextSibling;\n node.parentNode?.removeChild(node);\n node = next;\n }\n marker.start.parentNode?.removeChild(marker.start);\n marker.end.parentNode?.removeChild(marker.end);\n}\n\nfunction mountNodeValue(range: MarkerRange, value: unknown): (() => void) | undefined {\n if (value === null || value === undefined || value === false || value === true) return undefined;\n if (Array.isArray(value)) {\n const cleanups: Array<() => void> = [];\n for (const item of value) {\n const cleanup = mountNodeValue(range, item);\n if (cleanup) cleanups.push(cleanup);\n }\n return cleanups.length ? () => { for (let i = cleanups.length - 1; i >= 0; i--) cleanups[i](); } : undefined;\n }\n if (isElurTemplate(value)) return value._render(range.end.parentNode!, range.end);\n if (isElurComponent(value)) return value.render()._render(range.end.parentNode!, range.end);\n const node = document.createTextNode(String(value));\n range.end.parentNode!.insertBefore(node, range.end);\n return () => node.parentNode?.removeChild(node);\n}\n\nfunction findTextNode(range: MarkerRange): Text | null {\n let node = range.start.nextSibling;\n while (node && node !== range.end) {\n if (node.nodeType === Node.TEXT_NODE) return node as Text;\n node = node.nextSibling;\n }\n return null;\n}\n\nfunction clearRange(range: MarkerRange): void {\n let node = range.start.nextSibling;\n while (node && node !== range.end) {\n const next = node.nextSibling;\n node.parentNode?.removeChild(node);\n node = next;\n }\n}\n\nfunction throwMismatch(\n options: HydrateOptions,\n index: number,\n kind: HydrationMismatch[\"kind\"],\n message: string,\n): never {\n const mismatch = { index, kind, message } satisfies HydrationMismatch;\n options.onMismatch?.(mismatch);\n const error = new Error(`[elur] Hydration marker mismatch: ${message}`);\n Object.assign(error, { mismatch });\n throw error;\n}"],"mappings":"kVA8DA,SAAgB,EACZ,EACA,EACA,EAA0B,EAAE,CACb,CACf,GAAI,CAGA,GAAI,EAAA,sBAAsB,EAAM,CAAE,CAC9B,IAAM,EAAO,IAAI,EAAA,kBAAkB,EAAM,CAiBzC,OAhBA,EAAK,SAAS,CACV,OAAQ,EACR,OAAQ,KACR,SAAU,EAAQ,SAClB,OAAS,GAAW,CAChB,GAAI,EAAA,eAAe,EAAO,CAAE,CACxB,IAAM,EAAI,EAAO,EAAA,0BAIjB,OAHK,GACD,EAAc,EAAS,GAAI,aAAc,iDAAiD,CAEvF,EAAkB,EAAI,EAAW,EAAQ,CAEpD,OAAQ,GACF,UAAU,EAAW,KAAK,EAEvC,CAAC,CACK,CAAE,YAAe,EAAK,SAAS,CAAE,CAE5C,GAAI,EAAA,gBAAgB,EAAM,CAAE,OAAO,EAAiB,EAAO,EAAW,EAAQ,CAC9E,IAAM,EAAa,EAAM,EAAA,0BAGzB,OAFK,GAAY,EAAc,EAAS,GAAI,aAAc,uCAAuC,CAE1F,CAAE,QADO,EAAkB,EAAa,EAAW,EAAQ,CACvC,OACtB,EAAO,CACZ,GAAI,EAAQ,WAAa,QAAS,MAAM,EAGxC,GAFI,EAAQ,WAAa,WAAW,QAAQ,KAAK,8CAA+C,EAAM,CACtG,EAAU,iBAAiB,CACvB,EAAA,sBAAsB,EAAM,CAAE,CAE9B,IAAM,EAAO,IAAI,EAAA,kBAAkB,EAAM,CAEzC,OADA,EAAK,MAAM,EAAW,KAAK,CACpB,CAAE,YAAe,EAAK,SAAS,CAAE,CAK5C,MAAO,CAAE,QAHO,EAAA,gBAAgB,EAAM,CAChC,EAAA,gBAAgB,EAAO,EAAW,KAAK,CACvC,EAAM,QAAQ,EAAW,KAAK,CACT,EAInC,SAAS,EACL,EACA,EACA,EACe,CACf,EAAA,uBAAuB,CACvB,IA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AO,EAAK,CACvC,GAAS,EAAS,KAAK,EAAQ,CAEvC,OAAO,EAAS,WAAe,CAAE,IAAK,IAAI,EAAI,EAAS,OAAS,EAAG,GAAK,EAAG,IAAK,EAAS,IAAI,EAAM,IAAA,GAEvG,GAAI,EAAA,eAAe,EAAM,CAAE,OAAO,EAAM,QAAQ,EAAM,IAAI,WAAa,EAAM,IAAI,CACjF,GAAI,EAAA,gBAAgB,EAAM,CAAE,OAAO,EAAM,QAAQ,CAAC,QAAQ,EAAM,IAAI,WAAa,EAAM,IAAI,CAC3F,IAAM,EAAO,SAAS,eAAe,OAAO,EAAM,CAAC,CAEnD,OADA,EAAM,IAAI,WAAY,aAAa,EAAM,EAAM,IAAI,KACtC,EAAK,YAAY,YAAY,EAAK,CAGnD,SAAS,EAAa,EAAiC,CACnD,IAAI,EAAO,EAAM,MAAM,YACvB,KAAO,GAAQ,IAAS,EAAM,KAAK,CAC/B,GAAI,EAAK,WAAa,KAAK,UAAW,OAAO,EAC7C,EAAO,EAAK,YAEhB,OAAO,KAGX,SAAS,EAAW,EAA0B,CAC1C,IAAI,EAAO,EAAM,MAAM,YACvB,KAAO,GAAQ,IAAS,EAAM,KAAK,CAC/B,IAAM,EAAO,EAAK,YAClB,EAAK,YAAY,YAAY,EAAK,CAClC,EAAO,GAIf,SAAS,EACL,EACA,EACA,EACA,EACK,CACL,IAAM,EAAW,CAAE,QAAO,OAAM,UAAS,CACzC,EAAQ,aAAa,EAAS,CAC9B,IAAM,EAAY,MAAM,qCAAqC,IAAU,CAEvE,MADA,OAAO,OAAO,EAAO,CAAE,WAAU,CAAC,CAC5B"}
@@ -0,0 +1,30 @@
1
+ import { type ElurComponent } from "../lifecycle.js";
2
+ import { type ComponentInvocation } from "./component.js";
3
+ import { type ElurMountHandle, type ElurTemplate } from "../template/types.js";
4
+ export interface HydrateOptions {
5
+ mismatch?: "throw" | "warn-remount" | "remount";
6
+ onMismatch?: (error: HydrationMismatch) => void;
7
+ context?: unknown;
8
+ }
9
+ export interface HydrationMismatch {
10
+ index: number;
11
+ kind: "node" | "attribute" | "event" | "descriptor" | "keyed";
12
+ message: string;
13
+ }
14
+ export declare function hydrate(value: ElurTemplate | ElurComponent | ComponentInvocation<any>, container: Element, options?: HydrateOptions): ElurMountHandle;
15
+ /**
16
+ * @internal — C.13: activación de un binding de nodo durante hidratación
17
+ * compilada. El runtime del plugin localiza los markers por posición y
18
+ * delega aquí — misma semántica que el path de markers globales.
19
+ */
20
+ export declare function _hydrateNodeRange(range: {
21
+ start: Comment;
22
+ end: Comment;
23
+ }, value: unknown, options?: HydrateOptions, keyedItems?: Array<{
24
+ start: Comment;
25
+ end: Comment;
26
+ serializedKey: string;
27
+ }>, arrayItems?: Array<{
28
+ start: Comment;
29
+ end: Comment;
30
+ }>): (() => void) | undefined;
@@ -0,0 +1,30 @@
1
+ import { type ElurComponent } from "../lifecycle.js";
2
+ import { type ComponentInvocation } from "./component.js";
3
+ import { type ElurMountHandle, type ElurTemplate } from "../template/types.js";
4
+ export interface HydrateOptions {
5
+ mismatch?: "throw" | "warn-remount" | "remount";
6
+ onMismatch?: (error: HydrationMismatch) => void;
7
+ context?: unknown;
8
+ }
9
+ export interface HydrationMismatch {
10
+ index: number;
11
+ kind: "node" | "attribute" | "event" | "descriptor" | "keyed";
12
+ message: string;
13
+ }
14
+ export declare function hydrate(value: ElurTemplate | ElurComponent | ComponentInvocation<any>, container: Element, options?: HydrateOptions): ElurMountHandle;
15
+ /**
16
+ * @internal — C.13: activación de un binding de nodo durante hidratación
17
+ * compilada. El runtime del plugin localiza los markers por posición y
18
+ * delega aquí — misma semántica que el path de markers globales.
19
+ */
20
+ export declare function _hydrateNodeRange(range: {
21
+ start: Comment;
22
+ end: Comment;
23
+ }, value: unknown, options?: HydrateOptions, keyedItems?: Array<{
24
+ start: Comment;
25
+ end: Comment;
26
+ serializedKey: string;
27
+ }>, arrayItems?: Array<{
28
+ start: Comment;
29
+ end: Comment;
30
+ }>): (() => void) | undefined;