@ogygia/compiler 0.0.0 → 0.14.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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -1
  3. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  4. package/dist/app-spec.d.ts +18 -0
  5. package/dist/app-spec.js +22 -0
  6. package/dist/blank-styles.d.ts +1 -0
  7. package/dist/blank-styles.js +24 -0
  8. package/dist/bom.d.ts +2 -0
  9. package/dist/bom.js +7 -0
  10. package/dist/build-cache.d.ts +13 -0
  11. package/dist/build-cache.js +65 -0
  12. package/dist/ctx.d.ts +238 -0
  13. package/dist/ctx.js +221 -0
  14. package/dist/dev/css-scope.d.ts +16 -0
  15. package/dist/dev/css-scope.js +32 -0
  16. package/dist/dev/dev-hmr.d.ts +24 -0
  17. package/dist/dev/dev-hmr.js +51 -0
  18. package/dist/dev/hmr.d.ts +34 -0
  19. package/dist/dev/hmr.js +52 -0
  20. package/dist/driver.d.ts +349 -0
  21. package/dist/driver.js +1401 -0
  22. package/dist/exports/index.d.ts +77 -0
  23. package/dist/exports/index.js +349 -0
  24. package/dist/exports/parse.d.ts +65 -0
  25. package/dist/exports/parse.js +251 -0
  26. package/dist/fouc-css.d.ts +102 -0
  27. package/dist/fouc-css.js +304 -0
  28. package/dist/free-vars.d.ts +32 -0
  29. package/dist/free-vars.js +454 -0
  30. package/dist/fs.d.ts +31 -0
  31. package/dist/fs.js +82 -0
  32. package/dist/ids.d.ts +49 -0
  33. package/dist/ids.js +52 -0
  34. package/dist/index.d.ts +23 -0
  35. package/dist/index.js +23 -0
  36. package/dist/kit.d.ts +204 -0
  37. package/dist/kit.js +554 -0
  38. package/dist/leg.d.ts +34 -0
  39. package/dist/leg.js +26 -0
  40. package/dist/link/analyses.d.ts +26 -0
  41. package/dist/link/analyses.js +237 -0
  42. package/dist/link/build-output.d.ts +47 -0
  43. package/dist/link/build-output.js +168 -0
  44. package/dist/link/caps.d.ts +32 -0
  45. package/dist/link/caps.js +39 -0
  46. package/dist/link/context-detect.d.ts +28 -0
  47. package/dist/link/context-detect.js +143 -0
  48. package/dist/link/emit-gate.d.ts +43 -0
  49. package/dist/link/emit-gate.js +55 -0
  50. package/dist/link/file-token.d.ts +11 -0
  51. package/dist/link/file-token.js +15 -0
  52. package/dist/link/island-deps.d.ts +183 -0
  53. package/dist/link/island-deps.js +802 -0
  54. package/dist/link/location-map.d.ts +24 -0
  55. package/dist/link/location-map.js +51 -0
  56. package/dist/link/own-reach.d.ts +15 -0
  57. package/dist/link/own-reach.js +188 -0
  58. package/dist/link/registry-stub.d.ts +50 -0
  59. package/dist/link/registry-stub.js +163 -0
  60. package/dist/link/relocations.d.ts +79 -0
  61. package/dist/link/relocations.js +198 -0
  62. package/dist/link/router-css.d.ts +38 -0
  63. package/dist/link/router-css.js +124 -0
  64. package/dist/link/runtime-entry.d.ts +103 -0
  65. package/dist/link/runtime-entry.js +183 -0
  66. package/dist/link/server-manifest.d.ts +25 -0
  67. package/dist/link/server-manifest.js +102 -0
  68. package/dist/link/transport.d.ts +42 -0
  69. package/dist/link/transport.js +91 -0
  70. package/dist/macros/dollar.d.ts +24 -0
  71. package/dist/macros/dollar.js +397 -0
  72. package/dist/macros/pipeline.d.ts +50 -0
  73. package/dist/macros/pipeline.js +133 -0
  74. package/dist/macros/source.d.ts +9 -0
  75. package/dist/macros/source.js +115 -0
  76. package/dist/macros/store.d.ts +22 -0
  77. package/dist/macros/store.js +217 -0
  78. package/dist/macros/wire.d.ts +17 -0
  79. package/dist/macros/wire.js +116 -0
  80. package/dist/map-chain.d.ts +18 -0
  81. package/dist/map-chain.js +42 -0
  82. package/dist/messages.d.ts +672 -0
  83. package/dist/messages.js +938 -0
  84. package/dist/ownership-stamps.d.ts +9 -0
  85. package/dist/ownership-stamps.js +101 -0
  86. package/dist/parse/oxc.d.ts +36 -0
  87. package/dist/parse/oxc.js +35 -0
  88. package/dist/parse/roots.d.ts +4 -0
  89. package/dist/parse/roots.js +27 -0
  90. package/dist/parse/scan.d.ts +65 -0
  91. package/dist/parse/scan.js +297 -0
  92. package/dist/parse/svelte-ast.d.ts +7 -0
  93. package/dist/parse/svelte-ast.js +99 -0
  94. package/dist/program.d.ts +140 -0
  95. package/dist/program.js +304 -0
  96. package/dist/queries.d.ts +105 -0
  97. package/dist/queries.js +326 -0
  98. package/dist/region/emit.d.ts +168 -0
  99. package/dist/region/emit.js +292 -0
  100. package/dist/region/identity.d.ts +32 -0
  101. package/dist/region/identity.js +46 -0
  102. package/dist/region/ir.d.ts +56 -0
  103. package/dist/region/ir.js +0 -0
  104. package/dist/region/marked-imports.d.ts +27 -0
  105. package/dist/region/marked-imports.js +265 -0
  106. package/dist/region/transform.d.ts +189 -0
  107. package/dist/region/transform.js +1565 -0
  108. package/dist/scan-facts.d.ts +36 -0
  109. package/dist/scan-facts.js +54 -0
  110. package/dist/script-request.d.ts +1 -0
  111. package/dist/script-request.js +33 -0
  112. package/dist/splice.d.ts +11 -0
  113. package/dist/splice.js +33 -0
  114. package/dist/transportables.d.ts +23 -0
  115. package/dist/transportables.js +144 -0
  116. package/dist/virtual/core.d.ts +158 -0
  117. package/dist/virtual/core.js +588 -0
  118. package/dist/virtual/resolver.d.ts +56 -0
  119. package/dist/virtual/resolver.js +249 -0
  120. package/dist/virtual/specifier.d.ts +10 -0
  121. package/dist/virtual/specifier.js +6 -0
  122. package/dist/virtual/table.d.ts +118 -0
  123. package/dist/virtual/table.js +54 -0
  124. package/dist/virtual/types.d.ts +17 -0
  125. package/dist/virtual/types.js +100 -0
  126. package/dist/virtual/value-names.d.ts +2 -0
  127. package/dist/virtual/value-names.js +18 -0
  128. package/dist/vite/definers.d.ts +16 -0
  129. package/dist/vite/definers.js +69 -0
  130. package/dist/vite/dev-maps.d.ts +34 -0
  131. package/dist/vite/dev-maps.js +91 -0
  132. package/dist/vite/index.d.ts +21 -0
  133. package/dist/vite/index.js +874 -0
  134. package/dist/vite/kit-dirs.d.ts +6 -0
  135. package/dist/vite/kit-dirs.js +53 -0
  136. package/dist/vite/late-island.d.ts +11 -0
  137. package/dist/vite/late-island.js +19 -0
  138. package/dist/vite/lazy-files.d.ts +2 -0
  139. package/dist/vite/lazy-files.js +72 -0
  140. package/dist/vite/options.d.ts +195 -0
  141. package/dist/vite/options.js +72 -0
  142. package/dist/vite/package-files.d.ts +3 -0
  143. package/dist/vite/package-files.js +88 -0
  144. package/dist/vite/paths.d.ts +14 -0
  145. package/dist/vite/paths.js +37 -0
  146. package/dist/vite/plugin-api.d.ts +316 -0
  147. package/dist/vite/plugin-api.js +328 -0
  148. package/dist/vite/session.d.ts +28 -0
  149. package/dist/vite/session.js +43 -0
  150. package/dist/vite/sourcemaps.d.ts +19 -0
  151. package/dist/vite/sourcemaps.js +75 -0
  152. package/dist/vite/style-preprocess.d.ts +2 -0
  153. package/dist/vite/style-preprocess.js +84 -0
  154. package/dist/vite/svelte-entries.d.ts +4 -0
  155. package/dist/vite/svelte-entries.js +10 -0
  156. package/package.json +87 -12
