@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,994 @@
1
+ import { escape_amp_quot } from "../escape.js";
2
+ // src/server/reversible.ts
3
+ /**
4
+ * REVERSIBLE TRANSFORMS — an app's server transform (a web-component server render, say) may reshape
5
+ * the markup ogygia hands it, Svelte-owned markup included, and ogygia puts back what hydration needs.
6
+ *
7
+ * The one rule this rests on, vendor-neutral: **a custom element's server render may move its light
8
+ * DOM children** (a scoped render emulates slots by moving them into its rendered tree). So:
9
+ *
10
+ * 1. MARK, before the transform: every custom element gets an id (`og-h="K"` when ogygia will restore
11
+ * it — in Svelte-owned markup, above Svelte-owned markup, or anywhere in a hole / lake answer;
12
+ * `og-u="K"` otherwise), and each of its children a tag (`og-c="K.i"` on an element, a
13
+ * `<!--og-c K.i t|c-->` comment before a text or comment node). Text a trimmer could change,
14
+ * deeper inside a restored host's children, gets `<!--og-t K.n-->`.
15
+ * 2. The app's transform runs. On an `og-h` host it renders the plan: its slot positions as real
16
+ * `<slot>` wrappers, `og-shadow="key …"` (the sheets for the host's shadow root), `og-keep="attr …"`.
17
+ * 3. SETTLE, after it: hosts without a plan (no `og-shadow`) lose every mark and are left as the
18
+ * transform wrote them; a planned host keeps its marks plus what the restorer needs to put the
19
+ * children back exactly (`og-r`: the attributes to reset; the original text of a trimmed or
20
+ * dropped text node). Start tags the HTML parser would restructure (an `<a>` in an `<a>`, a block
21
+ * in a `<p>`, …) where the render introduced the tag or the element it would close become
22
+ * `<og-as tag="…">` stand-ins. `data-og-head` assets move into `<head>` (a document), deduped.
23
+ *
24
+ * The browser half (runtime/restore.ts) attaches each planned host's shadow root, moves the rendered
25
+ * tree into it, and puts Svelte's children back — before anything snapshots or hydrates.
26
+ *
27
+ * Pure string work over one tokenizer pass each (indexOf-driven, no regex, no DOM): it runs on every
28
+ * response of an app that configures a transform.
29
+ */
30
+ const RAW = /* @__PURE__ */ new Set([
31
+ "script",
32
+ "style",
33
+ "textarea",
34
+ "title",
35
+ "xmp",
36
+ "iframe",
37
+ "noembed",
38
+ "noframes"
39
+ ]);
40
+ const VOID = /* @__PURE__ */ new Set([
41
+ "area",
42
+ "base",
43
+ "br",
44
+ "col",
45
+ "embed",
46
+ "hr",
47
+ "img",
48
+ "input",
49
+ "link",
50
+ "meta",
51
+ "source",
52
+ "track",
53
+ "wbr",
54
+ "param",
55
+ "keygen",
56
+ "frame"
57
+ ]);
58
+ function is_space(c) {
59
+ return c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
60
+ }
61
+ function is_alpha(c) {
62
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122;
63
+ }
64
+ /** Index of the `>` ending the tag at `open`, respecting quoted values; `html.length` if none. */
65
+ function tag_end(html, open) {
66
+ let quote = 0;
67
+ for (let i = open + 1; i < html.length; i++) {
68
+ const c = html.charCodeAt(i);
69
+ if (quote) {
70
+ if (c === quote) quote = 0;
71
+ } else if (c === 34 || c === 39) quote = c;
72
+ else if (c === 62) return i;
73
+ }
74
+ return html.length;
75
+ }
76
+ function read_name(html, from) {
77
+ let i = from;
78
+ while (i < html.length) {
79
+ const c = html.charCodeAt(i);
80
+ if (is_space(c) || c === 62 || c === 47) break;
81
+ i++;
82
+ }
83
+ return i;
84
+ }
85
+ /** The raw-text body end (`<` of the matching `</name`), or `html.length`. */
86
+ function raw_end(html, from, name) {
87
+ let at = from;
88
+ for (;;) {
89
+ const lt = html.indexOf("</", at);
90
+ if (lt === -1) return html.length;
91
+ let ok = true;
92
+ for (let k = 0; k < name.length; k++) {
93
+ const c = html.charCodeAt(lt + 2 + k);
94
+ if ((c >= 65 && c <= 90 ? c + 32 : c) !== name.charCodeAt(k)) {
95
+ ok = false;
96
+ break;
97
+ }
98
+ }
99
+ const after = html.charCodeAt(lt + 2 + name.length);
100
+ if (ok && (Number.isNaN(after) || is_space(after) || after === 62 || after === 47)) return lt;
101
+ at = lt + 2;
102
+ }
103
+ }
104
+ /** A tag name, lower-cased only when it has an upper-case letter (the common case allocates nothing
105
+ * beyond the slice). */
106
+ function tag_name(html, from, to) {
107
+ const name = html.slice(from, to);
108
+ for (let k = from; k < to; k++) {
109
+ const c = html.charCodeAt(k);
110
+ if (c >= 65 && c <= 90) return name.toLowerCase();
111
+ }
112
+ return name;
113
+ }
114
+ /**
115
+ * The tokenizer: ONE token object, rewritten in place by each `next()` (a document is tens of
116
+ * thousands of tokens; an object per token, or a generator, is garbage the collector pays for on
117
+ * every request). Read a token's fields before the next `next()`.
118
+ */
119
+ var Lexer = class {
120
+ t = "text";
121
+ name = "";
122
+ start = 0;
123
+ end = 0;
124
+ name_end = 0;
125
+ self = false;
126
+ #html;
127
+ #i = 0;
128
+ /** the raw-text element just opened: its body is the next token */
129
+ #raw = "";
130
+ constructor(html) {
131
+ this.#html = html;
132
+ }
133
+ #set(t, start, end) {
134
+ this.t = t;
135
+ this.start = start;
136
+ this.end = end;
137
+ this.#i = end;
138
+ return true;
139
+ }
140
+ next() {
141
+ const html = this.#html;
142
+ const n = html.length;
143
+ let i = this.#i;
144
+ if (this.#raw) {
145
+ const name = this.#raw;
146
+ this.#raw = "";
147
+ const re = raw_end(html, i, name);
148
+ if (re > i) return this.#set("raw", i, re);
149
+ i = this.#i = re;
150
+ }
151
+ if (i >= n) return false;
152
+ const lt = html.indexOf("<", i);
153
+ if (lt === -1) return this.#set("text", i, n);
154
+ const c1 = html.charCodeAt(lt + 1);
155
+ if (!(is_alpha(c1) || c1 === 47 && is_alpha(html.charCodeAt(lt + 2)) || c1 === 33 || c1 === 63)) {
156
+ let j = lt + 1;
157
+ for (;;) {
158
+ const nx = html.indexOf("<", j);
159
+ if (nx === -1) {
160
+ j = n;
161
+ break;
162
+ }
163
+ const d = html.charCodeAt(nx + 1);
164
+ if (is_alpha(d) || d === 47 && is_alpha(html.charCodeAt(nx + 2)) || d === 33 || d === 63) {
165
+ j = nx;
166
+ break;
167
+ }
168
+ j = nx + 1;
169
+ }
170
+ return this.#set("text", i, j);
171
+ }
172
+ if (lt > i) return this.#set("text", i, lt);
173
+ if (html.startsWith("<!--", lt)) {
174
+ const close = html.indexOf("-->", lt + 4);
175
+ return this.#set("comment", lt, close === -1 ? n : close + 3);
176
+ }
177
+ if (c1 === 33 || c1 === 63) return this.#set("other", lt, tag_end(html, lt) + 1);
178
+ if (c1 === 47) {
179
+ const ne = read_name(html, lt + 2);
180
+ this.name = tag_name(html, lt + 2, ne);
181
+ return this.#set("end", lt, tag_end(html, lt) + 1);
182
+ }
183
+ const ne = read_name(html, lt + 1);
184
+ const name = tag_name(html, lt + 1, ne);
185
+ const gt = tag_end(html, lt);
186
+ this.name = name;
187
+ this.name_end = ne;
188
+ this.self = html.charCodeAt(gt - 1) === 47;
189
+ if (RAW.has(name) && !this.self) this.#raw = name;
190
+ return this.#set("start", lt, gt + 1);
191
+ }
192
+ };
193
+ /** (the attributes of a tag nobody asked about: one shared empty list, never an allocation per tag) */
194
+ const NO_ATTRS = Object.freeze([]);
195
+ /** (nothing to remove from a tag without ogygia's marks; only a tag with marks ever adds to its set) */
196
+ const NO_REMOVE = /* @__PURE__ */ new Set();
197
+ function parse_attrs(html, from, to) {
198
+ const out = [];
199
+ let i = from;
200
+ while (i < to) {
201
+ let c = html.charCodeAt(i);
202
+ if (is_space(c) || c === 47) {
203
+ i++;
204
+ continue;
205
+ }
206
+ const ns = i;
207
+ while (i < to) {
208
+ c = html.charCodeAt(i);
209
+ if (is_space(c) || c === 61 || c === 62 || c === 47) break;
210
+ i++;
211
+ }
212
+ const name = html.slice(ns, i).toLowerCase();
213
+ let j = i;
214
+ while (j < to && is_space(html.charCodeAt(j))) j++;
215
+ if (html.charCodeAt(j) === 61) {
216
+ j++;
217
+ while (j < to && is_space(html.charCodeAt(j))) j++;
218
+ const q = html.charCodeAt(j);
219
+ let value;
220
+ if (q === 34 || q === 39) {
221
+ const close = html.indexOf(q === 34 ? "\"" : "'", j + 1);
222
+ const e = close === -1 || close > to ? to : close;
223
+ value = html.slice(j + 1, e);
224
+ j = e + 1;
225
+ } else {
226
+ const vs = j;
227
+ while (j < to && !is_space(html.charCodeAt(j)) && html.charCodeAt(j) !== 62) j++;
228
+ value = html.slice(vs, j);
229
+ }
230
+ if (name) out.push({
231
+ name,
232
+ value: decode(value),
233
+ start: ns,
234
+ end: j
235
+ });
236
+ i = j;
237
+ } else {
238
+ if (name) out.push({
239
+ name,
240
+ value: "",
241
+ start: ns,
242
+ end: i
243
+ });
244
+ if (i === ns) i++;
245
+ }
246
+ }
247
+ return out;
248
+ }
249
+ const NAMED = {
250
+ amp: "&",
251
+ lt: "<",
252
+ gt: ">",
253
+ quot: "\"",
254
+ apos: "'",
255
+ nbsp: "\xA0",
256
+ "#39": "'"
257
+ };
258
+ /** Decode character references (the common named ones and every numeric one): enough to compare two
259
+ * serializations of the same text or attribute value. */
260
+ function decode(s) {
261
+ if (s.indexOf("&") === -1) return s;
262
+ let out = "";
263
+ let i = 0;
264
+ for (;;) {
265
+ const amp = s.indexOf("&", i);
266
+ if (amp === -1) return out + s.slice(i);
267
+ out += s.slice(i, amp);
268
+ const semi = s.indexOf(";", amp);
269
+ if (semi === -1 || semi - amp > 10) {
270
+ out += "&";
271
+ i = amp + 1;
272
+ continue;
273
+ }
274
+ const ref = s.slice(amp + 1, semi);
275
+ let ch;
276
+ if (ref.charCodeAt(0) === 35) {
277
+ const code = ref[1] === "x" || ref[1] === "X" ? parseInt(ref.slice(2), 16) : parseInt(ref.slice(1), 10);
278
+ if (Number.isFinite(code) && code > 0 && code <= 1114111) ch = String.fromCodePoint(code);
279
+ } else ch = NAMED[ref];
280
+ if (ch === void 0) {
281
+ out += "&";
282
+ i = amp + 1;
283
+ } else {
284
+ out += ch;
285
+ i = semi + 1;
286
+ }
287
+ }
288
+ }
289
+ const esc_attr = escape_amp_quot;
290
+ /** JSON safe inside an HTML comment: no `--`, no `>`. */
291
+ function comment_json(v) {
292
+ return replace_all(replace_all(JSON.stringify(v), "-", "\\u002d"), ">", "\\u003e");
293
+ }
294
+ function script_json(v) {
295
+ return replace_all(JSON.stringify(v), "<", "\\u003c");
296
+ }
297
+ /** `replaceAll` behind a native search: no copy when there is nothing to replace. */
298
+ function replace_all(s, from, to) {
299
+ return s.indexOf(from) === -1 ? s : s.replaceAll(from, to);
300
+ }
301
+ const P_CLOSERS = /* @__PURE__ */ new Set([
302
+ "address",
303
+ "article",
304
+ "aside",
305
+ "blockquote",
306
+ "center",
307
+ "details",
308
+ "dialog",
309
+ "dir",
310
+ "div",
311
+ "dl",
312
+ "fieldset",
313
+ "figcaption",
314
+ "figure",
315
+ "footer",
316
+ "form",
317
+ "header",
318
+ "hgroup",
319
+ "main",
320
+ "menu",
321
+ "nav",
322
+ "ol",
323
+ "p",
324
+ "search",
325
+ "section",
326
+ "summary",
327
+ "ul",
328
+ "h1",
329
+ "h2",
330
+ "h3",
331
+ "h4",
332
+ "h5",
333
+ "h6",
334
+ "pre",
335
+ "listing",
336
+ "table",
337
+ "hr",
338
+ "xmp",
339
+ "li",
340
+ "dd",
341
+ "dt",
342
+ "plaintext"
343
+ ]);
344
+ const HEADINGS = /* @__PURE__ */ new Set([
345
+ "h1",
346
+ "h2",
347
+ "h3",
348
+ "h4",
349
+ "h5",
350
+ "h6"
351
+ ]);
352
+ const SCOPE = /* @__PURE__ */ new Set([
353
+ "applet",
354
+ "caption",
355
+ "html",
356
+ "table",
357
+ "td",
358
+ "th",
359
+ "marquee",
360
+ "object",
361
+ "template",
362
+ "foreignobject",
363
+ "desc"
364
+ ]);
365
+ const TRACKED = new Map([
366
+ "a",
367
+ "nobr",
368
+ "button",
369
+ "form",
370
+ "li",
371
+ "dd",
372
+ "dt",
373
+ "p",
374
+ "td",
375
+ "th",
376
+ "tr"
377
+ ].map((n, i) => [n, i]));
378
+ function push(stack, f) {
379
+ const slot = TRACKED.get(f.name) ?? -1;
380
+ (stack.slots ??= []).push(slot);
381
+ if (slot !== -1) (stack.open ??= Array.from({ length: TRACKED.size }, () => 0))[slot]++;
382
+ stack.push(f);
383
+ }
384
+ /** Close the elements from `k` up. */
385
+ function cut(stack, k) {
386
+ const slots = stack.slots;
387
+ if (slots) {
388
+ const open = stack.open;
389
+ if (open) {
390
+ for (let j = slots.length - 1; j >= k; j--) if (slots[j] !== -1) open[slots[j]]--;
391
+ }
392
+ slots.length = k;
393
+ }
394
+ stack.length = k;
395
+ }
396
+ /** The index of the open `name` in scope, or -1. (A stand-in `<og-as tag="a">` is not an `<a>` to
397
+ * the parser: the element's own name is what counts.) */
398
+ function in_scope(stack, name, extra) {
399
+ const slot = TRACKED.get(name);
400
+ if (slot === void 0 || !stack.open?.[slot]) return -1;
401
+ for (let k = stack.length - 1; k >= 0; k--) {
402
+ const f = stack[k];
403
+ if (f.name === name) return k;
404
+ if (SCOPE.has(f.name) || extra?.has(f.name)) return -1;
405
+ }
406
+ return -1;
407
+ }
408
+ const BUTTON_SCOPE = /* @__PURE__ */ new Set(["button"]);
409
+ const LIST_SCOPE = /* @__PURE__ */ new Set(["ol", "ul"]);
410
+ /** `implied_close`: the parser ignores this start tag (a form in a form) */
411
+ const DROP = -2;
412
+ /** What the parser does to the stack BEFORE inserting start tag `name`: the index of the element it
413
+ * would close (and everything above it), -1 for nothing, or `DROP` (it ignores the tag). A number,
414
+ * never an object: this runs on every start tag. */
415
+ function implied_close(stack, name) {
416
+ if (name === "a" || name === "nobr" || name === "button") return in_scope(stack, name);
417
+ if (name === "form") return in_scope(stack, "form") === -1 ? -1 : DROP;
418
+ if (name === "li") {
419
+ const li = in_scope(stack, "li", LIST_SCOPE);
420
+ if (li !== -1) return li;
421
+ }
422
+ if (name === "dd" || name === "dt") {
423
+ const k = Math.max(in_scope(stack, "dd"), in_scope(stack, "dt"));
424
+ if (k !== -1) return k;
425
+ }
426
+ if (P_CLOSERS.has(name)) {
427
+ const p = in_scope(stack, "p", BUTTON_SCOPE);
428
+ if (p !== -1) return p;
429
+ if (HEADINGS.has(name)) {
430
+ const top = stack[stack.length - 1];
431
+ if (top && HEADINGS.has(top.name)) return stack.length - 1;
432
+ }
433
+ }
434
+ if (name === "option" || name === "optgroup") {
435
+ const top = stack[stack.length - 1];
436
+ if (top && top.name === "option") return stack.length - 1;
437
+ }
438
+ if (name === "td" || name === "th") {
439
+ const k = Math.max(in_scope(stack, "td"), in_scope(stack, "th"));
440
+ if (k !== -1) return k;
441
+ }
442
+ if (name === "tr") {
443
+ const k = in_scope(stack, "tr");
444
+ if (k !== -1) return k;
445
+ }
446
+ return -1;
447
+ }
448
+ /** An end tag: close up to the innermost element of that name (a stand-in answers to its real tag,
449
+ * whose end tag the settle pass rewrites). */
450
+ function pop_to(stack, name) {
451
+ for (let k = stack.length - 1; k >= 0; k--) if ((stack[k].as ?? stack[k].name) === name) {
452
+ cut(stack, k);
453
+ return;
454
+ }
455
+ }
456
+ function is_custom(name, foreign) {
457
+ if (foreign || name.indexOf("-") === -1 || !is_alpha(name.charCodeAt(0))) return false;
458
+ return !name.startsWith("ogygia-") && !name.startsWith("og-");
459
+ }
460
+ /** Who renders a region's inside, for Svelte ownership: a hole's and a lake's are opaque to any
461
+ * hydration — and so is a BAKED live region's (its first HTML is one `{@html}` string to Svelte), the
462
+ * same set the client calls opaque (region-attrs.ts `OPAQUE_SELECTOR`). Restoring a host in there to
463
+ * Svelte's render undid what the server's transform wrote for no hydration to follow (a closed
464
+ * dropdown lost `hidden` and pushed the page down until its own runtime set it again). */
465
+ function region_kind(attrs) {
466
+ if (attrs.some((a) => a.name === "endpoint")) return "hole";
467
+ if (attrs.some((a) => a.name === "wake" && a.value === "none" || a.name === "data-og-baked")) return "lake";
468
+ return "island";
469
+ }
470
+ /** Text the serializer could change: whitespace-only, or with leading / trailing whitespace. */
471
+ function trimmable(s) {
472
+ if (!s.length) return false;
473
+ const a = s.charCodeAt(0);
474
+ const b = s.charCodeAt(s.length - 1);
475
+ return is_space(a) || is_space(b) || a === 160 || b === 160 || s.indexOf("&nbsp;") !== -1 || s.indexOf("&#160;") !== -1;
476
+ }
477
+ /** (the record of a host ogygia won't restore: shared, never written) */
478
+ const NO_RECORD = Object.freeze({});
479
+ const NO_CHILDREN = /* @__PURE__ */ new Map();
480
+ const NO_TEXTS = /* @__PURE__ */ new Map();
481
+ const attr_map = (attrs) => {
482
+ const m = {};
483
+ for (const a of attrs) m[a.name] = a.value;
484
+ return m;
485
+ };
486
+ /**
487
+ * Which custom elements (in document order) get a plan: every one in an ANSWER — markup the runtime
488
+ * morphs into a live page (a hole / lake answer, or a document the router fetched: `answer`) — whose
489
+ * hosts meet live ones its own runtime already rendered, so they must arrive in the form the restorer
490
+ * gives (Svelte's children in the light DOM), never in the transform's server form only the
491
+ * component's first hydrate reads (that form, morphed into a live host, left the transform's tree in
492
+ * its light DOM: a site nav collapsed to one unstyled item after an in-place navigation). In a
493
+ * document loaded as one, every one in Svelte-owned markup, and every one with Svelte-owned markup
494
+ * below it (a server-owned host around an island: adopting it would reach into the island). A first
495
+ * pass, so the marking pass knows a host's plan before it reaches the host's children.
496
+ */
497
+ function plan_hosts(html, kind, csr, answer) {
498
+ const planned = [];
499
+ const stack = [];
500
+ let in_body = kind !== "document";
501
+ for (const tok = new Lexer(html); tok.next();) if (tok.t === "start") {
502
+ const name = tok.name;
503
+ if (name === "body") in_body = true;
504
+ const close = implied_close(stack, name);
505
+ if (close === DROP) continue;
506
+ if (close !== -1) cut(stack, close);
507
+ const parent = stack[stack.length - 1];
508
+ const foreign = name === "svg" || name === "math" || !!parent?.foreign;
509
+ let owned = name === "body" && kind === "document" && csr || (parent ? parent.owned : false);
510
+ if (name === "ogygia-region") owned = region_kind(parse_attrs(html, tok.name_end, tok.end - 1)) === "island";
511
+ let host = -1;
512
+ if (in_body && is_custom(name, foreign)) {
513
+ host = planned.length;
514
+ planned.push(answer || kind !== "document" || owned);
515
+ }
516
+ if (owned && !(parent ? parent.owned : false)) {
517
+ for (const f of stack) if (f.host !== -1) planned[f.host] = true;
518
+ }
519
+ if (!(VOID.has(name) || tok.self && foreign)) push(stack, {
520
+ name,
521
+ host,
522
+ owned,
523
+ foreign
524
+ });
525
+ } else if (tok.t === "end") pop_to(stack, tok.name);
526
+ return planned;
527
+ }
528
+ /** Is there any custom element (in a document: after `<body`) — a hop from `<` to `<` reading only
529
+ * tag names, no tokenization. Most pages of most apps have none, and then there is nothing to mark. */
530
+ function has_custom_element(html, document) {
531
+ let at = document ? html.indexOf("<body") : 0;
532
+ if (at === -1) return false;
533
+ for (at = html.indexOf("<", at); at !== -1; at = html.indexOf("<", at + 1)) {
534
+ if (!is_alpha(html.charCodeAt(at + 1))) continue;
535
+ const ne = read_name(html, at + 1);
536
+ const dash = html.indexOf("-", at + 1);
537
+ if (dash !== -1 && dash < ne && is_custom(tag_name(html, at + 1, ne), false)) return true;
538
+ }
539
+ return false;
540
+ }
541
+ /**
542
+ * Tag `html` for the transform. `csr`: a Kit-hydrated document (its whole body is Svelte's, except
543
+ * lakes and holes). `answer`: a document the router fetched, morphed into the live page (every host
544
+ * planned, as in a region answer — see `plan_hosts`). Returns the tagged HTML, or `null` when there is
545
+ * no custom element to tag (the transform then gets the HTML as is, and settle has nothing to do).
546
+ */
547
+ function mark(html, kind, csr, answer = false) {
548
+ if (!has_custom_element(html, kind === "document")) return null;
549
+ const planned = plan_hosts(html, kind, csr, answer);
550
+ if (!planned.length) return null;
551
+ const out = [];
552
+ let pos = 0;
553
+ const hosts = /* @__PURE__ */ new Map();
554
+ let next_k = 0;
555
+ const stack = [];
556
+ let in_body = kind !== "document";
557
+ let last_was_pre_start = false;
558
+ const top = () => stack[stack.length - 1];
559
+ const under_now = () => top() ? top().under : -1;
560
+ for (const tok = new Lexer(html); tok.next();) {
561
+ if (tok.t === "start") {
562
+ const name = tok.name;
563
+ if (name === "body") in_body = true;
564
+ const close = implied_close(stack, name);
565
+ if (close === DROP) continue;
566
+ if (close !== -1) cut(stack, close);
567
+ const parent = top();
568
+ const foreign = name === "svg" || name === "math" || !!parent?.foreign;
569
+ const custom = in_body && is_custom(name, foreign);
570
+ const child_of_host = !!parent && parent.host !== -1 && in_body;
571
+ const recorded = custom && planned[next_k] === true || child_of_host && planned[parent.host] === true;
572
+ const attrs = name === "ogygia-region" || name === "template" || recorded ? parse_attrs(html, tok.name_end, tok.end - 1) : NO_ATTRS;
573
+ let owned = name === "body" && kind === "document" && csr || (parent ? parent.owned : false);
574
+ if (name === "ogygia-region") owned = region_kind(attrs) === "island";
575
+ let insert = "";
576
+ const shadow_tpl = name === "template" && attrs.some((a) => a.name === "shadowrootmode");
577
+ if (child_of_host && !shadow_tpl) {
578
+ const i = parent.next++;
579
+ insert += ` og-c="${parent.host}.${i}"`;
580
+ if (planned[parent.host]) hosts.get(parent.host).children.set(i, { attrs: attr_map(attrs) });
581
+ }
582
+ let host = -1;
583
+ if (custom) {
584
+ host = next_k++;
585
+ const is_planned = planned[host] ?? false;
586
+ hosts.set(host, {
587
+ planned: is_planned,
588
+ owned,
589
+ attrs: is_planned ? attr_map(attrs) : NO_RECORD,
590
+ children: is_planned ? /* @__PURE__ */ new Map() : NO_CHILDREN,
591
+ texts: is_planned ? /* @__PURE__ */ new Map() : NO_TEXTS,
592
+ text_next: 0,
593
+ inner_start: tok.end,
594
+ inner_end: tok.end
595
+ });
596
+ insert += is_planned ? ` og-h="${host}"` : ` og-u="${host}"`;
597
+ }
598
+ if (insert) {
599
+ out.push(html.slice(pos, tok.name_end), insert);
600
+ pos = tok.name_end;
601
+ }
602
+ if (!(VOID.has(name) || tok.self && foreign)) push(stack, {
603
+ name,
604
+ host,
605
+ next: 0,
606
+ owned,
607
+ under: host !== -1 && planned[host] ? host : under_now(),
608
+ introduced: false,
609
+ foreign
610
+ });
611
+ last_was_pre_start = name === "pre" || name === "listing";
612
+ continue;
613
+ }
614
+ if (tok.t === "end") {
615
+ const name = tok.name;
616
+ for (let k = stack.length - 1; k >= 0; k--) if (stack[k].name === name) {
617
+ for (let j = stack.length - 1; j >= k; j--) {
618
+ const f = stack[j];
619
+ if (f.host !== -1) hosts.get(f.host).inner_end = tok.start;
620
+ }
621
+ cut(stack, k);
622
+ break;
623
+ }
624
+ last_was_pre_start = false;
625
+ continue;
626
+ }
627
+ if (tok.t === "text" || tok.t === "comment") {
628
+ const parent = top();
629
+ if (parent && parent.host !== -1 && in_body && !hosts.get(parent.host).planned) parent.next++;
630
+ else if (parent && parent.host !== -1 && in_body) {
631
+ const i = parent.next++;
632
+ const rec = hosts.get(parent.host);
633
+ if (tok.t === "text") {
634
+ const raw = html.slice(tok.start, tok.end);
635
+ rec.children.set(i, { text: raw });
636
+ out.push(html.slice(pos, tok.start), `<!--og-c ${parent.host}.${i} t-->`);
637
+ } else {
638
+ rec.children.set(i, {});
639
+ out.push(html.slice(pos, tok.start), `<!--og-c ${parent.host}.${i} c-->`);
640
+ }
641
+ pos = tok.start;
642
+ } else if (tok.t === "text" && parent && under_now() !== -1 && !last_was_pre_start) {
643
+ const raw = html.slice(tok.start, tok.end);
644
+ if (trimmable(raw)) {
645
+ const k = under_now();
646
+ const rec = hosts.get(k);
647
+ const n = rec.text_next++;
648
+ rec.texts.set(n, raw);
649
+ out.push(html.slice(pos, tok.start), `<!--og-t ${k}.${n}-->`);
650
+ pos = tok.start;
651
+ }
652
+ }
653
+ last_was_pre_start = false;
654
+ continue;
655
+ }
656
+ last_was_pre_start = false;
657
+ }
658
+ if (!hosts.size) return null;
659
+ out.push(html.slice(pos));
660
+ return {
661
+ html: out.join(""),
662
+ record: {
663
+ kind,
664
+ source: html,
665
+ hosts
666
+ }
667
+ };
668
+ }
669
+ /** How the stand-ins keep their element's box before the restore swaps them back (zero specificity:
670
+ * the component's own class rules still win). */
671
+ const STAND_IN_CSS = ":where(og-as){display:inline}:where(og-as[tag=address],og-as[tag=article],og-as[tag=aside],og-as[tag=blockquote],og-as[tag=center],og-as[tag=details],og-as[tag=dialog],og-as[tag=dir],og-as[tag=div],og-as[tag=dl],og-as[tag=dd],og-as[tag=dt],og-as[tag=fieldset],og-as[tag=figcaption],og-as[tag=figure],og-as[tag=footer],og-as[tag=form],og-as[tag=header],og-as[tag=hgroup],og-as[tag=main],og-as[tag=menu],og-as[tag=nav],og-as[tag=ol],og-as[tag=p],og-as[tag=search],og-as[tag=section],og-as[tag=summary],og-as[tag=ul],og-as[tag=h1],og-as[tag=h2],og-as[tag=h3],og-as[tag=h4],og-as[tag=h5],og-as[tag=h6],og-as[tag=pre],og-as[tag=listing],og-as[tag=hr],og-as[tag=xmp]){display:block}:where(og-as[tag=li]){display:list-item}:where(og-as[tag=table]){display:table}:where(og-as[tag=button]){display:inline-block}";
672
+ /** The attributes a restore resets: `name → Svelte's value`, or `null` to remove. */
673
+ function attr_diff(now, was, keep) {
674
+ let diff = null;
675
+ const seen = /* @__PURE__ */ new Set();
676
+ for (const a of now) {
677
+ if (a.name.startsWith("og-")) continue;
678
+ seen.add(a.name);
679
+ if (a.name in was) {
680
+ if (was[a.name] !== a.value) (diff ??= {})[a.name] = was[a.name];
681
+ } else if (!keep.has(a.name)) (diff ??= {})[a.name] = null;
682
+ }
683
+ for (const name in was) if (!seen.has(name) && !name.startsWith("og-")) (diff ??= {})[name] = was[name];
684
+ return diff;
685
+ }
686
+ /** Rewrite a start tag: drop the attributes named in `drop`, append `add`, rename to `rename`. */
687
+ function rewrite_start(html, tok, attrs, drop, add, rename) {
688
+ let s = "<" + (rename ?? html.slice(tok.start + 1, tok.name_end));
689
+ let at = tok.name_end;
690
+ for (const a of attrs) {
691
+ if (!drop.has(a.name)) continue;
692
+ let from = a.start;
693
+ while (from > at && is_space(html.charCodeAt(from - 1))) from--;
694
+ s += html.slice(at, from);
695
+ at = a.end;
696
+ }
697
+ const close = html.charCodeAt(tok.end - 2) === 47 ? tok.end - 2 : tok.end - 1;
698
+ return s + html.slice(at, close) + add + html.slice(close, tok.end);
699
+ }
700
+ function settle(html, record, opts = {}) {
701
+ const plan = /* @__PURE__ */ new Set();
702
+ for (let at = html.indexOf(" og-shadow="); at !== -1; at = html.indexOf(" og-shadow=", at + 11)) {
703
+ const lt = html.lastIndexOf("<", at);
704
+ if (lt === -1) continue;
705
+ const gt = tag_end(html, lt);
706
+ if (gt < at) continue;
707
+ const h = parse_attrs(html, read_name(html, lt + 1), gt).find((a) => a.name === "og-h");
708
+ if (h) plan.add(Number(h.value));
709
+ }
710
+ /** Does the tag at `[from, to)` hold `needle`? A forward-only cursor: tags come in document order,
711
+ * so each occurrence is searched for once (a search from every tag is quadratic in the gaps). */
712
+ const within = (needle) => {
713
+ let at = html.indexOf(needle);
714
+ return (from, to) => {
715
+ if (at !== -1 && at < from) at = html.indexOf(needle, from);
716
+ return at !== -1 && at < to;
717
+ };
718
+ };
719
+ const og_in = within(" og-");
720
+ const head_in = within("data-og-head");
721
+ const out = [];
722
+ let pos = 0;
723
+ const stack = [];
724
+ const head = [];
725
+ const head_keys = /* @__PURE__ */ new Set();
726
+ let head_cut = null;
727
+ let stand_ins = 0;
728
+ let pending_text = null;
729
+ const doc = record.kind === "document";
730
+ /** Close a pending text mark: `text` is the text that follows it in the output (or null: none). */
731
+ const finish_text = (text) => {
732
+ const p = pending_text;
733
+ pending_text = null;
734
+ const rec = record.hosts.get(p.k);
735
+ const was = p.og === "c" ? rec?.children.get(p.i)?.text : rec?.texts.get(p.i);
736
+ if (was === void 0) {
737
+ out[p.comment_at] = "";
738
+ return;
739
+ }
740
+ if (!plan.has(p.k)) {
741
+ out[p.comment_at] = "";
742
+ if (text === null || decode(text) !== decode(was)) for (let s = stack.length - 1; s >= 0; s--) {
743
+ const a = stack[s].host;
744
+ if (a === -1 || !plan.has(a)) continue;
745
+ const ra = record.hosts.get(a);
746
+ if (ra) out[p.comment_at] = `<!--og-t ${a}.${ra.text_next++} ${comment_json(decode(was))}-->`;
747
+ break;
748
+ }
749
+ return;
750
+ }
751
+ if (p.og === "t") {
752
+ out[p.comment_at] = text !== null && decode(text) === decode(was) ? "" : `<!--og-t ${p.k}.${p.i} ${comment_json(decode(was))}-->`;
753
+ return;
754
+ }
755
+ out[p.comment_at] = text !== null && decode(text) === decode(was) ? `<!--og-c ${p.k}.${p.i} t-->` : `<!--og-c ${p.k}.${p.i} t ${comment_json(decode(was))}-->`;
756
+ };
757
+ for (const tok = new Lexer(html); tok.next();) {
758
+ if (head_cut) {
759
+ if (tok.t === "end" && tok.name === head_cut.name && --head_cut.depth === 0) {
760
+ const asset = html.slice(head_cut.start, tok.end);
761
+ pos = tok.end;
762
+ if (!head_keys.has(head_cut.key)) {
763
+ head_keys.add(head_cut.key);
764
+ head.push(asset);
765
+ }
766
+ head_cut = null;
767
+ } else if (tok.t === "start" && tok.name === head_cut.name) head_cut.depth++;
768
+ continue;
769
+ }
770
+ if (pending_text && tok.t !== "text") finish_text(null);
771
+ if (tok.t === "text") {
772
+ if (pending_text) {
773
+ out.push(html.slice(pos, tok.start));
774
+ pos = tok.start;
775
+ finish_text(html.slice(tok.start, tok.end));
776
+ }
777
+ continue;
778
+ }
779
+ if (tok.t === "comment") {
780
+ const body = html.slice(tok.start + 4, tok.end - 3);
781
+ const is_c = body.startsWith("og-c ");
782
+ const is_t = body.startsWith("og-t ");
783
+ if (!is_c && !is_t) continue;
784
+ const sp = body.indexOf(" ", 5);
785
+ const id = body.slice(5, sp === -1 ? body.length : sp);
786
+ const dot = id.indexOf(".");
787
+ const k = Number(id.slice(0, dot));
788
+ const i = Number(id.slice(dot + 1));
789
+ out.push(html.slice(pos, tok.start));
790
+ pos = tok.end;
791
+ if (is_c && body.endsWith(" c")) {
792
+ out.push(plan.has(k) ? html.slice(tok.start, tok.end) : "");
793
+ continue;
794
+ }
795
+ out.push("");
796
+ pending_text = {
797
+ k,
798
+ i,
799
+ comment_at: out.length - 1,
800
+ og: is_c ? "c" : "t"
801
+ };
802
+ continue;
803
+ }
804
+ if (tok.t === "start") {
805
+ const name = tok.name;
806
+ const implied = implied_close(stack, name);
807
+ const drop = implied === DROP;
808
+ const close = drop ? -1 : implied;
809
+ const parent = stack[stack.length - 1];
810
+ const has_og = og_in(tok.start, tok.end);
811
+ const head_attr = head_in(tok.start, tok.end);
812
+ const attrs = has_og || head_attr || close !== -1 ? parse_attrs(html, tok.name_end, tok.end - 1) : NO_ATTRS;
813
+ if (doc && head_attr && !has_og) {
814
+ const key = attrs.find((a) => a.name === "data-og-head")?.value;
815
+ if (key !== void 0 && (name === "style" || name === "link" || name === "template")) {
816
+ out.push(html.slice(pos, tok.start));
817
+ pos = tok.start;
818
+ if (name === "link" || tok.self) {
819
+ pos = tok.end;
820
+ if (!head_keys.has(key)) {
821
+ head_keys.add(key);
822
+ head.push(html.slice(tok.start, tok.end));
823
+ }
824
+ } else head_cut = {
825
+ start: tok.start,
826
+ name,
827
+ depth: 1,
828
+ key
829
+ };
830
+ continue;
831
+ }
832
+ }
833
+ const og_c = has_og ? attrs.find((a) => a.name === "og-c") : void 0;
834
+ const og_h = has_og ? attrs.find((a) => a.name === "og-h" || a.name === "og-u") : void 0;
835
+ const foreign = name === "svg" || name === "math" || !!parent?.foreign;
836
+ const is_host = !!og_h;
837
+ const introduced = og_c ? false : parent ? parent.host !== -1 ? true : parent.introduced : false;
838
+ let stand_in = false;
839
+ if ((close !== -1 || drop) && !foreign) {
840
+ const trigger = close !== -1 ? stack[close] : void 0;
841
+ if (introduced || trigger?.introduced || drop && introduced) stand_in = true;
842
+ }
843
+ if (!stand_in) {
844
+ if (close !== -1) cut(stack, close);
845
+ if (drop) continue;
846
+ }
847
+ const remove = has_og ? /* @__PURE__ */ new Set() : NO_REMOVE;
848
+ let add = "";
849
+ let reset = null;
850
+ let planned_host = false;
851
+ if (og_h) {
852
+ const k = Number(og_h.value);
853
+ if (og_h.name === "og-u" || !plan.has(k)) {
854
+ remove.add(og_h.name);
855
+ remove.add("og-shadow");
856
+ remove.add("og-keep");
857
+ } else {
858
+ planned_host = true;
859
+ const keep = new Set((attrs.find((a) => a.name === "og-keep")?.value ?? "").split(" ").filter(Boolean));
860
+ reset = attr_diff(attrs, record.hosts.get(k)?.attrs ?? {}, keep);
861
+ }
862
+ }
863
+ if (og_c) {
864
+ const dot = og_c.value.indexOf(".");
865
+ const k = Number(og_c.value.slice(0, dot));
866
+ if (!plan.has(k)) remove.add("og-c");
867
+ else if (!planned_host && og_h?.name !== "og-u") reset = attr_diff(attrs, record.hosts.get(k)?.children.get(Number(og_c.value.slice(dot + 1)))?.attrs ?? {}, /* @__PURE__ */ new Set());
868
+ }
869
+ if (reset) add += ` og-r="${esc_attr(JSON.stringify(reset))}"`;
870
+ if (stand_in) {
871
+ add += ` tag="${name}"`;
872
+ stand_ins++;
873
+ }
874
+ if (remove.size || add || stand_in) {
875
+ out.push(html.slice(pos, tok.start), rewrite_start(html, tok, attrs, remove, add, stand_in ? "og-as" : void 0));
876
+ pos = tok.end;
877
+ }
878
+ if (!(VOID.has(name) || tok.self && foreign)) push(stack, {
879
+ name: stand_in ? "og-as" : name,
880
+ as: stand_in ? name : void 0,
881
+ host: is_host ? Number(og_h.value) : -1,
882
+ next: 0,
883
+ owned: false,
884
+ under: -1,
885
+ introduced,
886
+ foreign
887
+ });
888
+ continue;
889
+ }
890
+ if (tok.t === "end") {
891
+ const name = tok.name;
892
+ for (let k = stack.length - 1; k >= 0; k--) {
893
+ const f = stack[k];
894
+ if ((f.as ?? f.name) === name) {
895
+ if (f.as) {
896
+ out.push(html.slice(pos, tok.start), "</og-as>");
897
+ pos = tok.end;
898
+ }
899
+ cut(stack, k);
900
+ break;
901
+ }
902
+ }
903
+ continue;
904
+ }
905
+ }
906
+ if (pending_text) finish_text(null);
907
+ out.push(html.slice(pos));
908
+ let check;
909
+ if (opts.dev) for (const k of plan) {
910
+ const rec = record.hosts.get(k);
911
+ if (rec && rec.planned) (check ??= {})[k] = record.source.slice(rec.inner_start, rec.inner_end);
912
+ }
913
+ return {
914
+ html: out.join(""),
915
+ planned: plan.size,
916
+ stand_ins,
917
+ head,
918
+ ...check ? { check } : {}
919
+ };
920
+ }
921
+ /** The dev check's payload: each planned Svelte-owned host's original children, by its id. */
922
+ function check_script(check) {
923
+ return `<script type="application/ogygia-restore-check">${script_json(check)}<\/script>`;
924
+ }
925
+ /** The host id right after `at` (digits), and where they end. */
926
+ function read_id(s, at) {
927
+ let n = 0;
928
+ let j = at;
929
+ while (j < s.length && s.charCodeAt(j) >= 48 && s.charCodeAt(j) <= 57) n = n * 10 + (s.charCodeAt(j++) - 48);
930
+ return j === at ? null : {
931
+ id: n,
932
+ end: j
933
+ };
934
+ }
935
+ /** Rewrite every host id in ogygia's marks through `map` (ids it lacks stay). */
936
+ function remap(html, map) {
937
+ let out = "";
938
+ let pos = 0;
939
+ for (let a = html.indexOf("og-"); a !== -1; a = html.indexOf("og-", a + 3)) {
940
+ const c = html.charCodeAt(a + 3);
941
+ let id_at = -1;
942
+ if ((c === 104 || c === 117 || c === 99) && html.charCodeAt(a + 4) === 61 && html.charCodeAt(a + 5) === 34) id_at = a + 6;
943
+ else if ((c === 99 || c === 116) && html.charCodeAt(a + 4) === 32 && html.startsWith("<!--", a - 4)) id_at = a + 5;
944
+ if (id_at === -1) continue;
945
+ const r = read_id(html, id_at);
946
+ if (!r) continue;
947
+ const to = map(r.id);
948
+ if (to === void 0 || to === r.id) continue;
949
+ out += html.slice(pos, id_at) + to;
950
+ pos = r.end;
951
+ a = r.end - 3;
952
+ }
953
+ return pos === 0 ? html : out + html.slice(pos);
954
+ }
955
+ /**
956
+ * STABLE MARKS FOR A CACHING TRANSFORM. ogygia numbers hosts across the whole document, so the same
957
+ * block carries other ids on another page, and a render cache keyed on its markup never hits.
958
+ * `localizeMarks(block)` renumbers the block's marks from 0 (in order of appearance): cache on the
959
+ * result, then `back(rendered)` puts the document's ids back on whatever the render returned.
960
+ *
961
+ * ```ts
962
+ * const local = localizeMarks(block);
963
+ * const rendered = cache.get(local.html) ?? cache.set(local.html, await render(local.html));
964
+ * return local.back(rendered);
965
+ * ```
966
+ */
967
+ function localizeMarks(html) {
968
+ const to_local = /* @__PURE__ */ new Map();
969
+ const local = remap(html, (id) => {
970
+ let l = to_local.get(id);
971
+ if (l === void 0) to_local.set(id, l = to_local.size);
972
+ return l;
973
+ });
974
+ const to_doc = new Map([...to_local].map(([d, l]) => [l, d]));
975
+ return {
976
+ html: local,
977
+ back: (rendered) => remap(rendered, (id) => to_doc.get(id))
978
+ };
979
+ }
980
+ /**
981
+ * The whole server round trip for one piece of markup: mark → the app's transform → settle. Kit-free
982
+ * (exported from `ogygia/markup` for tests that harvest markup and run a transform over it).
983
+ */
984
+ async function transformMarkup(html, transform, opts = {}) {
985
+ const marked = mark(html, opts.kind ?? "region", !!opts.csr);
986
+ if (!marked) return {
987
+ html: await transform(html),
988
+ planned: 0,
989
+ stand_ins: 0,
990
+ head: []
991
+ };
992
+ return settle(await transform(marked.html), marked.record, { dev: opts.dev });
993
+ }
994
+ export { STAND_IN_CSS, check_script, decode, localizeMarks, mark, settle, transformMarkup };