@ogygia/compiler 0.14.1 → 0.15.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.
package/dist/messages.js CHANGED
@@ -498,6 +498,46 @@ const BUILD_ERRORS = {
498
498
  paths inside the package only.
499
499
  `
500
500
  },
501
+ runtime_features_unnamed: {
502
+ text: (a) => prose`
503
+ A region in this build needs the runtime's ${a.features}, but the runtime its pages load
504
+ was named without it. The pages would load a runtime that is not there, or one that lacks
505
+ what the region needs.
506
+ `,
507
+ details: () => prose`
508
+ The server build names the runtime its pages load once it has compiled every module, and
509
+ hands that name and its features to the client build, which ships that runtime. One side
510
+ found a region needing a feature the other side's runtime does not have: a file only one of
511
+ them compiled. This is an ogygia bug; please report it with the build's output.
512
+ `
513
+ },
514
+ server_features_late: {
515
+ text: (a) => prose`
516
+ ${a.modules} needs the runtime's ${a.features}, but the server build compiled it after
517
+ it had fixed which features its own code carries. The server would render that region
518
+ without the code for it.
519
+ `,
520
+ details: () => prose`
521
+ The server build fixes its feature word when it first loads ogygia's server code, from
522
+ the app's source and the files packages list under \`"ogygia.files"\`. A component it
523
+ reaches only while bundling (one from an installed package that does not list it) is
524
+ read after that, and a feature only it needs is missing from the server's code. List the
525
+ component in its package's \`"ogygia.files"\`, or place the region from the app's own
526
+ source, so the server build reads it before it fixes its features.
527
+ `
528
+ },
529
+ server_runtime_unnamed: {
530
+ text: () => prose`
531
+ The server build's handoff names no runtime, so the client build cannot tell which runtime
532
+ the pages load.
533
+ `,
534
+ details: () => prose`
535
+ The server build writes a handoff file for the client build, beside its own output, that
536
+ names the runtime its pages load. This one names none: it was written by another ogygia
537
+ version, or it is left over from an earlier build. Run the whole build again (server, then
538
+ client) with one ogygia version.
539
+ `
540
+ },
501
541
  plugin_without_ogygia: {
502
542
  text: (a) => `\`${a.plugin}\` is listed in vite.config but \`ogygia()\` is not — add \`ogygia()\` from \`ogygia/vite\` to \`plugins\`.`,
503
543
  details: () => prose`
@@ -736,6 +776,20 @@ const WARNED = {
736
776
  bundler starts. Move the file there, or declare it in its package's \`ogygia.files\`.
737
777
  `
738
778
  },
