@ogygia/core 0.12.2 → 0.13.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 (227) hide show
  1. package/dist/LateIsland.svelte +3 -2
  2. package/dist/LateIslandAwait.svelte +6 -2
  3. package/dist/Region.svelte +22 -33
  4. package/dist/boundary.d.ts +0 -2
  5. package/dist/boundary.js +8 -6
  6. package/dist/compiler/debarrel/barrel.d.ts +15 -8
  7. package/dist/compiler/debarrel/barrel.js +92 -45
  8. package/dist/compiler/debarrel/plugin.js +41 -17
  9. package/dist/compiler/dev/dev-hmr.d.ts +3 -0
  10. package/dist/compiler/dev/dev-hmr.js +3 -0
  11. package/dist/compiler/driver.js +11 -4
  12. package/dist/compiler/flags.js +21 -7
  13. package/dist/compiler/fouc-css.js +5 -1
  14. package/dist/compiler/kit.js +5 -1
  15. package/dist/compiler/link/build-output.js +12 -3
  16. package/dist/compiler/macros/bake.js +18 -4
  17. package/dist/compiler/macros/dollar.js +6 -1
  18. package/dist/compiler/macros/source.js +6 -1
  19. package/dist/compiler/macros/store.js +10 -2
  20. package/dist/compiler/macros/wire.js +6 -1
  21. package/dist/compiler/parse/scan.js +10 -3
  22. package/dist/compiler/region/transform.js +188 -74
  23. package/dist/context-bridge.js +13 -5
  24. package/dist/context.d.ts +9 -0
  25. package/dist/context.js +30 -1
  26. package/dist/document.d.ts +1 -1
  27. package/dist/document.js +7 -1
  28. package/dist/early-holes-head.d.ts +5 -0
  29. package/dist/early-holes-head.js +20 -0
  30. package/dist/early-holes.d.ts +34 -0
  31. package/dist/early-holes.js +51 -0
  32. package/dist/entry-hydrate.js +9 -12
  33. package/dist/events/bus.js +7 -2
  34. package/dist/events/schema.d.ts +2 -2
  35. package/dist/fn-transport.js +4 -3
  36. package/dist/hooks.js +94 -163
  37. package/dist/insights/page-assets.js +11 -3
  38. package/dist/insights/page-insights.d.ts +0 -2
  39. package/dist/insights/page-insights.js +14 -10
  40. package/dist/insights/session-insights.js +2 -2
  41. package/dist/internal-instruments.d.ts +3 -1
  42. package/dist/internal-instruments.js +3 -1
  43. package/dist/internal-server.d.ts +3 -2
  44. package/dist/internal-server.js +3 -2
  45. package/dist/internal.d.ts +1 -2
  46. package/dist/internal.js +1 -2
  47. package/dist/keep-fallback.d.ts +0 -2
  48. package/dist/keep-fallback.js +4 -5
  49. package/dist/live-transport.js +3 -2
  50. package/dist/messages/build.d.ts +585 -0
  51. package/dist/messages/build.js +800 -0
  52. package/dist/messages/core.d.ts +464 -0
  53. package/dist/messages/core.js +843 -0
  54. package/dist/messages/define.d.ts +62 -0
  55. package/dist/messages/define.js +49 -0
  56. package/dist/messages/index.d.ts +6 -0
  57. package/dist/messages/index.js +6 -0
  58. package/dist/messages/island.d.ts +4 -0
  59. package/dist/messages/island.js +34 -0
  60. package/dist/messages/lazy.d.ts +3 -0
  61. package/dist/messages/lazy.js +22 -0
  62. package/dist/messages/prose.d.ts +15 -0
  63. package/dist/messages/prose.js +43 -0
  64. package/dist/messages/server.d.ts +142 -0
  65. package/dist/messages/server.js +246 -0
  66. package/dist/nested.d.ts +3 -0
  67. package/dist/nested.js +8 -1
  68. package/dist/plugin/css.js +14 -13
  69. package/dist/plugin/facts.d.ts +2 -0
  70. package/dist/plugin/facts.js +10 -6
  71. package/dist/plugin/hooks.d.ts +7 -17
  72. package/dist/plugin/hooks.js +32 -4
  73. package/dist/plugin/index.d.ts +9 -2
  74. package/dist/plugin/request-scope.d.ts +20 -0
  75. package/dist/plugin/request-scope.js +149 -0
  76. package/dist/plugin/server.d.ts +20 -2
  77. package/dist/plugin/server.js +98 -28
  78. package/dist/plugin/testing.d.ts +6 -0
  79. package/dist/plugin/testing.js +14 -2
  80. package/dist/policies.d.ts +21 -0
  81. package/dist/policies.js +66 -0
  82. package/dist/preference.js +6 -1
  83. package/dist/preload.js +6 -9
  84. package/dist/ref-watch.d.ts +0 -10
  85. package/dist/ref-watch.js +14 -1
  86. package/dist/ref.js +17 -5
  87. package/dist/region-snippet.js +9 -3
  88. package/dist/region.js +2 -1
  89. package/dist/report-thrown.d.ts +9 -0
  90. package/dist/report-thrown.js +15 -0
  91. package/dist/rules.d.ts +17 -0
  92. package/dist/rules.js +57 -0
  93. package/dist/runtime/beacon.d.ts +0 -4
  94. package/dist/runtime/beacon.js +58 -43
  95. package/dist/runtime/boot-link.js +19 -2
  96. package/dist/runtime/client-hooks.js +2 -1
  97. package/dist/runtime/concurrency.d.ts +16 -5
  98. package/dist/runtime/concurrency.js +123 -7
  99. package/dist/runtime/core.d.ts +3 -1
  100. package/dist/runtime/core.js +718 -384
  101. package/dist/runtime/devalue-lane.d.ts +13 -0
  102. package/dist/runtime/devalue-lane.js +49 -0
  103. package/dist/runtime/disclose-version.d.ts +1 -0
  104. package/dist/runtime/disclose-version.js +14 -0
  105. package/dist/runtime/early-holes.d.ts +4 -0
  106. package/dist/runtime/early-holes.js +40 -0
  107. package/dist/runtime/entry-locations.js +40 -49
  108. package/dist/runtime/foreign-props.d.ts +0 -7
  109. package/dist/runtime/foreign-props.js +2 -1
  110. package/dist/runtime/form-continuity.d.ts +2 -2
  111. package/dist/runtime/form-continuity.js +30 -8
  112. package/dist/runtime/frame-nav.d.ts +7 -1
  113. package/dist/runtime/frame-nav.js +84 -18
  114. package/dist/runtime/frame-store.d.ts +25 -16
  115. package/dist/runtime/frame-store.js +124 -98
  116. package/dist/runtime/frames.js +8 -4
  117. package/dist/runtime/hole-facts.js +6 -7
  118. package/dist/runtime/hole-fetch.d.ts +17 -0
  119. package/dist/runtime/hole-fetch.js +47 -0
  120. package/dist/runtime/hydrate-core.d.ts +4 -4
  121. package/dist/runtime/hydrate-core.js +80 -64
  122. package/dist/runtime/import-again.d.ts +33 -0
  123. package/dist/runtime/import-again.js +217 -0
  124. package/dist/runtime/interaction-replay.d.ts +5 -3
  125. package/dist/runtime/interaction-replay.js +6 -6
  126. package/dist/runtime/interaction.d.ts +14 -3
  127. package/dist/runtime/interaction.js +46 -23
  128. package/dist/runtime/kit-page-thread.svelte.d.ts +2 -1
  129. package/dist/runtime/kit-page-thread.svelte.js +44 -20
  130. package/dist/runtime/lakes.d.ts +1 -1
  131. package/dist/runtime/lakes.js +18 -5
  132. package/dist/runtime/live.d.ts +1 -2
  133. package/dist/runtime/live.js +6 -8
  134. package/dist/runtime/load-scheduler.d.ts +29 -18
  135. package/dist/runtime/load-scheduler.js +236 -136
  136. package/dist/runtime/nav-handle.js +25 -6
  137. package/dist/runtime/navigation.d.ts +24 -0
  138. package/dist/runtime/navigation.js +24 -0
  139. package/dist/runtime/ownership.d.ts +1 -1
  140. package/dist/runtime/page-defer.js +3 -3
  141. package/dist/runtime/parse-html.d.ts +15 -4
  142. package/dist/runtime/parse-html.js +24 -5
  143. package/dist/runtime/pushable-props.svelte.d.ts +21 -0
  144. package/dist/runtime/pushable-props.svelte.js +37 -0
  145. package/dist/runtime/region-endpoint-url.js +4 -6
  146. package/dist/runtime/region-machines.d.ts +111 -0
  147. package/dist/runtime/region-machines.js +97 -0
  148. package/dist/runtime/region-sheets.d.ts +31 -0
  149. package/dist/runtime/region-sheets.js +49 -0
  150. package/dist/runtime/restore-report.d.ts +1 -0
  151. package/dist/runtime/restore-report.js +36 -0
  152. package/dist/runtime/restore.d.ts +5 -2
  153. package/dist/runtime/restore.js +33 -14
  154. package/dist/runtime/router-nav.d.ts +32 -12
  155. package/dist/runtime/router-nav.js +320 -228
  156. package/dist/runtime/router.d.ts +83 -19
  157. package/dist/runtime/router.js +297 -129
  158. package/dist/runtime/rules.d.ts +35 -0
  159. package/dist/runtime/rules.js +137 -0
  160. package/dist/runtime/schedule.d.ts +6 -3
  161. package/dist/runtime/schedule.js +172 -57
  162. package/dist/runtime/seeds.d.ts +5 -1
  163. package/dist/runtime/seeds.js +11 -5
  164. package/dist/runtime/session.d.ts +46 -7
  165. package/dist/runtime/session.js +78 -10
  166. package/dist/runtime/slots.d.ts +53 -20
  167. package/dist/runtime/slots.js +2 -3
  168. package/dist/runtime/soft-refresh.d.ts +16 -0
  169. package/dist/runtime/soft-refresh.js +14 -0
  170. package/dist/runtime/svelte-warnings.d.ts +4 -10
  171. package/dist/runtime/svelte-warnings.js +7 -4
  172. package/dist/runtime/wire-classes.js +21 -8
  173. package/dist/runtime/wire-format.js +6 -3
  174. package/dist/script.js +8 -7
  175. package/dist/seed-ref-reviver.d.ts +0 -9
  176. package/dist/seed-ref-reviver.js +2 -1
  177. package/dist/seed-refs.d.ts +46 -36
  178. package/dist/seed-refs.js +131 -92
  179. package/dist/server/document-tail.d.ts +6 -0
  180. package/dist/server/document-tail.js +7 -1
  181. package/dist/server/early-holes-csp.d.ts +14 -0
  182. package/dist/server/early-holes-csp.js +73 -0
  183. package/dist/server/page-facts.d.ts +4 -1
  184. package/dist/server/page-facts.js +4 -1
  185. package/dist/server/page-seed.d.ts +2 -2
  186. package/dist/server/page-seed.js +104 -11
  187. package/dist/server/page-stream.d.ts +14 -1
  188. package/dist/server/page-stream.js +119 -2
  189. package/dist/server/personal-response.d.ts +0 -5
  190. package/dist/server/personal-response.js +6 -2
  191. package/dist/server/props-wire.js +5 -1
  192. package/dist/server/region-endpoint.js +10 -2
  193. package/dist/server/render-cache.d.ts +24 -20
  194. package/dist/server/render-cache.js +99 -40
  195. package/dist/server/render-page.js +46 -15
  196. package/dist/server/request-stats.d.ts +10 -8
  197. package/dist/server/request-stats.js +20 -12
  198. package/dist/server/rules.d.ts +11 -0
  199. package/dist/server/rules.js +64 -0
  200. package/dist/server/signing-key.js +31 -18
  201. package/dist/server/stream-regions.d.ts +14 -1
  202. package/dist/server/stream-regions.js +38 -2
  203. package/dist/shared-state.js +5 -1
  204. package/dist/shims/app-navigation.js +3 -2
  205. package/dist/shims/page-store.svelte.js +16 -2
  206. package/dist/source.js +7 -2
  207. package/dist/store-transport.js +12 -5
  208. package/dist/transport.js +3 -2
  209. package/dist/vite/index.js +83 -74
  210. package/dist/vite/kit-dirs.js +7 -1
  211. package/dist/vite/options.d.ts +2 -1
  212. package/dist/vite/options.js +11 -20
  213. package/dist/vite/package-files.js +13 -3
  214. package/dist/vite/paths.d.ts +2 -0
  215. package/dist/vite/paths.js +4 -4
  216. package/dist/vite/plugin-api.d.ts +6 -5
  217. package/dist/vite/plugin-api.js +42 -14
  218. package/dist/vite/style-preprocess.js +10 -3
  219. package/package.json +8 -1
  220. package/dist/KeepHost.svelte +0 -19
  221. package/dist/KeepHost.svelte.d.ts +0 -10
  222. package/dist/LiveHost.svelte +0 -19
  223. package/dist/LiveHost.svelte.d.ts +0 -10
  224. package/dist/NestedProvider.svelte +0 -13
  225. package/dist/NestedProvider.svelte.d.ts +0 -8
  226. package/dist/runtime/page-cache.d.ts +0 -23
  227. package/dist/runtime/page-cache.js +0 -74
