@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,683 @@
1
+ import { fs } from "../host.js";
2
+ import { parse_module } from "../parse/oxc.js";
3
+ import { blank_styles } from "../blank-styles.js";
4
+ import { parse } from "svelte/compiler";
5
+ // src/compiler/link/page-keys.ts
6
+ /**
7
+ * WHICH `page.data` KEYS does a module read? — the static analysis behind seed shaping.
8
+ *
9
+ * The page seed (`application/ogygia-page`) exists so an island can read `$page` through the shim,
10
+ * and it used to be all-or-nothing: one island reading `page.data._locale` shipped the whole
11
+ * `page.data` (368 KB on a measured CMS home page, 199 KB of it a header entry no island ever
12
+ * touched). This analysis reads a module ONCE, at transform time, on the compiler's own parsers —
13
+ * oxc for `.ts` / `.js`, Svelte's for `.svelte` (both scripts and the template's expressions) —
14
+ * resolves the `page` binding through its aliases, and answers with the set of top-level
15
+ * `page.data` keys the module can reach. The build unions the answers over an island's chunk
16
+ * closure (island-deps.ts) and the handle ships only those keys.
17
+ *
18
+ * CONSERVATIVE BY CONSTRUCTION. Any read the analysis cannot resolve to a literal key — `page.data`
19
+ * handed to a function, aliased whole, indexed with a variable, spread, `page.subscribe(...)`, a
20
+ * namespace import, the whole page passed on — answers `'all'`, and the seed ships whole as
21
+ * before. A wrong `'all'` costs bytes; a wrong key set would cost an island its data, so every
22
+ * doubt goes to `'all'`.
23
+ */
24
+ /** Kit's page-store specifiers as an author writes them; the driver's shim rewrite runs after
25
+ * this analysis, so the source still names them. */
26
+ const PAGE_SPECIFIER_RE = /^\$app\/(?:state|stores)$/;
27
+ /** The page fields that are never shaped — reading them commits nothing about `data`. */
28
+ const SAFE_FIELDS = /* @__PURE__ */ new Set([
29
+ "url",
30
+ "params",
31
+ "route",
32
+ "status",
33
+ "error",
34
+ "form",
35
+ "state"
36
+ ]);
37
+ /** Keys the walker never descends into (positions, back-references). */
38
+ const SKIP_KEYS = /* @__PURE__ */ new Set([
39
+ "start",
40
+ "end",
41
+ "loc",
42
+ "range",
43
+ "parent",
44
+ "metadata",
45
+ "leadingComments",
46
+ "trailingComments"
47
+ ]);
48
+ /** Cheap pre-filter for the transform hot path: no page specifier in the text → nothing to parse. */
49
+ const PAGE_SPECIFIER_HINT_RE = /\$app\/st(?:ate|ores)/;
50
+ /** The analysis giving up on a module: WHY, and WHERE (a source offset), so the build can name the
51
+ * line that makes a page ship all of `page.data`. */
52
+ var All = class extends Error {
53
+ why;
54
+ at;
55
+ constructor(why, at) {
56
+ super(why);
57
+ this.why = why;
58
+ this.at = at;
59
+ }
60
+ };
61
+ /**
62
+ * The top-level `page.data` keys a module reads, or `'all'` when a read cannot be pinned to a
63
+ * literal key, or `null` when the module never imports the page (nothing to ship for it).
64
+ * `kind` picks the parser: `'svelte'` for a component source, `'script'` for `.ts` / `.js`.
65
+ */
66
+ function page_data_keys(code, id, kind) {
67
+ return page_data_keys_answer(code, id, kind).keys;
68
+ }
69
+ /** The same answer with the reason an `'all'` was given (for the build report). */
70
+ function page_data_keys_answer(code, id, kind) {
71
+ if (!PAGE_SPECIFIER_HINT_RE.test(code)) return {
72
+ keys: null,
73
+ reason: null,
74
+ pending: []
75
+ };
76
+ const roots = parse_roots(code, id, kind);
77
+ if (!roots) return {
78
+ keys: "all",
79
+ reason: {
80
+ why: "the module did not parse here (the bundler will say why)",
81
+ line: null
82
+ },
83
+ pending: []
84
+ };
85
+ const scan = new Scan(code);
86
+ try {
87
+ for (const root of roots) scan.collect_bindings(root);
88
+ if (!scan.refs.size) return {
89
+ keys: null,
90
+ reason: null,
91
+ pending: []
92
+ };
93
+ for (const root of roots) scan.walk(root, null, null);
94
+ return {
95
+ keys: scan.keys,
96
+ reason: null,
97
+ pending: scan.pending
98
+ };
99
+ } catch (e) {
100
+ if (e instanceof All) return {
101
+ keys: "all",
102
+ reason: {
103
+ why: e.why,
104
+ line: e.at === null ? null : line_of(code, e.at)
105
+ },
106
+ pending: []
107
+ };
108
+ throw e;
109
+ }
110
+ }
111
+ function summarize_export(code, id, kind, name, arg) {
112
+ const roots = parse_roots(code, id, kind);
113
+ if (!roots) return "all";
114
+ let fn = null;
115
+ let named_follow = null;
116
+ const stars = [];
117
+ let imported = name;
118
+ const local_fns = /* @__PURE__ */ new Map();
119
+ const imports = /* @__PURE__ */ new Map();
120
+ for (const root of roots) {
121
+ visit(root, (node) => {
122
+ if (node.type === "FunctionDeclaration" && node.id?.name && !enclosing_scope(node)) local_fns.set(node.id.name, node);
123
+ if (node.type === "VariableDeclarator" && node.id?.type === "Identifier" && node.init && (node.init.type === "ArrowFunctionExpression" || node.init.type === "FunctionExpression") && !enclosing_scope(node)) local_fns.set(node.id.name, node.init);
124
+ if (node.type === "ImportDeclaration") {
125
+ for (const s of node.specifiers ?? []) if (s.type === "ImportSpecifier") imports.set(s.local.name, {
126
+ specifier: String(node.source?.value ?? ""),
127
+ imported: spec_name(s.imported) ?? s.local.name
128
+ });
129
+ }
130
+ if (node.type === "ExportAllDeclaration" && node.source) stars.push(String(node.source.value));
131
+ if (node.type !== "ExportNamedDeclaration") return;
132
+ for (const s of node.specifiers ?? []) {
133
+ if (spec_name(s.exported) !== name) continue;
134
+ const local = spec_name(s.local) ?? name;
135
+ if (node.source) {
136
+ named_follow = String(node.source.value);
137
+ imported = local;
138
+ } else if (local_fns.has(local)) fn = local_fns.get(local);
139
+ else if (imports.has(local)) {
140
+ named_follow = imports.get(local).specifier;
141
+ imported = imports.get(local).imported;
142
+ }
143
+ }
144
+ const d = node.declaration;
145
+ if (!d) return;
146
+ if (d.type === "FunctionDeclaration" && d.id?.name === name) fn = d;
147
+ if (d.type === "VariableDeclaration") {
148
+ for (const v of d.declarations ?? []) if (v.id?.type === "Identifier" && v.id.name === name && v.init && (v.init.type === "ArrowFunctionExpression" || v.init.type === "FunctionExpression")) fn = v.init;
149
+ }
150
+ });
151
+ if (fn) break;
152
+ }
153
+ if (!fn) {
154
+ if (named_follow) return {
155
+ follow: [named_follow],
156
+ imported
157
+ };
158
+ return stars.length ? {
159
+ follow: stars,
160
+ imported
161
+ } : "all";
162
+ }
163
+ const param = fn.params?.[arg];
164
+ if (!param || param.type !== "Identifier") return "all";
165
+ const scan = new Scan(code);
166
+ try {
167
+ scan.seed_param(param.name, fn);
168
+ scan.walk(fn.body, fn, "body");
169
+ if (scan.pending.length) return "all";
170
+ return scan.keys;
171
+ } catch (e) {
172
+ if (e instanceof All) return "all";
173
+ throw e;
174
+ }
175
+ }
176
+ function line_of(code, offset) {
177
+ let line = 1;
178
+ for (let i = 0; i < offset && i < code.length; i++) if (code.charCodeAt(i) === 10) line++;
179
+ return line;
180
+ }
181
+ /** Climb out of the wrappers TypeScript and the parsers put around an expression without
182
+ * changing what it is: `(page as any)`, `page!`, `page satisfies T`, `(page)`, an optional chain. */
183
+ const WRAPPERS = /* @__PURE__ */ new Set([
184
+ "TSAsExpression",
185
+ "TSNonNullExpression",
186
+ "TSSatisfiesExpression",
187
+ "TSTypeAssertion",
188
+ "ParenthesizedExpression",
189
+ "ChainExpression"
190
+ ]);
191
+ function unwrap_up(node) {
192
+ let cur = node;
193
+ let parent = cur.__parent;
194
+ let key = cur.__key;
195
+ while (parent && WRAPPERS.has(parent.type) && key === "expression") {
196
+ cur = parent;
197
+ parent = cur.__parent;
198
+ key = cur.__key;
199
+ }
200
+ return {
201
+ node: cur,
202
+ parent,
203
+ key
204
+ };
205
+ }
206
+ /** Union two answers: `'all'` absorbs everything, `null` is the identity. */
207
+ function merge_page_keys(a, b) {
208
+ if (a === "all" || b === "all") return "all";
209
+ if (!a) return b;
210
+ if (!b) return a;
211
+ return /* @__PURE__ */ new Set([...a, ...b]);
212
+ }
213
+ /** Does this module even mention a page-store specifier? (the transform's pre-filter) */
214
+ function mentions_page_store(code) {
215
+ return PAGE_SPECIFIER_HINT_RE.test(code);
216
+ }
217
+ function parse_roots(code, id, kind) {
218
+ if (kind === "script") {
219
+ const r = parse_module(code, id);
220
+ return r.ok && r.program ? [r.program] : null;
221
+ }
222
+ let ast;
223
+ try {
224
+ ast = parse(blank_styles(code), {
225
+ modern: true,
226
+ filename: id
227
+ });
228
+ } catch {
229
+ return null;
230
+ }
231
+ const roots = [];
232
+ if (ast.module?.content) roots.push(ast.module.content);
233
+ if (ast.instance?.content) roots.push(ast.instance.content);
234
+ if (ast.fragment) roots.push(ast.fragment);
235
+ return roots;
236
+ }
237
+ /** Function-like nodes: the scopes an alias lives in. */
238
+ const SCOPE_TYPES = /* @__PURE__ */ new Set([
239
+ "FunctionDeclaration",
240
+ "FunctionExpression",
241
+ "ArrowFunctionExpression",
242
+ "ClassMethod",
243
+ "MethodDefinition",
244
+ "PropertyDefinition",
245
+ "Program",
246
+ "Fragment",
247
+ "Root"
248
+ ]);
249
+ var Scan = class {
250
+ /** Every name that IS the page: import locals (module-wide), whole-page aliases and
251
+ * derived/subscribe params (each valid inside the function that declares it — an unrelated
252
+ * `value` in another method is not the page just because one method aliased it so). */
253
+ refs = /* @__PURE__ */ new Set();
254
+ #scopes = /* @__PURE__ */ new Map();
255
+ keys = /* @__PURE__ */ new Set();
256
+ /** Calls handing the page to an imported helper, for the build to follow (see PendingCall). */
257
+ pending = [];
258
+ /** Import bindings of this module: local name → what and from where. */
259
+ #imports = /* @__PURE__ */ new Map();
260
+ /** Module-level function declarations by name (`function f(p) {}` / `const f = (p) => …`). */
261
+ #local_fns = /* @__PURE__ */ new Map();
262
+ code;
263
+ constructor(code) {
264
+ this.code = code;
265
+ }
266
+ /** For {@link summarize_export}: the helper's own parameter IS the page, inside the helper. */
267
+ seed_param(name, fn) {
268
+ this.#add_ref(name, fn.body ?? fn);
269
+ this.#scopes.get(name).add(fn);
270
+ }
271
+ #add_ref(name, at) {
272
+ const scope = at ? enclosing_scope(at) : null;
273
+ let scopes = this.#scopes.get(name);
274
+ if (!scopes) this.#scopes.set(name, scopes = /* @__PURE__ */ new Set());
275
+ if (scopes.has(scope)) return false;
276
+ scopes.add(scope);
277
+ this.refs.add(name);
278
+ return true;
279
+ }
280
+ /** Is `name`, used at `use`, one of the page's names in scope there? */
281
+ #in_scope(name, use) {
282
+ const scopes = this.#scopes.get(name);
283
+ if (!scopes) return false;
284
+ if (scopes.has(null)) return true;
285
+ for (let n = use; n; n = n.__parent) if (scopes.has(n)) return true;
286
+ return false;
287
+ }
288
+ /** Pass 1: bindings. Imports, then aliases grown to a fixed point (an alias of an alias). */
289
+ collect_bindings(root) {
290
+ visit(root, (node) => {
291
+ if (node.type === "FunctionDeclaration" && node.id?.name && !enclosing_scope(node)) this.#local_fns.set(node.id.name, node);
292
+ if (node.type === "VariableDeclarator" && node.id?.type === "Identifier" && node.init && (node.init.type === "ArrowFunctionExpression" || node.init.type === "FunctionExpression") && !enclosing_scope(node)) this.#local_fns.set(node.id.name, node.init);
293
+ if (node.type !== "ImportDeclaration") return;
294
+ const specifier = String(node.source?.value ?? "");
295
+ for (const s of node.specifiers ?? []) if (s.type === "ImportSpecifier") this.#imports.set(s.local.name, {
296
+ specifier,
297
+ imported: spec_name(s.imported) ?? s.local.name
298
+ });
299
+ else if (s.type === "ImportDefaultSpecifier") this.#imports.set(s.local.name, {
300
+ specifier,
301
+ imported: "default"
302
+ });
303
+ if (!PAGE_SPECIFIER_RE.test(specifier)) return;
304
+ for (const s of node.specifiers ?? []) {
305
+ if (s.type === "ImportNamespaceSpecifier" || s.type === "ImportDefaultSpecifier") throw new All("the page store is imported as a namespace", s.start ?? null);
306
+ if (s.type === "ImportSpecifier" && spec_name(s.imported) === "page") this.#add_ref(s.local.name, null);
307
+ }
308
+ });
309
+ if (!this.refs.size) return;
310
+ let grew = true;
311
+ while (grew) {
312
+ grew = false;
313
+ visit(root, (node) => {
314
+ if (node.type === "VariableDeclarator" && node.init && this.is_page_value(unwrap_down(node.init))) {
315
+ if (node.id?.type === "Identifier") {
316
+ if (this.#add_ref(node.id.name, node)) grew = true;
317
+ } else throw new All("the page is destructured (`const { data } = page`)", node.start ?? null);
318
+ }
319
+ if (node.type === "CallExpression") {
320
+ const callee = node.callee;
321
+ const args = node.arguments ?? [];
322
+ if (callee?.type === "Identifier" && this.#local_fns.has(callee.name)) {
323
+ const fn = this.#local_fns.get(callee.name);
324
+ args.forEach((a, i) => {
325
+ if (!this.is_page_value(a)) return;
326
+ const p = fn.params?.[i];
327
+ if (p?.type === "Identifier") {
328
+ if (this.#add_ref(p.name, fn.body ?? fn)) grew = true;
329
+ this.#scopes.get(p.name).add(fn);
330
+ }
331
+ });
332
+ }
333
+ if (callee?.type === "MemberExpression" && !callee.computed && callee.property?.name === "subscribe" && this.is_page_value(callee.object)) {
334
+ const fn = args[0];
335
+ const p = fn?.params?.[0];
336
+ if (fn && p?.type === "Identifier" && this.#add_ref(p.name, fn.body ?? fn)) {
337
+ this.#scopes.get(p.name).add(fn);
338
+ grew = true;
339
+ }
340
+ }
341
+ if (callee?.type === "Identifier" && callee.name === "derived" && args.length >= 2) {
342
+ const fn = args[1];
343
+ const param = fn?.params?.[0];
344
+ if (args[0]?.type === "Identifier" && this.is_page_value(args[0])) {
345
+ if (param?.type === "Identifier") {
346
+ if (this.#add_ref(param.name, fn)) grew = true;
347
+ } else if (param) throw new All("a derived() over the page destructures its parameter", param.start ?? null);
348
+ } else if (args[0]?.type === "ArrayExpression") args[0].elements.forEach((el, i) => {
349
+ if (el?.type !== "Identifier" || !this.is_page_value(el)) return;
350
+ const p = param?.type === "ArrayPattern" ? param.elements[i] : null;
351
+ if (p?.type === "Identifier") {
352
+ if (this.#add_ref(p.name, fn)) grew = true;
353
+ } else throw new All("a derived([…, page, …]) does not name the page parameter", (p ?? el).start ?? null);
354
+ });
355
+ }
356
+ }
357
+ });
358
+ }
359
+ }
360
+ /** Is this expression the page value itself? `page`, `$page`, `get(page)`. */
361
+ is_page_value(raw) {
362
+ const n = unwrap_down(raw);
363
+ if (n.type === "Identifier") {
364
+ const bare = n.name.startsWith("$") ? n.name.slice(1) : n.name;
365
+ return this.#in_scope(n.name, n) || bare !== n.name && this.#in_scope(bare, n);
366
+ }
367
+ if (n.type === "CallExpression" && n.callee?.type === "Identifier" && n.callee.name === "get") {
368
+ const a = n.arguments?.[0];
369
+ return !!a && a.type === "Identifier" && this.#in_scope(a.name, a);
370
+ }
371
+ return false;
372
+ }
373
+ /** Pass 2: every use of a page value, judged by its parent. */
374
+ walk(node, parent, key) {
375
+ if (!node || typeof node !== "object") return;
376
+ if (Array.isArray(node)) {
377
+ for (const child of node) this.walk(child, parent, key);
378
+ return;
379
+ }
380
+ if (typeof node.type === "string" && this.is_page_value(node) && !is_declaration(node, parent, key)) {
381
+ this.judge(node, parent, key);
382
+ if (node.type === "CallExpression") return;
383
+ }
384
+ if (node.type === "IfStatement" || node.type === "ConditionalExpression") {
385
+ const side = runs_on(node.test);
386
+ if (side) {
387
+ this.walk(node.test, node, "test");
388
+ if (side !== "server") this.walk(node.consequent, node, "consequent");
389
+ if (side !== "client" && node.alternate) this.walk(node.alternate, node, "alternate");
390
+ return;
391
+ }
392
+ }
393
+ if (node.type === "LogicalExpression" && node.operator === "&&" && runs_on(node.left) === "server") {
394
+ this.walk(node.left, node, "left");
395
+ return;
396
+ }
397
+ for (const k of Object.keys(node)) {
398
+ if (SKIP_KEYS.has(k)) continue;
399
+ const v = node[k];
400
+ if (v && typeof v === "object") this.walk(v, node, k);
401
+ }
402
+ }
403
+ judge(value, raw_parent, raw_key) {
404
+ const { node: v, parent, key } = raw_parent && WRAPPERS.has(raw_parent.type) ? unwrap_up(value) : {
405
+ node: value,
406
+ parent: raw_parent,
407
+ key: raw_key
408
+ };
409
+ const at = value.start ?? null;
410
+ if (!parent) throw new All("the page is used bare", at);
411
+ if (parent.type === "MemberExpression" && key === "object") {
412
+ const field = member_name(parent);
413
+ if (field === "data") {
414
+ this.judge_data(parent);
415
+ return;
416
+ }
417
+ if (field !== null && SAFE_FIELDS.has(field)) return;
418
+ if (field === "subscribe") {
419
+ const call = parent.__parent;
420
+ const fn = call?.type === "CallExpression" && parent.__key === "callee" ? call.arguments?.[0] : null;
421
+ if (fn && (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") && fn.params?.[0]?.type === "Identifier") return;
422
+ throw new All("`page.subscribe(…)` hands a subscriber the whole page", at);
423
+ }
424
+ throw new All(field === null ? "the page is indexed with an expression" : `\`page.${field}\` is read`, at);
425
+ }
426
+ if (parent.type === "VariableDeclarator" && key === "init") return;
427
+ if (parent.type === "CallExpression" && key === "arguments" && parent.callee?.type === "Identifier") {
428
+ const name = parent.callee.name;
429
+ if (name === "derived" || name === "get") return;
430
+ const fn = this.#local_fns.get(name);
431
+ if (fn) {
432
+ const i = parent.arguments.indexOf(v);
433
+ if (fn.params?.[i]?.type === "Identifier") return;
434
+ throw new All(`the whole page is passed to \`${name}(…)\`, whose parameter is destructured`, at);
435
+ }
436
+ const imp = this.#imports.get(name);
437
+ if (imp) {
438
+ this.pending.push({
439
+ specifier: imp.specifier,
440
+ imported: imp.imported,
441
+ arg: parent.arguments.indexOf(v),
442
+ line: at === null ? null : line_of(this.code, at)
443
+ });
444
+ return;
445
+ }
446
+ throw new All(`the whole page is passed to \`${name}(…)\``, at);
447
+ }
448
+ if (parent.type === "ArrayExpression") return;
449
+ if (parent.type === "CallExpression" && key === "arguments" && parent.callee?.type === "MemberExpression" && parent.callee.object?.name === "Object" && parent.callee.property?.name === "keys") return;
450
+ throw new All("the whole page escapes (passed on, returned, spread, exported or compared)", at);
451
+ }
452
+ /** `page.data` reached: the grandparent decides — a literal key, a destructuring, or all. */
453
+ judge_data(data_member) {
454
+ let { parent: owner, key: owner_key } = unwrap_up(data_member);
455
+ const at = data_member.start ?? null;
456
+ while (owner && owner.type === "LogicalExpression" && (owner.operator === "||" || owner.operator === "??") && owner_key === "left") {
457
+ const up = unwrap_up(owner);
458
+ owner = up.parent;
459
+ owner_key = up.key;
460
+ }
461
+ if (!owner) throw new All("`page.data` is used bare", at);
462
+ if (owner.type === "MemberExpression" && owner_key === "object") {
463
+ const k = member_name(owner);
464
+ if (k === null) throw new All("`page.data[…]` is indexed with an expression", at);
465
+ this.keys.add(k);
466
+ return;
467
+ }
468
+ if (owner.type === "VariableDeclarator" && owner_key === "init" && owner.id?.type === "ObjectPattern") {
469
+ for (const p of owner.id.properties) {
470
+ if (p.type !== "Property" || p.computed) throw new All("`page.data` is destructured with a rest or computed key", p.start ?? at);
471
+ const k = p.key?.type === "Identifier" ? p.key.name : p.key?.type === "Literal" ? String(p.key.value) : null;
472
+ if (k === null) throw new All("`page.data` is destructured with a non-literal key", p.start ?? at);
473
+ this.keys.add(k);
474
+ }
475
+ return;
476
+ }
477
+ throw new All(owner.type === "CallExpression" ? `\`page.data\` is handed whole to ${call_name(owner)}(…)` : owner.type === "VariableDeclarator" ? "`page.data` is aliased whole (`const d = page.data`)" : owner.type === "SpreadElement" ? "`page.data` is spread" : owner.type === "ReturnStatement" || owner.type === "ArrowFunctionExpression" ? "`page.data` is returned whole" : `\`page.data\` is used whole (${owner.type})`, at);
478
+ }
479
+ };
480
+ /** The nearest function-like ancestor an alias declared at `node` belongs to (`null` = module). */
481
+ /**
482
+ * Which side a test lets through: `'server'` when it is true only on the server
483
+ * (`typeof window === 'undefined'`, `typeof document == 'undefined'`, `import.meta.env.SSR`),
484
+ * `'client'` for its negation (`!==`, `!`), null for anything else.
485
+ */
486
+ function runs_on(test) {
487
+ const t = test ? unwrap_down(test) : null;
488
+ if (!t) return null;
489
+ if (t.type === "UnaryExpression" && t.operator === "!") {
490
+ const inner = runs_on(t.argument);
491
+ return inner === "server" ? "client" : inner === "client" ? "server" : null;
492
+ }
493
+ if (t.type === "MemberExpression" && !t.computed && t.property?.name === "SSR" && t.object?.type === "MemberExpression" && t.object.property?.name === "env" && t.object.object?.type === "MetaProperty") return "server";
494
+ if (t.type !== "BinaryExpression") return null;
495
+ const eq = t.operator === "===" || t.operator === "==";
496
+ if (!eq && t.operator !== "!==" && t.operator !== "!=") return null;
497
+ const typeof_global = (n) => n?.type === "UnaryExpression" && n.operator === "typeof" && n.argument?.type === "Identifier" && (n.argument.name === "window" || n.argument.name === "document");
498
+ const undef = (n) => (n?.type === "Literal" || n?.type === "StringLiteral") && n.value === "undefined";
499
+ const l = unwrap_down(t.left);
500
+ const r = unwrap_down(t.right);
501
+ if (!(typeof_global(l) && undef(r) || typeof_global(r) && undef(l))) return null;
502
+ return eq ? "server" : "client";
503
+ }
504
+ function enclosing_scope(node) {
505
+ for (let n = node.__parent; n; n = n.__parent) if (SCOPE_TYPES.has(n.type)) return n.type === "Program" || n.type === "Fragment" || n.type === "Root" ? null : n;
506
+ return null;
507
+ }
508
+ /** `(page as any)` → `page`: the expression under TypeScript / parenthesis wrappers. */
509
+ function unwrap_down(n) {
510
+ let cur = n;
511
+ while (cur && WRAPPERS.has(cur.type) && cur.expression) cur = cur.expression;
512
+ return cur;
513
+ }
514
+ function call_name(call) {
515
+ const c = call.callee;
516
+ if (!c) return "?";
517
+ if (c.type === "Identifier") return c.name;
518
+ if (c.type === "MemberExpression") return `${c.object?.name ?? "…"}.${c.property?.name ?? "…"}`;
519
+ return "?";
520
+ }
521
+ /** `a.b` → 'b'; `a['b']` → 'b'; `a[expr]` → null. */
522
+ function member_name(m) {
523
+ if (!m.computed) return m.property?.type === "Identifier" ? m.property.name : null;
524
+ const p = m.property;
525
+ if (p?.type === "Literal" && typeof p.value === "string") return p.value;
526
+ if (p?.type === "TemplateLiteral" && p.expressions?.length === 0) return p.quasis?.[0]?.value?.cooked ?? null;
527
+ return null;
528
+ }
529
+ function spec_name(n) {
530
+ if (!n) return null;
531
+ if (n.type === "Identifier") return n.name;
532
+ if (n.type === "Literal") return String(n.value);
533
+ return null;
534
+ }
535
+ /** An identifier in a DECLARING position is not a use of the page value. */
536
+ function is_declaration(node, parent, key) {
537
+ if (!parent || node.type !== "Identifier") return false;
538
+ if (parent.type === "VariableDeclarator" && key === "id") return true;
539
+ if (parent.type === "Property" && key === "key" && !parent.computed) return true;
540
+ if (parent.type === "MemberExpression" && key === "property" && !parent.computed) return true;
541
+ if (parent.type === "ImportSpecifier" || parent.type === "ImportDefaultSpecifier" || parent.type === "ImportNamespaceSpecifier") return true;
542
+ if (key === "params") return true;
543
+ if (parent.type === "ArrayPattern" || parent.type === "ObjectPattern" || parent.type === "AssignmentPattern" || parent.type === "RestElement") return true;
544
+ if ((parent.type === "FunctionDeclaration" || parent.type === "FunctionExpression" || parent.type === "ClassDeclaration") && key === "id") return true;
545
+ if (parent.type === "LabeledStatement" && key === "label") return true;
546
+ return false;
547
+ }
548
+ /** Generic pre-order visit; annotates each node with its parent and the key it hangs from, which
549
+ * `judge_data` reads one level up. Arrays are transparent. */
550
+ function visit(root, fn) {
551
+ const rec = (node, parent, key) => {
552
+ if (!node || typeof node !== "object") return;
553
+ if (Array.isArray(node)) {
554
+ for (const child of node) rec(child, parent, key);
555
+ return;
556
+ }
557
+ if (typeof node.type === "string") {
558
+ Object.defineProperty(node, "__parent", {
559
+ value: parent,
560
+ enumerable: false,
561
+ configurable: true
562
+ });
563
+ Object.defineProperty(node, "__key", {
564
+ value: key,
565
+ enumerable: false,
566
+ configurable: true
567
+ });
568
+ fn(node);
569
+ }
570
+ for (const k of Object.keys(node)) {
571
+ if (SKIP_KEYS.has(k)) continue;
572
+ const v = node[k];
573
+ if (v && typeof v === "object") rec(v, node, k);
574
+ }
575
+ };
576
+ rec(root, null, null);
577
+ }
578
+ /** How deep a re-export chain the build follows before giving up (a barrel of barrels). */
579
+ const FOLLOW_MAX_HOPS = 4;
580
+ const SVELTE_EXT_RE = /\.svelte$/;
581
+ const SCRIPT_EXT_RE = /\.(?:[cm]?[jt]sx?)$/;
582
+ /**
583
+ * For every module with pending `helper(page)` calls: resolve each helper, summarize its export,
584
+ * fold the answer into the module's keys (`'all'` with a reason when the helper cannot be
585
+ * summarized). Runs once per build, before the closure union. `read` and `resolve` are the
586
+ * build's (fs + the bundler's resolver), threaded in so this stays testable.
587
+ */
588
+ async function follow_pending_page_calls(program, resolve, read = read_file_sync) {
589
+ const summaries = /* @__PURE__ */ new Map();
590
+ for (const [module, calls] of program.page_pending) {
591
+ let keys = program.page_keys.get(module) ?? /* @__PURE__ */ new Set();
592
+ for (const call of calls) {
593
+ if (keys === "all") break;
594
+ const answer = await summarize_call(call, module, resolve, read, summaries);
595
+ if (answer.keys === "all") {
596
+ keys = "all";
597
+ program.page_key_reasons.set(module, {
598
+ why: `the whole page is passed to \`${call.imported}(…)\` — ${answer.why}`,
599
+ line: call.line
600
+ });
601
+ break;
602
+ }
603
+ keys = merge_page_keys(keys, answer.keys) ?? keys;
604
+ }
605
+ program.page_keys.set(module, keys ?? /* @__PURE__ */ new Set());
606
+ }
607
+ program.page_pending.clear();
608
+ }
609
+ async function summarize_call(call, importer, resolve, read, memo) {
610
+ let specifier = call.specifier;
611
+ let from = importer;
612
+ let name = call.imported;
613
+ for (let hop = 0; hop < FOLLOW_MAX_HOPS; hop++) {
614
+ let resolved;
615
+ try {
616
+ resolved = await resolve(specifier, from);
617
+ } catch {
618
+ resolved = null;
619
+ }
620
+ if (!resolved?.id) return {
621
+ keys: "all",
622
+ why: `\`${specifier}\` could not be resolved from the caller`
623
+ };
624
+ const file = resolved.id.split("?")[0];
625
+ const memo_key = `${file}#${name}#${call.arg}`;
626
+ const hit = memo.get(memo_key);
627
+ if (hit) return {
628
+ keys: hit,
629
+ why: ""
630
+ };
631
+ const kind = SVELTE_EXT_RE.test(file) ? "svelte" : SCRIPT_EXT_RE.test(file) ? "script" : null;
632
+ const code = kind ? read(file) : null;
633
+ if (!kind || code === null) return {
634
+ keys: "all",
635
+ why: `the helper's module (${file}) could not be read`
636
+ };
637
+ const summary = summarize_export(code, file, kind, name, call.arg);
638
+ if (summary === "all") return {
639
+ keys: "all",
640
+ why: `\`${name}\` in ${file} hands the page on, or is not a plain function`
641
+ };
642
+ if (!is_reexport(summary)) {
643
+ memo.set(memo_key, summary);
644
+ return {
645
+ keys: summary,
646
+ why: ""
647
+ };
648
+ }
649
+ if (summary.follow.length === 1) {
650
+ specifier = summary.follow[0];
651
+ from = file;
652
+ name = summary.imported;
653
+ continue;
654
+ }
655
+ for (const source of summary.follow) {
656
+ const sub = await summarize_call({
657
+ ...call,
658
+ specifier: source,
659
+ imported: summary.imported
660
+ }, file, resolve, read, memo);
661
+ if (sub.keys !== "all") return sub;
662
+ }
663
+ return {
664
+ keys: "all",
665
+ why: `\`${name}\` was not found behind the \`export *\` of ${file}`
666
+ };
667
+ }
668
+ return {
669
+ keys: "all",
670
+ why: `\`${name}\` sits behind more than ${FOLLOW_MAX_HOPS} re-exports`
671
+ };
672
+ }
673
+ function is_reexport(s) {
674
+ return typeof s === "object" && s !== null && "follow" in s;
675
+ }
676
+ function read_file_sync(file) {
677
+ try {
678
+ return fs.readFileSync(file, "utf8");
679
+ } catch {
680
+ return null;
681
+ }
682
+ }
683
+ export { follow_pending_page_calls, mentions_page_store, merge_page_keys, page_data_keys, page_data_keys_answer, parse_roots, summarize_export };