779
+ server_exports_kept: {
780
+ text: (a) => prose`
781
+ the server build kept what ${a.file} exports and nothing imports: ${a.reason}. The server
782
+ works as built; it is only larger than it needs to be. Please report it.
783
+ `,
784
+ details: () => prose`
785
+ The bundler fixes a shared server chunk's exports before the build's feature word removes
786
+ the code that used some of them, so after the bundle is made ogygia drops each export no
787
+ chunk imports, and the code only those exports reached, by having the bundler shake the
788
+ chunk again. When a step of that fails, the chunk is left exactly as the bundler wrote it:
789
+ nothing is lost but bytes. This is an ogygia bug, or another plugin wrote code the pass
790
+ cannot read.
791
+ `
792
+ },
739
793
  relocation_unpatched: {
740
794
  text: (a) => prose`
741
795
  the ${a.name} in the ${a.leg} build was left unpatched: a value the build fills in at the end
@@ -873,8 +927,9 @@ const WARNED = {
873
927
  text: () => "could not write the server-leg island handoff:",
874
928
  details: () => prose`
875
929
  The server build writes which components it transformed, so the client build emits only
876
- the islands those pages place. Writing it failed (the error follows the message). The
877
- build goes on and emits every island it found.
930
+ the islands those pages place, and which runtime its pages load, so the client build ships
931
+ that one. Writing it failed (the error follows the message), so the build stops: without
932
+ it the pages could name a runtime the client build never makes.
878
933
  `
879
934
  },
880
935
  package_files_missing: {
package/dist/program.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RuntimeMarks } from "./link/runtime-entry.js";
1
+ import { FeatureId, RuntimeMarks } from "./link/runtime-entry.js";
2
2
  import { ScanFacts } from "./scan-facts.js";
3
3
  /** Strip a `?query` off a module id (host vs component vs Vite watch paths). */
4
4
  export declare const strip_id: (id: string) => string;
@@ -35,6 +35,10 @@ export interface IslandDescriptor {
35
35
  kind?: "hydrate" | "defer" | "lake";
36
36
  server?: boolean;
37
37
  fetchWhen?: string;
38
+ /** a hole's `prefetch` schedule */
39
+ prefetch?: string;
40
+ /** a lake's `remount.revalidate` schedule */
41
+ revalidate?: string;
38
42
  strategy?: string;
39
43
  wakeAfter?: string;
40
44
  held?: boolean;
@@ -91,6 +95,9 @@ export declare class Program {
91
95
  * chunk — or drag its imports into a client build whose server pass never saw them (a
92
96
  * `.remote.ts` there fails Kit's "expected to find metadata" check). */
93
97
  readonly ssr_transformed: Set<string>;
98
+ /** BUILD, server leg: the feature word its bundle was made with, set as
99
+ * `ogygia:server/runtime-flags` loads (null before), for the server handoff. */
100
+ server_word: number | null;
94
101
  /** Every scanned file's facts, and the app-wide answers folded from them (./scan-facts.ts). */
95
102
  readonly scan: ScanFacts;
96
103
  /** Absolute paths of app modules that define a transportable class, in scan order. */
@@ -114,6 +121,8 @@ export declare class Program {
114
121
  island_reads_page: boolean;
115
122
  /** Build-time capability marks for the sticky runtime entry. Incomplete → kitchen-sink. */
116
123
  readonly runtime_marks: RuntimeMarks;
124
+ /** The features the runtime entry was made with (`ship_runtime`), or null before it loaded. */
125
+ get shipped_features(): ReadonlySet<FeatureId> | null;
117
126
  /** An empty program with the same options: the next build's (`Compiler.start_leg`). */
118
127
  fresh(): Program;
119
128
  constructor(init: {
@@ -132,6 +141,9 @@ export declare class Program {
132
141
  server_regions_written: ReadonlySet<string> | null;
133
142
  /** Replace this host's claims; shared ids keep one registry entry (path+strategy dedupe). */
134
143
  register(result: RegisterResult, hostId: string): void;
144
+ /** BUILD, server leg: each feature the server's word left out, and the module whose regions
145
+ * first needed it after the word was fixed (driver.ts `#refuse_late_features`). */
146
+ readonly server_late: Map<FeatureId, string>;
135
147
  /** A deleted component: every region of it goes, with every host's claim on it (a claim kept
136
148
  * would outrank the next host to mark it: test/region-host-order.test.ts). Returns the virtual
137
149
  * paths that went. */
package/dist/program.js CHANGED
@@ -4,6 +4,7 @@ import { warn } from "./messages.js";
4
4
  import { same_module_path } from "./dev/hmr.js";
5
5
  import { ScanFacts } from "./scan-facts.js";
6
6
  import path from "node:path";
7
+ import { feature_word } from "@ogygia/core/contract";
7
8
  // src/program.ts
8
9
  /** Strip a `?query` off a module id (host vs component vs Vite watch paths). */
9
10
  const strip_id = (id) => id ? id.split("?")[0] : id;
@@ -30,6 +31,9 @@ var Program = class Program {
30
31
  * chunk — or drag its imports into a client build whose server pass never saw them (a
31
32
  * `.remote.ts` there fails Kit's "expected to find metadata" check). */
32
33
  ssr_transformed = /* @__PURE__ */ new Set();
34
+ /** BUILD, server leg: the feature word its bundle was made with, set as
35
+ * `ogygia:server/runtime-flags` loads (null before), for the server handoff. */
36
+ server_word = null;
33
37
  /** Every scanned file's facts, and the app-wide answers folded from them (./scan-facts.ts). */
34
38
  scan = new ScanFacts();
35
39
  /** Absolute paths of app modules that define a transportable class, in scan order. */
@@ -67,6 +71,10 @@ var Program = class Program {
67
71
  * registration that needs one more is reported (`runtime_marks_late`), once per feature. */
68
72
  #runtime_shipped = null;
69
73
  #late_said = /* @__PURE__ */ new Set();
74
+ /** The features the runtime entry was made with (`ship_runtime`), or null before it loaded. */
75
+ get shipped_features() {
76
+ return this.#runtime_shipped;
77
+ }
70
78
  #init;
71
79
  /** An empty program with the same options: the next build's (`Compiler.start_leg`). */
72
80
  fresh() {
@@ -81,6 +89,8 @@ var Program = class Program {
81
89
  remoteSeeds: false,
82
90
  hydrate: [],
83
91
  defer: [],
92
+ prefetch: [],
93
+ revalidate: [],
84
94
  persistKeys: [],
85
95
  router: init.router,
86
96
  live: false,
@@ -109,6 +119,8 @@ var Program = class Program {
109
119
  const runtime_marks = this.runtime_marks;
110
120
  if (patch.hydrate) runtime_marks.hydrate = [.../* @__PURE__ */ new Set([...runtime_marks.hydrate || [], ...patch.hydrate])];
111
121
  if (patch.defer) runtime_marks.defer = [.../* @__PURE__ */ new Set([...runtime_marks.defer || [], ...patch.defer])];
122
+ if (patch.prefetch) runtime_marks.prefetch = [.../* @__PURE__ */ new Set([...runtime_marks.prefetch || [], ...patch.prefetch])];
123
+ if (patch.revalidate) runtime_marks.revalidate = [.../* @__PURE__ */ new Set([...runtime_marks.revalidate || [], ...patch.revalidate])];
112
124
  if (patch.persistKeys) runtime_marks.persistKeys = [.../* @__PURE__ */ new Set([...runtime_marks.persistKeys || [], ...patch.persistKeys])];
113
125
  if (patch.router) runtime_marks.router = true;
114
126
  if (patch.live) runtime_marks.live = true;
@@ -178,6 +190,8 @@ var Program = class Program {
178
190
  if (kind === "defer") this.note_runtime_mark({ defer: [isl.fetchWhen || "load"] });
179
191
  if (kind === "hydrate") this.note_runtime_mark({ hydrate: [isl.strategy || "load"] });
180
192
  if (isl.wakeAfter) this.note_runtime_mark({ hydrate: [isl.wakeAfter] });
193
+ if (isl.prefetch) this.note_runtime_mark({ prefetch: [isl.prefetch] });
194
+ if (isl.revalidate) this.note_runtime_mark({ revalidate: [isl.revalidate] });
181
195
  if (kind === "lake") this.note_runtime_mark({
182
196
  lakes: true,
183
197
  hydrate: ["none"]
@@ -263,6 +277,18 @@ var Program = class Program {
263
277
  }
264
278
  host_index.set(key, idx);
265
279
  this.#check_late(hostId);
280
+ this.#note_server_late(hostId);
281
+ }
282
+ /** BUILD, server leg: each feature the server's word left out, and the module whose regions
283
+ * first needed it after the word was fixed (driver.ts `#refuse_late_features`). */
284
+ server_late = /* @__PURE__ */ new Map();
285
+ #note_server_late(host) {
286
+ const word = this.server_word;
287
+ if (word === null) return;
288
+ for (const id of resolveFeatures({
289
+ ...this.runtime_marks,
290
+ complete: true
291
+ })) if (!(word & feature_word([id])) && !this.server_late.has(id)) this.server_late.set(id, host);
266
292
  }
267
293
  /** A deleted component: every region of it goes, with every host's claim on it (a claim kept
268
294
  * would outrank the next host to mark it: test/region-host-order.test.ts). Returns the virtual
@@ -979,7 +979,8 @@ var FileCompilation = class {
979
979
  server: swr,
980
980
  kind: "lake",
981
981
  lakes: ["OgygiaLakeInner"],
982
- identity
982
+ identity,
983
+ revalidate: swr ? mark.options?.when : void 0
983
984
  });
984
985
  }
985
986
  rewrite_binding(info.node, binding_rewrite(local, bindingPath, componentPath, true));
@@ -1016,6 +1017,7 @@ var FileCompilation = class {
1016
1017
  identity,
1017
1018
  strategy: mark.strategy,
1018
1019
  fetchWhen: mark.options?.when,
1020
+ prefetch: mark.options?.prefetch,
1019
1021
  wakeAfter: deferred_hydrate ? mark.options?.hydrate : void 0,
1020
1022
  keep: mark.options?.keep
1021
1023
  } : make_wake_island({
@@ -2,7 +2,7 @@ import { CompileCtx } from "../ctx.js";
2
2
  import { ClientRealmFile, ServerRealm } from "../link/caps.js";
3
3
  import { Program } from "../program.js";
4
4
  import { ConstantEntry, Entry, FamilyEntry, Leg, Parts, RequestEntry, ValueEntry } from "./table.js";
5
- import { DevtoolsBootUrlModule, DevtoolsMetaModule, HydrateFeaturesModule, KitTransportModule, KitWireModule, ProfilerMapsModule, RateLimitModule, RegionDepsModule, RegionTtlModule, RouteConfigModule, RouteCsrModule, RouterConfigModule, RuntimeFlagsModule, RuntimeHookName, RuntimeUrlModule, SecretModule, ServerManifestModule, ServerPluginsModule, ServerRegionsModule, SessionCookieModule, TransportModule, TransportablesModule, VirtualConstants } from "@ogygia/core/contract";
5
+ import { DevtoolsBootUrlModule, DevtoolsMetaModule, FeatureCodeModule, HookBitsModule, HooksModule, HydrateFeaturesModule, KitTransportModule, KitWireModule, ProfilerMapsModule, ProgramsModule, RateLimitModule, RegionDepsModule, RegionTtlModule, RemoteSeedsModule, RouteConfigModule, RouteCsrModule, RouterConfigModule, RuntimeFlagsModule, RuntimeUrlModule, SecretModule, ServerFlagsModule, ServerManifestModule, ServerPluginsModule, ServerRegionsModule, SessionCookieModule, TransportModule, TransportablesModule, VirtualConstants } from "@ogygia/core/contract";
6
6
  /** What core's entries read off the compile session (the driver implements it). */
7
7
  export interface CoreApp {
8
8
  readonly ctx: CompileCtx;
@@ -32,7 +32,22 @@ export declare const core_path: (app: CoreApp, module: string) => string;
32
32
  export declare const runtime: Family;
33
33
  export declare const runtime_entry: Family;
34
34
  export declare const runtime_flags: Family<RuntimeFlagsModule>;
35
+ /** The browser's feature word, for the server leg (link/runtime-entry.ts `generateServerFlagsSource`). */
36
+ export declare const server_flags: Family<ServerFlagsModule>;
37
+ /** A region's three programs, on both legs (link/runtime-entry.ts `generateProgramsSource`). */
38
+ export declare const programs: Family<ProgramsModule>;
39
+ /** The hydrate-phase features' modules the hydrate core reads (link/runtime-entry.ts
40
+ * `generateHydrateFeaturesSource`). */
35
41
  export declare const hydrate_features: Family<HydrateFeaturesModule>;
42
+ /** The remote-seeds feature's module (link/runtime-entry.ts `generateRemoteSeedsSource`). */
43
+ export declare const remote_seeds: Family<RemoteSeedsModule>;
44
+ /** The boot features' modules the region element calls directly (link/runtime-entry.ts
45
+ * `generateFeatureCodeSource`). */
46
+ export declare const feature_code: Family<FeatureCodeModule>;
47
+ /** The runtime hooks the app's client realms subscribe to (link/hooks.ts `generateHooksSource`). */
48
+ export declare const hooks: Family<HooksModule>;
49
+ /** A lazy chunk's hooks, a `0`/`1` bit each (link/hooks.ts `generateHookBitsSource`). */
50
+ export declare const hook_bits: Family<HookBitsModule>;
36
51
  export declare const devtools_meta: Value<DevtoolsMetaModule>;
37
52
  export declare const transport: Family<TransportModule>;
38
53
  export declare const transportables: Family<TransportablesModule>;
@@ -78,10 +93,10 @@ export interface ConstantInput {
78
93
  devtools: boolean;
79
94
  devtools_lazy: boolean;
80
95
  rules: boolean;
81
- client_plugins: boolean;
82
- /** the runtime hooks some plugin's browser half subscribes to */
83
- hooks: readonly RuntimeHookName[];
84
96
  kit_major: number | null;
97
+ /** Kit may hydrate a document the app serves (kit.ts `kit_may_hydrate`; dev and a federated
98
+ * app: always) */
99
+ kit_pages: boolean;
85
100
  version: string;
86
101
  dev_server: boolean;
87
102
  }
@@ -97,48 +112,12 @@ export declare const devtools_gate: Constant;
97
112
  export declare const devtools_lazy: Constant;
98
113
  /** ogygia's rules on itself, in a build made for e2e (`OGYGIA_RULES=1`); dev has them always */
99
114
  export declare const rules_gate: Constant;
100
- /** a plugin's browser half is in the boot: the runtime calls its hooks */
101
- export declare const client_plugins_gate: Constant;
102
- /** a plugin's browser half subscribes to `regionMount`; otherwise its emit point folds out */
103
- export declare const hook_region_mount: Constant;
104
- /** a plugin's browser half subscribes to `regionUnmount` */
105
- export declare const hook_region_unmount: Constant;
106
- /** a plugin's browser half subscribes to `regionHydrate` (around Svelte's hydrate) */
107
- export declare const hook_region_hydrate: Constant;
108
- /** a plugin's browser half subscribes to `answerParsed` */
109
- export declare const hook_answer_parsed: Constant;
110
- /** a plugin's browser half subscribes to `answerPlaced` */
111
- export declare const hook_answer_placed: Constant;
112
- /** a plugin's browser half subscribes to `regionHydrated` */
113
- export declare const hook_region_hydrated: Constant;
114
- /** a plugin's browser half subscribes to `regionFailed` */
115
- export declare const hook_region_failed: Constant;
116
- /** a plugin's browser half subscribes to `regionWoke` */
117
- export declare const hook_region_woke: Constant;
118
- /** a plugin's browser half subscribes to `regionMismatched` */
119
- export declare const hook_region_mismatched: Constant;
120
- /** a plugin's browser half subscribes to `holeAnswered` */
121
- export declare const hook_hole_answered: Constant;
122
- /** a plugin's browser half subscribes to `holeFailed` */
123
- export declare const hook_hole_failed: Constant;
124
- /** a plugin's browser half subscribes to `holeBatchMissed` */
125
- export declare const hook_hole_batch_missed: Constant;
126
- /** a plugin's browser half subscribes to `entryFallback` */
127
- export declare const hook_entry_fallback: Constant;
128
- /** a plugin's browser half subscribes to `reloadNeeded` */
129
- export declare const hook_reload_needed: Constant;
130
- /** a plugin's browser half subscribes to `navStarted` */
131
- export declare const hook_nav_started: Constant;
132
- /** a plugin's browser half subscribes to `navigated` */
133
- export declare const hook_navigated: Constant;
134
- /** a plugin's browser half subscribes to `criticalSettled` */
135
- export declare const hook_critical_settled: Constant;
136
- /** a plugin's browser half subscribes to `loadStarted` */
137
- export declare const hook_load_started: Constant;
138
- /** a plugin's browser half subscribes to `warning` */
139
- export declare const hook_warning: Constant;
140
115
  /** the app's Kit major (2, 3), or null when none was found (kit-paths.ts) */
141
116
  export declare const kit_major: Constant<VirtualConstants["__OGYGIA_KIT_MAJOR__"]>;
117
+ /** Kit may hydrate a document the app serves (a csr=true page, error render or routeless response,
118
+ * or a `csr` the build cannot read); off, the runtime's and island code's mixed-mode paths fold out
119
+ * and a document that says Kit hydrates it is refused at boot (`kit_page_unbuilt`) */
120
+ export declare const kit_pages: Constant;
142
121
  /** the installed ogygia's version, which the runtime discloses (`window.__ogygia.v`) */
143
122
  export declare const version: Constant<VirtualConstants["__OGYGIA_VERSION__"]>;
144
123
  /** the dev HMR bridge's served URL on the dev server; '' in a build, so its script folds out */
@@ -1,16 +1,17 @@
1
1
  import { csrTrueRouteIds, errorCsrTrueRouteIds, rootLayoutCsrTrue } from "../kit.js";
2
- import { generateHydrateFeaturesSource, generateRuntimeEntrySource, generateRuntimeFlagsSource } from "../link/runtime-entry.js";
2
+ import { generateFeatureCodeSource, generateHydrateFeaturesSource, generateProgramsSource, generateRemoteSeedsSource, generateRuntimeEntrySource, generateRuntimeFlagsSource, generateServerFlagsSource, server_feature_word } from "../link/runtime-entry.js";
3
+ import { generateHookBitsSource, generateHooksSource } from "../link/hooks.js";
3
4
  import { island_deps_module } from "../link/island-deps.js";
4
5
  import { router_css_module } from "../link/router-css.js";
5
6
  import { client_realms_source, route_config_module, server_plugins_module } from "../link/caps.js";
6
7
  import { kit_transport_module, transport_module, transportables_client_module, transportables_server_module } from "../link/transport.js";
7
- import { server_island_ids, server_manifest_module, server_regions_module } from "../link/server-manifest.js";
8
+ import { RUNTIME_URL_TOKEN, server_island_ids, server_manifest_module, server_regions_module } from "../link/server-manifest.js";
8
9
  import { registry_stub_names, registry_stub_source } from "../link/registry-stub.js";
9
10
  import { dev_hmr_client_source } from "../dev/dev-hmr.js";
10
11
  import { PROFILER_MAPS_PLACEHOLDER, REGION_FAMILY } from "../ids.js";
11
12
  import { defines, specifier_of, virtual } from "./table.js";
12
13
  import path from "node:path";
13
- import { RUNTIME_HOOK_CONSTANTS, dedent } from "@ogygia/core/contract";
14
+ import { dedent } from "@ogygia/core/contract";
14
15
  import fs from "node:fs";
15
16
  import { cache } from "@ogygia/machine";
16
17
  // src/virtual/core.ts
@@ -93,7 +94,7 @@ const runtime_flags = virtual.family({
93
94
  realm: "boot",
94
95
  id: "runtime-flags",
95
96
  exports: {
96
- FRAMES: "FRAMES",
97
+ HAS: "HAS",
97
98
  load_wire_codec: "load_wire_codec"
98
99
  },
99
100
  load(app) {
@@ -103,21 +104,97 @@ const runtime_flags = virtual.family({
103
104
  return generateRuntimeFlagsSource(app.program.runtime_marks, ctx.runtime_dir);
104
105
  }
105
106
  });
107
+ /** The browser's feature word, for the server leg (link/runtime-entry.ts `generateServerFlagsSource`). */
108
+ const server_flags = virtual.family({
109
+ realm: "server",
110
+ id: "runtime-flags",
111
+ exports: { HAS: "HAS" },
112
+ settles: true,
113
+ load(app) {
114
+ if (!app.ctx.is_build) return generateServerFlagsSource({}, true);
115
+ app.prescan();
116
+ app.program.server_word = server_feature_word(app.program.runtime_marks);
117
+ return generateServerFlagsSource(app.program.runtime_marks);
118
+ }
119
+ });
120
+ /** A region's three programs, on both legs (link/runtime-entry.ts `generateProgramsSource`). */
121
+ const programs = virtual.family({
122
+ realm: "region",
123
+ id: "programs",
124
+ exports: {
125
+ HAS_FRAMES: "HAS_FRAMES",
126
+ HAS_LAKES: "HAS_LAKES",
127
+ HAS_LIVE: "HAS_LIVE"
128
+ },
129
+ settles: true,
130
+ load(app) {
131
+ if (!app.ctx.is_build) return generateProgramsSource({}, true);
132
+ app.prescan();
133
+ return generateProgramsSource(app.program.runtime_marks);
134
+ }
135
+ });
136
+ /** The hydrate-phase features' modules the hydrate core reads (link/runtime-entry.ts
137
+ * `generateHydrateFeaturesSource`). */
106
138
  const hydrate_features = virtual.family({
107
139
  realm: "boot",
108
140
  id: "hydrate-features",
109
- exports: { install_hydrate_features: "install" },
110
141
  load(app) {
111
142
  const { ctx, program } = app;
112
143
  if (!ctx.is_build) {
113
144
  const rt = dev_runtime_of(ctx.runtime_dir);
114
- const code = generateHydrateFeaturesSource({}, rt?.dir ?? ctx.runtime_dir, true).code;
115
- return rt?.ts ? code.split(".js\";").join(".ts\";") : code;
145
+ const dir = rt?.dir ?? ctx.runtime_dir;
146
+ return generateHydrateFeaturesSource({}, dir, true, rt?.ts ? ".ts" : ".js").code;
116
147
  }
117
148
  app.prescan();
118
149
  return generateHydrateFeaturesSource(program.runtime_marks, ctx.runtime_dir).code;
119
150
  }
120
151
  });
152
+ /** The remote-seeds feature's module (link/runtime-entry.ts `generateRemoteSeedsSource`). */
153
+ const remote_seeds = virtual.family({
154
+ realm: "boot",
155
+ id: "remote-seeds",
156
+ load(app) {
157
+ const { ctx, program } = app;
158
+ if (!ctx.is_build) {
159
+ const rt = dev_runtime_of(ctx.runtime_dir);
160
+ return generateRemoteSeedsSource({}, rt?.dir ?? ctx.runtime_dir, true, rt?.ts ? ".ts" : ".js");
161
+ }
162
+ app.prescan();
163
+ return generateRemoteSeedsSource(program.runtime_marks, ctx.runtime_dir);
164
+ }
165
+ });
166
+ /** The boot features' modules the region element calls directly (link/runtime-entry.ts
167
+ * `generateFeatureCodeSource`). */
168
+ const feature_code = virtual.family({
169
+ realm: "boot",
170
+ id: "feature-code",
171
+ load(app) {
172
+ const { ctx } = app;
173
+ if (!ctx.is_build) {
174
+ const rt = dev_runtime_of(ctx.runtime_dir);
175
+ return generateFeatureCodeSource({}, rt?.dir ?? ctx.runtime_dir, true, rt?.ts ? ".ts" : ".js");
176
+ }
177
+ app.prescan();
178
+ return generateFeatureCodeSource(app.program.runtime_marks, ctx.runtime_dir);
179
+ }
180
+ });
181
+ /** The runtime hooks the app's client realms subscribe to (link/hooks.ts `generateHooksSource`). */
182
+ const hooks = virtual.family({
183
+ realm: "boot",
184
+ id: "hooks",
185
+ load(app) {
186
+ const { ctx } = app;
187
+ const clients = app.plugins().client;
188
+ const rt = ctx.is_build ? null : dev_runtime_of(ctx.runtime_dir);
189
+ return generateHooksSource(clients, rt?.dir ?? ctx.runtime_dir, rt?.ts ? ".ts" : ".js");
190
+ }
191
+ });
192
+ /** A lazy chunk's hooks, a `0`/`1` bit each (link/hooks.ts `generateHookBitsSource`). */
193
+ const hook_bits = virtual.family({
194
+ realm: "boot",
195
+ id: "hook-bits",
196
+ load: (app) => generateHookBitsSource(app.plugins().client)
197
+ });
121
198
  const devtools_meta = virtual.value({
122
199
  realm: "boot",
123
200
  id: "devtools-meta",
@@ -176,8 +253,7 @@ const runtime_url = virtual.value({
176
253
  id: "runtime-url",
177
254
  from(app) {
178
255
  if (app.ctx.is_dev) return { runtime_url: vite_dev_url(specifier_of(runtime)) };
179
- app.prescan();
180
- return { runtime_url: app.runtime_chunk_url() };
256
+ return { runtime_url: RUNTIME_URL_TOKEN };
181
257
  }
182
258
  });
183
259
  /** The dev HMR bridge's served URL: the dev server's `__OGYGIA_DEV_HMR_URL__` (`''` in a build, so
@@ -193,6 +269,7 @@ const region_deps = virtual.family({
193
269
  id: "region-deps",
194
270
  exports: {
195
271
  region_deps: "region_deps",
272
+ wake_code: "wake_code",
196
273
  region_interactivity: "region_interactivity",
197
274
  chunk_contents: "chunk_contents",
198
275
  chunk_heavy: "chunk_heavy",
@@ -281,7 +358,11 @@ const rate_limit = virtual.value({
281
358
  const server_plugins = virtual.family({
282
359
  realm: "server",
283
360
  id: "server-plugins",
284
- exports: { server_plugins: "plugins" },
361
+ exports: {
362
+ server_plugins: "plugins",
363
+ server_plugin_count: "plugin_count",
364
+ server_hook_measures: "measures"
365
+ },
285
366
  load: (app, { ssr }) => server_plugins_module(ssr, app.plugins().server)
286
367
  });
287
368
  const profiler_maps = virtual.value({
@@ -368,6 +449,7 @@ const kit_transport = virtual.family({
368
449
  realm: "region",
369
450
  id: "kit-transport",
370
451
  exports: { kit_transport: "transport" },
452
+ settles: true,
371
453
  load({ ctx, program }, { ssr }) {
372
454
  const crosses = program.runtime_marks.wire === true || program.crosses_wire;
373
455
  return kit_transport_module(crosses, posix(`${ctx.runtime_dir}/..`), ssr);
@@ -430,58 +512,18 @@ const rules_gate = virtual.constant({
430
512
  id: "__OGYGIA_RULES__",
431
513
  from: (o) => o.rules
432
514
  });
433
- /** a plugin's browser half is in the boot: the runtime calls its hooks */
434
- const client_plugins_gate = virtual.constant({
435
- id: "__OGYGIA_CLIENT_PLUGINS__",
436
- from: (o) => o.client_plugins
437
- });
438
- const hook_gate = (name) => virtual.constant({
439
- id: RUNTIME_HOOK_CONSTANTS[name],
440
- from: (o) => o.hooks.includes(name)
441
- });
442
- /** a plugin's browser half subscribes to `regionMount`; otherwise its emit point folds out */
443
- const hook_region_mount = hook_gate("regionMount");
444
- /** a plugin's browser half subscribes to `regionUnmount` */
445
- const hook_region_unmount = hook_gate("regionUnmount");
446
- /** a plugin's browser half subscribes to `regionHydrate` (around Svelte's hydrate) */
447
- const hook_region_hydrate = hook_gate("regionHydrate");
448
- /** a plugin's browser half subscribes to `answerParsed` */
449
- const hook_answer_parsed = hook_gate("answerParsed");
450
- /** a plugin's browser half subscribes to `answerPlaced` */
451
- const hook_answer_placed = hook_gate("answerPlaced");
452
- /** a plugin's browser half subscribes to `regionHydrated` */
453
- const hook_region_hydrated = hook_gate("regionHydrated");
454
- /** a plugin's browser half subscribes to `regionFailed` */
455
- const hook_region_failed = hook_gate("regionFailed");
456
- /** a plugin's browser half subscribes to `regionWoke` */
457
- const hook_region_woke = hook_gate("regionWoke");
458
- /** a plugin's browser half subscribes to `regionMismatched` */
459
- const hook_region_mismatched = hook_gate("regionMismatched");
460
- /** a plugin's browser half subscribes to `holeAnswered` */
461
- const hook_hole_answered = hook_gate("holeAnswered");
462
- /** a plugin's browser half subscribes to `holeFailed` */
463
- const hook_hole_failed = hook_gate("holeFailed");
464
- /** a plugin's browser half subscribes to `holeBatchMissed` */
465
- const hook_hole_batch_missed = hook_gate("holeBatchMissed");
466
- /** a plugin's browser half subscribes to `entryFallback` */
467
- const hook_entry_fallback = hook_gate("entryFallback");
468
- /** a plugin's browser half subscribes to `reloadNeeded` */
469
- const hook_reload_needed = hook_gate("reloadNeeded");
470
- /** a plugin's browser half subscribes to `navStarted` */
471
- const hook_nav_started = hook_gate("navStarted");
472
- /** a plugin's browser half subscribes to `navigated` */
473
- const hook_navigated = hook_gate("navigated");
474
- /** a plugin's browser half subscribes to `criticalSettled` */
475
- const hook_critical_settled = hook_gate("criticalSettled");
476
- /** a plugin's browser half subscribes to `loadStarted` */
477
- const hook_load_started = hook_gate("loadStarted");
478
- /** a plugin's browser half subscribes to `warning` */
479
- const hook_warning = hook_gate("warning");
480
515
  /** the app's Kit major (2, 3), or null when none was found (kit-paths.ts) */
481
516
  const kit_major = virtual.constant({
482
517
  id: "__OGYGIA_KIT_MAJOR__",
483
518
  from: (o) => o.kit_major
484
519
  });
520
+ /** Kit may hydrate a document the app serves (a csr=true page, error render or routeless response,
521
+ * or a `csr` the build cannot read); off, the runtime's and island code's mixed-mode paths fold out
522
+ * and a document that says Kit hydrates it is refused at boot (`kit_page_unbuilt`) */
523
+ const kit_pages = virtual.constant({
524
+ id: "__OGYGIA_KIT_PAGES__",
525
+ from: (o) => o.kit_pages
526
+ });
485
527
  /** the installed ogygia's version, which the runtime discloses (`window.__ogygia.v`) */
486
528
  const version = virtual.constant({
487
529
  id: "__OGYGIA_VERSION__",
@@ -499,27 +541,8 @@ const CORE_CONSTANTS = [
499
541
  devtools_gate,
500
542
  devtools_lazy,
501
543
  rules_gate,
502
- client_plugins_gate,
503
- hook_region_mount,
504
- hook_region_unmount,
505
- hook_region_hydrate,
506
- hook_answer_parsed,
507
- hook_answer_placed,
508
- hook_region_hydrated,
509
- hook_region_failed,
510
- hook_region_woke,
511
- hook_region_mismatched,
512
- hook_hole_answered,
513
- hook_hole_failed,
514
- hook_hole_batch_missed,
515
- hook_entry_fallback,
516
- hook_reload_needed,
517
- hook_nav_started,
518
- hook_navigated,
519
- hook_critical_settled,
520
- hook_load_started,
521
- hook_warning,
522
544
  kit_major,
545
+ kit_pages,
523
546
  version,
524
547
  dev_hmr_url
525
548
  ];
@@ -549,10 +572,16 @@ const CORE_VIRTUALS = [
549
572
  runtime,
550
573
  runtime_entry,
551
574
  runtime_flags,
575
+ server_flags,
576
+ programs,
552
577
  devtools_meta,
553
578
  transport,
554
579
  transportables,
555
580
  hydrate_features,
581
+ remote_seeds,
582
+ feature_code,
583
+ hooks,
584
+ hook_bits,
556
585
  hmr,
557
586
  devtools_boot,
558
587
  runtime_url,
@@ -585,4 +614,4 @@ const CORE_VIRTUALS = [
585
614
  fouc_scoped,
586
615
  client_binding_stub
587
616
  ];
588
- export { CORE_CONSTANTS, CORE_PARTS, CORE_PROBE, CORE_VIRTUALS, DEV_HMR_URL, client_binding_stub, client_plugins_gate, continuity_forms, core_defines, core_path, dev_hmr_url, devtools_boot, devtools_boot_url, devtools_gate, devtools_lazy, devtools_meta, fouc_css, fouc_scoped, hmr, hook_answer_parsed, hook_answer_placed, hook_critical_settled, hook_entry_fallback, hook_hole_answered, hook_hole_batch_missed, hook_hole_failed, hook_load_started, hook_nav_started, hook_navigated, hook_region_failed, hook_region_hydrate, hook_region_hydrated, hook_region_mismatched, hook_region_mount, hook_region_unmount, hook_region_woke, hook_reload_needed, hook_warning, hydrate_features, kit_major, kit_transport, kit_wire, profiler_maps, rate_limit, region_binding, region_deps, region_endpoint, region_entry, region_lazy, region_ttl, region_wrapper, registry_stub, request_event, route_config, route_csr, router_config, router_css, rules_gate, runtime, runtime_entry, runtime_flags, runtime_url, secret, server_delta, server_manifest, server_plugins, server_regions, session_cookie, sign, transport, transportables, transportables_eager, version };
617
+ export { CORE_CONSTANTS, CORE_PARTS, CORE_PROBE, CORE_VIRTUALS, DEV_HMR_URL, client_binding_stub, continuity_forms, core_defines, core_path, dev_hmr_url, devtools_boot, devtools_boot_url, devtools_gate, devtools_lazy, devtools_meta, feature_code, fouc_css, fouc_scoped, hmr, hook_bits, hooks, hydrate_features, kit_major, kit_pages, kit_transport, kit_wire, profiler_maps, programs, rate_limit, region_binding, region_deps, region_endpoint, region_entry, region_lazy, region_ttl, region_wrapper, registry_stub, remote_seeds, request_event, route_config, route_csr, router_config, router_css, rules_gate, runtime, runtime_entry, runtime_flags, runtime_url, secret, server_delta, server_flags, server_manifest, server_plugins, server_regions, session_cookie, sign, transport, transportables, transportables_eager, version };
@@ -59,4 +59,6 @@ export declare class VirtualTable<A> {
59
59
  /** Is the module only definitions (a realm module, or an entry it re-exports from)? The bundler
60
60
  * may then drop it, and what it imports, when none of its names is used. */
61
61
  side_effect_free(id: string): boolean;
62
+ /** Is the resolved id a module whose source is the bundle's runtime (`settles`)? */
63
+ settles(id: string): boolean;
62
64
  }
@@ -252,6 +252,11 @@ var VirtualTable = class {
252
252
  const e = this.#by_resolved.get(id);
253
253
  return e !== void 0 && realm_exports(e, this.#names).length > 0;
254
254
  }
255
+ /** Is the resolved id a module whose source is the bundle's runtime (`settles`)? */
256
+ settles(id) {
257
+ const e = this.#by_resolved.get(id);
258
+ return e?.kind === "family" && e.settles === true;
259
+ }
255
260
  };
256
261
  function tracked(app, parts, cx) {
257
262
  if (typeof app !== "object" || app === null) return app;
@@ -27,6 +27,9 @@ export interface Leg {
27
27
  kitCodec?: string | null;
28
28
  /** the import chain that reached the module being loaded (resolver.ts `import_chain`) */
29
29
  via?: () => string;
30
+ /** BUILD, server leg: resolves once the bundler has compiled every module of the bundle but the
31
+ * ones `skip` names (vite/graph-compiled.ts) */
32
+ compiled?: (skip: (id: string) => boolean) => Promise<void>;
30
33
  }
31
34
  type Source = string | Promise<string>;
32
35
  interface Base {
@@ -72,6 +75,9 @@ export interface FamilyEntry<A, M = Record<never, never>> extends Base {
72
75
  parse?(rest: string): string | null;
73
76
  /** the module's source; `undefined`: not this table's to load (the driver's registry is) */
74
77
  load?(app: A, leg: Leg, rest: string): Source | null;
78
+ /** the module's source is the runtime the whole bundle needs (its marks): on a build's server
79
+ * leg it loads once every other module has compiled ({@link Leg.compiled}) */
80
+ settles?: true;
75
81
  /** what the realm module re-exports from it, by its name there */
76
82
  exports?: RealmExports<keyof M & string>;
77
83
  /** (type only: never set) */
@@ -0,0 +1,21 @@
1
+ /** The part of a bundler's plugin context the wait reads (Rolldown's, Vite's build). */
2
+ export interface CompiledGraph {
3
+ getModuleIds(): Iterable<string>;
4
+ getModuleInfo(id: string): {
5
+ code: string | null;
6
+ } | null;
7
+ resolve(source: string): Promise<{
8
+ external?: unknown;
9
+ } | null>;
10
+ load(options: {
11
+ id: string;
12
+ resolveDependencies: boolean;
13
+ }): Promise<unknown>;
14
+ }
15
+ /**
16
+ * Resolves once the bundler has compiled every module of the bundle (loaded, transformed, its
17
+ * imports resolved), dynamic imports and their imports included, but the ones `skip` names: the
18
+ * modules that wait here themselves, which would otherwise wait on each other. Each round loads
19
+ * what the last one found, until a round finds nothing new. An external module is never loaded.
20
+ */
21
+ export declare function graph_compiled(graph: CompiledGraph, skip: (id: string) => boolean): Promise<void>;