@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Puru Vijayvargia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,64 @@
1
1
  # @ogygia/compiler
2
2
 
3
- Placeholder that reserves this name for [ogygia](https://ogygiajs.dev). The first real release is 0.14.
3
+ The compiler of [ogygia](https://ogygiajs.dev). It rewrites your marked imports into regions, links
4
+ the build, and holds the Vite plugin.
5
+
6
+ Published, but apps do not install it directly. They install `ogygia`, whose `ogygia/vite` is this
7
+ package's `./vite`, and whose `ogygia/internal/compiler` is this package's main entry. Plugin
8
+ packages (`@ogygia/router`, `@ogygia/content`, `@ogygia/flags`, `@ogygia/federation`,
9
+ `@ogygia/devtools`, `@ogygia/postrender`, `@ogygia/rewrite`, …) and `@ogygia/cli` import it to hook
10
+ into the build.
11
+
12
+ ## Entries
13
+
14
+ | import | what it is |
15
+ | ----------------------- | ------------------------------------------------------------------------------------------------ |
16
+ | `@ogygia/compiler` | the source-to-source engine: the region transform, `Compiler`, `Program`, `CompileCtx`. Internal |
17
+ | `@ogygia/compiler/vite` | the `ogygia()` Vite plugin, and `definePlugin()` for plugin packages |
18
+ | `@ogygia/compiler/ids` | the virtual module ids and naming helpers. Safe to load in the browser |
19
+
20
+ Nothing here is a stable public API on its own. The public face is `ogygia/vite`.
21
+
22
+ ## Use
23
+
24
+ An app lists the plugin through `ogygia`:
25
+
26
+ ```ts
27
+ // vite.config.ts
28
+ import { sveltekit } from '@sveltejs/kit/vite';
29
+ import { ogygia } from 'ogygia/vite';
30
+ import { defineConfig } from 'vite';
31
+
32
+ export default defineConfig({ plugins: [ogygia(), sveltekit()] });
33
+ ```
34
+
35
+ A plugin package declares itself with `definePlugin()` (this is `@ogygia/router`'s whole plugin):
36
+
37
+ ```ts
38
+ import { definePlugin, type OgygiaPlugin } from '@ogygia/compiler/vite';
39
+
40
+ export function router(): OgygiaPlugin {
41
+ return definePlugin({
42
+ name: '@ogygia/router',
43
+ build(b) {
44
+ b.pageModules({ importers: ['@ogygia/router'] });
45
+ }
46
+ });
47
+ }
48
+ ```
49
+
50
+ The plugin API is internal and can change between releases.
51
+
52
+ ## Work on it
53
+
54
+ ```bash
55
+ pnpm --filter @ogygia/compiler build # writes the virtual-module types, then tsdown
56
+ pnpm --filter @ogygia/compiler test # vitest
57
+ pnpm --filter @ogygia/compiler check # tsc on src and test, then vitest
58
+ ```
59
+
60
+ Some tests import the built `dist/` (the plugin runs from it), so build before you test. Bench files
61
+ are in `bench/`.
62
+
63
+ More: [Writing a plugin](https://ogygiajs.dev/docs/core/plugins),
64
+ [`internal/notes/compiler-refactor.md`](../../internal/notes/compiler-refactor.md).
@@ -0,0 +1,5 @@
1
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js
2
+ function _taggedTemplateLiteral(e, t) {
3
+ return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
4
+ }
5
+ export { _taggedTemplateLiteral as default };
@@ -0,0 +1,18 @@
1
+ /** An app alias, as Vite's `resolve.alias` lists it (Kit's `$lib` and `kit.alias` among them). */
2
+ export interface AppAlias {
3
+ find: string | RegExp;
4
+ replacement: string;
5
+ }
6
+ export interface AppSpecCtx {
7
+ readonly root: string;
8
+ readonly libDir: string;
9
+ readonly alias?: readonly AppAlias[];
10
+ /** The compiler's file system (`CompileCtx.fs.stat`). Absent: a root-absolute path is a file-system path. */
11
+ readonly stat?: (abs: string) => "file" | "dir" | null;
12
+ }
13
+ /**
14
+ * The absolute path `spec` names from `importer` (a file path, possibly without its extension):
15
+ * `$lib/…`, a relative path, a root-absolute `/…` (under the app root when its first directory is
16
+ * there, as Vite tries it; else the file-system path), or an app alias. Null: a package specifier.
17
+ */
18
+ export declare function resolve_app_spec(spec: string, importer: string, ctx: AppSpecCtx): string | null;
@@ -0,0 +1,22 @@
1
+ import path from "node:path";
2
+ // src/app-spec.ts
3
+ /**
4
+ * The absolute path `spec` names from `importer` (a file path, possibly without its extension):
5
+ * `$lib/…`, a relative path, a root-absolute `/…` (under the app root when its first directory is
6
+ * there, as Vite tries it; else the file-system path), or an app alias. Null: a package specifier.
7
+ */
8
+ function resolve_app_spec(spec, importer, ctx) {
9
+ if (spec === "$lib" || spec.startsWith("$lib/")) return path.join(ctx.libDir, spec === "$lib" ? "" : spec.slice(5));
10
+ if (spec.startsWith(".")) return path.resolve(path.dirname(importer), spec);
11
+ if (spec.startsWith("/")) {
12
+ if (spec.startsWith(`${ctx.root}/`) || !ctx.root) return path.normalize(spec);
13
+ const top = spec.slice(1).split("/")[0];
14
+ return top && ctx.stat?.(path.join(ctx.root, top)) != null ? path.join(ctx.root, spec) : path.normalize(spec);
15
+ }
16
+ for (const a of ctx.alias ?? []) if (typeof a.find === "string") {
17
+ if (spec === a.find) return a.replacement;
18
+ if (spec.startsWith(`${a.find}/`)) return a.replacement + spec.slice(a.find.length);
19
+ } else if (a.find.test(spec)) return spec.replace(a.find, a.replacement);
20
+ return null;
21
+ }
22
+ export { resolve_app_spec };
@@ -0,0 +1 @@
1
+ export declare function blank_styles(code: string): string;
@@ -0,0 +1,24 @@
1
+ import { component_blocks } from "./parse/scan.js";
2
+ // src/blank-styles.ts
3
+ const MAY_STYLE = /<style/i;
4
+ function blank_styles(code) {
5
+ if (!MAY_STYLE.test(code)) return code;
6
+ let out = "";
7
+ let at = 0;
8
+ for (const b of component_blocks(code)) {
9
+ if (b.kind !== "style") continue;
10
+ out += code.slice(at, b.start);
11
+ let run = 0;
12
+ for (let k = b.start; k < b.end; k++) {
13
+ const c = code[k];
14
+ if (c === "\n" || c === "\r") {
15
+ out += " ".repeat(run) + c;
16
+ run = 0;
17
+ } else run++;
18
+ }
19
+ out += " ".repeat(run);
20
+ at = b.end;
21
+ }
22
+ return at === 0 ? code : out + code.slice(at);
23
+ }
24
+ export { blank_styles };
package/dist/bom.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** `source` without a leading byte-order mark (the same string when there is none). */
2
+ export declare function strip_bom(source: string): string;
package/dist/bom.js ADDED
@@ -0,0 +1,7 @@
1
+ // src/bom.ts
2
+ const BOM = 65279;
3
+ /** `source` without a leading byte-order mark (the same string when there is none). */
4
+ function strip_bom(source) {
5
+ return source.charCodeAt(0) === BOM ? source.slice(1) : source;
6
+ }
7
+ export { strip_bom };
@@ -0,0 +1,13 @@
1
+ /** Point the cache at a project (the Vite plugin calls this with the app root at config time). */
2
+ export declare function configure_build_cache(project_root: string): void;
3
+ /** Test hook: force the cache root (or `null` to disable, `undefined` to re-probe). */
4
+ export declare function __set_build_cache_root(dir: string | null | undefined): void;
5
+ export declare class BuildCache<T> {
6
+ readonly namespace: string;
7
+ constructor(namespace: string);
8
+ /** This namespace's DIRECTORY, for artifact trees the consumer manages itself (git checkouts).
9
+ * Returns the ensured absolute path, or `null` when the cache is unavailable. */
10
+ dir(): string | null;
11
+ get(key: string): T | null;
12
+ set(key: string, value: T): void;
13
+ }
@@ -0,0 +1,65 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ // src/build-cache.ts
4
+ let root;
5
+ let configured;
6
+ /** Point the cache at a project (the Vite plugin calls this with the app root at config time). */
7
+ function configure_build_cache(project_root) {
8
+ if (configured === project_root) return;
9
+ configured = project_root;
10
+ root = void 0;
11
+ }
12
+ /** Test hook: force the cache root (or `null` to disable, `undefined` to re-probe). */
13
+ function __set_build_cache_root(dir) {
14
+ root = dir;
15
+ if (dir === void 0) configured = void 0;
16
+ }
17
+ function cache_root() {
18
+ if (root !== void 0) return root;
19
+ try {
20
+ const d = path.join(configured ?? process.cwd(), "node_modules", ".ogygia");
21
+ fs.mkdirSync(d, { recursive: true });
22
+ root = d;
23
+ } catch {
24
+ root = null;
25
+ }
26
+ return root;
27
+ }
28
+ var BuildCache = class {
29
+ namespace;
30
+ constructor(namespace) {
31
+ this.namespace = namespace;
32
+ }
33
+ /** This namespace's DIRECTORY, for artifact trees the consumer manages itself (git checkouts).
34
+ * Returns the ensured absolute path, or `null` when the cache is unavailable. */
35
+ dir() {
36
+ const r = cache_root();
37
+ if (!r) return null;
38
+ try {
39
+ const d = path.join(r, this.namespace);
40
+ fs.mkdirSync(d, { recursive: true });
41
+ return d;
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+ get(key) {
47
+ const d = this.dir();
48
+ if (!d) return null;
49
+ try {
50
+ return JSON.parse(fs.readFileSync(path.join(d, `${key}.json`), "utf8"));
51
+ } catch {
52
+ return null;
53
+ }
54
+ }
55
+ set(key, value) {
56
+ const d = this.dir();
57
+ if (!d) return;
58
+ try {
59
+ const tmp = path.join(d, `${key}.${process.pid}.tmp`);
60
+ fs.writeFileSync(tmp, JSON.stringify(value));
61
+ fs.renameSync(tmp, path.join(d, `${key}.json`));
62
+ } catch {}
63
+ }
64
+ };
65
+ export { BuildCache, __set_build_cache_root, configure_build_cache };
package/dist/ctx.d.ts ADDED
@@ -0,0 +1,238 @@
1
+ import { Fs } from "./fs.js";
2
+ import { KitDirs, Routes } from "./kit.js";
3
+ import { ClientRealmFile, ServerRealm } from "./link/caps.js";
4
+ import { AliasEntry, PluginMacro } from "./macros/pipeline.js";
5
+ import { AppSpecCtx } from "./app-spec.js";
6
+ import { PreprocessCss } from "./fouc-css.js";
7
+ import { ImportKeys } from "./region/transform.js";
8
+ /** The part of a seed-shaping plugin the compiler calls (the whole of it: vite/plugin-api.ts
9
+ * `PageReads`): each module the transform reads, and each module's answer when chunks are finished. */
10
+ export interface PageReadsSink {
11
+ module(id: string, code: string): void;
12
+ keys(id: string): ReadonlySet<string> | "unknown" | null;
13
+ }
14
+ /** A plugin's reader of the prescan (`b.prescan`): the modules it asked for, as the prescan reads
15
+ * them, and the end of a build. */
16
+ export interface PrescanHook {
17
+ /** Only modules that import one of these specifiers are handed over. */
18
+ readonly imports: readonly string[];
19
+ /** One module the prescan read: its absolute path, its identity (package-relative in a package's
20
+ * declared files, else relative to the app root; POSIX), its source. */
21
+ module(m: {
22
+ readonly file: string;
23
+ readonly rel: string;
24
+ readonly code: string;
25
+ }): void;
26
+ /** A `vite build` wrote its client output (the last leg, on the main thread). */
27
+ written?(): void;
28
+ }
29
+ /** One dependency package's declared compile surface (`"ogygia": { "files": […] }` in ITS
30
+ * package.json) — produced by the plugin's discovery (`vite/package-files.ts`), consumed here
31
+ * type-only: the node:fs/glob work lives plugin-side.
32
+ * All paths are posix REALPATHS — Vite resolves ids through symlinks (pnpm), so gate matching
33
+ * must speak real paths or every check silently misses. */
34
+ export interface PackageScan {
35
+ /** The package's published name — the stable identity prefix for its regions. */
36
+ name: string;
37
+ /** realpath of the package root. */
38
+ root: string;
39
+ /** Declared bare directories (prefix-matched, so files added mid-dev still count). */
40
+ dirs: string[];
41
+ /** Individually declared / glob-expanded files. */
42
+ files: string[];
43
+ }
44
+ export interface CompileCtxInit {
45
+ root: string;
46
+ /** the app's Kit dirs, as the plugin read them (default: `default_kit_dirs(root)`) */
47
+ kit_dirs?: KitDirs;
48
+ base: string;
49
+ /** SvelteKit `config.kit.appDir` (default `_app`) — the dir Kit emits AND serves its immutable
50
+ * assets under. ogygia's runtime + island chunks MUST land here too: a custom appDir otherwise
51
+ * 404s them (Kit's adapter only maps `<appDir>/immutable/*` to the immutable-cache route). Read
52
+ * from Kit's `__SVELTEKIT_APP_DIR__` build define; `_app` when Kit isn't present (standalone).
53
+ * NOTE: only the app-internal PATH lives here. `base` / `paths.assets` (CDN) resolution is Kit's
54
+ * `asset()`'s job — `Region.svelte` runs every baked entry / runtime URL through it at SSR — so
55
+ * ogygia never bakes a base into these URLs (doing so double-applies it). */
56
+ app_dir: string;
57
+ libDir: string;
58
+ /** A plugin asked for the build's measurement data (`b.measure()`: the profiler) — embedded maps,
59
+ * per-island detail. */
60
+ measure: boolean;
61
+ /** The server halves of the app's plugins (module path + options), in app order — baked into
62
+ * `ogygia:server/server-plugins`. Optional (default none). */
63
+ server_plugins?: readonly ServerRealm[];
64
+ /** The browser halves of the app's plugins (name, absolute module path), in app order —
65
+ * imported by the runtime's boot. Optional (default none). */
66
+ client_plugins?: readonly ClientRealmFile[];
67
+ /** The keys the plugins claim inside Kit's `config` page option (`b.routeConfig`) — read from the
68
+ * route files and baked into `ogygia:server/route-config`. Optional (default none). */
69
+ route_config?: readonly string[];
70
+ /** A plugin asked island entries to keep their foreign-hydrate exports (`b.foreignHydrate()`:
71
+ * another app's runtime wakes this app's islands, and this app's pages carry other apps' regions:
72
+ * the `foreign` runtime mark). Optional (default off). */
73
+ foreign_hydrate?: boolean;
74
+ /** Dependency packages that DECLARED their ogygia compile surface (`"ogygia": { "files": […] }`
75
+ * in THEIR package.json) — prescanned + transformed like app source, node_modules gates lifted
76
+ * for exactly these paths. Optional (default none). */
77
+ pkg_scan?: PackageScan[];
78
+ /** PAGE MODULES (`b.pageModules()`): modules that render pages outside Kit's routes, whose reachable
79
+ * components get router-css. `page_importers`: a compiled module importing one of these specifiers
80
+ * is one; `page_files`: absolute paths that are page modules themselves. Optional (default none). */
81
+ page_importers?: readonly string[];
82
+ page_files?: readonly string[];
83
+ is_dev: boolean;
84
+ id_salt: string;
85
+ visibleMargin: string | undefined;
86
+ presets: Record<string, unknown>;
87
+ import_keys: ImportKeys;
88
+ /** Resolved Vite aliases (an island's closure walk; every plugin macro gets them). */
89
+ resolve_alias: readonly AliasEntry[];
90
+ /** The plugin's preprocessor for a component's CSS (fouc-css.ts `scoped_component_css`). Absent:
91
+ * a host with no bundler, which compiles the source as it is. */
92
+ preprocess_css?: PreprocessCss;
93
+ /** The plugins' `import.meta.og.*` macros (`b.macro`), in plugin order. Optional (default none). */
94
+ macros?: readonly PluginMacro[];
95
+ /** The plugin that reads which `page.data` keys a module reads (`b.pageReads`), handed each
96
+ * module the build compiles. Optional (default none: every region gets all of `page.data`). */
97
+ page_reads?: PageReadsSink | null;
98
+ /** The plugins' prescan readers (`b.prescan`), in plugin order. Optional (default none). */
99
+ prescans?: readonly PrescanHook[];
100
+ /** The names of the plugins listed beside `ogygia()` (`'@ogygia/flags'`). Optional (default none). */
101
+ plugins?: readonly string[];
102
+ /** ogygia's own package root — the `auto_brand` macro skips ogygia source (it can't self-register). */
103
+ pkg_root: string;
104
+ /** Per-build HMAC material baked into the SSR-only `ogygia:server/secret`. */
105
+ build_secret: string;
106
+ /** Region-endpoint rate limit (SSR-only), `{ max: 0 }` when disabled. */
107
+ rate_limit: {
108
+ max: number;
109
+ windowMs: number;
110
+ };
111
+ /** Cookie name sealed into the region MAC, or '' when unbound. */
112
+ session_cookie: string;
113
+ /** Capability-URL TTL in seconds. */
114
+ region_ttl: number;
115
+ /** How long after expiry an anonymous capability still renews, in seconds (`0` = never). */
116
+ renew_window: number;
117
+ /** Router on (app-wide). `false` tree-shakes the feature out. */
118
+ router_enabled: boolean;
119
+ /** View Transitions on for SPA navs. */
120
+ router_view_transitions: boolean;
121
+ /** The app's `src/hooks.client.{ts,js}` absolute path, or null — its `init` runs on boot for
122
+ * csr=false pages (see runtime/client-hooks.ts). */
123
+ client_hooks?: string | null;
124
+ /** Package-internal absolute paths the emit inlines into generated virtual sources. */
125
+ runtime_dir: string;
126
+ runtime_hash: string;
127
+ /** Kit's internal wire-protocol module (deep-imported by absolute path), or null: none found. */
128
+ kit_wire_path?: string | null;
129
+ client_binding_stub_file: string;
130
+ /** `$app/*` → on-disk client-shim path map (island modules under csr=false). */
131
+ app_shims: Record<string, string>;
132
+ /** `command === 'build'` — gates the transform-time deterministic island-chunk emit. */
133
+ is_build: boolean;
134
+ /** Core's event emits compiled in (a plugin's `b.events()`: devtools). Bakes the standalone dock
135
+ * boot for csr=true pages into `ogygia:server/devtools-boot-url`. */
136
+ devtools: boolean;
137
+ /** Where the app's files are read from (./fs.ts). Optional (default the disk). */
138
+ fs?: Fs;
139
+ }
140
+ export declare class CompileCtx {
141
+ #private;
142
+ /** Every read of the app's files goes through here (./fs.ts). */
143
+ readonly fs: Fs;
144
+ /** Kit's route worlds and route config, read through `fs` (one cache set per file system). */
145
+ readonly routes: Routes;
146
+ readonly root: string;
147
+ /** The app's Kit dirs (`kit.files.routes`, `kit.outDir`). */
148
+ readonly kit_dirs: KitDirs;
149
+ readonly base: string;
150
+ readonly app_dir: string;
151
+ readonly libDir: string;
152
+ readonly pkg_scan: PackageScan[];
153
+ readonly page_importers: readonly string[];
154
+ readonly page_files: readonly string[];
155
+ readonly measure: boolean;
156
+ readonly server_plugins: readonly ServerRealm[];
157
+ readonly client_plugins: readonly ClientRealmFile[];
158
+ readonly route_config: readonly string[];
159
+ readonly foreign_hydrate: boolean;
160
+ readonly is_dev: boolean;
161
+ readonly id_salt: string;
162
+ readonly visibleMargin: string | undefined;
163
+ readonly presets: Record<string, unknown>;
164
+ readonly import_keys: ImportKeys;
165
+ readonly resolve_alias: readonly AliasEntry[];
166
+ /** What an app import specifier is resolved against (app-spec.ts): the root, `$lib`, the aliases. */
167
+ get app_spec(): AppSpecCtx;
168
+ readonly preprocess_css: PreprocessCss | undefined;
169
+ readonly macros: readonly PluginMacro[];
170
+ readonly page_reads: PageReadsSink | null;
171
+ readonly prescans: readonly PrescanHook[];
172
+ readonly plugins: readonly string[];
173
+ readonly pkg_root: string;
174
+ readonly build_secret: string;
175
+ readonly rate_limit: {
176
+ max: number;
177
+ windowMs: number;
178
+ };
179
+ readonly session_cookie: string;
180
+ readonly region_ttl: number;
181
+ readonly renew_window: number;
182
+ readonly router_enabled: boolean;
183
+ readonly router_view_transitions: boolean;
184
+ readonly client_hooks: string | null;
185
+ readonly runtime_dir: string;
186
+ readonly runtime_hash: string;
187
+ readonly kit_wire_path: string | null;
188
+ readonly client_binding_stub_file: string;
189
+ readonly app_shims: Record<string, string>;
190
+ readonly is_build: boolean;
191
+ readonly devtools: boolean;
192
+ constructor(init: CompileCtxInit);
193
+ /** True when `code` carries an ogygia `with { … }` island hint (gates node_modules `.svelte`). */
194
+ has_island_hint(code: string): boolean;
195
+ /** True when a JS module has a real `import … with { <mark key>: … }` declaration. The hint
196
+ * above is a text sniff, so it also matches a comment, a string or generated code that merely
197
+ * mentions `with { wake }`; this parses. A module that does not parse counts as marked, so a
198
+ * warning that depends on it errs toward speaking. */
199
+ has_marked_import(code: string, id: string): boolean;
200
+ /** True when `id` is inside a dependency's DECLARED `ogygia.files` surface — those files are
201
+ * prescanned + transformed exactly like app source (the node_modules gates lift for them). */
202
+ in_declared_pkg(id: string): boolean;
203
+ /** True for the app's own source (anything not installed: the app, its workspace packages,
204
+ * virtual modules) and for a dependency's declared `ogygia.files`. */
205
+ is_own_source(id: string): boolean;
206
+ /** Install-independent region identity for a file under a declared package: `<name>/<rel>`.
207
+ * Store paths carry version + peer-resolution hashes (`node_modules/.pnpm/pkg@1.2.3(...)`),
208
+ * so a root-relative identity would change per install/machine and prod HTML would stop
209
+ * matching its chunks. Returns `null` for anything not under a declared package root. */
210
+ pkg_identity(abs: string): string | null;
211
+ /** The runtime's feature set, as a name segment: the prescan's feature hash, and a trailing `h` when
212
+ * the app has `hooks.client.ts` (the runtime entry then dynamic-imports it). Empty until prescan
213
+ * runs. Both the stable name and the content-hashed file carry it, so a name says which runtime. */
214
+ runtime_features(program_feature_hash: string): string;
215
+ /** The runtime's STABLE name (`RUNTIME_HASH` ⊕ its features): its identity — the key the handoff
216
+ * maps to the content-hashed file the page loads (a name, not a file). Computed here
217
+ * (not the caller) so both build legs name it identically. `program_feature_hash` is the scan's
218
+ * `Scan.feature_hash`, threaded in by the caller so this stays a pure naming function. */
219
+ runtime_chunk_filename(program_feature_hash: string): string;
220
+ /** App-internal URL of the runtime chunk (leading slash + appDir; NO base). SSR bakes it as the
221
+ * `<script src>`, then `asset()` prepends base / the assets CDN at render time. */
222
+ runtime_chunk_url(program_feature_hash: string): string;
223
+ /** Output filename for a hydrate island chunk (under the app dir; an on-disk build path). */
224
+ island_chunk_filename(iid: string): string;
225
+ /** App-internal URL of a hydrate island chunk (leading slash + appDir; NO base — `asset()` adds it). */
226
+ island_public_url(iid: string): string;
227
+ /** Read a file as UTF-8, or `null` if it can't be read (the transform tolerates missing deps). */
228
+ read_file(abs: string): string | null;
229
+ /** Virtual island ENTRY module id for an island id. */
230
+ island_virtual_id(iid: string): string;
231
+ /** Virtual wrapper `.svelte` module id for an island id. */
232
+ wrapper_virtual_id(iid: string): string;
233
+ /** Dev URL for a dynamic `import(entry)` of a virtual island module. Base-LESS, exactly like the
234
+ * prod island/runtime URLs and the dev runtime URL: `Region.svelte` runs it through Kit's `asset()`
235
+ * at SSR, which is the sole base authority. Baking `base` here would double it (Vite dev serves
236
+ * `/@id/…` UNDER base, and `asset()` already adds that prefix). */
237
+ dev_url_for(virtualPath: string): string;
238
+ }