@ogygia/core 0.0.0 → 0.11.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 (548) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -1
  3. package/ambient.d.ts +194 -0
  4. package/dist/ClientBindingStub.svelte +6 -0
  5. package/dist/ClientBindingStub.svelte.d.ts +26 -0
  6. package/dist/KeepHost.svelte +19 -0
  7. package/dist/KeepHost.svelte.d.ts +10 -0
  8. package/dist/LakeBoundary.svelte +16 -0
  9. package/dist/LakeBoundary.svelte.d.ts +11 -0
  10. package/dist/LateIsland.svelte +22 -0
  11. package/dist/LateIsland.svelte.d.ts +15 -0
  12. package/dist/LateIslandAwait.svelte +17 -0
  13. package/dist/LateIslandAwait.svelte.d.ts +15 -0
  14. package/dist/LiveHost.svelte +19 -0
  15. package/dist/LiveHost.svelte.d.ts +10 -0
  16. package/dist/NestedProvider.svelte +13 -0
  17. package/dist/NestedProvider.svelte.d.ts +8 -0
  18. package/dist/OgygiaBoundary.svelte +5 -0
  19. package/dist/OgygiaBoundary.svelte.d.ts +17 -0
  20. package/dist/PromiseRegion.svelte +40 -0
  21. package/dist/PromiseRegion.svelte.d.ts +15 -0
  22. package/dist/PromiseRegionAwait.svelte +27 -0
  23. package/dist/PromiseRegionAwait.svelte.d.ts +15 -0
  24. package/dist/Provide.svelte +27 -0
  25. package/dist/Provide.svelte.d.ts +8 -0
  26. package/dist/RawHtml.svelte +9 -0
  27. package/dist/RawHtml.svelte.d.ts +6 -0
  28. package/dist/Region.svelte +1173 -0
  29. package/dist/Region.svelte.d.ts +68 -0
  30. package/dist/SlotBoundary.svelte +13 -0
  31. package/dist/SlotBoundary.svelte.d.ts +7 -0
  32. package/dist/app.d.ts +4 -0
  33. package/dist/app.js +3 -0
  34. package/dist/boundary.d.ts +35 -0
  35. package/dist/boundary.js +127 -0
  36. package/dist/build-cache.d.ts +13 -0
  37. package/dist/build-cache.js +77 -0
  38. package/dist/compiler/blank-styles.d.ts +1 -0
  39. package/dist/compiler/blank-styles.js +63 -0
  40. package/dist/compiler/bom.d.ts +2 -0
  41. package/dist/compiler/bom.js +15 -0
  42. package/dist/compiler/browser-full.d.ts +8 -0
  43. package/dist/compiler/browser-full.js +8 -0
  44. package/dist/compiler/browser.d.ts +11 -0
  45. package/dist/compiler/browser.js +11 -0
  46. package/dist/compiler/content/transportables.d.ts +26 -0
  47. package/dist/compiler/content/transportables.js +219 -0
  48. package/dist/compiler/ctx.d.ts +180 -0
  49. package/dist/compiler/ctx.js +183 -0
  50. package/dist/compiler/debarrel/barrel.d.ts +55 -0
  51. package/dist/compiler/debarrel/barrel.js +248 -0
  52. package/dist/compiler/debarrel/options.d.ts +67 -0
  53. package/dist/compiler/debarrel/options.js +31 -0
  54. package/dist/compiler/debarrel/parse.d.ts +65 -0
  55. package/dist/compiler/debarrel/parse.js +256 -0
  56. package/dist/compiler/debarrel/plugin.d.ts +31 -0
  57. package/dist/compiler/debarrel/plugin.js +190 -0
  58. package/dist/compiler/debarrel/rewrite.d.ts +27 -0
  59. package/dist/compiler/debarrel/rewrite.js +118 -0
  60. package/dist/compiler/debarrel/svelte.d.ts +13 -0
  61. package/dist/compiler/debarrel/svelte.js +56 -0
  62. package/dist/compiler/dev/css-scope.d.ts +16 -0
  63. package/dist/compiler/dev/css-scope.js +38 -0
  64. package/dist/compiler/dev/dev-hmr.d.ts +25 -0
  65. package/dist/compiler/dev/dev-hmr.js +29 -0
  66. package/dist/compiler/dev/hmr.d.ts +34 -0
  67. package/dist/compiler/dev/hmr.js +57 -0
  68. package/dist/compiler/dev/region-bytes.d.ts +34 -0
  69. package/dist/compiler/dev/region-bytes.js +126 -0
  70. package/dist/compiler/driver.d.ts +280 -0
  71. package/dist/compiler/driver.js +1352 -0
  72. package/dist/compiler/flags.d.ts +16 -0
  73. package/dist/compiler/flags.js +101 -0
  74. package/dist/compiler/fouc-css.d.ts +97 -0
  75. package/dist/compiler/fouc-css.js +335 -0
  76. package/dist/compiler/free-vars.d.ts +20 -0
  77. package/dist/compiler/free-vars.js +327 -0
  78. package/dist/compiler/host.d.ts +65 -0
  79. package/dist/compiler/host.js +51 -0
  80. package/dist/compiler/ids.d.ts +84 -0
  81. package/dist/compiler/ids.js +86 -0
  82. package/dist/compiler/index.d.ts +11 -0
  83. package/dist/compiler/index.js +11 -0
  84. package/dist/compiler/kit.d.ts +129 -0
  85. package/dist/compiler/kit.js +563 -0
  86. package/dist/compiler/link/build-output.d.ts +44 -0
  87. package/dist/compiler/link/build-output.js +147 -0
  88. package/dist/compiler/link/caps.d.ts +48 -0
  89. package/dist/compiler/link/caps.js +64 -0
  90. package/dist/compiler/link/context-detect.d.ts +23 -0
  91. package/dist/compiler/link/context-detect.js +137 -0
  92. package/dist/compiler/link/emit-gate.d.ts +11 -0
  93. package/dist/compiler/link/emit-gate.js +40 -0
  94. package/dist/compiler/link/entry-shim.d.ts +4 -0
  95. package/dist/compiler/link/entry-shim.js +29 -0
  96. package/dist/compiler/link/island-deps.d.ts +142 -0
  97. package/dist/compiler/link/island-deps.js +525 -0
  98. package/dist/compiler/link/manifest.d.ts +5 -0
  99. package/dist/compiler/link/manifest.js +9 -0
  100. package/dist/compiler/link/page-keys.d.ts +64 -0
  101. package/dist/compiler/link/page-keys.js +683 -0
  102. package/dist/compiler/link/registry-stub.d.ts +41 -0
  103. package/dist/compiler/link/registry-stub.js +212 -0
  104. package/dist/compiler/link/router-config.d.ts +11 -0
  105. package/dist/compiler/link/router-config.js +15 -0
  106. package/dist/compiler/link/router-css.d.ts +22 -0
  107. package/dist/compiler/link/router-css.js +142 -0
  108. package/dist/compiler/link/runtime-entry.d.ts +71 -0
  109. package/dist/compiler/link/runtime-entry.js +132 -0
  110. package/dist/compiler/link/server-manifest.d.ts +12 -0
  111. package/dist/compiler/link/server-manifest.js +45 -0
  112. package/dist/compiler/link/speculation.d.ts +17 -0
  113. package/dist/compiler/link/speculation.js +36 -0
  114. package/dist/compiler/link/transport.d.ts +31 -0
  115. package/dist/compiler/link/transport.js +67 -0
  116. package/dist/compiler/macros/bake.d.ts +20 -0
  117. package/dist/compiler/macros/bake.js +317 -0
  118. package/dist/compiler/macros/browser.d.ts +11 -0
  119. package/dist/compiler/macros/browser.js +69 -0
  120. package/dist/compiler/macros/dedent.d.ts +12 -0
  121. package/dist/compiler/macros/dedent.js +36 -0
  122. package/dist/compiler/macros/dollar.d.ts +15 -0
  123. package/dist/compiler/macros/dollar.js +387 -0
  124. package/dist/compiler/macros/pipeline.d.ts +31 -0
  125. package/dist/compiler/macros/pipeline.js +106 -0
  126. package/dist/compiler/macros/source.d.ts +6 -0
  127. package/dist/compiler/macros/source.js +127 -0
  128. package/dist/compiler/macros/store.d.ts +17 -0
  129. package/dist/compiler/macros/store.js +244 -0
  130. package/dist/compiler/macros/wire.d.ts +14 -0
  131. package/dist/compiler/macros/wire.js +160 -0
  132. package/dist/compiler/ownership-stamps.d.ts +6 -0
  133. package/dist/compiler/ownership-stamps.js +144 -0
  134. package/dist/compiler/parse/oxc.d.ts +34 -0
  135. package/dist/compiler/parse/oxc.js +59 -0
  136. package/dist/compiler/parse/scan.d.ts +43 -0
  137. package/dist/compiler/parse/scan.js +232 -0
  138. package/dist/compiler/program.d.ts +140 -0
  139. package/dist/compiler/program.js +242 -0
  140. package/dist/compiler/region/emit.d.ts +169 -0
  141. package/dist/compiler/region/emit.js +286 -0
  142. package/dist/compiler/region/identity.d.ts +28 -0
  143. package/dist/compiler/region/identity.js +75 -0
  144. package/dist/compiler/region/ir.d.ts +65 -0
  145. package/dist/compiler/region/ir.js +0 -0
  146. package/dist/compiler/region/transform.d.ts +178 -0
  147. package/dist/compiler/region/transform.js +1933 -0
  148. package/dist/compiler/script-request.d.ts +1 -0
  149. package/dist/compiler/script-request.js +43 -0
  150. package/dist/context-bridge.d.ts +65 -0
  151. package/dist/context-bridge.js +217 -0
  152. package/dist/context-registry.d.ts +40 -0
  153. package/dist/context-registry.js +15 -0
  154. package/dist/context.d.ts +72 -0
  155. package/dist/context.js +158 -0
  156. package/dist/current-region.d.ts +14 -0
  157. package/dist/current-region.js +36 -0
  158. package/dist/document.d.ts +41 -0
  159. package/dist/document.js +125 -0
  160. package/dist/entry-hydrate.d.ts +5 -0
  161. package/dist/entry-hydrate.js +42 -0
  162. package/dist/escape.d.ts +18 -0
  163. package/dist/escape.js +37 -0
  164. package/dist/events/bus.d.ts +33 -0
  165. package/dist/events/bus.js +153 -0
  166. package/dist/events/index.d.ts +4 -0
  167. package/dist/events/index.js +4 -0
  168. package/dist/events/schema.d.ts +389 -0
  169. package/dist/events/schema.js +23 -0
  170. package/dist/events/server-registry.d.ts +7 -0
  171. package/dist/events/server-registry.js +13 -0
  172. package/dist/events/sinks.d.ts +64 -0
  173. package/dist/events/sinks.js +85 -0
  174. package/dist/fn-transport.d.ts +33 -0
  175. package/dist/fn-transport.js +140 -0
  176. package/dist/frame.d.ts +20 -0
  177. package/dist/frame.js +19 -0
  178. package/dist/holes-record.d.ts +6 -0
  179. package/dist/holes-record.js +8 -0
  180. package/dist/hooks.d.ts +43 -0
  181. package/dist/hooks.js +1191 -0
  182. package/dist/hydration-info.d.ts +1 -0
  183. package/dist/hydration-info.js +31 -0
  184. package/dist/index.d.ts +21 -0
  185. package/dist/index.js +17 -0
  186. package/dist/insights/attr-rules.d.ts +15 -0
  187. package/dist/insights/attr-rules.js +27 -0
  188. package/dist/insights/cpu.d.ts +82 -0
  189. package/dist/insights/cpu.js +177 -0
  190. package/dist/insights/fp-drift.d.ts +28 -0
  191. package/dist/insights/fp-drift.js +148 -0
  192. package/dist/insights/hole-segments.d.ts +26 -0
  193. package/dist/insights/hole-segments.js +50 -0
  194. package/dist/insights/html-diff.d.ts +25 -0
  195. package/dist/insights/html-diff.js +157 -0
  196. package/dist/insights/hydration-hazards.d.ts +36 -0
  197. package/dist/insights/hydration-hazards.js +136 -0
  198. package/dist/insights/hydration-status.d.ts +2 -0
  199. package/dist/insights/hydration-status.js +0 -0
  200. package/dist/insights/index.d.ts +14 -0
  201. package/dist/insights/index.js +12 -0
  202. package/dist/insights/page-assets.d.ts +211 -0
  203. package/dist/insights/page-assets.js +608 -0
  204. package/dist/insights/page-insights.d.ts +749 -0
  205. package/dist/insights/page-insights.js +2157 -0
  206. package/dist/insights/session-data.d.ts +108 -0
  207. package/dist/insights/session-data.js +0 -0
  208. package/dist/insights/session-insights.d.ts +121 -0
  209. package/dist/insights/session-insights.js +548 -0
  210. package/dist/insights/switch.d.ts +53 -0
  211. package/dist/insights/switch.js +91 -0
  212. package/dist/insights/testing-version.d.ts +19 -0
  213. package/dist/insights/testing-version.js +21 -0
  214. package/dist/insights/third-party.d.ts +75 -0
  215. package/dist/insights/third-party.js +160 -0
  216. package/dist/internal-instruments.d.ts +13 -0
  217. package/dist/internal-instruments.js +12 -0
  218. package/dist/internal-reconcile.d.ts +3 -0
  219. package/dist/internal-reconcile.js +3 -0
  220. package/dist/internal-register.d.ts +7 -0
  221. package/dist/internal-register.js +7 -0
  222. package/dist/internal-server.d.ts +7 -0
  223. package/dist/internal-server.js +7 -0
  224. package/dist/internal.d.ts +13 -0
  225. package/dist/internal.js +13 -0
  226. package/dist/island-graph.d.ts +36 -0
  227. package/dist/island-graph.js +89 -0
  228. package/dist/keep-fallback-marker.d.ts +7 -0
  229. package/dist/keep-fallback-marker.js +9 -0
  230. package/dist/keep-fallback.d.ts +13 -0
  231. package/dist/keep-fallback.js +39 -0
  232. package/dist/kit-paths.d.ts +2 -0
  233. package/dist/kit-paths.js +39 -0
  234. package/dist/late-region-registry.d.ts +40 -0
  235. package/dist/late-region-registry.js +36 -0
  236. package/dist/live-transport.d.ts +57 -0
  237. package/dist/live-transport.js +145 -0
  238. package/dist/markup.d.ts +4 -0
  239. package/dist/markup.js +4 -0
  240. package/dist/own-package.d.ts +15 -0
  241. package/dist/own-package.js +20 -0
  242. package/dist/page-defer.d.ts +33 -0
  243. package/dist/page-defer.js +35 -0
  244. package/dist/page-facts-script.d.ts +7 -0
  245. package/dist/page-facts-script.js +9 -0
  246. package/dist/page-seed-registry.d.ts +72 -0
  247. package/dist/page-seed-registry.js +31 -0
  248. package/dist/plugin/capability.d.ts +14 -0
  249. package/dist/plugin/capability.js +44 -0
  250. package/dist/plugin/client.d.ts +39 -0
  251. package/dist/plugin/client.js +6 -0
  252. package/dist/plugin/css.d.ts +3 -0
  253. package/dist/plugin/css.js +54 -0
  254. package/dist/plugin/facts.d.ts +42 -0
  255. package/dist/plugin/facts.js +37 -0
  256. package/dist/plugin/hooks.d.ts +33 -0
  257. package/dist/plugin/hooks.js +38 -0
  258. package/dist/plugin/index.d.ts +127 -0
  259. package/dist/plugin/index.js +26 -0
  260. package/dist/plugin/routes.d.ts +32 -0
  261. package/dist/plugin/routes.js +35 -0
  262. package/dist/plugin/server.d.ts +27 -0
  263. package/dist/plugin/server.js +92 -0
  264. package/dist/plugin/standard-schema.d.ts +27 -0
  265. package/dist/plugin/standard-schema.js +0 -0
  266. package/dist/plugin/testing.d.ts +13 -0
  267. package/dist/plugin/testing.js +54 -0
  268. package/dist/plugin/utils.d.ts +13 -0
  269. package/dist/plugin/utils.js +19 -0
  270. package/dist/portable-form.d.ts +22 -0
  271. package/dist/portable-form.js +52 -0
  272. package/dist/preference.d.ts +35 -0
  273. package/dist/preference.js +84 -0
  274. package/dist/preload.d.ts +1 -0
  275. package/dist/preload.js +21 -0
  276. package/dist/ref-watch.d.ts +31 -0
  277. package/dist/ref-watch.js +66 -0
  278. package/dist/ref.d.ts +124 -0
  279. package/dist/ref.js +272 -0
  280. package/dist/region-brand.d.ts +8 -0
  281. package/dist/region-brand.js +10 -0
  282. package/dist/region-core.d.ts +2 -0
  283. package/dist/region-core.js +1 -0
  284. package/dist/region-snippet.d.ts +73 -0
  285. package/dist/region-snippet.js +351 -0
  286. package/dist/region.d.ts +127 -0
  287. package/dist/region.js +162 -0
  288. package/dist/request-event.d.ts +1 -0
  289. package/dist/request-event.js +37 -0
  290. package/dist/router-css.d.ts +39 -0
  291. package/dist/router-css.js +66 -0
  292. package/dist/runtime/app-transport.d.ts +2 -0
  293. package/dist/runtime/app-transport.js +13 -0
  294. package/dist/runtime/beacon.d.ts +271 -0
  295. package/dist/runtime/beacon.js +2190 -0
  296. package/dist/runtime/boot-link.d.ts +1 -0
  297. package/dist/runtime/boot-link.js +44 -0
  298. package/dist/runtime/client-hooks.d.ts +5 -0
  299. package/dist/runtime/client-hooks.js +22 -0
  300. package/dist/runtime/client-plugins.d.ts +8 -0
  301. package/dist/runtime/client-plugins.js +34 -0
  302. package/dist/runtime/concurrency.d.ts +12 -0
  303. package/dist/runtime/concurrency.js +29 -0
  304. package/dist/runtime/connected.d.ts +12 -0
  305. package/dist/runtime/connected.js +16 -0
  306. package/dist/runtime/context.d.ts +1 -0
  307. package/dist/runtime/context.js +19 -0
  308. package/dist/runtime/core.d.ts +15 -0
  309. package/dist/runtime/core.js +1173 -0
  310. package/dist/runtime/drift-watch.d.ts +9 -0
  311. package/dist/runtime/drift-watch.js +60 -0
  312. package/dist/runtime/entry-locations.d.ts +33 -0
  313. package/dist/runtime/entry-locations.js +119 -0
  314. package/dist/runtime/foreign-props.d.ts +8 -0
  315. package/dist/runtime/foreign-props.js +14 -0
  316. package/dist/runtime/form-continuity.d.ts +10 -0
  317. package/dist/runtime/form-continuity.js +107 -0
  318. package/dist/runtime/frame-nav.d.ts +36 -0
  319. package/dist/runtime/frame-nav.js +225 -0
  320. package/dist/runtime/frame-store.d.ts +62 -0
  321. package/dist/runtime/frame-store.js +214 -0
  322. package/dist/runtime/frames.d.ts +1 -0
  323. package/dist/runtime/frames.js +25 -0
  324. package/dist/runtime/full.d.ts +4 -0
  325. package/dist/runtime/full.js +32 -0
  326. package/dist/runtime/hash.d.ts +41 -0
  327. package/dist/runtime/hash.js +79 -0
  328. package/dist/runtime/hole-facts.d.ts +8 -0
  329. package/dist/runtime/hole-facts.js +57 -0
  330. package/dist/runtime/host-classes.d.ts +24 -0
  331. package/dist/runtime/host-classes.js +43 -0
  332. package/dist/runtime/hydrate-core.d.ts +101 -0
  333. package/dist/runtime/hydrate-core.js +605 -0
  334. package/dist/runtime/index.d.ts +2 -0
  335. package/dist/runtime/index.js +1 -0
  336. package/dist/runtime/interaction-replay.d.ts +11 -0
  337. package/dist/runtime/interaction-replay.js +70 -0
  338. package/dist/runtime/interaction.d.ts +33 -0
  339. package/dist/runtime/interaction.js +217 -0
  340. package/dist/runtime/island-graph-preload.d.ts +13 -0
  341. package/dist/runtime/island-graph-preload.js +99 -0
  342. package/dist/runtime/kit-boot.d.ts +29 -0
  343. package/dist/runtime/kit-boot.js +60 -0
  344. package/dist/runtime/kit-page-thread.svelte.d.ts +1 -0
  345. package/dist/runtime/kit-page-thread.svelte.js +116 -0
  346. package/dist/runtime/lake-anchors.d.ts +13 -0
  347. package/dist/runtime/lake-anchors.js +19 -0
  348. package/dist/runtime/lakes.d.ts +15 -0
  349. package/dist/runtime/lakes.js +212 -0
  350. package/dist/runtime/live.d.ts +3 -0
  351. package/dist/runtime/live.js +17 -0
  352. package/dist/runtime/load-scheduler.d.ts +53 -0
  353. package/dist/runtime/load-scheduler.js +317 -0
  354. package/dist/runtime/morph.d.ts +42 -0
  355. package/dist/runtime/morph.js +671 -0
  356. package/dist/runtime/nav-handle.d.ts +25 -0
  357. package/dist/runtime/nav-handle.js +71 -0
  358. package/dist/runtime/nav-hooks.d.ts +2 -0
  359. package/dist/runtime/nav-hooks.js +23 -0
  360. package/dist/runtime/nearest-attr.d.ts +4 -0
  361. package/dist/runtime/nearest-attr.js +16 -0
  362. package/dist/runtime/observe.d.ts +27 -0
  363. package/dist/runtime/observe.js +63 -0
  364. package/dist/runtime/own-cost.d.ts +9 -0
  365. package/dist/runtime/own-cost.js +35 -0
  366. package/dist/runtime/ownership.d.ts +101 -0
  367. package/dist/runtime/ownership.js +115 -0
  368. package/dist/runtime/page-cache.d.ts +23 -0
  369. package/dist/runtime/page-cache.js +74 -0
  370. package/dist/runtime/page-defer.d.ts +14 -0
  371. package/dist/runtime/page-defer.js +103 -0
  372. package/dist/runtime/parse-html.d.ts +40 -0
  373. package/dist/runtime/parse-html.js +81 -0
  374. package/dist/runtime/reconcile.d.ts +41 -0
  375. package/dist/runtime/reconcile.js +194 -0
  376. package/dist/runtime/region-attrs.d.ts +95 -0
  377. package/dist/runtime/region-attrs.js +153 -0
  378. package/dist/runtime/region-endpoint-url.d.ts +76 -0
  379. package/dist/runtime/region-endpoint-url.js +169 -0
  380. package/dist/runtime/region-ids.d.ts +8 -0
  381. package/dist/runtime/region-ids.js +33 -0
  382. package/dist/runtime/remote-seeds.d.ts +2 -0
  383. package/dist/runtime/remote-seeds.js +21 -0
  384. package/dist/runtime/render-blocking.d.ts +2 -0
  385. package/dist/runtime/render-blocking.js +30 -0
  386. package/dist/runtime/restore.d.ts +34 -0
  387. package/dist/runtime/restore.js +390 -0
  388. package/dist/runtime/router-nav.d.ts +63 -0
  389. package/dist/runtime/router-nav.js +740 -0
  390. package/dist/runtime/router.d.ts +201 -0
  391. package/dist/runtime/router.js +593 -0
  392. package/dist/runtime/schedule.d.ts +49 -0
  393. package/dist/runtime/schedule.js +256 -0
  394. package/dist/runtime/seeds.d.ts +50 -0
  395. package/dist/runtime/seeds.js +208 -0
  396. package/dist/runtime/session.d.ts +52 -0
  397. package/dist/runtime/session.js +130 -0
  398. package/dist/runtime/sidecar.d.ts +3 -0
  399. package/dist/runtime/sidecar.js +56 -0
  400. package/dist/runtime/slots.d.ts +183 -0
  401. package/dist/runtime/slots.js +44 -0
  402. package/dist/runtime/spa-cacheable.d.ts +7 -0
  403. package/dist/runtime/spa-cacheable.js +18 -0
  404. package/dist/runtime/speculate-hint.d.ts +1 -0
  405. package/dist/runtime/speculate-hint.js +35 -0
  406. package/dist/runtime/svelte-warnings.d.ts +28 -0
  407. package/dist/runtime/svelte-warnings.js +71 -0
  408. package/dist/runtime/wire-classes.d.ts +3 -0
  409. package/dist/runtime/wire-classes.js +69 -0
  410. package/dist/runtime/wire-format.d.ts +7 -0
  411. package/dist/runtime/wire-format.js +22 -0
  412. package/dist/script.d.ts +134 -0
  413. package/dist/script.js +184 -0
  414. package/dist/seed-refs.d.ts +105 -0
  415. package/dist/seed-refs.js +487 -0
  416. package/dist/server/capability-lifetime.d.ts +28 -0
  417. package/dist/server/capability-lifetime.js +31 -0
  418. package/dist/server/dead-kit-resolves.d.ts +1 -0
  419. package/dist/server/dead-kit-resolves.js +39 -0
  420. package/dist/server/document-assembly.d.ts +30 -0
  421. package/dist/server/document-assembly.js +26 -0
  422. package/dist/server/document-tail.d.ts +113 -0
  423. package/dist/server/document-tail.js +208 -0
  424. package/dist/server/endpoint.d.ts +51 -0
  425. package/dist/server/endpoint.js +90 -0
  426. package/dist/server/entry-location.d.ts +8 -0
  427. package/dist/server/entry-location.js +29 -0
  428. package/dist/server/fingerprint.d.ts +1 -0
  429. package/dist/server/fingerprint.js +25 -0
  430. package/dist/server/head-presence.d.ts +45 -0
  431. package/dist/server/head-presence.js +156 -0
  432. package/dist/server/hmac.d.ts +38 -0
  433. package/dist/server/hmac.js +89 -0
  434. package/dist/server/hole-graph.d.ts +7 -0
  435. package/dist/server/hole-graph.js +71 -0
  436. package/dist/server/hole-urls.d.ts +3 -0
  437. package/dist/server/hole-urls.js +76 -0
  438. package/dist/server/html-scan.d.ts +19 -0
  439. package/dist/server/html-scan.js +60 -0
  440. package/dist/server/kit-context.d.ts +78 -0
  441. package/dist/server/kit-context.js +110 -0
  442. package/dist/server/late-wire.d.ts +22 -0
  443. package/dist/server/late-wire.js +28 -0
  444. package/dist/server/page-facts.d.ts +25 -0
  445. package/dist/server/page-facts.js +138 -0
  446. package/dist/server/page-seed.d.ts +33 -0
  447. package/dist/server/page-seed.js +60 -0
  448. package/dist/server/page-stream.d.ts +55 -0
  449. package/dist/server/page-stream.js +121 -0
  450. package/dist/server/payload.d.ts +6 -0
  451. package/dist/server/payload.js +22 -0
  452. package/dist/server/personal-response.d.ts +6 -0
  453. package/dist/server/personal-response.js +13 -0
  454. package/dist/server/props-wire.d.ts +56 -0
  455. package/dist/server/props-wire.js +178 -0
  456. package/dist/server/rate-limit.d.ts +22 -0
  457. package/dist/server/rate-limit.js +63 -0
  458. package/dist/server/region-css.d.ts +5 -0
  459. package/dist/server/region-css.js +30 -0
  460. package/dist/server/region-endpoint.d.ts +35 -0
  461. package/dist/server/region-endpoint.js +142 -0
  462. package/dist/server/region-props.d.ts +6 -0
  463. package/dist/server/region-props.js +44 -0
  464. package/dist/server/remote-seed-gate.d.ts +50 -0
  465. package/dist/server/remote-seed-gate.js +66 -0
  466. package/dist/server/render-cache.d.ts +26 -0
  467. package/dist/server/render-cache.js +51 -0
  468. package/dist/server/render-page.d.ts +51 -0
  469. package/dist/server/render-page.js +176 -0
  470. package/dist/server/render-region-html.d.ts +2 -0
  471. package/dist/server/render-region-html.js +19 -0
  472. package/dist/server/request-stats.d.ts +174 -0
  473. package/dist/server/request-stats.js +54 -0
  474. package/dist/server/reversible.d.ts +83 -0
  475. package/dist/server/reversible.js +994 -0
  476. package/dist/server/seed-shape.d.ts +22 -0
  477. package/dist/server/seed-shape.js +24 -0
  478. package/dist/server/shared-cache.d.ts +35 -0
  479. package/dist/server/shared-cache.js +104 -0
  480. package/dist/server/signing-key.d.ts +11 -0
  481. package/dist/server/signing-key.js +47 -0
  482. package/dist/server/sized-lru.d.ts +20 -0
  483. package/dist/server/sized-lru.js +68 -0
  484. package/dist/server/split-regions.d.ts +81 -0
  485. package/dist/server/split-regions.js +368 -0
  486. package/dist/server/stream-regions.d.ts +5 -0
  487. package/dist/server/stream-regions.js +36 -0
  488. package/dist/shared-state.d.ts +7 -0
  489. package/dist/shared-state.js +152 -0
  490. package/dist/shims/app-environment.d.ts +4 -0
  491. package/dist/shims/app-environment.js +6 -0
  492. package/dist/shims/app-navigation.d.ts +33 -0
  493. package/dist/shims/app-navigation.js +119 -0
  494. package/dist/shims/app-paths.d.ts +6 -0
  495. package/dist/shims/app-paths.js +18 -0
  496. package/dist/shims/app-state.svelte.d.ts +23 -0
  497. package/dist/shims/app-state.svelte.js +50 -0
  498. package/dist/shims/app-stores.d.ts +21 -0
  499. package/dist/shims/app-stores.js +54 -0
  500. package/dist/shims/kit-bridge.d.ts +29 -0
  501. package/dist/shims/kit-bridge.js +7 -0
  502. package/dist/shims/kit-remote/client-stub.d.ts +27 -0
  503. package/dist/shims/kit-remote/client-stub.js +43 -0
  504. package/dist/shims/kit-remote/paths-internal-stub.d.ts +3 -0
  505. package/dist/shims/kit-remote/paths-internal-stub.js +5 -0
  506. package/dist/shims/kit-remote/remote-cache.d.ts +49 -0
  507. package/dist/shims/kit-remote/remote-cache.js +73 -0
  508. package/dist/shims/kit-remote/state-stub.d.ts +8 -0
  509. package/dist/shims/kit-remote/state-stub.js +8 -0
  510. package/dist/shims/page-store.svelte.d.ts +39 -0
  511. package/dist/shims/page-store.svelte.js +77 -0
  512. package/dist/source.d.ts +29 -0
  513. package/dist/source.js +87 -0
  514. package/dist/store-transport.d.ts +86 -0
  515. package/dist/store-transport.js +229 -0
  516. package/dist/tool-fetches.d.ts +5 -0
  517. package/dist/tool-fetches.js +41 -0
  518. package/dist/transport.d.ts +48 -0
  519. package/dist/transport.js +181 -0
  520. package/dist/unscoped-css.d.ts +26 -0
  521. package/dist/unscoped-css.js +53 -0
  522. package/dist/vite/dev-maps.d.ts +33 -0
  523. package/dist/vite/dev-maps.js +140 -0
  524. package/dist/vite/index.d.ts +19 -0
  525. package/dist/vite/index.js +820 -0
  526. package/dist/vite/kit-dirs.d.ts +7 -0
  527. package/dist/vite/kit-dirs.js +67 -0
  528. package/dist/vite/late-island.d.ts +25 -0
  529. package/dist/vite/late-island.js +33 -0
  530. package/dist/vite/module-map.d.ts +8 -0
  531. package/dist/vite/module-map.js +144 -0
  532. package/dist/vite/options.d.ts +208 -0
  533. package/dist/vite/options.js +74 -0
  534. package/dist/vite/package-files.d.ts +3 -0
  535. package/dist/vite/package-files.js +84 -0
  536. package/dist/vite/paths.d.ts +45 -0
  537. package/dist/vite/paths.js +112 -0
  538. package/dist/vite/plugin-api.d.ts +166 -0
  539. package/dist/vite/plugin-api.js +212 -0
  540. package/dist/vite/profiler-maps.d.ts +23 -0
  541. package/dist/vite/profiler-maps.js +178 -0
  542. package/dist/vite/server-sourcemaps.d.ts +8 -0
  543. package/dist/vite/server-sourcemaps.js +80 -0
  544. package/dist/vite/sourcemaps.d.ts +18 -0
  545. package/dist/vite/sourcemaps.js +80 -0
  546. package/dist/vite/style-preprocess.d.ts +2 -0
  547. package/dist/vite/style-preprocess.js +96 -0
  548. package/package.json +180 -6
