@ogygia/compiler 0.0.0 → 0.14.1
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/LICENSE +21 -0
- package/README.md +62 -1
- package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
- package/dist/app-spec.d.ts +18 -0
- package/dist/app-spec.js +22 -0
- package/dist/blank-styles.d.ts +1 -0
- package/dist/blank-styles.js +24 -0
- package/dist/bom.d.ts +2 -0
- package/dist/bom.js +7 -0
- package/dist/build-cache.d.ts +13 -0
- package/dist/build-cache.js +65 -0
- package/dist/ctx.d.ts +238 -0
- package/dist/ctx.js +221 -0
- package/dist/dev/css-scope.d.ts +16 -0
- package/dist/dev/css-scope.js +32 -0
- package/dist/dev/dev-hmr.d.ts +24 -0
- package/dist/dev/dev-hmr.js +51 -0
- package/dist/dev/hmr.d.ts +34 -0
- package/dist/dev/hmr.js +52 -0
- package/dist/driver.d.ts +351 -0
- package/dist/driver.js +1402 -0
- package/dist/exports/index.d.ts +77 -0
- package/dist/exports/index.js +349 -0
- package/dist/exports/parse.d.ts +65 -0
- package/dist/exports/parse.js +251 -0
- package/dist/fouc-css.d.ts +112 -0
- package/dist/fouc-css.js +314 -0
- package/dist/free-vars.d.ts +32 -0
- package/dist/free-vars.js +454 -0
- package/dist/fs.d.ts +31 -0
- package/dist/fs.js +82 -0
- package/dist/ids.d.ts +49 -0
- package/dist/ids.js +52 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/kit.d.ts +204 -0
- package/dist/kit.js +554 -0
- package/dist/leg.d.ts +34 -0
- package/dist/leg.js +26 -0
- package/dist/link/analyses.d.ts +26 -0
- package/dist/link/analyses.js +237 -0
- package/dist/link/build-output.d.ts +47 -0
- package/dist/link/build-output.js +168 -0
- package/dist/link/caps.d.ts +32 -0
- package/dist/link/caps.js +39 -0
- package/dist/link/context-detect.d.ts +28 -0
- package/dist/link/context-detect.js +143 -0
- package/dist/link/emit-gate.d.ts +43 -0
- package/dist/link/emit-gate.js +55 -0
- package/dist/link/file-token.d.ts +11 -0
- package/dist/link/file-token.js +15 -0
- package/dist/link/island-deps.d.ts +183 -0
- package/dist/link/island-deps.js +802 -0
- package/dist/link/location-map.d.ts +24 -0
- package/dist/link/location-map.js +51 -0
- package/dist/link/own-reach.d.ts +15 -0
- package/dist/link/own-reach.js +188 -0
- package/dist/link/registry-stub.d.ts +50 -0
- package/dist/link/registry-stub.js +163 -0
- package/dist/link/relocations.d.ts +79 -0
- package/dist/link/relocations.js +204 -0
- package/dist/link/router-css.d.ts +38 -0
- package/dist/link/router-css.js +124 -0
- package/dist/link/runtime-entry.d.ts +103 -0
- package/dist/link/runtime-entry.js +183 -0
- package/dist/link/server-manifest.d.ts +25 -0
- package/dist/link/server-manifest.js +102 -0
- package/dist/link/transport.d.ts +42 -0
- package/dist/link/transport.js +91 -0
- package/dist/macros/dollar.d.ts +24 -0
- package/dist/macros/dollar.js +397 -0
- package/dist/macros/pipeline.d.ts +50 -0
- package/dist/macros/pipeline.js +133 -0
- package/dist/macros/source.d.ts +9 -0
- package/dist/macros/source.js +115 -0
- package/dist/macros/store.d.ts +22 -0
- package/dist/macros/store.js +217 -0
- package/dist/macros/wire.d.ts +17 -0
- package/dist/macros/wire.js +116 -0
- package/dist/map-chain.d.ts +18 -0
- package/dist/map-chain.js +42 -0
- package/dist/messages.d.ts +673 -0
- package/dist/messages.js +938 -0
- package/dist/ownership-stamps.d.ts +11 -0
- package/dist/ownership-stamps.js +112 -0
- package/dist/parse/oxc.d.ts +36 -0
- package/dist/parse/oxc.js +35 -0
- package/dist/parse/roots.d.ts +4 -0
- package/dist/parse/roots.js +27 -0
- package/dist/parse/scan.d.ts +65 -0
- package/dist/parse/scan.js +297 -0
- package/dist/parse/svelte-ast.d.ts +7 -0
- package/dist/parse/svelte-ast.js +99 -0
- package/dist/program.d.ts +140 -0
- package/dist/program.js +304 -0
- package/dist/queries.d.ts +105 -0
- package/dist/queries.js +326 -0
- package/dist/region/emit.d.ts +168 -0
- package/dist/region/emit.js +292 -0
- package/dist/region/identity.d.ts +32 -0
- package/dist/region/identity.js +46 -0
- package/dist/region/ir.d.ts +56 -0
- package/dist/region/ir.js +0 -0
- package/dist/region/marked-imports.d.ts +27 -0
- package/dist/region/marked-imports.js +265 -0
- package/dist/region/transform.d.ts +189 -0
- package/dist/region/transform.js +1565 -0
- package/dist/scan-facts.d.ts +36 -0
- package/dist/scan-facts.js +54 -0
- package/dist/script-request.d.ts +1 -0
- package/dist/script-request.js +33 -0
- package/dist/splice.d.ts +11 -0
- package/dist/splice.js +33 -0
- package/dist/transportables.d.ts +23 -0
- package/dist/transportables.js +144 -0
- package/dist/virtual/core.d.ts +158 -0
- package/dist/virtual/core.js +588 -0
- package/dist/virtual/resolver.d.ts +62 -0
- package/dist/virtual/resolver.js +265 -0
- package/dist/virtual/specifier.d.ts +10 -0
- package/dist/virtual/specifier.js +6 -0
- package/dist/virtual/table.d.ts +120 -0
- package/dist/virtual/table.js +54 -0
- package/dist/virtual/types.d.ts +17 -0
- package/dist/virtual/types.js +100 -0
- package/dist/virtual/value-names.d.ts +2 -0
- package/dist/virtual/value-names.js +18 -0
- package/dist/vite/definers.d.ts +16 -0
- package/dist/vite/definers.js +69 -0
- package/dist/vite/dev-maps.d.ts +34 -0
- package/dist/vite/dev-maps.js +91 -0
- package/dist/vite/index.d.ts +21 -0
- package/dist/vite/index.js +890 -0
- package/dist/vite/kit-dirs.d.ts +6 -0
- package/dist/vite/kit-dirs.js +53 -0
- package/dist/vite/late-island.d.ts +8 -0
- package/dist/vite/late-island.js +18 -0
- package/dist/vite/lazy-files.d.ts +2 -0
- package/dist/vite/lazy-files.js +72 -0
- package/dist/vite/options.d.ts +195 -0
- package/dist/vite/options.js +72 -0
- package/dist/vite/package-files.d.ts +3 -0
- package/dist/vite/package-files.js +88 -0
- package/dist/vite/paths.d.ts +16 -0
- package/dist/vite/paths.js +39 -0
- package/dist/vite/plugin-api.d.ts +316 -0
- package/dist/vite/plugin-api.js +328 -0
- package/dist/vite/route-watch.d.ts +15 -0
- package/dist/vite/route-watch.js +32 -0
- package/dist/vite/session.d.ts +28 -0
- package/dist/vite/session.js +43 -0
- package/dist/vite/sourcemaps.d.ts +19 -0
- package/dist/vite/sourcemaps.js +75 -0
- package/dist/vite/style-preprocess.d.ts +2 -0
- package/dist/vite/style-preprocess.js +84 -0
- package/dist/vite/svelte-entries.d.ts +4 -0
- package/dist/vite/svelte-entries.js +10 -0
- package/dist/vite/svelte-options.d.ts +20 -0
- package/dist/vite/svelte-options.js +22 -0
- package/package.json +87 -12
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { OgygiaError } from "../messages.js";
|
|
2
|
+
import { OGYGIA_SCHEME } from "./specifier.js";
|
|
3
|
+
import { RESOLVED } from "../ids.js";
|
|
4
|
+
import { realm_exports, specifier_of, value_names, write_value } from "./table.js";
|
|
5
|
+
import { input } from "../queries.js";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
// src/virtual/resolver.ts
|
|
8
|
+
const PART = input("session part", (part) => part, () => 0);
|
|
9
|
+
const REALM_NAMED_IMPORT_G = /\b(import|export)\s*\{([^}]*)\}\s*from\s*(['"])ogygia:(server|boot|region|dev)\3;?/g;
|
|
10
|
+
/** The files that imported `start`, nearest first, each the first importer not yet named, back to
|
|
11
|
+
* one nothing imports (or a cycle): `` `a.ts` ← `b.svelte` ``, relative to `root`. Virtual ids are
|
|
12
|
+
* passed through, never named. */
|
|
13
|
+
function import_chain(start, importers_of, root) {
|
|
14
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15
|
+
const named = [];
|
|
16
|
+
for (let id = start; id !== void 0 && !seen.has(id);) {
|
|
17
|
+
seen.add(id);
|
|
18
|
+
if (!id.startsWith("\0")) named.push(`\`${path.relative(root, id.split("?")[0])}\``);
|
|
19
|
+
id = importers_of(id)?.find((importer) => !seen.has(importer));
|
|
20
|
+
}
|
|
21
|
+
return named.join(" ← ");
|
|
22
|
+
}
|
|
23
|
+
/** The realms each leg may import: the server leg server and region, the browser leg boot and
|
|
24
|
+
* region; dev only on the dev server. */
|
|
25
|
+
function realm_allowed(realm, env) {
|
|
26
|
+
if (realm === "region") return true;
|
|
27
|
+
if (realm === "dev") return env.dev;
|
|
28
|
+
return realm === (env.ssr ? "server" : "boot");
|
|
29
|
+
}
|
|
30
|
+
function check_realm(id, realm, env) {
|
|
31
|
+
if (!realm_allowed(realm, env)) throw new OgygiaError("virtual_wrong_realm", {
|
|
32
|
+
id,
|
|
33
|
+
realm,
|
|
34
|
+
leg: env.ssr ? "server" : "browser",
|
|
35
|
+
via: env.via?.()
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** Is this specifier (or resolved id) in ogygia's virtual namespace? */
|
|
39
|
+
const is_virtual_specifier = (source) => source.startsWith("ogygia:") || source.startsWith(`\0ogygia:`);
|
|
40
|
+
/** The one resolver over the virtual-module table: a specifier → its resolved id, a resolved id →
|
|
41
|
+
* its source, and a dev change → the modules it invalidates. */
|
|
42
|
+
var VirtualTable = class {
|
|
43
|
+
/** specifier or alias → its one-module entry */
|
|
44
|
+
#single = /* @__PURE__ */ new Map();
|
|
45
|
+
/** resolved id → its one-module entry */
|
|
46
|
+
#by_resolved = /* @__PURE__ */ new Map();
|
|
47
|
+
/** prefix → its family (prefixes never nest) */
|
|
48
|
+
#prefixes = [];
|
|
49
|
+
/** a core module (its path under `src/`, no extension) → the built file the bundler imports */
|
|
50
|
+
#core_path;
|
|
51
|
+
/** each value entry's export names (generated: ./value-names.ts) */
|
|
52
|
+
#names;
|
|
53
|
+
/** the session's fields → the part each one is */
|
|
54
|
+
#parts;
|
|
55
|
+
/** the session's queries: a load is a reader of them (`watch`), the parts among them */
|
|
56
|
+
#db;
|
|
57
|
+
/** resolved id and leg → what that leg's last load read: one id is loaded on both legs and can
|
|
58
|
+
* read different things on each (bounded by the modules the table serves, twice) */
|
|
59
|
+
#reads = /* @__PURE__ */ new Map();
|
|
60
|
+
constructor(entries, core_path, names, parts, db) {
|
|
61
|
+
this.#core_path = core_path;
|
|
62
|
+
this.#names = names;
|
|
63
|
+
this.#parts = parts;
|
|
64
|
+
this.#db = db;
|
|
65
|
+
for (const e of entries) {
|
|
66
|
+
if (e.kind === "constant") continue;
|
|
67
|
+
const spec = specifier_of(e);
|
|
68
|
+
if (this.#single.has(spec) || this.#prefixes.some(([p]) => p === spec)) throw new OgygiaError("virtual_duplicate", { id: spec });
|
|
69
|
+
if (e.kind === "family" && e.parse) this.#prefixes.push([spec, e]);
|
|
70
|
+
else {
|
|
71
|
+
this.#single.set(spec, e);
|
|
72
|
+
this.#by_resolved.set(RESOLVED(spec), e);
|
|
73
|
+
}
|
|
74
|
+
const names = this.#realms[e.realm] ??= /* @__PURE__ */ new Map();
|
|
75
|
+
for (const [name, own] of realm_exports(e, this.#names)) {
|
|
76
|
+
if (names.has(name)) throw new OgygiaError("virtual_duplicate", { id: `${e.realm}:${name}` });
|
|
77
|
+
names.set(name, [own, specifier_of(e)]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** realm → its realm module's names → [the entry module's own name, the entry module's id] */
|
|
82
|
+
#realms = {};
|
|
83
|
+
/** The realm a realm module's specifier (`ogygia:server`) or resolved id names, or null. */
|
|
84
|
+
#realm_of(id) {
|
|
85
|
+
const bare = id.startsWith("\0") ? id.slice(1) : id;
|
|
86
|
+
if (!bare.startsWith("ogygia:")) return null;
|
|
87
|
+
const realm = bare.slice(OGYGIA_SCHEME.length);
|
|
88
|
+
return this.#realms[realm] ? realm : null;
|
|
89
|
+
}
|
|
90
|
+
/** A realm module's source: one named re-export per name, from the module that has it. */
|
|
91
|
+
#realm_source(realm) {
|
|
92
|
+
const by_module = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const [name, [own, module]] of this.#realms[realm]) {
|
|
94
|
+
const list = by_module.get(module) ?? [];
|
|
95
|
+
list.push(own === name ? name : `${own} as ${name}`);
|
|
96
|
+
by_module.set(module, list);
|
|
97
|
+
}
|
|
98
|
+
const rank = (module) => {
|
|
99
|
+
const kind = this.#by_resolved.get(RESOLVED(module))?.kind;
|
|
100
|
+
if (kind === "value") return 0;
|
|
101
|
+
return kind === "request" ? 2 : 1;
|
|
102
|
+
};
|
|
103
|
+
return [...by_module].sort(([a], [b]) => rank(a) - rank(b)).map(([module, names]) => `export { ${names.join(", ")} } from ${JSON.stringify(module)};`).join("\n");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A specifier → its resolved id. `undefined`: not a table id, or a family whose ids the driver
|
|
107
|
+
* resolves itself (an island's entry, a registry stub). An id in the namespace that nothing
|
|
108
|
+
* declares fails here with `virtual_unknown`.
|
|
109
|
+
*/
|
|
110
|
+
resolve(source, env) {
|
|
111
|
+
if (source.startsWith("\0")) return this.#realm_of(source) || this.#by_resolved.has(source) ? source : void 0;
|
|
112
|
+
const realm = this.#realm_of(source);
|
|
113
|
+
if (realm) {
|
|
114
|
+
if (env) check_realm(source, realm, env);
|
|
115
|
+
return RESOLVED(source);
|
|
116
|
+
}
|
|
117
|
+
const single = this.#single.get(source);
|
|
118
|
+
if (single) {
|
|
119
|
+
if (single.kind === "family" && !single.load) return void 0;
|
|
120
|
+
if (env) check_realm(source, single.realm, env);
|
|
121
|
+
return RESOLVED(source);
|
|
122
|
+
}
|
|
123
|
+
const family = this.#family_of(source);
|
|
124
|
+
if (family) {
|
|
125
|
+
if (env) check_realm(source, family.realm, env);
|
|
126
|
+
return family.load ? RESOLVED(source) : void 0;
|
|
127
|
+
}
|
|
128
|
+
const q = source.indexOf("?");
|
|
129
|
+
if (is_virtual_specifier(source) && !(q !== -1 && this.claims(source.slice(0, q)))) throw new OgygiaError("virtual_unknown", { id: source });
|
|
130
|
+
}
|
|
131
|
+
/** Does a family claim this specifier (resolved or not)? */
|
|
132
|
+
claims(source) {
|
|
133
|
+
const bare = source.startsWith("\0") ? source.slice(1) : source;
|
|
134
|
+
return this.#single.has(bare) || this.#family_of(bare) !== void 0;
|
|
135
|
+
}
|
|
136
|
+
#family_of(source) {
|
|
137
|
+
for (const [prefix, family] of this.#prefixes) if (source.startsWith(prefix) && family.parse(source.slice(prefix.length)) !== null) return family;
|
|
138
|
+
}
|
|
139
|
+
/** A resolved id → its module source; `null`: not a module this table loads. Records what the
|
|
140
|
+
* load read (the session's parts, and every query it read), for {@link moved}. */
|
|
141
|
+
load(id, app, leg) {
|
|
142
|
+
const browser = {
|
|
143
|
+
ssr: false,
|
|
144
|
+
dev: true,
|
|
145
|
+
via: leg.via
|
|
146
|
+
};
|
|
147
|
+
const [wrong] = leg.ssr ? [] : this.misplaced([id], browser);
|
|
148
|
+
if (wrong) check_realm(id, wrong[1], browser);
|
|
149
|
+
const key = `${leg.ssr ? "ssr" : "client"} ${id}`;
|
|
150
|
+
const { value, reads } = this.#db.watch((cx) => this.#load(id, tracked(app, this.#parts, cx), leg));
|
|
151
|
+
if (value === null) this.#reads.delete(key);
|
|
152
|
+
else this.#reads.set(key, {
|
|
153
|
+
id,
|
|
154
|
+
reads
|
|
155
|
+
});
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
/** A dev change to `part` (one not yet a query: the registry, the marks, the routes, ...). */
|
|
159
|
+
move(part) {
|
|
160
|
+
this.#db.set(PART, part, this.#db.revision + 1);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Every module that something its last load read has changed under, which the caller
|
|
164
|
+
* invalidates: a part that moved, or a query whose answer is different now. Each is named once;
|
|
165
|
+
* its next load records its reads afresh.
|
|
166
|
+
*/
|
|
167
|
+
moved() {
|
|
168
|
+
const out = /* @__PURE__ */ new Set();
|
|
169
|
+
for (const [key, { id, reads }] of this.#reads) {
|
|
170
|
+
if (!this.#db.moved(reads)) continue;
|
|
171
|
+
out.add(id);
|
|
172
|
+
this.#reads.delete(key);
|
|
173
|
+
}
|
|
174
|
+
return [...out];
|
|
175
|
+
}
|
|
176
|
+
#load(id, app, leg) {
|
|
177
|
+
const realm = this.#realm_of(id);
|
|
178
|
+
if (realm) return this.#realm_source(realm);
|
|
179
|
+
const e = this.#by_resolved.get(id);
|
|
180
|
+
if (e) {
|
|
181
|
+
if (e.kind === "value") {
|
|
182
|
+
const data = e.from(app, leg);
|
|
183
|
+
const names = value_names(e, this.#names);
|
|
184
|
+
const keys = Object.keys(data);
|
|
185
|
+
let same = keys.length === names.length;
|
|
186
|
+
for (const k of keys) same &&= names.includes(k);
|
|
187
|
+
if (!same) throw new OgygiaError("virtual_names_stale", { id: specifier_of(e) });
|
|
188
|
+
return names.map((name) => `export const ${name} = ${write_value(data[name])};`).join("\n");
|
|
189
|
+
}
|
|
190
|
+
if (e.kind === "request") {
|
|
191
|
+
const from = "core" in e.module ? this.#core_path(app, e.module.core) : e.module.package;
|
|
192
|
+
return `export { ${[...new Set(Object.values(e.exports))].join(", ")} } from ${JSON.stringify(from)};`;
|
|
193
|
+
}
|
|
194
|
+
return e.load?.(app, leg, "") ?? null;
|
|
195
|
+
}
|
|
196
|
+
if (!id.startsWith("\0")) return null;
|
|
197
|
+
const bare = id.slice(1);
|
|
198
|
+
for (const [prefix, family] of this.#prefixes) if (family.load && bare.startsWith(prefix)) return family.load(app, leg, bare.slice(prefix.length));
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* A module's named imports of a realm module, rewritten to import each name from the entry
|
|
203
|
+
* module that has it: `import { regionTtl, sign } from 'ogygia:server'` becomes one import per
|
|
204
|
+
* entry. The realm module is the API; the bundler's graph keeps one edge per entry, so what a
|
|
205
|
+
* page ships (its chunks and their contents) is decided by the names it uses, never by the realm
|
|
206
|
+
* module's other entries. `null`: nothing to rewrite. (`import *` keeps the realm module.)
|
|
207
|
+
*/
|
|
208
|
+
split_realm_imports(code) {
|
|
209
|
+
if (!code.includes("ogygia:")) return null;
|
|
210
|
+
let changed = false;
|
|
211
|
+
const out = code.replace(REALM_NAMED_IMPORT_G, (whole, kw, list, quote, realm) => {
|
|
212
|
+
const names = this.#realms[realm];
|
|
213
|
+
if (!names) return whole;
|
|
214
|
+
const by_module = /* @__PURE__ */ new Map();
|
|
215
|
+
for (const part of list.split(",")) {
|
|
216
|
+
const spec = part.trim();
|
|
217
|
+
if (!spec) continue;
|
|
218
|
+
const [name, local = name] = spec.split(/\s+as\s+/);
|
|
219
|
+
const found = names.get(name);
|
|
220
|
+
if (!found) return whole;
|
|
221
|
+
const [own, module] = found;
|
|
222
|
+
const list_for = by_module.get(module) ?? [];
|
|
223
|
+
list_for.push(own === local ? own : `${own} as ${local}`);
|
|
224
|
+
by_module.set(module, list_for);
|
|
225
|
+
}
|
|
226
|
+
changed = true;
|
|
227
|
+
return [...by_module].map(([module, l]) => `${kw} { ${l.join(", ")} } from ${quote}${module}${quote};`).join(" ");
|
|
228
|
+
});
|
|
229
|
+
return changed ? out : null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* THE BUNDLE CHECK: every module of one leg's output that is a table module of a realm the leg
|
|
233
|
+
* may not hold, as `[id, realm]`. Reads the finished graph, so a module reached through a
|
|
234
|
+
* re-export (laundered past the resolve check) is caught too.
|
|
235
|
+
*/
|
|
236
|
+
misplaced(module_ids, env) {
|
|
237
|
+
const out = [];
|
|
238
|
+
for (const id of module_ids) {
|
|
239
|
+
const realm = this.#realm_of(id) ?? this.#by_resolved.get(id)?.realm ?? this.#prefix_realm(id);
|
|
240
|
+
if (realm && !realm_allowed(realm, env)) out.push([id, realm]);
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
}
|
|
244
|
+
#prefix_realm(id) {
|
|
245
|
+
if (!id.startsWith("\0")) return void 0;
|
|
246
|
+
for (const [prefix, family] of this.#prefixes) if (id.startsWith(prefix, 1)) return family.realm;
|
|
247
|
+
}
|
|
248
|
+
/** Is the module only definitions (a realm module, or an entry it re-exports from)? The bundler
|
|
249
|
+
* may then drop it, and what it imports, when none of its names is used. */
|
|
250
|
+
side_effect_free(id) {
|
|
251
|
+
if (this.#realm_of(id)) return true;
|
|
252
|
+
const e = this.#by_resolved.get(id);
|
|
253
|
+
return e !== void 0 && realm_exports(e, this.#names).length > 0;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
function tracked(app, parts, cx) {
|
|
257
|
+
if (typeof app !== "object" || app === null) return app;
|
|
258
|
+
return new Proxy(app, { get(target, key) {
|
|
259
|
+
const part = typeof key === "string" ? parts[key] : void 0;
|
|
260
|
+
if (part) cx.get(PART, part);
|
|
261
|
+
const v = Reflect.get(target, key);
|
|
262
|
+
return typeof v === "function" ? v.bind(target) : v;
|
|
263
|
+
} });
|
|
264
|
+
}
|
|
265
|
+
export { VirtualTable, import_chain, is_virtual_specifier, realm_allowed };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a virtual module may run, named in its specifier (`ogygia:<realm>/<id>`): `server` (Node,
|
|
3
|
+
* per request), `boot` (the browser runtime), `region` (inside region chunks, rendered on the
|
|
4
|
+
* server too), `dev` (the dev server only).
|
|
5
|
+
*/
|
|
6
|
+
export type Realm = "server" | "boot" | "region" | "dev";
|
|
7
|
+
/** The prefix every realm-named specifier starts with. */
|
|
8
|
+
export declare const OGYGIA_SCHEME = "ogygia:";
|
|
9
|
+
/** A module's specifier: `ogygia:<realm>/<id>`. */
|
|
10
|
+
export declare const specifier: (realm: Realm, id: string) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/virtual/specifier.ts
|
|
2
|
+
/** The prefix every realm-named specifier starts with. */
|
|
3
|
+
const OGYGIA_SCHEME = "ogygia:";
|
|
4
|
+
/** A module's specifier: `ogygia:<realm>/<id>`. */
|
|
5
|
+
const specifier = (realm, id) => `${OGYGIA_SCHEME}${realm}/${id}`;
|
|
6
|
+
export { OGYGIA_SCHEME, specifier };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ExportIndex } from "../exports/index.js";
|
|
2
|
+
import { WalkResolve } from "../fouc-css.js";
|
|
3
|
+
import { OGYGIA_SCHEME, Realm, specifier } from "./specifier.js";
|
|
4
|
+
/** A part of the session a module's `from`/`load` can read. The table records which parts each
|
|
5
|
+
* load read (through {@link Parts}); a dev change to a part reloads exactly those modules. */
|
|
6
|
+
export type Part = "options" | "regions" | "routes" | "plugins" | "styles";
|
|
7
|
+
/** The session's fields → the part each one is (`null`: read freely, never a reason to reload). */
|
|
8
|
+
export type Parts<A> = Readonly<Record<keyof A & string, Part | null>>;
|
|
9
|
+
/** A generated module's specifier, which names no file: ogygia's (`ogygia:`) or another plugin's
|
|
10
|
+
* (`virtual:`, the convention). */
|
|
11
|
+
export declare const is_generated_specifier: (s: string) => boolean;
|
|
12
|
+
/** An entry's specifier, which is also the id the bundler keys its module by. */
|
|
13
|
+
export declare const specifier_of: (e: {
|
|
14
|
+
realm: Realm;
|
|
15
|
+
id: string;
|
|
16
|
+
}) => string;
|
|
17
|
+
/** The build's leg a module is loaded for, and the bundler values the driver cannot see. */
|
|
18
|
+
export interface Leg {
|
|
19
|
+
ssr: boolean;
|
|
20
|
+
/** the app's universal hooks file (its `transport`), if any */
|
|
21
|
+
universalHooks: string | null;
|
|
22
|
+
/** the bundler's resolver */
|
|
23
|
+
resolve?: (spec: string, importer: string) => Promise<string | null>;
|
|
24
|
+
/** `resolve`'s export index (compiler/exports/), for a walk through barrels */
|
|
25
|
+
exports?: ExportIndex<WalkResolve>;
|
|
26
|
+
/** Kit 3's own codec module (`#app/internal/transport`), when the app's Kit has one */
|
|
27
|
+
kitCodec?: string | null;
|
|
28
|
+
/** the import chain that reached the module being loaded (resolver.ts `import_chain`) */
|
|
29
|
+
via?: () => string;
|
|
30
|
+
}
|
|
31
|
+
type Source = string | Promise<string>;
|
|
32
|
+
interface Base {
|
|
33
|
+
realm: Realm;
|
|
34
|
+
id: string;
|
|
35
|
+
}
|
|
36
|
+
/** A value module: `from` returns its data (JSON, plus `Set`), and the module has one named export
|
|
37
|
+
* per key of it (never a default), which is also its name in the realm module. The keys are read
|
|
38
|
+
* off a probe run at core build time ({@link ValueNames}); the generated `.d.ts` types each one off
|
|
39
|
+
* the entry, `ValueOf<typeof entry>['name']`. */
|
|
40
|
+
export interface ValueEntry<A, T extends object = Record<string, unknown>> extends Base {
|
|
41
|
+
kind: "value";
|
|
42
|
+
from(app: A, leg: Leg): T;
|
|
43
|
+
}
|
|
44
|
+
/** Each value entry's export names, by specifier: generated at core build time from a probe run of
|
|
45
|
+
* its `from` (./value-names.ts), so the realm module knows them without running it. */
|
|
46
|
+
export type ValueNames = Readonly<Record<string, readonly string[]>>;
|
|
47
|
+
/** Where a request module's functions live: one of core's own modules (by its path under `src/`,
|
|
48
|
+
* no extension), or a package's. The generated `.d.ts` re-exports that module's own types. */
|
|
49
|
+
export type RequestModule = {
|
|
50
|
+
core: string;
|
|
51
|
+
} | {
|
|
52
|
+
package: string;
|
|
53
|
+
};
|
|
54
|
+
/** A module's names in its realm module → its own export names. */
|
|
55
|
+
export type RealmExports<K extends string = string> = Readonly<Record<string, K>>;
|
|
56
|
+
/** A server module of functions, so secrets and per-request things are never baked in. `_A` keeps
|
|
57
|
+
* one shape for every kind: a request reads nothing off the session. */
|
|
58
|
+
export interface RequestEntry<_A> extends Base {
|
|
59
|
+
kind: "request";
|
|
60
|
+
realm: "server";
|
|
61
|
+
module: RequestModule;
|
|
62
|
+
/** the functions it re-exports, by their name in the realm module */
|
|
63
|
+
exports: RealmExports;
|
|
64
|
+
}
|
|
65
|
+
/** A generated-code module. `M` is what it exports (an interface in `contract/`): the generated
|
|
66
|
+
* `.d.ts` reads it off the entry ({@link ModuleOf}); the entry carries it as a type only. A module
|
|
67
|
+
* without `exports` only runs: it keeps its own id, and the realm module never imports it. */
|
|
68
|
+
export interface FamilyEntry<A, M = Record<never, never>> extends Base {
|
|
69
|
+
kind: "family";
|
|
70
|
+
/** with `parse`, the entry is a prefix (`id` ends in `/`) and `parse` reads the rest; without it,
|
|
71
|
+
* the entry is the one module named `id` */
|
|
72
|
+
parse?(rest: string): string | null;
|
|
73
|
+
/** the module's source; `undefined`: not this table's to load (the driver's registry is) */
|
|
74
|
+
load?(app: A, leg: Leg, rest: string): Source | null;
|
|
75
|
+
/** what the realm module re-exports from it, by its name there */
|
|
76
|
+
exports?: RealmExports<keyof M & string>;
|
|
77
|
+
/** (type only: never set) */
|
|
78
|
+
readonly shape?: M;
|
|
79
|
+
}
|
|
80
|
+
/** A value entry's module type: what its `from` returns. */
|
|
81
|
+
export type ValueOf<E extends {
|
|
82
|
+
from: (...a: never[]) => unknown;
|
|
83
|
+
}> = Awaited<ReturnType<E["from"]>>;
|
|
84
|
+
/** A family entry's module type: the contract interface it declares. */
|
|
85
|
+
export type ModuleOf<E extends {
|
|
86
|
+
shape?: unknown;
|
|
87
|
+
}> = NonNullable<E["shape"]>;
|
|
88
|
+
/** An entry's names in its realm module → its module's own names (none: it is not re-exported). */
|
|
89
|
+
export declare function realm_exports(e: ModuleEntry<unknown>, names: ValueNames): [string, string][];
|
|
90
|
+
/** A value entry's export names; one with none generated fails with `virtual_names_stale`. */
|
|
91
|
+
export declare function value_names(e: ValueEntry<unknown, object>, names: ValueNames): readonly string[];
|
|
92
|
+
/** A switch: a `define` the bundler inlines, so the code it gates folds out. Read at config time
|
|
93
|
+
* from `I` (the resolved options), not from a compile session: it is no module. The generated
|
|
94
|
+
* `.d.ts` declares its global as `ConstOf<typeof entry>`. */
|
|
95
|
+
export interface ConstantEntry<I, T extends boolean | number | string | null = boolean> {
|
|
96
|
+
kind: "constant";
|
|
97
|
+
/** the `define` name */
|
|
98
|
+
id: string;
|
|
99
|
+
from(input: I): T;
|
|
100
|
+
}
|
|
101
|
+
/** A constant entry's type: what its `from` returns. */
|
|
102
|
+
export type ConstOf<E extends {
|
|
103
|
+
from: (...a: never[]) => unknown;
|
|
104
|
+
}> = ReturnType<E["from"]>;
|
|
105
|
+
/** The `define` map of a set of constants. */
|
|
106
|
+
export declare function defines<I>(constants: readonly ConstantEntry<I, any>[], input: I): Record<string, string>;
|
|
107
|
+
export type ModuleEntry<A> = ValueEntry<A, any> | RequestEntry<A> | FamilyEntry<A, any>;
|
|
108
|
+
export type Entry<A> = ModuleEntry<A> | ConstantEntry<any, any>;
|
|
109
|
+
/** The constructors, one per kind: a value (build-time data), a request (a server module of
|
|
110
|
+
* functions), a family (generated code), a constant (a `define`, no module, read at config time).
|
|
111
|
+
* Each returns its argument, kind set, so a declaration reads as data. */
|
|
112
|
+
export declare const virtual: {
|
|
113
|
+
value: <A, T extends object>(e: Omit<ValueEntry<A, T>, "kind">) => ValueEntry<A, T>;
|
|
114
|
+
request: <A>(e: Omit<RequestEntry<A>, "kind">) => RequestEntry<A>;
|
|
115
|
+
family: <A, M = Record<never, never>>(e: Omit<FamilyEntry<A, M>, "kind">) => FamilyEntry<A, M>;
|
|
116
|
+
constant: <I, T extends boolean | number | string | null>(e: Omit<ConstantEntry<I, T>, "kind">) => ConstantEntry<I, T>;
|
|
117
|
+
};
|
|
118
|
+
/** A value as module source: JSON, with each `Set` written as `new Set([…])`. */
|
|
119
|
+
export declare function write_value(v: unknown): string;
|
|
120
|
+
export { OGYGIA_SCHEME, type Realm, specifier };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { OgygiaError } from "../messages.js";
|
|
2
|
+
import { OGYGIA_SCHEME, specifier } from "./specifier.js";
|
|
3
|
+
// src/virtual/table.ts
|
|
4
|
+
/** A generated module's specifier, which names no file: ogygia's (`ogygia:`) or another plugin's
|
|
5
|
+
* (`virtual:`, the convention). */
|
|
6
|
+
const is_generated_specifier = (s) => s.startsWith("ogygia:") || s.startsWith("virtual:");
|
|
7
|
+
/** An entry's specifier, which is also the id the bundler keys its module by. */
|
|
8
|
+
const specifier_of = (e) => specifier(e.realm, e.id);
|
|
9
|
+
/** An entry's names in its realm module → its module's own names (none: it is not re-exported). */
|
|
10
|
+
function realm_exports(e, names) {
|
|
11
|
+
if (e.kind === "value") return value_names(e, names).map((n) => [n, n]);
|
|
12
|
+
return Object.entries(e.exports ?? {});
|
|
13
|
+
}
|
|
14
|
+
/** A value entry's export names; one with none generated fails with `virtual_names_stale`. */
|
|
15
|
+
function value_names(e, names) {
|
|
16
|
+
const list = names[specifier_of(e)];
|
|
17
|
+
if (!list) throw new OgygiaError("virtual_names_stale", { id: specifier_of(e) });
|
|
18
|
+
return list;
|
|
19
|
+
}
|
|
20
|
+
/** The `define` map of a set of constants. */
|
|
21
|
+
function defines(constants, input) {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const c of constants) out[c.id] = JSON.stringify(c.from(input));
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
/** The constructors, one per kind: a value (build-time data), a request (a server module of
|
|
27
|
+
* functions), a family (generated code), a constant (a `define`, no module, read at config time).
|
|
28
|
+
* Each returns its argument, kind set, so a declaration reads as data. */
|
|
29
|
+
const virtual = {
|
|
30
|
+
value: (e) => ({
|
|
31
|
+
kind: "value",
|
|
32
|
+
...e
|
|
33
|
+
}),
|
|
34
|
+
request: (e) => ({
|
|
35
|
+
kind: "request",
|
|
36
|
+
...e
|
|
37
|
+
}),
|
|
38
|
+
family: (e) => ({
|
|
39
|
+
kind: "family",
|
|
40
|
+
...e
|
|
41
|
+
}),
|
|
42
|
+
constant: (e) => ({
|
|
43
|
+
kind: "constant",
|
|
44
|
+
...e
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
/** A value as module source: JSON, with each `Set` written as `new Set([…])`. */
|
|
48
|
+
function write_value(v) {
|
|
49
|
+
if (v instanceof Set) return v.size ? `new Set(${JSON.stringify([...v])})` : "new Set()";
|
|
50
|
+
if (Array.isArray(v)) return `[${v.map(write_value).join(", ")}]`;
|
|
51
|
+
if (v !== null && typeof v === "object") return `{ ${Object.entries(v).map(([k, x]) => `${JSON.stringify(k)}: ${write_value(x)}`).join(", ")} }`;
|
|
52
|
+
return JSON.stringify(v);
|
|
53
|
+
}
|
|
54
|
+
export { OGYGIA_SCHEME, defines, is_generated_specifier, realm_exports, specifier, specifier_of, value_names, virtual, write_value };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Realm } from "./specifier.js";
|
|
2
|
+
import { Entry, Leg, ValueNames } from "./table.js";
|
|
3
|
+
/**
|
|
4
|
+
* Each value entry's export names, by specifier: the keys of its `from` run once against `probe` (a
|
|
5
|
+
* session and leg that read nothing off disk). Sorted by specifier, so the generated file is stable.
|
|
6
|
+
*/
|
|
7
|
+
export declare function probe_value_names<A>(entries: readonly Entry<A>[], probe: A, leg: Leg): Record<string, string[]>;
|
|
8
|
+
/** The generated names module (./value-names.ts). */
|
|
9
|
+
export declare function value_names_source(names: Record<string, string[]>): string;
|
|
10
|
+
export declare const REALMS: readonly Realm[];
|
|
11
|
+
/** The constants' globals (`declare const __OGYGIA_X__`), each typed by core's `VirtualConstants`. */
|
|
12
|
+
export declare function constant_types(entries: Record<string, unknown>): string;
|
|
13
|
+
/**
|
|
14
|
+
* The `.d.ts` text of each realm. `entries` is the module that exports the table's entries, by
|
|
15
|
+
* export name. A prefix family declares nothing: its members are generated per file.
|
|
16
|
+
*/
|
|
17
|
+
export declare function virtual_types<A>(entries: Record<string, unknown>, names: ValueNames): Record<Realm, string>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { OGYGIA_SCHEME, specifier } from "./specifier.js";
|
|
2
|
+
import { realm_exports, specifier_of, value_names } from "./table.js";
|
|
3
|
+
import { dedent } from "@ogygia/core/contract";
|
|
4
|
+
// src/virtual/types.ts
|
|
5
|
+
/**
|
|
6
|
+
* Each value entry's export names, by specifier: the keys of its `from` run once against `probe` (a
|
|
7
|
+
* session and leg that read nothing off disk). Sorted by specifier, so the generated file is stable.
|
|
8
|
+
*/
|
|
9
|
+
function probe_value_names(entries, probe, leg) {
|
|
10
|
+
const out = {};
|
|
11
|
+
const values = entries.filter((e) => e.kind === "value");
|
|
12
|
+
for (const e of values.sort((a, b) => specifier_of(a) < specifier_of(b) ? -1 : 1)) out[specifier_of(e)] = Object.keys(e.from(probe, leg));
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
/** The generated names module (./value-names.ts). */
|
|
16
|
+
function value_names_source(names) {
|
|
17
|
+
const lines = Object.entries(names).map(([id, list]) => `\t${JSON.stringify(id)}: [${list.map((n) => JSON.stringify(n)).join(", ")}]`);
|
|
18
|
+
return `${dedent`
|
|
19
|
+
import type { ValueNames } from './table.ts';
|
|
20
|
+
|
|
21
|
+
export const CORE_VALUE_NAMES: ValueNames = {
|
|
22
|
+
${lines.join(",\n")}
|
|
23
|
+
};
|
|
24
|
+
`}\n`;
|
|
25
|
+
}
|
|
26
|
+
const REALMS = [
|
|
27
|
+
"server",
|
|
28
|
+
"boot",
|
|
29
|
+
"region",
|
|
30
|
+
"dev"
|
|
31
|
+
];
|
|
32
|
+
const CORE_DIST_FROM_VIRTUAL_DIR = "../dist";
|
|
33
|
+
const CONTRACT = `import('${CORE_DIST_FROM_VIRTUAL_DIR}/contract/virtual-modules.js')`;
|
|
34
|
+
const request_from = (e) => "core" in e.module ? `${CORE_DIST_FROM_VIRTUAL_DIR}/${e.module.core}.js` : e.module.package;
|
|
35
|
+
const shape_of = (e) => `${CONTRACT}.VirtualModules['${specifier_of(e)}']`;
|
|
36
|
+
function realm_lines(e, value) {
|
|
37
|
+
const names = realm_exports(e, value);
|
|
38
|
+
if (names.length === 0) return [];
|
|
39
|
+
if (e.kind === "request") return [`export { ${names.map(([name, own]) => own === name ? name : `${own} as ${name}`).join(", ")} } from '${request_from(e)}';`];
|
|
40
|
+
return names.map(([name, own]) => `export const ${name}: ${shape_of(e)}['${own}'];`);
|
|
41
|
+
}
|
|
42
|
+
function own_body(e, value) {
|
|
43
|
+
if (e.kind === "value") return value_names(e, value).map((n) => `export const ${n}: ${shape_of(e)}['${n}'];`).join("\n");
|
|
44
|
+
if (e.kind === "request") return `export { ${[...new Set(Object.values(e.exports))].join(", ")} } from '${request_from(e)}';`;
|
|
45
|
+
return dedent`
|
|
46
|
+
const module: ${shape_of(e)};
|
|
47
|
+
export = module;
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
const declare = (name, text) => `${dedent`
|
|
51
|
+
declare module '${name}' {
|
|
52
|
+
${text}
|
|
53
|
+
}
|
|
54
|
+
`}\n`;
|
|
55
|
+
/** The constants' globals (`declare const __OGYGIA_X__`), each typed by core's `VirtualConstants`. */
|
|
56
|
+
function constant_types(entries) {
|
|
57
|
+
const lines = [];
|
|
58
|
+
for (const [, value] of Object.entries(entries).sort(([a], [b]) => a < b ? -1 : 1)) {
|
|
59
|
+
const e = value;
|
|
60
|
+
if (typeof e !== "object" || e === null || e.kind !== "constant") continue;
|
|
61
|
+
lines.push(`declare const ${e.id}: ${CONTRACT}.VirtualConstants['${e.id}'];`);
|
|
62
|
+
}
|
|
63
|
+
return `${dedent`
|
|
64
|
+
// ogygia's switches, the \`define\`s its build inlines. GENERATED from the virtual-module
|
|
65
|
+
// table's constants (packages/compiler/src/virtual/core.ts) by
|
|
66
|
+
// \`node packages/compiler/scripts/virtual-types.ts\`. Do not edit.
|
|
67
|
+
|
|
68
|
+
${lines.join("\n")}
|
|
69
|
+
`}\n`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The `.d.ts` text of each realm. `entries` is the module that exports the table's entries, by
|
|
73
|
+
* export name. A prefix family declares nothing: its members are generated per file.
|
|
74
|
+
*/
|
|
75
|
+
function virtual_types(entries, names) {
|
|
76
|
+
const out = {};
|
|
77
|
+
const sorted = Object.entries(entries).sort(([a], [b]) => a < b ? -1 : 1);
|
|
78
|
+
for (const realm of REALMS) {
|
|
79
|
+
const realm_module = [];
|
|
80
|
+
let own = "";
|
|
81
|
+
for (const [, value] of sorted) {
|
|
82
|
+
const e = value;
|
|
83
|
+
if (typeof e !== "object" || e === null || !("kind" in e) || e.kind === "constant") continue;
|
|
84
|
+
if (e.realm !== realm || e.kind === "family" && (e.parse || !e.load)) continue;
|
|
85
|
+
const m = e;
|
|
86
|
+
realm_module.push(...realm_lines(m, names));
|
|
87
|
+
own += declare(specifier(realm, m.id), own_body(m, names));
|
|
88
|
+
}
|
|
89
|
+
out[realm] = dedent`
|
|
90
|
+
// The \`ogygia:${realm}\` module and its entries' own ids. GENERATED from the virtual-module
|
|
91
|
+
// table (packages/compiler/src/virtual/core.ts) by
|
|
92
|
+
// \`node packages/compiler/scripts/virtual-types.ts\`; every type is core's contract
|
|
93
|
+
// (src/contract/virtual-modules.ts). Do not edit.
|
|
94
|
+
|
|
95
|
+
${declare(`${OGYGIA_SCHEME}${realm}`, realm_module.join("\n"))}${own}
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
export { REALMS, constant_types, probe_value_names, value_names_source, virtual_types };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/virtual/value-names.ts
|
|
2
|
+
const CORE_VALUE_NAMES = {
|
|
3
|
+
"ogygia:boot/devtools-meta": ["region_names"],
|
|
4
|
+
"ogygia:server/devtools-boot-url": ["devtools_boot_url"],
|
|
5
|
+
"ogygia:server/profiler-maps": ["profiler_maps"],
|
|
6
|
+
"ogygia:server/rate-limit": ["rate_limit"],
|
|
7
|
+
"ogygia:server/region-ttl": ["region_ttl", "renew_window"],
|
|
8
|
+
"ogygia:server/route-csr": [
|
|
9
|
+
"csr_true_routes",
|
|
10
|
+
"error_csr_true_routes",
|
|
11
|
+
"root_layout_csr_true"
|
|
12
|
+
],
|
|
13
|
+
"ogygia:server/router-config": ["router_enabled", "view_transitions"],
|
|
14
|
+
"ogygia:server/runtime-url": ["runtime_url"],
|
|
15
|
+
"ogygia:server/secret": ["build_key", "build_had_secret"],
|
|
16
|
+
"ogygia:server/session-cookie": ["session_cookie"]
|
|
17
|
+
};
|
|
18
|
+
export { CORE_VALUE_NAMES };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
/** A plugin's definers: the module they are imported from, and their exported names. */
|
|
4
|
+
export type Definers = {
|
|
5
|
+
module: string;
|
|
6
|
+
names: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
/** `code` with every definer call marked, and its map; null when it calls none (or does not parse:
|
|
9
|
+
* a module mid-edit is left alone). */
|
|
10
|
+
export declare function mark_definer_calls(code: string, id: string, definers: readonly Definers[]): {
|
|
11
|
+
code: string;
|
|
12
|
+
map: ReturnType<MagicString["generateMap"]>;
|
|
13
|
+
} | null;
|
|
14
|
+
/** The dev transform: every server module that imports a definer has its definer calls marked. A
|
|
15
|
+
* normal-order plugin (plain JS, imports as written). Inert in a build. */
|
|
16
|
+
export declare function definers_plugin(definers: () => readonly Definers[]): Plugin;
|