@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,110 @@
1
+ // src/server/kit-context.ts
2
+ /**
3
+ * Kit's request context for ogygia's OWN server render roots.
4
+ *
5
+ * Kit's server `$app/state` answers `page.*` from `getContext('__request__').page` — a Svelte
6
+ * context Kit's page render sets on ITS root. Every `svelte/server` `render()` ogygia starts is a
7
+ * fresh root with no such context: the routeless document (`document()`), the inline island render
8
+ * (`region.ts`), the deferred-region endpoint, snippet bodies. A component reading `page.data`
9
+ * during SSR under any of them crashed with "reading 'page' of undefined". Every such root now
10
+ * passes `kit_render_context()`, which rebuilds Kit's shape from the per-request page snapshot
11
+ * (Region.svelte records it; the handle keeps it in the request bag) or, absent that, from the
12
+ * live request via the reader hooks.ts installs.
13
+ *
14
+ * Isomorphic and dependency-free by design: `region.ts` is in the client graph, so nothing here may
15
+ * import Kit's server internals. The reader rides ONE `globalThis` + `Symbol.for` slot — the
16
+ * PAGE-STATE-SINGLETON law (dist entries can double-evaluate a module).
17
+ */
18
+ const KIT_REQUEST_CONTEXT = "__request__";
19
+ /** Kit's `$app/stores` server side reads `getContext('__svelte__')` — `{ page, navigating, updated }`
20
+ * stores Kit's page render sets on ITS root (`render.js`). Same gap as `__request__`: a component
21
+ * using the (deprecated, still everywhere) `$page` store crashed under every ogygia render root. */
22
+ const KIT_STORES_CONTEXT = "__svelte__";
23
+ const SLOT = Symbol.for("ogygia.kit-context");
24
+ const slots = globalThis[SLOT] ??= {
25
+ reader: null,
26
+ event_reader: null
27
+ };
28
+ /** hooks.ts installs the request-scoped reader (page snapshot + live event). */
29
+ function set_kit_page_reader(fn) {
30
+ slots.reader = fn;
31
+ }
32
+ /** hooks.ts installs the live `RequestEvent` reader — what `requestEvent()` (public, isomorphic)
33
+ * hands a server island: `locals`, `cookies`, `url`, `request` of the request rendering it. */
34
+ function set_kit_event_reader(fn) {
35
+ slots.event_reader = fn;
36
+ }
37
+ /** hooks.ts installs the render-page port: in a request rendering for a page it is not (a hole, a
38
+ * remote call), that page is looked up once (server/page-facts.ts) so the reader answers from it,
39
+ * and an answer carries the facts its islands read. */
40
+ function set_render_page_port(port) {
41
+ slots.render_page = port;
42
+ }
43
+ /**
44
+ * Await before an async render root starts: the page this render belongs to, ready for the reader.
45
+ * Inside a page request, on the client, or for a render that reads no `page.data`: nothing to wait for
46
+ * (`undefined`, no microtask).
47
+ */
48
+ function kit_page_ready(reads_data = null) {
49
+ return slots.render_page?.ready(reads_data);
50
+ }
51
+ /** Append to a render root's HTML: the page facts its islands read, when it rendered for a page. */
52
+ function kit_page_facts_tail() {
53
+ return slots.render_page?.tail() ?? "";
54
+ }
55
+ /** Append to a minted hole endpoint: its page version (server/render-page.ts), or `''`. */
56
+ function kit_page_version(hole_id) {
57
+ return slots.render_page?.version(hole_id) ?? "";
58
+ }
59
+ /** The live event the installed reader answers (null off-request / on the client). */
60
+ function kit_request_event() {
61
+ return slots.event_reader?.() ?? null;
62
+ }
63
+ /** A page no component can crash on: what a render outside any request sees (tests, tools). */
64
+ function empty_kit_page() {
65
+ return {
66
+ url: void 0,
67
+ params: {},
68
+ route: { id: null },
69
+ status: 200,
70
+ data: {},
71
+ form: null,
72
+ error: null,
73
+ state: {}
74
+ };
75
+ }
76
+ /** A frozen server-side store: the value is known for the whole render, nothing ever changes it
77
+ * (Kit's own page render uses `writable`s it never writes after start). Hand-rolled so this
78
+ * module stays dependency-free for the client graph. */
79
+ function frozen_store(value) {
80
+ return { subscribe(fn) {
81
+ fn(value);
82
+ return () => {};
83
+ } };
84
+ }
85
+ /** Kit's `__svelte__` context shape: what `getStores()` in `$app/stores` destructures. */
86
+ function kit_stores_context(page) {
87
+ return {
88
+ page: frozen_store(page),
89
+ navigating: frozen_store(null),
90
+ updated: {
91
+ ...frozen_store(false),
92
+ check: async () => false
93
+ }
94
+ };
95
+ }
96
+ /** The `context` option for a `svelte/server` `render()` ogygia starts. An explicit `page` (the
97
+ * document root, built from the router's seed) wins; else the request reader; else empty. Both
98
+ * of Kit's contexts ride along: `__request__` for `$app/state`, `__svelte__` for `$app/stores`.
99
+ * The `__request__` entry also carries the live `event` (Kit's own render sets `{ page }` only)
100
+ * — the channel `requestEvent()` reads, so a server island can see its request without importing
101
+ * `$app/server` (which Kit's client guard rejects the moment a csr=true page shares the layout). */
102
+ function kit_render_context(page, event) {
103
+ const resolved = page ?? slots.reader?.() ?? empty_kit_page();
104
+ const live = event ?? slots.event_reader?.() ?? null;
105
+ return /* @__PURE__ */ new Map([[KIT_REQUEST_CONTEXT, {
106
+ page: resolved,
107
+ event: live
108
+ }], [KIT_STORES_CONTEXT, kit_stores_context(resolved)]]);
109
+ }
110
+ export { KIT_REQUEST_CONTEXT, KIT_STORES_CONTEXT, empty_kit_page, kit_page_facts_tail, kit_page_ready, kit_page_version, kit_render_context, kit_request_event, set_kit_event_reader, set_kit_page_reader, set_render_page_port };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The LATE WIRE — how a region that resolves after the document flushed reaches the page down the SAME
3
+ * response. A slot (`<og-late-slot>`, also what `<Region of={promise}>` renders around its placeholder)
4
+ * sits in the flushed document; each later state rides down as an inert `<template data-og-late>` chunk
5
+ * that ONE small classic inline script in the head swaps in as it parses. Module scripts don't run until
6
+ * parsing ENDS, which for a streamed document is the very thing we're not waiting for. After an SPA
7
+ * navigation the runtime applies remaining templates itself (runtime/router-nav.ts).
8
+ *
9
+ * A renderer that delivers late chunks (the server router's streamed document) speaks this format; core
10
+ * owns it because core's components emit the slots and core's runtime consumes the chunks.
11
+ */
12
+ /** Wrap html as the swappable slot `id` (display:contents — layout-invisible). */
13
+ export declare function late_slot(id: string, html: string): string;
14
+ /** A late chunk: inert template + nothing else — the boot script (or the runtime, post-SPA-swap)
15
+ * performs the swap. Multiple chunks for one slot apply in order (progressive states). */
16
+ export declare function late_chunk(id: string, html: string): string;
17
+ /**
18
+ * The classic inline boot: observes streamed-in `<template data-og-late>` nodes DURING parse and
19
+ * swaps each into its slot immediately (stylesheet links hoist to head first so the swap never
20
+ * paints unstyled). Kept dependency-free and tiny — it must run before any module script can.
21
+ */
22
+ export declare const LATE_BOOT_SCRIPT: string;
@@ -0,0 +1,28 @@
1
+ // src/server/late-wire.ts
2
+ /**
3
+ * The LATE WIRE — how a region that resolves after the document flushed reaches the page down the SAME
4
+ * response. A slot (`<og-late-slot>`, also what `<Region of={promise}>` renders around its placeholder)
5
+ * sits in the flushed document; each later state rides down as an inert `<template data-og-late>` chunk
6
+ * that ONE small classic inline script in the head swaps in as it parses. Module scripts don't run until
7
+ * parsing ENDS, which for a streamed document is the very thing we're not waiting for. After an SPA
8
+ * navigation the runtime applies remaining templates itself (runtime/router-nav.ts).
9
+ *
10
+ * A renderer that delivers late chunks (the server router's streamed document) speaks this format; core
11
+ * owns it because core's components emit the slots and core's runtime consumes the chunks.
12
+ */
13
+ /** Wrap html as the swappable slot `id` (display:contents — layout-invisible). */
14
+ function late_slot(id, html) {
15
+ return `<og-late-slot data-og-slot="${id}" style="display:contents">${html}</og-late-slot>`;
16
+ }
17
+ /** A late chunk: inert template + nothing else — the boot script (or the runtime, post-SPA-swap)
18
+ * performs the swap. Multiple chunks for one slot apply in order (progressive states). */
19
+ function late_chunk(id, html) {
20
+ return `<template data-og-late="${id}">${html}</template>`;
21
+ }
22
+ /**
23
+ * The classic inline boot: observes streamed-in `<template data-og-late>` nodes DURING parse and
24
+ * swaps each into its slot immediately (stylesheet links hoist to head first so the swap never
25
+ * paints unstyled). Kept dependency-free and tiny — it must run before any module script can.
26
+ */
27
+ const LATE_BOOT_SCRIPT = "<script data-og-late-boot>(function(){function ap(t){var id=t.getAttribute(\"data-og-late\");var s=document.querySelector('og-late-slot[data-og-slot=\"'+id+'\"]');if(!s){t.remove();return}var c=t.content;var ls=c.querySelectorAll('link[rel=\"stylesheet\"],style');for(var i=0;i<ls.length;i++){var l=ls[i];var h=l.getAttribute&&l.getAttribute(\"href\");if(h&&document.head.querySelector('link[href=\"'+h+'\"]'))l.remove();else document.head.appendChild(l)}while(s.firstChild)s.removeChild(s.firstChild);s.appendChild(c);t.remove()}var mo=new MutationObserver(function(ms){for(var i=0;i<ms.length;i++){var ad=ms[i].addedNodes;for(var j=0;j<ad.length;j++){var n=ad[j];if(n.nodeType===1&&n.tagName===\"TEMPLATE\"&&n.hasAttribute(\"data-og-late\"))ap(n)}}});mo.observe(document.documentElement,{childList:true,subtree:true});addEventListener(\"DOMContentLoaded\",function(){var ts=document.querySelectorAll(\"template[data-og-late]\");for(var i=0;i<ts.length;i++)ap(ts[i]);mo.disconnect()},{once:true});})()<\/script>";
28
+ export { LATE_BOOT_SCRIPT, late_chunk, late_slot };
@@ -0,0 +1,25 @@
1
+ /** Marks ogygia's own lookup: the handle answers it without setting up a page render. */
2
+ export declare const PAGE_FACTS_HEADER = "x-ogygia-page-facts";
3
+ /** The route id and params Kit matched for the looked-up page (the data alone carries neither). */
4
+ export declare const PAGE_FACTS_ROUTE_HEADER = "x-ogygia-page-route";
5
+ export type PageFacts = {
6
+ url: URL;
7
+ params: Record<string, string | undefined>;
8
+ route: {
9
+ id: string | null;
10
+ };
11
+ data: Record<string, unknown>;
12
+ };
13
+ type Decoders = Record<string, (value: unknown) => unknown>;
14
+ type Fetch = (input: string, init?: RequestInit) => Promise<Response>;
15
+ /** Kit's data URL for a page, as its client builds it: the data suffix on the path, the page's
16
+ * search kept, the trailing-slash marker when the path ends in `/`. */
17
+ export declare function data_url_of(page: URL): string;
18
+ /**
19
+ * The page's facts, or a reason they are not available (a redirect, an error, a load that threw,
20
+ * not a Kit data answer). `decoders`: the app's `transport` decoders, as Kit's client uses them.
21
+ */
22
+ export declare function look_up_page(page: URL, fetch: Fetch, decoders: Decoders): Promise<PageFacts | {
23
+ miss: string;
24
+ }>;
25
+ export {};
@@ -0,0 +1,138 @@
1
+ import * as devalue from "devalue";
2
+ // src/server/page-facts.ts
3
+ /**
4
+ * PAGE FACTS — the page a render outside its page belongs to (internal/notes/region-page-context.md).
5
+ *
6
+ * A hole renders in the islands endpoint's request, a region refreshed by a remote `query` /
7
+ * `command` in the remote call's: no page render around them, so no `page.data`. Their page is the
8
+ * same-origin `Referer`, and its data is looked up through Kit itself — the data request Kit's own
9
+ * client makes on a navigation (`<page>/__data.json`). The app's handle chain and the page's server
10
+ * loads run with the visitor's cookies: the facts are the server's, for this visitor, now; nothing
11
+ * the browser could forge or that a cache could have kept from someone else.
12
+ *
13
+ * Cheap by construction: the caller looks up only when a render reads `page.data`, once per request;
14
+ * only the answer's FIRST line is waited for (a streamed promise in the data resolves later, in the
15
+ * background, without holding the render); no regex.
16
+ */
17
+ /** Marks ogygia's own lookup: the handle answers it without setting up a page render. */
18
+ const PAGE_FACTS_HEADER = "x-ogygia-page-facts";
19
+ /** The route id and params Kit matched for the looked-up page (the data alone carries neither). */
20
+ const PAGE_FACTS_ROUTE_HEADER = "x-ogygia-page-route";
21
+ /** Kit's data URL for a page, as its client builds it: the data suffix on the path, the page's
22
+ * search kept, the trailing-slash marker when the path ends in `/`. */
23
+ function data_url_of(page) {
24
+ const u = new URL(page.href);
25
+ u.hash = "";
26
+ const p = page.pathname;
27
+ u.pathname = p.endsWith(".html") ? p.slice(0, -5) + ".html__data.json" : (p.endsWith("/") ? p.slice(0, -1) : p) + "/__data.json";
28
+ if (p.endsWith("/")) u.searchParams.append("x-sveltekit-trailing-slash", "1");
29
+ return u.href;
30
+ }
31
+ /**
32
+ * The page's facts, or a reason they are not available (a redirect, an error, a load that threw,
33
+ * not a Kit data answer). `decoders`: the app's `transport` decoders, as Kit's client uses them.
34
+ */
35
+ async function look_up_page(page, fetch, decoders) {
36
+ let res;
37
+ try {
38
+ res = await fetch(data_url_of(page), { headers: { [PAGE_FACTS_HEADER]: "1" } });
39
+ } catch (e) {
40
+ return { miss: `the data request failed (${String(e?.message ?? e)})` };
41
+ }
42
+ if (!res.ok || !res.body) {
43
+ res.body?.cancel().catch(() => {});
44
+ return { miss: `the data request answered ${res.status}` };
45
+ }
46
+ const reader = res.body.getReader();
47
+ const text = new TextDecoder();
48
+ let buf = "";
49
+ let nl = -1;
50
+ while ((nl = buf.indexOf("\n")) === -1) {
51
+ const { done, value } = await reader.read();
52
+ if (done) break;
53
+ buf += text.decode(value, { stream: true });
54
+ }
55
+ const first = nl === -1 ? buf : buf.slice(0, nl);
56
+ const rest = nl === -1 ? "" : buf.slice(nl + 1);
57
+ const stop = (miss) => {
58
+ reader.cancel().catch(() => {});
59
+ return { miss };
60
+ };
61
+ let head;
62
+ try {
63
+ head = JSON.parse(first);
64
+ } catch {
65
+ return stop("the answer is not Kit data");
66
+ }
67
+ if (head?.type === "redirect") return stop(`a load redirected to ${head.location}`);
68
+ if (head?.type !== "data" || !Array.isArray(head.nodes)) return stop("the answer is not Kit data");
69
+ const deferreds = /* @__PURE__ */ new Map();
70
+ const revive = (flat) => devalue.unflatten(flat, {
71
+ ...decoders,
72
+ Promise: (id) => {
73
+ const p = new Promise((fulfil, reject) => deferreds.set(id, {
74
+ fulfil,
75
+ reject
76
+ }));
77
+ p.catch(() => {});
78
+ return p;
79
+ }
80
+ });
81
+ const data = {};
82
+ try {
83
+ for (const node of head.nodes) {
84
+ if (node?.type === "error") return stop("a load threw");
85
+ if (node?.type === "data") Object.assign(data, revive(node.data));
86
+ }
87
+ } catch (e) {
88
+ return stop(`its data did not decode (${String(e?.message ?? e)})`);
89
+ }
90
+ if (deferreds.size) settle_streamed(reader, text, rest, deferreds, revive);
91
+ else reader.cancel().catch(() => {});
92
+ let route = { id: null };
93
+ let params = {};
94
+ const named = res.headers.get(PAGE_FACTS_ROUTE_HEADER);
95
+ if (named) try {
96
+ const r = JSON.parse(decodeURIComponent(named));
97
+ route = { id: r.id ?? null };
98
+ params = r.params ?? {};
99
+ } catch {}
100
+ return {
101
+ url: page,
102
+ params,
103
+ route,
104
+ data
105
+ };
106
+ }
107
+ /** The streamed promises in the page's data, fulfilled as their lines arrive (Kit's `chunk` lines). */
108
+ async function settle_streamed(reader, text, buf, deferreds, revive) {
109
+ const line = (raw) => {
110
+ if (!raw) return;
111
+ try {
112
+ const chunk = JSON.parse(raw);
113
+ if (chunk.type !== "chunk" || chunk.id === void 0) return;
114
+ const d = deferreds.get(chunk.id);
115
+ if (!d) return;
116
+ deferreds.delete(chunk.id);
117
+ if (chunk.error !== void 0) d.reject(revive(chunk.error));
118
+ else d.fulfil(revive(chunk.data));
119
+ } catch {}
120
+ };
121
+ try {
122
+ for (;;) {
123
+ let nl;
124
+ while ((nl = buf.indexOf("\n")) !== -1) {
125
+ line(buf.slice(0, nl));
126
+ buf = buf.slice(nl + 1);
127
+ }
128
+ if (!deferreds.size) break;
129
+ const { done, value } = await reader.read();
130
+ if (done) break;
131
+ buf += text.decode(value, { stream: true });
132
+ }
133
+ line(buf);
134
+ } catch {} finally {
135
+ reader.cancel().catch(() => {});
136
+ }
137
+ }
138
+ export { PAGE_FACTS_HEADER, PAGE_FACTS_ROUTE_HEADER, data_url_of, look_up_page };
@@ -0,0 +1,33 @@
1
+ import { stringify } from "devalue";
2
+ type PageLike = {
3
+ url?: {
4
+ href?: string;
5
+ };
6
+ params?: Record<string, string>;
7
+ route?: {
8
+ id: string | null;
9
+ };
10
+ status?: number;
11
+ data?: unknown;
12
+ form?: unknown;
13
+ error?: unknown;
14
+ };
15
+ /** The seed's text and the lane it is in (`json` → the runtime reads it with `JSON.parse`). */
16
+ export interface SeedText {
17
+ text: string;
18
+ json: boolean;
19
+ }
20
+ export declare class PageSeed {
21
+ /**
22
+ * Public page slice for islands. url/params/route/status are always plain and MUST survive;
23
+ * data/form/error may carry a non-serializable leaf (function/store/class) — that ONE field is
24
+ * dropped, never the whole seed. Promises should already be resolved by the handle
25
+ * (`resolve_promises`) before this. See INVARIANTS.md · PAGE-SEED.
26
+ *
27
+ * `json`: the caller proved the whole slice JSON-exact (seed-refs.ts `analyze`) — then the seed
28
+ * goes out as native `JSON.stringify` output (an order of magnitude cheaper than devalue on a
29
+ * CMS tree), escaped once for the `<script>`. devalue output needs no escape (it writes `<`).
30
+ */
31
+ static serialize(page_ref: PageLike, stringify_fn?: typeof stringify, json?: boolean): SeedText | null;
32
+ }
33
+ export {};
@@ -0,0 +1,60 @@
1
+ import { escape_script_text } from "../escape.js";
2
+ import { stringify } from "devalue";
3
+ // src/server/page-seed.ts
4
+ /** Serialize a Kit `page` snapshot for a single document-level ogygia side-channel. */
5
+ var PageSeed = class {
6
+ /**
7
+ * Public page slice for islands. url/params/route/status are always plain and MUST survive;
8
+ * data/form/error may carry a non-serializable leaf (function/store/class) — that ONE field is
9
+ * dropped, never the whole seed. Promises should already be resolved by the handle
10
+ * (`resolve_promises`) before this. See INVARIANTS.md · PAGE-SEED.
11
+ *
12
+ * `json`: the caller proved the whole slice JSON-exact (seed-refs.ts `analyze`) — then the seed
13
+ * goes out as native `JSON.stringify` output (an order of magnitude cheaper than devalue on a
14
+ * CMS tree), escaped once for the `<script>`. devalue output needs no escape (it writes `<`).
15
+ */
16
+ static serialize(page_ref, stringify_fn = stringify, json = false) {
17
+ try {
18
+ const base = {
19
+ url: page_ref.url?.href,
20
+ params: page_ref.params,
21
+ route: page_ref.route,
22
+ status: page_ref.status
23
+ };
24
+ const full = {
25
+ ...base,
26
+ data: page_ref.data,
27
+ form: page_ref.form ?? null,
28
+ error: page_ref.error ?? null
29
+ };
30
+ if (json) try {
31
+ return {
32
+ text: escape_script_text(JSON.stringify(full)),
33
+ json: true
34
+ };
35
+ } catch {}
36
+ let raw;
37
+ try {
38
+ raw = stringify_fn(full);
39
+ } catch {
40
+ const safe = { ...base };
41
+ for (const key of [
42
+ "data",
43
+ "form",
44
+ "error"
45
+ ]) try {
46
+ stringify_fn(full[key]);
47
+ safe[key] = full[key];
48
+ } catch {}
49
+ raw = stringify_fn(safe);
50
+ }
51
+ return {
52
+ text: raw,
53
+ json: false
54
+ };
55
+ } catch {
56
+ return null;
57
+ }
58
+ }
59
+ };
60
+ export { PageSeed };
@@ -0,0 +1,55 @@
1
+ /** A THENABLE, not just a native Promise — Kit wraps streamed load promises, so `instanceof Promise`
2
+ * would miss them. Anything with a callable `.then` we can await. */
3
+ export declare const is_thenable: (v: unknown) => v is PromiseLike<unknown>;
4
+ /** Serializable stand-in for a pending promise leaf (streaming path). Encodes to its id. */
5
+ export declare class DeferRef {
6
+ readonly id: number;
7
+ constructor(id: number);
8
+ }
9
+ /** Serializable stand-in for an already-settled promise leaf (non-navigate path). Encodes to
10
+ * `[ok, value]`; the client revives it as a resolved/rejected Promise. */
11
+ export declare class SettledRef {
12
+ readonly ok: boolean;
13
+ readonly value: unknown;
14
+ constructor(ok: boolean, value: unknown);
15
+ }
16
+ export declare const defer_reducer: Record<string, (v: unknown) => unknown>;
17
+ export declare const page_seed_reducers: Record<string, (v: unknown) => unknown>;
18
+ export type Deferred = {
19
+ id: number;
20
+ promise: PromiseLike<unknown>;
21
+ };
22
+ /**
23
+ * Replace every promise in `value` with a {@link DeferRef}, returning the promise-free clone plus the
24
+ * deferred promises (id + promise to await). Plain objects/arrays are cloned; class instances and
25
+ * primitives pass through untouched. Ids continue from `start_id` so `data` and `form` share one id
26
+ * space across the whole seed. Bounded depth guards a pathological structure.
27
+ */
28
+ export declare function stage_deferred(value: unknown, start_id?: number): {
29
+ staged: unknown;
30
+ deferred: Deferred[];
31
+ next_id: number;
32
+ };
33
+ /**
34
+ * Non-navigate (SPA/router) fallback: deep-await every promise in `value`, wrapping each ORIGINAL
35
+ * promise position in a {@link SettledRef} (resolved OR rejected — a rejection is caught, never
36
+ * thrown, so the render can't crash). Nested promises inside a resolved value are settled too. The
37
+ * client revives each SettledRef as a resolved/rejected Promise, so `page.data.x` stays a Promise on
38
+ * this path exactly as on the streaming path, and `{#await …:catch}` works.
39
+ */
40
+ export declare function settle_deferred(value: unknown, depth?: number): Promise<unknown>;
41
+ /**
42
+ * The streamed resolve `<script>` body for one settled promise. The value is encoded WITH
43
+ * {@link defer_reducer} so a re-staged value carrying nested DeferRef markers (a promise that resolved
44
+ * to a value containing further promises) serializes — the client revives those as fresh pending
45
+ * promises that later resolve scripts settle, exactly like Kit's recursive deferral. `ok=false` carries
46
+ * a normalized `{ message }` (matches the page seed's error shape) so a rejected non-serializable value
47
+ * can't blow up the stream. `<` is escaped so the payload can't break out of the `<script>`.
48
+ */
49
+ export declare function resolve_script(global_name: string, id: number, settled: {
50
+ ok: boolean;
51
+ value: unknown;
52
+ }, reducers?: Record<string, (v: unknown) => unknown>): string;
53
+ export declare function normalize_error(err: unknown): {
54
+ message: string;
55
+ };
@@ -0,0 +1,121 @@
1
+ import { PAGE_DEFER_KEY, PAGE_SETTLED_KEY } from "../page-defer.js";
2
+ import { escape_script_text } from "../escape.js";
3
+ import { stringify } from "devalue";
4
+ // src/server/page-stream.ts
5
+ /**
6
+ * Server side of streaming `$page.data` promises into islands (see `../page-defer.ts` for the why).
7
+ *
8
+ * `stage_deferred` walks the captured page `data`/`form`, swaps every promise for a serializable
9
+ * DEFER MARKER, and hands back the promise-free clone plus the promises to await. The clone goes into
10
+ * the page seed (each marker becomes a real pending Promise on the client); as each promise settles we
11
+ * stream a `<script>__ogygia_page_resolve(id, ok, encoded)<\/script>` chunk that resolves it live.
12
+ */
13
+ const MAX_DEPTH = 64;
14
+ /** A THENABLE, not just a native Promise — Kit wraps streamed load promises, so `instanceof Promise`
15
+ * would miss them. Anything with a callable `.then` we can await. */
16
+ const is_thenable = (v) => !!v && (typeof v === "object" || typeof v === "function") && typeof v.then === "function";
17
+ /** Serializable stand-in for a pending promise leaf (streaming path). Encodes to its id. */
18
+ var DeferRef = class {
19
+ id;
20
+ constructor(id) {
21
+ this.id = id;
22
+ }
23
+ };
24
+ /** Serializable stand-in for an already-settled promise leaf (non-navigate path). Encodes to
25
+ * `[ok, value]`; the client revives it as a resolved/rejected Promise. */
26
+ var SettledRef = class {
27
+ ok;
28
+ value;
29
+ constructor(ok, value) {
30
+ this.ok = ok;
31
+ this.value = value;
32
+ }
33
+ };
34
+ const defer_reducer = { [PAGE_DEFER_KEY]: (v) => v instanceof DeferRef ? [v.id] : void 0 };
35
+ const page_seed_reducers = {
36
+ [PAGE_DEFER_KEY]: (v) => v instanceof DeferRef ? [v.id] : void 0,
37
+ [PAGE_SETTLED_KEY]: (v) => v instanceof SettledRef ? [v.ok, v.value] : void 0
38
+ };
39
+ /**
40
+ * Replace every promise in `value` with a {@link DeferRef}, returning the promise-free clone plus the
41
+ * deferred promises (id + promise to await). Plain objects/arrays are cloned; class instances and
42
+ * primitives pass through untouched. Ids continue from `start_id` so `data` and `form` share one id
43
+ * space across the whole seed. Bounded depth guards a pathological structure.
44
+ */
45
+ function stage_deferred(value, start_id = 0) {
46
+ const deferred = [];
47
+ let id = start_id;
48
+ const walk = (v, depth) => {
49
+ if (is_thenable(v)) {
50
+ const ref = new DeferRef(id++);
51
+ deferred.push({
52
+ id: ref.id,
53
+ promise: v
54
+ });
55
+ return ref;
56
+ }
57
+ if (depth > MAX_DEPTH) return v;
58
+ if (Array.isArray(v)) return v.map((x) => walk(x, depth + 1));
59
+ if (v && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype) {
60
+ const out = {};
61
+ for (const k in v) out[k] = walk(v[k], depth + 1);
62
+ return out;
63
+ }
64
+ return v;
65
+ };
66
+ return {
67
+ staged: walk(value, 0),
68
+ deferred,
69
+ next_id: id
70
+ };
71
+ }
72
+ /**
73
+ * Non-navigate (SPA/router) fallback: deep-await every promise in `value`, wrapping each ORIGINAL
74
+ * promise position in a {@link SettledRef} (resolved OR rejected — a rejection is caught, never
75
+ * thrown, so the render can't crash). Nested promises inside a resolved value are settled too. The
76
+ * client revives each SettledRef as a resolved/rejected Promise, so `page.data.x` stays a Promise on
77
+ * this path exactly as on the streaming path, and `{#await …:catch}` works.
78
+ */
79
+ async function settle_deferred(value, depth = 0) {
80
+ if (is_thenable(value)) try {
81
+ return new SettledRef(true, await settle_deferred(await value, depth + 1));
82
+ } catch (err) {
83
+ return new SettledRef(false, normalize_error(err));
84
+ }
85
+ if (depth > MAX_DEPTH) return value;
86
+ if (Array.isArray(value)) return Promise.all(value.map((x) => settle_deferred(x, depth + 1)));
87
+ if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
88
+ const out = {};
89
+ await Promise.all(Object.keys(value).map(async (k) => {
90
+ out[k] = await settle_deferred(value[k], depth + 1);
91
+ }));
92
+ return out;
93
+ }
94
+ return value;
95
+ }
96
+ /**
97
+ * The streamed resolve `<script>` body for one settled promise. The value is encoded WITH
98
+ * {@link defer_reducer} so a re-staged value carrying nested DeferRef markers (a promise that resolved
99
+ * to a value containing further promises) serializes — the client revives those as fresh pending
100
+ * promises that later resolve scripts settle, exactly like Kit's recursive deferral. `ok=false` carries
101
+ * a normalized `{ message }` (matches the page seed's error shape) so a rejected non-serializable value
102
+ * can't blow up the stream. `<` is escaped so the payload can't break out of the `<script>`.
103
+ */
104
+ function resolve_script(global_name, id, settled, reducers = defer_reducer) {
105
+ let ok = settled.ok;
106
+ let encoded;
107
+ try {
108
+ encoded = stringify(ok ? settled.value : normalize_error(settled.value), reducers);
109
+ } catch {
110
+ encoded = stringify({ message: "ogygia: streamed value is not serializable" });
111
+ ok = false;
112
+ }
113
+ const json = escape_script_text(JSON.stringify(encoded));
114
+ return `<script>${global_name}(${id},${ok},${json})<\/script>`;
115
+ }
116
+ function normalize_error(err) {
117
+ if (err instanceof Error) return { message: err.message };
118
+ if (err && typeof err === "object" && "message" in err) return { message: String(err.message) };
119
+ return { message: String(err) };
120
+ }
121
+ export { DeferRef, SettledRef, defer_reducer, is_thenable, normalize_error, page_seed_reducers, resolve_script, settle_deferred, stage_deferred };
@@ -0,0 +1,6 @@
1
+ export declare class B64Url {
2
+ /** @param str utf-8 string */
3
+ static encode(str: string): string;
4
+ /** @param b64 base64url string (decoded only after its MAC verified) */
5
+ static decode(b64: string): string;
6
+ }
@@ -0,0 +1,22 @@
1
+ // src/server/payload.ts
2
+ const NodeBuffer = globalThis.Buffer;
3
+ var B64Url = class {
4
+ /** @param str utf-8 string */
5
+ static encode(str) {
6
+ if (NodeBuffer) return NodeBuffer.from(str, "utf8").toString("base64url");
7
+ const bytes = new TextEncoder().encode(str);
8
+ let bin = "";
9
+ for (const b of bytes) bin += String.fromCharCode(b);
10
+ return btoa(bin).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
11
+ }
12
+ /** @param b64 base64url string (decoded only after its MAC verified) */
13
+ static decode(b64) {
14
+ if (NodeBuffer) return NodeBuffer.from(b64, "base64url").toString("utf8");
15
+ const norm = b64.replaceAll("-", "+").replaceAll("_", "/");
16
+ const bin = atob(norm);
17
+ const bytes = new Uint8Array(bin.length);
18
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
19
+ return new TextDecoder().decode(bytes);
20
+ }
21
+ };
22
+ export { B64Url };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A page made for ONE browser — its devtools events (hooks.ts), the profiler's beacon (profiler/), the
3
+ * switch's Set-Cookie — must never reach a shared cache, whatever `cache-control` the app set: a CDN that
4
+ * keeps HTML would hand that browser's page to every visitor.
5
+ */
6
+ export declare function mark_personal(response: Response): void;
@@ -0,0 +1,13 @@
1
+ // src/server/personal-response.ts
2
+ /**
3
+ * A page made for ONE browser — its devtools events (hooks.ts), the profiler's beacon (profiler/), the
4
+ * switch's Set-Cookie — must never reach a shared cache, whatever `cache-control` the app set: a CDN that
5
+ * keeps HTML would hand that browser's page to every visitor.
6
+ */
7
+ function mark_personal(response) {
8
+ try {
9
+ response.headers.set("cache-control", "private, no-store");
10
+ response.headers.append("vary", "Cookie");
11
+ } catch {}
12
+ }
13
+ export { mark_personal };