@@ -0,0 +1,671 @@
1
+ import { slots } from "./slots.js";
2
+ import { REGION_RENDER_ATTRS, attributes_writer, is_declared_foreign, is_region_owned, is_self_owned, mark_render_made, order_owner, owner_of, render_made, slots_light_dom } from "./ownership.js";
3
+ // src/runtime/morph.ts
4
+ /**
5
+ * # DOM morphing — reconcile a live element toward a freshly rendered region IN PLACE
6
+ *
7
+ * Live/held regions (`<ogygia-region live>`, `query.live` ticks, single-flight mutations) push new
8
+ * server-rendered HTML every frame. Instead of tearing the old subtree down and rebuilding it, this
9
+ * walks the OLD DOM and the NEW nodes together in a single pass and mutates the old tree the minimum
10
+ * amount to reach the new shape. Nodes that can be reused keep their identity, so the browser keeps
11
+ * focus, text selection, scroll position, typed-in form state, and running CSS transitions — the
12
+ * LiveView "the page breathes" property.
13
+ *
14
+ * Inspired by natemoo-re/micromorph and idiomorph, trimmed to what ogygia needs and hardened with
15
+ * real **keyed** matching (micromorph is index-aligned for body children).
16
+ *
17
+ * ## Algorithm (one pass, minimal allocations)
18
+ * `morph_children(parent, new_nodes)` reconciles `parent`'s existing children toward `new_nodes`:
19
+ * 1. Index the old children that carry a **key** (`data-key`, else `id`) into a map.
20
+ * 2. Walk `new_nodes` left-to-right against a cursor over the old children:
21
+ * - **Keyed hit** — a new node's key matches an old node anywhere: move that old node into
22
+ * position and morph it. Reorders / inserts / removals morph in place instead of cascading
23
+ * replacements down the list.
24
+ * - **Id-set hit** — a key-less new element wants keys that a key-less old sibling holds (see
25
+ * "Wrapper matching" below): move that old sibling into position and morph it.
26
+ * - **Positional hit** — cursor node is compatible (same node kind + tag, both key-less): morph
27
+ * it and advance. Old keyed nodes reserved for a later key are skipped, never consumed here.
28
+ * - **Miss** — insert a fresh copy of the new node before the cursor.
29
+ * 3. Remove every old node left unclaimed (trailing key-less nodes + unmatched keyed nodes).
30
+ *
31
+ * `morph_node(from, to)` reconciles one node against one node:
32
+ * - Text / comment: copy `nodeValue` in place.
33
+ * - Element, different tag or namespace: **replace** (`from` cannot become `to`).
34
+ * - Element, same tag: sync attributes, sync form DOM properties, recurse into children.
35
+ *
36
+ * ## State-preservation guarantees
37
+ * - **Identity** — a node that can be morphed is never replaced, so focus / selection / scroll /
38
+ * transitions on it and its subtree survive.
39
+ * - **Form state follows the server only when the server changed its mind** — the `value` /
40
+ * `checked` / `selected` PROPERTIES move only when the matching ATTRIBUTE differs between the
41
+ * previous render and the incoming one. A tick that re-sends the same default leaves what the
42
+ * user typed or toggled alone, focused or not (the browser's own dirty-value rule; htmx 4's morph
43
+ * rule). The control that currently holds focus is never touched at all, so mid-edit text and its
44
+ * selection survive even a changed default.
45
+ * - **Preserved subtrees** — an element marked `data-persist`, or a hydrated island root
46
+ * (`data-hydrated`), is kept exactly as-is: matched by key/position but never re-synced or
47
+ * recursed into. Islands own their DOM through Svelte reactivity (props push), not morphing, so
48
+ * this stops a live tick from re-creating a hydrated island root (the "hero bounce" reflow).
49
+ *
50
+ * ## Wrapper matching (id sets)
51
+ * A key-less wrapper is matched by the keys INSIDE it (idiomorph's "id sets"). Before a pass, every
52
+ * keyed descendant registers its key on each ancestor up to the morph root, on both trees. Two
53
+ * key-less same-tag siblings then stay in lockstep only when their sets agree: both empty, or they
54
+ * share a key (the same wrapper, re-rendered). Otherwise the remainder goes to the keyed phase, which
55
+ * MOVES the old sibling holding the wanted keys into place — a banner appearing above an island's
56
+ * wrapper no longer re-mounts the island — and refuses to consume an old wrapper a LATER new sibling
57
+ * wants. When nothing better exists the match is positional, exactly as before; a tree with no keys
58
+ * at all skips the whole mechanism.
59
+ *
60
+ * ## Namespaces
61
+ * Clones are made with `importNode`, which carries the source namespace, so SVG / `foreignObject`
62
+ * subtrees are created with the correct namespace. The morph-vs-replace test compares `namespaceURI`
63
+ * as well as `tagName`, so an HTML `<a>` is never morphed into an SVG `<a>`.
64
+ */
65
+ const ELEMENT = 1;
66
+ const TEXT = 3;
67
+ const COMMENT = 8;
68
+ const FOLLOWING = 4;
69
+ /** Feature entry: fill the `morph` slot (live static-region ticks morph in place). */
70
+ function install() {
71
+ slots.morph = morph_children;
72
+ slots.sync_attributes = sync_attributes;
73
+ }
74
+ /**
75
+ * Reconcile `parent`'s children toward `new_nodes` (a freshly parsed, detached region). Public slot
76
+ * shape: `(parent: Element, nodes: Node[]) => void` — a drop-in for the previous implementation.
77
+ *
78
+ * `new_nodes` is read but never mutated, so the recursion passes the incoming element's live
79
+ * `childNodes` straight through (see {@link morph_node}) — no per-level array snapshot. Accessed by
80
+ * index, so both a real `Array` (the top-level region) and a live `NodeList` (recursion) fit.
81
+ *
82
+ * Two phases:
83
+ * 1. **Lockstep** — walk old and new in parallel while their keys agree (both `null` and compatible,
84
+ * or the same non-null key), morphing in place. This is the dominant tick (same structure, values
85
+ * changed) and it allocates NOTHING — no key map, no cursor bookkeeping. Reorders/inserts/removals
86
+ * break the lockstep at the first divergence and hand the REMAINDER to phase 2.
87
+ * 2. **Keyed reconcile** — the general move/insert/remove algorithm, run only on the still-unmatched
88
+ * tail. The key map indexes just the remaining old children, so a change late in a long list still
89
+ * skips indexing the aligned prefix.
90
+ */
91
+ function morph_children(parent, new_nodes, options) {
92
+ const walk = options?.target === "walk";
93
+ if (is_declared_foreign(parent)) return;
94
+ if (walk) {
95
+ const owner = owner_of(parent);
96
+ if (owner !== "walk" && owner !== "region") return;
97
+ }
98
+ reconcile(parent, new_nodes, build_id_sets(parent, new_nodes), walk);
99
+ clear_aria_hidden_over_focus(parent);
100
+ }
101
+ /**
102
+ * WAI-ARIA safety net, run once after a morph settles: `aria-hidden="true"` must never sit on an
103
+ * ancestor of the focused element — the browser blocks it and the interaction dies (an on-demand
104
+ * dropdown, focused by the waking click, never opens because the morph stamped the region's fetched
105
+ * closed state onto its container). aria-hidden reaches the focused subtree two ways: an in-place
106
+ * attribute sync (guarded in {@link sync_attributes}) OR a freshly cloned/inserted subtree — importNode
107
+ * copies attributes wholesale, with no guard, which is the path a REPLACED container takes. So the guard
108
+ * alone was not enough. This sweep strips `aria-hidden="true"` from the focused element's ancestor chain
109
+ * up to (and including) the morph root, covering both paths. A no-op unless focus lives inside `parent`.
110
+ */
111
+ function clear_aria_hidden_over_focus(parent) {
112
+ const doc = owner_document(parent);
113
+ const active = doc.activeElement;
114
+ if (active == null || active === doc.body || !parent.contains(active)) return;
115
+ let n = active;
116
+ while (n) {
117
+ if (n.getAttribute("aria-hidden") === "true") n.removeAttribute("aria-hidden");
118
+ if (n === parent) break;
119
+ n = n.parentElement;
120
+ }
121
+ }
122
+ const KEYED_SELECTOR = "[data-key],[id]";
123
+ function build_id_sets(parent, new_nodes) {
124
+ let sets = null;
125
+ const register = (key, start, stop) => {
126
+ for (let a = start; a !== null && a !== stop && a.nodeType === ELEMENT; a = a.parentNode) {
127
+ let set = (sets ??= /* @__PURE__ */ new WeakMap()).get(a);
128
+ if (set === void 0) sets.set(a, set = /* @__PURE__ */ new Set());
129
+ set.add(key);
130
+ }
131
+ };
132
+ for (const el of parent.querySelectorAll(KEYED_SELECTOR)) {
133
+ const k = key_of(el);
134
+ if (k !== null) register(k, el.parentNode, parent);
135
+ }
136
+ const count = new_nodes.length;
137
+ for (let i = 0; i < count; i++) {
138
+ const root = new_nodes[i];
139
+ if (root.nodeType !== ELEMENT) continue;
140
+ for (const el of root.querySelectorAll(KEYED_SELECTOR)) {
141
+ const k = key_of(el);
142
+ if (k !== null) register(k, el.parentNode, root.parentNode);
143
+ }
144
+ }
145
+ return sets;
146
+ }
147
+ /** Lockstep test for two key-less siblings: neither holds a key (nothing to protect), or they share
148
+ * one (the same wrapper, re-rendered). Anything else breaks lockstep so phase 2 can look around. */
149
+ function id_sets_agree(sets, a, b) {
150
+ if (a.nodeType !== ELEMENT) return true;
151
+ const sa = sets.get(a);
152
+ const sb = sets.get(b);
153
+ if (sa === void 0) return sb === void 0;
154
+ if (sb === void 0) return false;
155
+ return intersects(sa, sb);
156
+ }
157
+ function intersects(a, b) {
158
+ if (a.size > b.size) [a, b] = [b, a];
159
+ for (const k of a) if (b.has(k)) return true;
160
+ return false;
161
+ }
162
+ /** The first remaining key-less old sibling that holds one of `wanted` and can become `next`. */
163
+ function find_holder(old_inner, wanted, next) {
164
+ for (const key of wanted) {
165
+ const holder = old_inner.get(key);
166
+ if (holder !== void 0 && same_node(holder, next)) return holder;
167
+ }
168
+ return null;
169
+ }
170
+ /** `el` is consumed: it no longer holds anything for a later new sibling. */
171
+ function release_holder(old_inner, sets, el) {
172
+ const held = sets.get(el);
173
+ if (held === void 0) return;
174
+ for (const key of held) if (old_inner.get(key) === el) old_inner.delete(key);
175
+ }
176
+ /** Does a new sibling AFTER `idx` want a key that `cursor` holds? Then `cursor` is spoken for. */
177
+ function reserved_for_later(sets, new_inner, cursor, idx) {
178
+ if (new_inner === null) return false;
179
+ const held = sets.get(cursor);
180
+ if (held === void 0) return false;
181
+ for (const key of held) {
182
+ const wanter = new_inner.get(key);
183
+ if (wanter !== void 0 && wanter > idx) return true;
184
+ }
185
+ return false;
186
+ }
187
+ /**
188
+ * Reconcile `parent`'s children toward `new_nodes`, by whoever ORDERS them (ownership.ts
189
+ * `order_owner`): the render's sequence by position ({@link reconcile_children}), or — under a
190
+ * self-owned element whose own runtime arranges its light DOM — by identity
191
+ * ({@link reconcile_by_identity}). Toward Svelte's walk, positions are always the render's (the walk
192
+ * binds by position).
193
+ */
194
+ function reconcile(parent, new_nodes, sets, walk) {
195
+ if (!walk && order_owner(parent) === "element") reconcile_by_identity(parent, new_nodes, sets);
196
+ else reconcile_children(parent, new_nodes, sets, walk);
197
+ }
198
+ /**
199
+ * The render's sequence, by position.
200
+ * @param walk the {@link MorphOptions.target} is Svelte's walk (the repair), threaded unchanged down
201
+ * the recursion — a subtree the walk never enters is skipped.
202
+ */
203
+ function reconcile_children(parent, new_nodes, sets, walk = false) {
204
+ const count = new_nodes.length;
205
+ let cursor = parent.firstChild;
206
+ let idx = 0;
207
+ while (idx < count && cursor) {
208
+ const next = new_nodes[idx];
209
+ const ck = key_of(cursor);
210
+ const nk = key_of(next);
211
+ if (ck !== nk) break;
212
+ if (nk === null) {
213
+ if (!same_node(cursor, next)) break;
214
+ if (sets !== null && !id_sets_agree(sets, cursor, next)) break;
215
+ const here = cursor;
216
+ cursor = cursor.nextSibling;
217
+ morph_same(here, next, sets, walk);
218
+ } else {
219
+ const here = cursor;
220
+ cursor = cursor.nextSibling;
221
+ morph_node(here, next, sets, walk);
222
+ }
223
+ idx++;
224
+ }
225
+ if (idx >= count) {
226
+ while (cursor) {
227
+ const gone = cursor;
228
+ cursor = cursor.nextSibling;
229
+ parent.removeChild(gone);
230
+ }
231
+ return;
232
+ }
233
+ if (cursor === null) {
234
+ for (; idx < count; idx++) parent.insertBefore(clone(new_nodes[idx]), null);
235
+ return;
236
+ }
237
+ let old_keys = null;
238
+ let old_inner = null;
239
+ for (let n = cursor; n; n = n.nextSibling) {
240
+ const k = key_of(n);
241
+ if (k !== null) (old_keys ??= /* @__PURE__ */ new Map()).set(k, n);
242
+ else if (sets !== null && n.nodeType === ELEMENT) {
243
+ const held = sets.get(n);
244
+ if (held !== void 0) {
245
+ old_inner ??= /* @__PURE__ */ new Map();
246
+ for (const key of held) if (!old_inner.has(key)) old_inner.set(key, n);
247
+ }
248
+ }
249
+ }
250
+ let new_inner = null;
251
+ if (old_inner !== null) for (let i = idx; i < count; i++) {
252
+ const n = new_nodes[i];
253
+ if (n.nodeType !== ELEMENT || key_of(n) !== null) continue;
254
+ const wanted = sets.get(n);
255
+ if (wanted === void 0) continue;
256
+ new_inner ??= /* @__PURE__ */ new Map();
257
+ for (const key of wanted) if (!new_inner.has(key)) new_inner.set(key, i);
258
+ }
259
+ if (old_keys === null && old_inner === null) for (; idx < count; idx++) {
260
+ const next = new_nodes[idx];
261
+ if (cursor && key_of(next) === null && same_node(cursor, next)) {
262
+ const here = cursor;
263
+ cursor = cursor.nextSibling;
264
+ morph_same(here, next, sets, walk);
265
+ } else parent.insertBefore(clone(next), cursor);
266
+ }
267
+ else for (; idx < count; idx++) {
268
+ const next = new_nodes[idx];
269
+ const next_key = key_of(next);
270
+ if (next_key !== null) {
271
+ const matched = old_keys?.get(next_key);
272
+ if (matched !== void 0) {
273
+ old_keys.delete(next_key);
274
+ if (matched === cursor) cursor = cursor.nextSibling;
275
+ else parent.insertBefore(matched, cursor);
276
+ morph_node(matched, next, sets, walk);
277
+ continue;
278
+ }
279
+ } else if (old_inner !== null && next.nodeType === ELEMENT) {
280
+ const wanted = sets.get(next);
281
+ const holder = wanted === void 0 ? null : find_holder(old_inner, wanted, next);
282
+ if (holder !== null) {
283
+ release_holder(old_inner, sets, holder);
284
+ if (holder === cursor) cursor = cursor.nextSibling;
285
+ else parent.insertBefore(holder, cursor);
286
+ morph_same(holder, next, sets, walk);
287
+ continue;
288
+ }
289
+ }
290
+ let cur_key = null;
291
+ while (cursor) {
292
+ cur_key = key_of(cursor);
293
+ if (cur_key === null || old_keys === null || !old_keys.has(cur_key)) break;
294
+ cursor = cursor.nextSibling;
295
+ }
296
+ if (cursor && next_key === null && cur_key === null && same_node(cursor, next) && (old_inner === null || !reserved_for_later(sets, new_inner, cursor, idx))) {
297
+ const here = cursor;
298
+ cursor = cursor.nextSibling;
299
+ if (old_inner !== null) release_holder(old_inner, sets, here);
300
+ morph_same(here, next, sets, walk);
301
+ continue;
302
+ }
303
+ parent.insertBefore(clone(next), cursor);
304
+ }
305
+ while (cursor) {
306
+ const gone = cursor;
307
+ cursor = cursor.nextSibling;
308
+ parent.removeChild(gone);
309
+ }
310
+ if (old_keys) {
311
+ for (const node of old_keys.values()) if (node.parentNode === parent) parent.removeChild(node);
312
+ }
313
+ }
314
+ /**
315
+ * THE ELEMENT ORDERS ITS CHILDREN (ownership.ts §11): a self-owned element's runtime relocates and
316
+ * wraps its light DOM, so positions are not the render's and never decide a match. Each new node
317
+ * finds its old counterpart by identity — key, then the id-set holder, then the next render-made
318
+ * sibling of the same tag — and is morphed IN PLACE (the element's arrangement stands; nothing
319
+ * re-upgrades: a byte-identical answer moves no node). A new node with no counterpart goes in after the
320
+ * last placed render node. Then EXISTENCE decides the leftovers: one the render made and no longer
321
+ * produces is removed (a stale fallback panel beside the answer's, painting over it); one the element
322
+ * made is never matched and never removed.
323
+ * An element that SLOTS its light DOM (ownership.ts `slots_light_dom`) arranges nothing: the render's
324
+ * nodes then end in the answer's order — the fewest moves, its own nodes untouched — and the render's
325
+ * leftover block markers go (a tab the CMS moved kept its old place; one the answer added landed
326
+ * among the wrong siblings).
327
+ */
328
+ function reconcile_by_identity(parent, new_nodes, sets) {
329
+ const count = new_nodes.length;
330
+ const slotted = slots_light_dom(parent);
331
+ const placed_in_order = [];
332
+ const render_tags = /* @__PURE__ */ new Set();
333
+ for (let i = 0; i < count; i++) if (new_nodes[i].nodeType === ELEMENT) render_tags.add(new_nodes[i].localName);
334
+ let by_key = null;
335
+ const by_tag = /* @__PURE__ */ new Map();
336
+ const others = [];
337
+ let old_inner = null;
338
+ for (let n = parent.firstChild; n; n = n.nextSibling) {
339
+ const k = key_of(n);
340
+ if (k !== null) (by_key ??= /* @__PURE__ */ new Map()).set(k, n);
341
+ else if (n.nodeType === ELEMENT) {
342
+ if (!render_made(n, render_tags)) continue;
343
+ const el = n;
344
+ let list = by_tag.get(el.localName);
345
+ if (!list) by_tag.set(el.localName, list = []);
346
+ list.push(el);
347
+ const held = sets?.get(el);
348
+ if (held !== void 0) {
349
+ old_inner ??= /* @__PURE__ */ new Map();
350
+ for (const key of held) if (!old_inner.has(key)) old_inner.set(key, el);
351
+ }
352
+ } else others.push(n);
353
+ }
354
+ const claimed = /* @__PURE__ */ new Set();
355
+ let anchor = null;
356
+ let other_at = 0;
357
+ for (let i = 0; i < count; i++) {
358
+ const next = new_nodes[i];
359
+ let match = null;
360
+ if (next.nodeType === ELEMENT) {
361
+ const k = key_of(next);
362
+ if (k !== null) {
363
+ const keyed = by_key?.get(k);
364
+ if (keyed !== void 0) {
365
+ by_key.delete(k);
366
+ match = keyed;
367
+ }
368
+ } else {
369
+ const wanted = old_inner !== null ? sets.get(next) : void 0;
370
+ const holder = wanted === void 0 ? null : find_holder(old_inner, wanted, next);
371
+ if (holder !== null && !claimed.has(holder)) match = holder;
372
+ else {
373
+ const queue = by_tag.get(next.localName);
374
+ while (queue?.length && claimed.has(queue[0])) queue.shift();
375
+ match = queue?.shift() ?? null;
376
+ }
377
+ if (match !== null && old_inner !== null) release_holder(old_inner, sets, match);
378
+ }
379
+ } else if (next.nodeType === COMMENT) {
380
+ let first = null;
381
+ for (let j = 0; j < others.length; j++) {
382
+ const o = others[j];
383
+ if (o.nodeType !== COMMENT || claimed.has(o) || o.data !== next.data) continue;
384
+ if (!slotted || anchor === null || anchor.compareDocumentPosition(o) & FOLLOWING) {
385
+ match = o;
386
+ break;
387
+ }
388
+ first ??= o;
389
+ }
390
+ match ??= first;
391
+ } else {
392
+ while (other_at < others.length && (others[other_at].nodeType !== next.nodeType || claimed.has(others[other_at]))) other_at++;
393
+ if (other_at < others.length) match = others[other_at++];
394
+ }
395
+ if (match !== null && !claimed.has(match)) {
396
+ claimed.add(match);
397
+ const before = match.previousSibling;
398
+ morph_node(match, next, sets, false);
399
+ const placed = match.parentNode === parent ? match : before ? before.nextSibling : parent.firstChild;
400
+ if (placed) {
401
+ mark_render_made(placed);
402
+ anchor = placed;
403
+ placed_in_order.push(placed);
404
+ }
405
+ continue;
406
+ }
407
+ const copy = clone(next);
408
+ parent.insertBefore(copy, anchor ? anchor.nextSibling : parent.firstChild);
409
+ mark_render_made(copy);
410
+ anchor = copy;
411
+ placed_in_order.push(copy);
412
+ }
413
+ for (const list of by_tag.values()) for (const el of list) if (!claimed.has(el) && el.parentNode === parent) parent.removeChild(el);
414
+ if (by_key) {
415
+ for (const n of by_key.values()) if (n.parentNode === parent && render_made(n, render_tags)) parent.removeChild(n);
416
+ }
417
+ if (slotted) {
418
+ for (const o of others) if (!claimed.has(o) && o.parentNode === parent && is_block_marker(o)) parent.removeChild(o);
419
+ order_render_nodes(parent, placed_in_order);
420
+ }
421
+ }
422
+ /** Svelte's block markers: `''`, or `[`-opened (`[`, `[!`, `[0`, `[-1`, …), or `]`. */
423
+ function is_block_marker(n) {
424
+ if (n.nodeType !== COMMENT) return false;
425
+ const d = n.data;
426
+ return d === "" || d === "]" || d.charCodeAt(0) === 91;
427
+ }
428
+ /**
429
+ * Put the render's placed nodes (`nodes`, in the answer's order) in that order among `parent`'s
430
+ * children, moving the fewest: the longest run already in order (longest increasing subsequence of
431
+ * their positions) stays, every other node goes right after its predecessor in the answer. Nodes not
432
+ * in the list — the element's own — are never moved. An answer already in order moves nothing.
433
+ */
434
+ function order_render_nodes(parent, nodes) {
435
+ const count = nodes.length;
436
+ if (count < 2) return;
437
+ const at = /* @__PURE__ */ new Map();
438
+ let index = 0;
439
+ for (let n = parent.firstChild; n; n = n.nextSibling) at.set(n, index++);
440
+ const tails = [];
441
+ const prev = new Int32Array(count).fill(-1);
442
+ for (let k = 0; k < count; k++) {
443
+ const p = at.get(nodes[k]);
444
+ let lo = 0;
445
+ let hi = tails.length;
446
+ while (lo < hi) {
447
+ const mid = lo + hi >> 1;
448
+ if (at.get(nodes[tails[mid]]) < p) lo = mid + 1;
449
+ else hi = mid;
450
+ }
451
+ if (lo > 0) prev[k] = tails[lo - 1];
452
+ tails[lo] = k;
453
+ }
454
+ if (tails.length === count) return;
455
+ const stay = new Uint8Array(count);
456
+ for (let k = tails[tails.length - 1]; k >= 0; k = prev[k]) stay[k] = 1;
457
+ let first_stay = null;
458
+ for (let k = 0; k < count && first_stay === null; k++) if (stay[k]) first_stay = nodes[k];
459
+ let last = null;
460
+ for (let k = 0; k < count; k++) {
461
+ const n = nodes[k];
462
+ if (!stay[k]) {
463
+ const ref = last ? last.nextSibling : first_stay;
464
+ if (ref !== n) parent.insertBefore(n, ref);
465
+ }
466
+ last = n;
467
+ }
468
+ }
469
+ /** A kept region root's ADDRESS is the render's that minted it ({@link REGION_RENDER_ATTRS}); the rest
470
+ * of its attributes and all its content are the runtime's / its answer's. A re-minted hole gets its
471
+ * new `endpoint` and fetches there (core.ts `#renew`), its current answer on screen until then. */
472
+ function sync_render_attributes(from, to, walk) {
473
+ if (walk || from.localName !== to.localName) return;
474
+ for (const name of REGION_RENDER_ATTRS) {
475
+ const next = to.getAttribute(name);
476
+ if (next !== null && next !== from.getAttribute(name)) from.setAttribute(name, next);
477
+ }
478
+ }
479
+ /** The attributes of `from` toward `to`, by who writes them (ownership.ts `attributes_writer`). */
480
+ function sync_by_writer(from, to, walk) {
481
+ const writer = attributes_writer(from);
482
+ if (writer === "render") sync_attributes(from, to, is_self_owned(from));
483
+ else if (writer === "region") sync_render_attributes(from, to, walk);
484
+ }
485
+ /**
486
+ * The morph key of a node: `data-key` (explicit), else `id`, else `null` (unkeyed → positional).
487
+ * Uses the reflected `.id` property (a direct field read) instead of `getAttribute('id')`, and only
488
+ * probes `data-key` — so the overwhelmingly common key-less element costs one attribute lookup.
489
+ */
490
+ function key_of(node) {
491
+ if (node.nodeType !== ELEMENT) return null;
492
+ const el = node;
493
+ const dk = el.getAttribute("data-key");
494
+ if (dk !== null) return dk;
495
+ const id = el.id;
496
+ return id !== "" ? id : null;
497
+ }
498
+ /** Same slot for positional reuse: same node kind, and (for elements) same tag + namespace. */
499
+ function same_node(a, b) {
500
+ if (a.nodeType !== b.nodeType) return false;
501
+ if (a.nodeType === ELEMENT) return a.tagName === b.tagName && a.namespaceURI === b.namespaceURI;
502
+ return true;
503
+ }
504
+ /**
505
+ * May the morph ENTER `el`? (runtime/ownership.ts.) Never a declared-foreign subtree (the app's
506
+ * `data-ogygia-keep` / `data-persist`) nor a hydrated / kept region (Svelte's reactivity owns it); and
507
+ * toward Svelte's walk, never a subtree the walk does not read (`data-og-opaque`, a slot). Such an
508
+ * element is matched — kept in place, identity intact — but neither synced nor recursed into.
509
+ *
510
+ * Upgraded custom elements (ownership.ts `is_upgraded_ce`) are entered, but their host ATTRIBUTES are
511
+ * their runtime's (`attributes_writer`): re-asserting a fresh render's stale markers (a per-render id,
512
+ * a scope class) over a live host made it lose its hydrated shadow and duplicate its content. Their
513
+ * children are reconciled by identity (`order_owner`, {@link reconcile_by_identity}): the children the
514
+ * element made are kept toward a live answer, removed toward Svelte's walk where the walk reads that
515
+ * position.
516
+ */
517
+ function off_limits(el, walk) {
518
+ if (is_declared_foreign(el) || is_region_owned(el)) return true;
519
+ return walk && owner_of(el) !== "walk";
520
+ }
521
+ /**
522
+ * Reconcile a single old node toward a single new node, replacing only when it cannot be morphed.
523
+ * Used by keyed matches, where `from` and `to` may be different tags (the reason the tag/namespace
524
+ * replace check lives here). Positional/lockstep callers have already proven compatibility via
525
+ * {@link same_node} and go through {@link morph_same}, skipping that recheck.
526
+ */
527
+ function morph_node(from, to, sets, walk) {
528
+ const kind = from.nodeType;
529
+ if (kind === TEXT || kind === COMMENT) {
530
+ if (from.nodeValue !== to.nodeValue) from.nodeValue = to.nodeValue;
531
+ return;
532
+ }
533
+ if (kind !== ELEMENT) return;
534
+ const ef = from;
535
+ const et = to;
536
+ if (off_limits(ef, walk)) {
537
+ if (attributes_writer(ef) === "region") sync_render_attributes(ef, et, walk);
538
+ return;
539
+ }
540
+ if (ef.tagName !== et.tagName || ef.namespaceURI !== et.namespaceURI) {
541
+ ef.parentNode?.replaceChild(clone(to), ef);
542
+ return;
543
+ }
544
+ sync_form_props(ef, et);
545
+ sync_by_writer(ef, et, walk);
546
+ reconcile(ef, et.childNodes, sets, walk);
547
+ }
548
+ /**
549
+ * Reconcile two nodes already known to be the same kind + (for elements) same tag + namespace — the
550
+ * positional/lockstep path. Skips the morph-vs-replace decision {@link morph_node} makes; the element
551
+ * body is inlined (not shared via a helper) to keep this leaf call one frame deep on the hot path.
552
+ */
553
+ function morph_same(from, to, sets, walk) {
554
+ const kind = from.nodeType;
555
+ if (kind === TEXT || kind === COMMENT) {
556
+ if (from.nodeValue !== to.nodeValue) from.nodeValue = to.nodeValue;
557
+ return;
558
+ }
559
+ if (kind !== ELEMENT) return;
560
+ const ef = from;
561
+ const et = to;
562
+ if (off_limits(ef, walk)) {
563
+ if (attributes_writer(ef) === "region") sync_render_attributes(ef, et, walk);
564
+ return;
565
+ }
566
+ sync_form_props(ef, et);
567
+ sync_by_writer(ef, et, walk);
568
+ reconcile(ef, et.childNodes, sets, walk);
569
+ }
570
+ /** Add + update + remove attributes so `from` matches `to` exactly. Boolean attrs are attr presence.
571
+ * `keep_extra` (a self-owned element, {@link is_self_owned}): add + update only — an attribute the
572
+ * element gave itself is not the render's to take away. */
573
+ function sync_attributes(from, to, keep_extra = false) {
574
+ const to_attrs = to.attributes;
575
+ const to_len = to_attrs.length;
576
+ for (let i = 0; i < to_len; i++) {
577
+ const attr = to_attrs[i];
578
+ if (from.getAttribute(attr.name) === attr.value) continue;
579
+ if (attr.name === "aria-hidden" && attr.value === "true" && subtree_has_focus(from)) continue;
580
+ from.setAttribute(attr.name, attr.value);
581
+ }
582
+ if (keep_extra) return;
583
+ const from_attrs = from.attributes;
584
+ if (from_attrs.length > to_len) for (let i = from_attrs.length - 1; i >= 0; i--) {
585
+ const name = from_attrs[i].name;
586
+ if (!to.hasAttribute(name)) from.removeAttribute(name);
587
+ }
588
+ }
589
+ /**
590
+ * Sync live form DOM *properties* (`value` / `checked` / `selected`) — attributes alone don't move
591
+ * these once a control is dirty. Runs BEFORE {@link sync_attributes}, because the rule is "follow
592
+ * the server only when the server changed its default": a property moves only when its attribute
593
+ * differs between the PREVIOUS render (still on `from`) and the incoming one (on `to`). A tick that
594
+ * re-sends the same default never clobbers what the user typed or toggled in a field they have since
595
+ * left — the browser's own dirty-value rule, and htmx 4's morph rule. The focused control is skipped
596
+ * outright so a live tick never touches what the user is typing (its selection is left alone too).
597
+ */
598
+ function sync_form_props(from, to) {
599
+ const tag = from.tagName;
600
+ if (tag !== "INPUT" && tag !== "TEXTAREA" && tag !== "SELECT" && tag !== "OPTION") return;
601
+ if (owner_document(from)?.activeElement === from) return;
602
+ const ff = from;
603
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") {
604
+ const next = to.getAttribute("value");
605
+ if (next !== null && next !== from.getAttribute("value") && ff.value !== next) ff.value = next;
606
+ }
607
+ if (tag === "INPUT") {
608
+ const next = to.hasAttribute("checked");
609
+ if (next !== from.hasAttribute("checked") && ff.checked !== next) ff.checked = next;
610
+ }
611
+ if (tag === "OPTION") {
612
+ const of = from;
613
+ const next = to.hasAttribute("selected");
614
+ if (next !== from.hasAttribute("selected") && of.selected !== next) of.selected = next;
615
+ }
616
+ }
617
+ /** `importNode(node, true)` — a deep copy owned by this document, carrying the source namespace. */
618
+ function clone(node) {
619
+ const copy = owner_document(node).importNode(node, true);
620
+ if (node.nodeType === ELEMENT && globalThis.__og_restore) carry_shadows(node, copy);
621
+ return copy;
622
+ }
623
+ /**
624
+ * `importNode` never copies a shadow root (unless it was made clonable), so a host restored in an
625
+ * answer's fragment would arrive with its rendered tree gone. Walk the source and the copy in lockstep
626
+ * (a deep copy has the same elements in the same order) and carry each open root across: its children
627
+ * copied the same way, its adopted sheets, and sheets still waiting for the host to be in the page
628
+ * (the restorer adopts those right after the insertion).
629
+ */
630
+ function carry_shadows(src, dst) {
631
+ const a = owner_document(src).createTreeWalker(src, 1);
632
+ const b = owner_document(dst).createTreeWalker(dst, 1);
633
+ for (let s = src, d = dst; s && d; s = a.nextNode(), d = b.nextNode()) {
634
+ const root = s.shadowRoot;
635
+ if (!root || root.mode !== "open" || d.shadowRoot) continue;
636
+ const copy = d.attachShadow({
637
+ mode: "open",
638
+ delegatesFocus: root.delegatesFocus
639
+ });
640
+ if (copy.customElementRegistry === null) {
641
+ const w = globalThis;
642
+ (w.__og_init ??= []).push(copy);
643
+ }
644
+ for (const c of Array.from(root.childNodes)) copy.appendChild(clone(c));
645
+ try {
646
+ if (root.adoptedStyleSheets.length) copy.adoptedStyleSheets = [...root.adoptedStyleSheets];
647
+ } catch {}
648
+ const pending = root.__og_pending;
649
+ if (pending) {
650
+ copy.__og_pending = pending;
651
+ const w = globalThis;
652
+ (w.__og_adopt ??= []).push({
653
+ shadow: copy,
654
+ sheets: pending
655
+ });
656
+ }
657
+ }
658
+ }
659
+ /** The owning document, falling back to the ambient `document` for detached nodes. */
660
+ function owner_document(node) {
661
+ return node.ownerDocument ?? document;
662
+ }
663
+ /** True when the currently focused element lives inside `el` — so putting `aria-hidden="true"` on `el`
664
+ * would hide the focused subtree (a WAI-ARIA violation the browser blocks). `activeElement` is `<body>`
665
+ * when nothing has focus, which no morphed subtree contains, so that reads as false. */
666
+ function subtree_has_focus(el) {
667
+ const doc = owner_document(el);
668
+ const active = doc.activeElement;
669
+ return active != null && active !== doc.body && el.contains(active);
670
+ }
671
+ export { install, morph_children, sync_attributes };