@@ -1,3 +1,5 @@
1
+ import { FetchedPage } from "./router-nav.js";
2
+ import { Navigation } from "./navigation.js";
1
3
  /**
2
4
  * The `<a>` a pointer event is about — through SHADOW ROOTS. A click inside a web component's
3
5
  * shadow tree (a web component such as `<x-link>`, `<x-button href>`, a breadcrumb item)
@@ -60,24 +62,63 @@ export declare function same_document_link(url: URL, current: URL, in_flight: st
60
62
  export declare function document_key(url: URL): string;
61
63
  /** Instant scroll to a hash target (or top). Ignores CSS `scroll-behavior: smooth`. */
62
64
  export declare function jump_to_hash(hash: string): void;
65
+ /** One entry of the visitor's history the router made (or took over): its address, and where the
66
+ * page was when the visitor left it: its scroll, and the id of the element that had focus. */
67
+ export interface HistoryEntry {
68
+ readonly id: string;
69
+ url: URL;
70
+ scroll: {
71
+ x: number;
72
+ y: number;
73
+ } | null;
74
+ focus: string | null;
75
+ }
76
+ /** How a navigation writes history: a new entry, the current one's address, or the entry a back or
77
+ * forward step is already on. */
78
+ export type HistoryMove = "push" | "replace" | "pop";
79
+ export declare class RouterHistory {
80
+ #private;
81
+ /** The entry of the page on screen. */
82
+ get current(): HistoryEntry;
83
+ /** Takes over the entry the browser is on as the router starts: its state names it now. */
84
+ start(): void;
85
+ /** The entry a history state names: this model's, `'foreign'` (another document's), or null
86
+ * (no id: an entry the browser or the app made). */
87
+ find(state: unknown): HistoryEntry | "foreign" | null;
88
+ /** The page on screen is being left: keep where it is. */
89
+ leave(): void;
90
+ /** A page goes in at `url` (the browser's entry is written now). `push`: a new entry after the
91
+ * one left; `replace`: the current one at a new address; `pop`: `to`, the entry a back or
92
+ * forward step is on. */
93
+ commit(url: URL, move: HistoryMove, to?: HistoryEntry): HistoryEntry;
94
+ /** The entry the browser stepped to, which no id names: this model's from now on. */
95
+ adopt(url: URL): HistoryEntry;
96
+ }
63
97
  export declare class SpaRouter {
64
98
  #private;
65
- /** href of the navigation in flight (set before the fetch, cleared when applied or aborted) */
66
- nav_target: string | null;
67
- /** The in-flight navigation's cancel handle: router-nav bumps `nav_gen` and sets `nav_abort` for
68
- * each navigation it starts, and stops at its next step once `nav_gen` moved on. */
69
- nav_gen: number;
70
- nav_abort: AbortController | null;
71
- /** pathname+search of the document currently in the DOM (hash ignored). */
72
- doc_key: string;
73
99
  /**
74
- * Full URL of the document currently displayed in the DOM. `navigate()` uses this as its `from`
100
+ * THE NAVIGATION, one machine (./navigation.ts): idle, claimed (the click, while the navigation
101
+ * chunk loads), loading (its fetch through its swap), settling (swapped: the last steps run). A
102
+ * new click is a new visit, so whatever the old one still had in flight sees it is not current
103
+ * (`nav.now !== mine`) and stops, and its fetch is aborted. It was three fields kept by hand; two
104
+ * clicks during the first chunk load once held the same generation and the last one was lost.
105
+ */
106
+ readonly nav: Navigation;
107
+ /** href of the router's navigation in flight (claimed or loading; cleared once it applied,
108
+ * ended, or went to the browser: `hand_off`) */
109
+ get nav_target(): string | null;
110
+ /** The visitor's history, as the router keeps it (`RouterHistory`): the rest is read from it. */
111
+ readonly history: RouterHistory;
112
+ /**
113
+ * Full URL of the page on screen: its history entry's. `navigate()` uses this as its `from`
75
114
  * instead of `location.href`, because on a `popstate` (back/forward) the browser has ALREADY
76
115
  * changed `location` to the target — so `location.href` would equal the target and the
77
116
  * same-document guard would wrongly bail into the hash-only branch, never swapping the body
78
117
  * (browser back left the old page's DOM in place). POP-FROM.
79
118
  */
80
- current_url: URL | null;
119
+ get current_url(): URL;
120
+ /** pathname+search of the page on screen (hash ignored). */
121
+ get doc_key(): string;
81
122
  beforeNavigate(fn: BeforeNavigateCallback): () => boolean;
82
123
  afterNavigate(fn: AfterNavigateCallback): () => boolean;
83
124
  /**
@@ -88,15 +129,38 @@ export declare class SpaRouter {
88
129
  * swapping left the URL on the old page and `/plain` in the DOM).
89
130
  */
90
131
  supersede(): void;
132
+ /**
133
+ * GIVE `visit`'s NAVIGATION TO THE BROWSER — a page the router will not render (a csr=true Kit
134
+ * page, a page that is not ogygia's, another build), or one it could not fetch or load its code
135
+ * for: a document navigation to `url`, from the document on screen (`from`).
136
+ *
137
+ * It ENDS the visit, on every path: from here on the navigation is the browser's, never the
138
+ * router's in flight. The browser may well keep this page on screen (a file download, a 204, a
139
+ * body it does not show), and then nothing else ends it: left `loading`, every later click on the
140
+ * link joined it and was swallowed (#266). A visit already left (a newer click took over, or back
141
+ * to the page on screen) hands nothing off: the browser never goes where the visitor no longer is.
142
+ *
143
+ * The router writes an entry only when a page goes in, so a click handed off has none: the
144
+ * browser's navigation is a new entry of its own, and one it keeps the page on screen for adds
145
+ * none (#297). A back or forward step is already on its entry, and a refresh on the one on
146
+ * screen: the browser's navigation REPLACES it, so its document holds the entry alone, never
147
+ * shares it with the router's page (back from a csr=true page then loads the router page, #259).
148
+ * So does a commit that failed after it wrote the entry (the address is already `url`).
149
+ *
150
+ * `error`: the navigation failed part way (its devalue did not load, its swap threw, #276). It
151
+ * is said (the page's error handler, as an uncaught throw would be), and the browser loads the
152
+ * page whole.
153
+ */
154
+ hand_off(url: URL, visit: Navigation["now"], move: HistoryMove, error?: unknown): void;
91
155
  bust_page_cache(): void;
92
- _page_cache_size(): number;
93
- fetch_page(href: string, signal?: AbortSignal, purpose?: "nav" | "prefetch" | "history"): Promise<string | null>;
156
+ /** The page at `href`, or `null` when there is none to have: the fetch failed (./router-nav.ts
157
+ * `fetch_page`), or the navigation code itself did not load. The prefetches (a hover, a
158
+ * viewport link, `preloadData`) start it and never wait on it: a rejection here was uncaught. */
159
+ fetch_page(href: string, signal?: AbortSignal, purpose?: "nav" | "prefetch" | "history"): Promise<FetchedPage | null>;
94
160
  navigate(url: URL, opts?: {
95
161
  push?: boolean;
96
- pop_scroll?: {
97
- x: number;
98
- y: number;
99
- } | null;
162
+ /** the entry a back or forward step is on */
163
+ pop?: HistoryEntry;
100
164
  type?: string;
101
165
  replace?: boolean;
102
166
  }): Promise<void>;
@@ -122,7 +186,9 @@ export declare class SpaRouter {
122
186
  * After start + every navigation, in IDLE: eager links warm now; viewport links get observed.
123
187
  * Only anchors under a preload-marked element are read — an unmarked anchor has no trigger. Idle,
124
188
  * because the scan competes with the freshly swapped page's own islands for the main thread and
125
- * a warm is speculation by definition.
189
+ * a warm is speculation by definition. The scan and its observer are the page visit's
190
+ * (./session.ts `PageVisit`): the next page's swap disconnects it, so the anchors of a page left
191
+ * behind are never held, and a scan still waiting for idle time when its page is left never runs.
126
192
  */
127
193
  scan_preload_links(): void;
128
194
  }
@@ -140,8 +206,6 @@ export declare function beforeNavigate(fn: BeforeNavigateCallback): () => boolea
140
206
  export declare function afterNavigate(fn: AfterNavigateCallback): () => boolean;
141
207
  /** Drop all warmed page HTML (call after mutations / auth changes). */
142
208
  export declare function bust_page_cache(): void;
143
- /** Test helper — current warmed entry count. */
144
- export declare function _page_cache_size(): number;
145
209
  /**
146
210
  * Programmatic same-origin navigation. Mirrors Kit's `goto()` subset.
147
211
  * @param url - Absolute or relative URL (http(s) only).