@@ -0,0 +1,36 @@
1
+ import { Queries, Query } from "./queries.js";
2
+ /** What the scan reads of one file. */
3
+ export interface FileFacts {
4
+ /** It crosses Kit's wire: a `.remote` file, or a `region`/`site`/content import. */
5
+ readonly crosses_wire: boolean;
6
+ /** It defines a transportable class (the eager-registration manifest lists it). */
7
+ readonly transportable: boolean;
8
+ /** Its import specifiers (the router CSS closure walks them). */
9
+ readonly specs: readonly string[];
10
+ /** It renders pages outside Kit's routes (`b.pageModules()`): a router CSS root. */
11
+ readonly router: boolean;
12
+ }
13
+ /**
14
+ * THE SCAN'S FACTS, as queries (./queries.ts). Each scanned file has its facts (what the prescan
15
+ * reads of it: does it cross Kit's wire, define a transportable class, render router pages); the
16
+ * app-wide answers the virtual modules bake (the transportable modules, whether anything crosses the
17
+ * wire, the router roots and their import specs) are folds over every scanned file's facts, in scan
18
+ * order. A file's facts are set when the prescan reads it and again when dev transforms it (null
19
+ * when it is deleted); each fold is computed again only when a fact it reads changed, so dev and a
20
+ * cold start give the same answers (test/scan-facts.test.ts).
21
+ */
22
+ export declare class ScanFacts {
23
+ #private;
24
+ readonly db: Queries;
25
+ /** How many files the scan ever read: the first that many of its scan order. */
26
+ readonly files: Query<string, number>;
27
+ readonly facts: Query<string, FileFacts | null>;
28
+ readonly transportable_modules: Query<string, ReadonlySet<string>>;
29
+ readonly wire_crossers: Query<string, ReadonlySet<string>>;
30
+ readonly router_modules: Query<string, ReadonlySet<string>>;
31
+ readonly module_specs: Query<string, ReadonlyMap<string, readonly string[]>>;
32
+ /** A file's facts, or none (`null`: it is deleted). A new file goes last in scan order. */
33
+ set(full: string, next: FileFacts | null): void;
34
+ /** Whether the scan read this file. */
35
+ has(full: string): boolean;
36
+ }
@@ -0,0 +1,54 @@
1
+ import { Queries, derived, input } from "./queries.js";
2
+ // src/scan-facts.ts
3
+ const ALL = "all";
4
+ const all = () => ALL;
5
+ const own = (k) => k;
6
+ /**
7
+ * THE SCAN'S FACTS, as queries (./queries.ts). Each scanned file has its facts (what the prescan
8
+ * reads of it: does it cross Kit's wire, define a transportable class, render router pages); the
9
+ * app-wide answers the virtual modules bake (the transportable modules, whether anything crosses the
10
+ * wire, the router roots and their import specs) are folds over every scanned file's facts, in scan
11
+ * order. A file's facts are set when the prescan reads it and again when dev transforms it (null
12
+ * when it is deleted); each fold is computed again only when a fact it reads changed, so dev and a
13
+ * cold start give the same answers (test/scan-facts.test.ts).
14
+ */
15
+ var ScanFacts = class {
16
+ db = new Queries("scan facts");
17
+ #order = [];
18
+ #at = /* @__PURE__ */ new Set();
19
+ /** How many files the scan ever read: the first that many of its scan order. */
20
+ files = input("scanned files", all, () => 0);
21
+ facts = input("file facts", own, () => null);
22
+ transportable_modules = this.#fold("transportable modules", (each) => new Set(each.filter(([, f]) => f.transportable).map(([file]) => file)));
23
+ wire_crossers = this.#fold("wire crossers", (each) => new Set(each.filter(([, f]) => f.crosses_wire).map(([file]) => file)));
24
+ router_modules = this.#fold("router modules", (each) => new Set(each.filter(([, f]) => f.router).map(([file]) => file)));
25
+ module_specs = this.#fold("module specs", (each) => new Map(each.filter(([, f]) => f.specs.length > 0).map(([file, f]) => [file, f.specs])));
26
+ /** A file's facts, or none (`null`: it is deleted). A new file goes last in scan order. */
27
+ set(full, next) {
28
+ const at = this.#at;
29
+ if (next !== null && !at.has(full)) {
30
+ at.add(full);
31
+ this.#order.push(full);
32
+ this.db.set(this.files, ALL, this.#order.length);
33
+ }
34
+ if (at.has(full)) this.db.set(this.facts, full, next);
35
+ }
36
+ /** Whether the scan read this file. */
37
+ has(full) {
38
+ return this.db.get(this.facts, full) !== null;
39
+ }
40
+ #fold(name, make) {
41
+ const order = this.#order;
42
+ const files = this.files;
43
+ const facts = this.facts;
44
+ return derived(name, all, (cx) => {
45
+ const each = [];
46
+ for (const f of order.slice(0, cx.get(files, ALL))) {
47
+ const facts_of = cx.get(facts, f);
48
+ if (facts_of) each.push([f, facts_of]);
49
+ }
50
+ return make(each);
51
+ });
52
+ }
53
+ };
54
+ export { ScanFacts };
@@ -0,0 +1 @@
1
+ export declare function is_script_request(id: string): boolean;
@@ -0,0 +1,33 @@
1
+ // src/script-request.ts
2
+ const NON_SCRIPT_FLAGS = /* @__PURE__ */ new Set([
3
+ "raw",
4
+ "url",
5
+ "inline",
6
+ "worker",
7
+ "sharedworker",
8
+ "direct"
9
+ ]);
10
+ const SCRIPT_LANGS = /* @__PURE__ */ new Set([
11
+ "js",
12
+ "ts",
13
+ "jsx",
14
+ "tsx",
15
+ "mjs",
16
+ "cjs",
17
+ "mts",
18
+ "cts"
19
+ ]);
20
+ function is_script_request(id) {
21
+ const q = id.indexOf("?");
22
+ if (q === -1) return true;
23
+ const end = id.indexOf("#", q);
24
+ for (const part of id.slice(q + 1, end === -1 ? void 0 : end).split("&")) {
25
+ const eq = part.indexOf("=");
26
+ const key = eq === -1 ? part : part.slice(0, eq);
27
+ if (NON_SCRIPT_FLAGS.has(key)) return false;
28
+ if (key === "type" && part.slice(eq + 1) !== "script") return false;
29
+ if (key.startsWith("lang.") && !SCRIPT_LANGS.has(key.slice(5))) return false;
30
+ }
31
+ return true;
32
+ }
33
+ export { is_script_request };
@@ -0,0 +1,11 @@
1
+ import { EncodedSourceMap } from "@jridgewell/remapping";
2
+ /** One replacement of `src.slice(start, end)` by `text`: an insert when `start === end`. */
3
+ export interface Edit {
4
+ start: number;
5
+ end: number;
6
+ text: string;
7
+ }
8
+ /** `src` with non-overlapping `edits` applied, in start order (inserts at one place in the given order). */
9
+ export declare function splice_text(src: string, edits: readonly Edit[]): string;
10
+ /** The map from `splice_text(src, edits)` back to `src` (named `source`). */
11
+ export declare function splice_map(src: string, edits: readonly Edit[], source: string): EncodedSourceMap;
package/dist/splice.js ADDED
@@ -0,0 +1,33 @@
1
+ import MagicString from "magic-string";
2
+ // src/splice.ts
3
+ /** `src` with non-overlapping `edits` applied, in start order (inserts at one place in the given order). */
4
+ function splice_text(src, edits) {
5
+ if (!edits.length) return src;
6
+ const sorted = [...edits].sort((a, b) => a.start - b.start);
7
+ let out = "";
8
+ let last = 0;
9
+ for (const e of sorted) {
10
+ out += src.slice(last, e.start) + e.text;
11
+ last = e.end;
12
+ }
13
+ return out + src.slice(last);
14
+ }
15
+ /** The map from `splice_text(src, edits)` back to `src` (named `source`). */
16
+ function splice_map(src, edits, source) {
17
+ const s = new MagicString(src);
18
+ for (const e of [...edits].sort((a, b) => a.start - b.start)) if (e.start === e.end) {
19
+ if (e.text) s.appendLeft(e.start, e.text);
20
+ } else if (e.text) s.overwrite(e.start, e.end, e.text);
21
+ else s.remove(e.start, e.end);
22
+ const map = s.generateMap({
23
+ hires: true,
24
+ source
25
+ });
26
+ return {
27
+ version: 3,
28
+ sources: map.sources,
29
+ names: map.names,
30
+ mappings: map.mappings
31
+ };
32
+ }
33
+ export { splice_map, splice_text };
@@ -0,0 +1,23 @@
1
+ import { Edit } from "./splice.js";
2
+ /**
3
+ * Does this module define an exported class carrying a transportable codec? Used to build the
4
+ * class loaders, the eager-registration manifest and the `wire` mark, so islands never need a
5
+ * manual `import` of the class. The registration's own question ({@link appendTransportRegistrations}),
6
+ * asked of raw or rewritten source alike, so the two cannot disagree.
7
+ *
8
+ * Over-approximates: a module it cannot parse may still define one, so it counts (a miss loses the
9
+ * loader and the wire mark; an extra loads one module). Test: transportables-prescan.test.ts.
10
+ */
11
+ export declare function moduleHasTransportable(code: string, id_n: string): boolean;
12
+ /**
13
+ * Append `__register_transportable` calls for every exported class in this module. Returns
14
+ * the augmented code, or null when there is no exported class. Append-only — the module's
15
+ * existing sourcemap stays valid.
16
+ */
17
+ export declare function appendTransportRegistrations(code: string, id_n: string, root: string): string | null;
18
+ /** True if a `.svelte` file's `<script module>` exports a transportable class. */
19
+ export declare function svelteModuleHasTransportable(code: string, id_n: string): boolean;
20
+ /** Inject registration for a `.svelte` module script's exported transportable classes. */
21
+ export declare function appendSvelteModuleRegistrations(code: string, id_n: string, root: string): string | null;
22
+ /** The insert `appendSvelteModuleRegistrations` makes to `code`, or `null` when it makes none. */
23
+ export declare function svelte_module_registration(code: string, id_n: string, root: string): Edit | null;
@@ -0,0 +1,144 @@
1
+ import { parse_module } from "./parse/oxc.js";
2
+ import { component_blocks } from "./parse/scan.js";
3
+ import { OgygiaError } from "./messages.js";
4
+ import { splice_text } from "./splice.js";
5
+ import path from "node:path";
6
+ // src/transportables.ts
7
+ const CLASS_KW = /\bclass\b/;
8
+ const SVELTE_EXT = /\.svelte$/;
9
+ const GENERATED_MARK = "// ogygia: generated registration (transportable codecs)";
10
+ function parse_body(code, id_n) {
11
+ const { program } = parse_module(code, id_n);
12
+ return program ? program.body ?? [] : null;
13
+ }
14
+ function exportedWireClasses(code, id_n) {
15
+ const body = parse_body(code, id_n);
16
+ return body ? exportedWireClassesFromBody(body, code, id_n) : [];
17
+ }
18
+ function exportedWireClassesFromBody(body, code, id_n) {
19
+ const classNodes = /* @__PURE__ */ new Map();
20
+ const exported = /* @__PURE__ */ new Map();
21
+ for (const node of body) if (node.type === "ClassDeclaration" && node.id) classNodes.set(node.id.name, node);
22
+ else if (node.type === "ExportNamedDeclaration") {
23
+ if (node.declaration?.type === "ClassDeclaration" && node.declaration.id?.name) {
24
+ classNodes.set(node.declaration.id.name, node.declaration);
25
+ exported.set(node.declaration.id.name, node.declaration.id.name);
26
+ }
27
+ if (!node.source) {
28
+ for (const spec of node.specifiers ?? []) if (spec.local?.type === "Identifier") exported.set(spec.local.name, spec.local.name);
29
+ }
30
+ } else if (node.type === "ExportDefaultDeclaration") {
31
+ const decl = node.declaration;
32
+ if (decl?.type === "ClassDeclaration" && decl.id?.name) {
33
+ classNodes.set(decl.id.name, decl);
34
+ exported.set("default", decl.id.name);
35
+ } else if (decl?.type === "ClassDeclaration" && classHasWireMember(decl)) throw new OgygiaError("wire_class_anonymous", {
36
+ file: id_n,
37
+ line: code.slice(0, decl.start ?? 0).split("\n").length
38
+ });
39
+ else if (decl?.type === "Identifier" && decl.name) exported.set("default", decl.name);
40
+ }
41
+ return [...exported].flatMap(([tag, local]) => {
42
+ const cls = classNodes.get(local);
43
+ return cls && classHasWireMember(cls) ? [{
44
+ tag,
45
+ local
46
+ }] : [];
47
+ });
48
+ }
49
+ function classHasWireMember(cls) {
50
+ return (cls.body?.body ?? []).some((m) => {
51
+ if (m.static !== true) return false;
52
+ if (m.computed === true && isWireSymbolKey(m.key)) return true;
53
+ return isWireMacroCall(m.value);
54
+ });
55
+ }
56
+ function isWireSymbolKey(key) {
57
+ const k = key;
58
+ if (k?.type !== "CallExpression") return false;
59
+ const callee = k.callee;
60
+ if (callee?.type !== "MemberExpression" || callee.object?.name !== "Symbol" || callee.property?.name !== "for") return false;
61
+ const arg = k.arguments?.[0];
62
+ return arg?.type === "Literal" && arg.value === "ogygia.wire";
63
+ }
64
+ function isWireMacroCall(value) {
65
+ const v = value;
66
+ if (v?.type !== "CallExpression") return false;
67
+ const callee = v.callee;
68
+ if (callee?.type !== "MemberExpression" || callee.computed || callee.property?.name !== "wire") return false;
69
+ const og = callee.object;
70
+ if (og?.type !== "MemberExpression" || og.computed || og.property?.name !== "og") return false;
71
+ const meta = og.object;
72
+ return meta?.type === "MetaProperty" && meta.meta?.name === "import" && meta.property?.name === "meta";
73
+ }
74
+ /**
75
+ * Does this module define an exported class carrying a transportable codec? Used to build the
76
+ * class loaders, the eager-registration manifest and the `wire` mark, so islands never need a
77
+ * manual `import` of the class. The registration's own question ({@link appendTransportRegistrations}),
78
+ * asked of raw or rewritten source alike, so the two cannot disagree.
79
+ *
80
+ * Over-approximates: a module it cannot parse may still define one, so it counts (a miss loses the
81
+ * loader and the wire mark; an extra loads one module). Test: transportables-prescan.test.ts.
82
+ */
83
+ function moduleHasTransportable(code, id_n) {
84
+ if (!CLASS_KW.test(code) || !code.includes("static")) return false;
85
+ const body = parse_body(code, id_n);
86
+ return body === null || exportedWireClassesFromBody(body, code, id_n).length > 0;
87
+ }
88
+ /**
89
+ * Append `__register_transportable` calls for every exported class in this module. Returns
90
+ * the augmented code, or null when there is no exported class. Append-only — the module's
91
+ * existing sourcemap stays valid.
92
+ */
93
+ function appendTransportRegistrations(code, id_n, root) {
94
+ if (code.includes(GENERATED_MARK)) return null;
95
+ if (!CLASS_KW.test(code)) return null;
96
+ const body = parse_body(code, id_n);
97
+ if (!body) return null;
98
+ const classes = exportedWireClassesFromBody(body, code, id_n);
99
+ if (classes.length === 0) return null;
100
+ return `${code + registrationBlock(path.relative(root, id_n).split("\\").join("/"), classes)}\n`;
101
+ }
102
+ function registrationBlock(rel, classes) {
103
+ const lines = [
104
+ "",
105
+ GENERATED_MARK,
106
+ `import { __register_transportable as __OGT } from 'ogygia/internal/register';`
107
+ ];
108
+ for (const { tag, local } of classes) lines.push(`__OGT(${JSON.stringify(`${rel}#${tag}`)}, ${local});`);
109
+ return lines.join("\n");
110
+ }
111
+ function moduleScriptOf(code) {
112
+ const mod = component_blocks(code).find((b) => b.kind === "script" && b.module);
113
+ return mod ? {
114
+ body: code.slice(mod.start, mod.end),
115
+ injectAt: mod.end
116
+ } : null;
117
+ }
118
+ /** True if a `.svelte` file's `<script module>` exports a transportable class. */
119
+ function svelteModuleHasTransportable(code, id_n) {
120
+ if (!code.includes("module") || !CLASS_KW.test(code)) return false;
121
+ const mod = moduleScriptOf(code);
122
+ if (!mod) return false;
123
+ return moduleHasTransportable(mod.body, id_n.replace(SVELTE_EXT, ".svelte.ts"));
124
+ }
125
+ /** Inject registration for a `.svelte` module script's exported transportable classes. */
126
+ function appendSvelteModuleRegistrations(code, id_n, root) {
127
+ const edit = svelte_module_registration(code, id_n, root);
128
+ return edit ? splice_text(code, [edit]) : null;
129
+ }
130
+ /** The insert `appendSvelteModuleRegistrations` makes to `code`, or `null` when it makes none. */
131
+ function svelte_module_registration(code, id_n, root) {
132
+ if (code.includes(GENERATED_MARK) || !CLASS_KW.test(code)) return null;
133
+ const mod = moduleScriptOf(code);
134
+ if (!mod) return null;
135
+ const exported = exportedWireClasses(mod.body, id_n.replace(SVELTE_EXT, ".svelte.ts"));
136
+ if (exported.length === 0) return null;
137
+ const rel = path.relative(root, id_n).split("\\").join("/");
138
+ return {
139
+ start: mod.injectAt,
140
+ end: mod.injectAt,
141
+ text: `\n${registrationBlock(rel, exported)}\n`
142
+ };
143
+ }
144
+ export { appendSvelteModuleRegistrations, appendTransportRegistrations, moduleHasTransportable, svelteModuleHasTransportable, svelte_module_registration };
@@ -0,0 +1,158 @@
1
+ import { CompileCtx } from "../ctx.js";
2
+ import { ClientRealmFile, ServerRealm } from "../link/caps.js";
3
+ import { Program } from "../program.js";
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";
6
+ /** What core's entries read off the compile session (the driver implements it). */
7
+ export interface CoreApp {
8
+ readonly ctx: CompileCtx;
9
+ readonly program: Program;
10
+ prescan(): void;
11
+ runtime_chunk_url(): string;
12
+ region_names(): Record<string, string>;
13
+ router_css_roots(): string[];
14
+ /** the app's Kit routes directory */
15
+ routes_dir(): string;
16
+ /** the plugins listed beside `ogygia()` */
17
+ plugins(): CorePlugins;
18
+ }
19
+ /** The plugins listed beside `ogygia()`: their server halves, browser halves, and the route
20
+ * `config` keys they claim. */
21
+ export interface CorePlugins {
22
+ server: readonly ServerRealm[];
23
+ client: readonly ClientRealmFile[];
24
+ route_config: readonly string[];
25
+ }
26
+ /** Which part of the session each field is (table.ts `Parts`): what a dev change to it reloads. */
27
+ export declare const CORE_PARTS: Parts<CoreApp>;
28
+ type Value<T extends object> = ValueEntry<CoreApp, T>;
29
+ type Family<M = Record<never, never>> = FamilyEntry<CoreApp, M>;
30
+ /** A core module (its path under `src/`, no extension) → the built file next to the runtime. */
31
+ export declare const core_path: (app: CoreApp, module: string) => string;
32
+ export declare const runtime: Family;
33
+ export declare const runtime_entry: Family;
34
+ export declare const runtime_flags: Family<RuntimeFlagsModule>;
35
+ export declare const hydrate_features: Family<HydrateFeaturesModule>;
36
+ export declare const devtools_meta: Value<DevtoolsMetaModule>;
37
+ export declare const transport: Family<TransportModule>;
38
+ export declare const transportables: Family<TransportablesModule>;
39
+ export declare const hmr: Family;
40
+ export declare const devtools_boot: Family;
41
+ export declare const runtime_url: Value<RuntimeUrlModule>;
42
+ /** The dev HMR bridge's served URL: the dev server's `__OGYGIA_DEV_HMR_URL__` (`''` in a build, so
43
+ * the script that loads it folds out of every leg: src/dev-hmr-url.ts). */
44
+ export declare const DEV_HMR_URL: string;
45
+ export declare const devtools_boot_url: Value<DevtoolsBootUrlModule>;
46
+ export declare const region_deps: Family<RegionDepsModule>;
47
+ export declare const router_css: Family;
48
+ export declare const secret: Value<SecretModule>;
49
+ export declare const sign: RequestEntry<CoreApp>;
50
+ export declare const request_event: RequestEntry<CoreApp>;
51
+ export declare const region_endpoint: RequestEntry<CoreApp>;
52
+ export declare const kit_wire: Family<KitWireModule>;
53
+ export declare const rate_limit: Value<RateLimitModule>;
54
+ export declare const server_plugins: Family<ServerPluginsModule>;
55
+ export declare const profiler_maps: Value<ProfilerMapsModule>;
56
+ export declare const router_config: Value<RouterConfigModule>;
57
+ export declare const session_cookie: Value<SessionCookieModule>;
58
+ export declare const region_ttl: Value<RegionTtlModule>;
59
+ export declare const route_csr: Value<RouteCsrModule>;
60
+ export declare const route_config: Family<RouteConfigModule>;
61
+ export declare const server_manifest: Family<ServerManifestModule>;
62
+ export declare const server_regions: Family<ServerRegionsModule>;
63
+ export declare const kit_transport: Family<KitTransportModule>;
64
+ export declare const transportables_eager: Family;
65
+ /** a csr=false route host's registry import on the client leg: its names as `undefined` */
66
+ export declare const registry_stub: Family;
67
+ export declare const region_entry: Family;
68
+ export declare const region_binding: Family;
69
+ export declare const region_lazy: Family;
70
+ export declare const region_wrapper: Family;
71
+ export declare const fouc_css: Family;
72
+ export declare const fouc_scoped: Family;
73
+ export declare const client_binding_stub: Family;
74
+ /** What core's switches read: the plugin's options, resolved at config time. */
75
+ export interface ConstantInput {
76
+ continuity_forms: boolean;
77
+ server_delta: boolean;
78
+ devtools: boolean;
79
+ devtools_lazy: boolean;
80
+ rules: boolean;
81
+ client_plugins: boolean;
82
+ /** the runtime hooks some plugin's browser half subscribes to */
83
+ hooks: readonly RuntimeHookName[];
84
+ kit_major: number | null;
85
+ version: string;
86
+ dev_server: boolean;
87
+ }
88
+ type Constant<T extends boolean | number | string | null = boolean> = ConstantEntry<ConstantInput, T>;
89
+ /** form continuity is on (`router: { forms }`) */
90
+ export declare const continuity_forms: Constant;
91
+ /** server-delta navigation is on (`router.serverDelta`, default off) */
92
+ export declare const server_delta: Constant;
93
+ /** the event layer: off unless a plugin asked (`b.events()`); off, every `if (DEVTOOLS) emit(…)`
94
+ * folds out and the bus tree-shakes away */
95
+ export declare const devtools_gate: Constant;
96
+ /** a build with devtools on: the dock and the page measuring wait until someone opens it */
97
+ export declare const devtools_lazy: Constant;
98
+ /** ogygia's rules on itself, in a build made for e2e (`OGYGIA_RULES=1`); dev has them always */
99
+ 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
+ /** the app's Kit major (2, 3), or null when none was found (kit-paths.ts) */
141
+ export declare const kit_major: Constant<VirtualConstants["__OGYGIA_KIT_MAJOR__"]>;
142
+ /** the installed ogygia's version, which the runtime discloses (`window.__ogygia.v`) */
143
+ export declare const version: Constant<VirtualConstants["__OGYGIA_VERSION__"]>;
144
+ /** the dev HMR bridge's served URL on the dev server; '' in a build, so its script folds out */
145
+ export declare const dev_hmr_url: Constant<VirtualConstants["__OGYGIA_DEV_HMR_URL__"]>;
146
+ /** Core's constants. */
147
+ export declare const CORE_CONSTANTS: readonly Constant<boolean | number | string | null>[];
148
+ /** The `define` map of core's constants, from the resolved options. */
149
+ export declare const core_defines: (input: ConstantInput) => Record<string, string>;
150
+ /** The session the value entries' names are probed with at core build time (types.ts
151
+ * `probe_value_names`): the dev server, no plugins, the browser leg, so no `from` reads disk. */
152
+ export declare const CORE_PROBE: {
153
+ app: CoreApp;
154
+ leg: Leg;
155
+ };
156
+ /** Core's entries, in the table's order. */
157
+ export declare const CORE_VIRTUALS: readonly Entry<CoreApp>[];
158
+ export {};