@ogygia/compiler 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +63 -2
- 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 +349 -0
- package/dist/driver.js +1401 -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 +102 -0
- package/dist/fouc-css.js +304 -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 +198 -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 +672 -0
- package/dist/messages.js +938 -0
- package/dist/ownership-stamps.d.ts +9 -0
- package/dist/ownership-stamps.js +101 -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 +56 -0
- package/dist/virtual/resolver.js +249 -0
- package/dist/virtual/specifier.d.ts +10 -0
- package/dist/virtual/specifier.js +6 -0
- package/dist/virtual/table.d.ts +118 -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 +874 -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 +11 -0
- package/dist/vite/late-island.js +19 -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 +14 -0
- package/dist/vite/paths.js +37 -0
- package/dist/vite/plugin-api.d.ts +316 -0
- package/dist/vite/plugin-api.js +328 -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/package.json +85 -3
package/dist/queries.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { cache } from "@ogygia/machine";
|
|
2
|
+
// src/queries.ts
|
|
3
|
+
/** An input: `read` is how its value is first fetched (a file system read, say). */
|
|
4
|
+
function input(name, key, read, equal = same) {
|
|
5
|
+
return {
|
|
6
|
+
name,
|
|
7
|
+
kind: "input",
|
|
8
|
+
key,
|
|
9
|
+
run: (_cx, arg) => read(arg),
|
|
10
|
+
equal
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** A derived answer: `run` reads only other queries, through `cx`. */
|
|
14
|
+
function derived(name, key, run, equal = same) {
|
|
15
|
+
return {
|
|
16
|
+
name,
|
|
17
|
+
kind: "derived",
|
|
18
|
+
key,
|
|
19
|
+
run,
|
|
20
|
+
equal
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const erase = (query) => query;
|
|
24
|
+
const NO_VALUE = -1;
|
|
25
|
+
const MUST_RUN = -1;
|
|
26
|
+
const RUNNING = -2;
|
|
27
|
+
const LET_GO = -3;
|
|
28
|
+
const RUNNING_LET_GO = -4;
|
|
29
|
+
const QUERIES_MAX = 1e5;
|
|
30
|
+
/**
|
|
31
|
+
* A database of queries. `name` names its store in messages; `max` is how many derived answers it
|
|
32
|
+
* remembers (one let go is computed again when next read). Inputs are never let go: they are the
|
|
33
|
+
* world an answer read, and some (`set`-only ones) have no other copy.
|
|
34
|
+
*
|
|
35
|
+
* An answer the compiler derives from the app's files is a query: a pure function of other
|
|
36
|
+
* queries, down to INPUTS (a file's text, a directory's listing) that only the outside world
|
|
37
|
+
* changes. The database remembers each answer with the queries it read, so after an input changes
|
|
38
|
+
* it computes again only what read it, and an answer that comes out the same stops there (early
|
|
39
|
+
* cutoff): its readers keep theirs. Nothing is cleared by hand, and a dev session's answers are
|
|
40
|
+
* always the ones a cold start on the same files gives (test/queries.test.ts checks exactly that,
|
|
41
|
+
* over random edits).
|
|
42
|
+
*
|
|
43
|
+
* Revisions: every input change is a new revision. An answer records the revision it last changed
|
|
44
|
+
* at and the one it was last checked at; a read in a later revision checks the answer's
|
|
45
|
+
* dependencies first (in the order they were read: a dependency read after one that changed may not
|
|
46
|
+
* be read at all now), and runs it again only if one of them changed. The check walks its own
|
|
47
|
+
* stack, so a chain of answers of any depth never grows the call stack.
|
|
48
|
+
*
|
|
49
|
+
* Internal to the compiler: not exported from the package.
|
|
50
|
+
*/
|
|
51
|
+
var Queries = class {
|
|
52
|
+
#table = /* @__PURE__ */ new Map();
|
|
53
|
+
#last_query;
|
|
54
|
+
#last_keyed = /* @__PURE__ */ new Map();
|
|
55
|
+
#held;
|
|
56
|
+
#revision = 0;
|
|
57
|
+
#current;
|
|
58
|
+
constructor(name, max = QUERIES_MAX) {
|
|
59
|
+
this.#held = cache({
|
|
60
|
+
name,
|
|
61
|
+
max,
|
|
62
|
+
onEvict: (slot) => this.#let_go(slot)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** The current revision: one more for each input change. */
|
|
66
|
+
get revision() {
|
|
67
|
+
return this.#revision;
|
|
68
|
+
}
|
|
69
|
+
get(query, arg) {
|
|
70
|
+
const slot = this.#slot_of(query, arg);
|
|
71
|
+
if (slot.verified !== this.#revision) this.#fresh(slot);
|
|
72
|
+
const into = this.#current;
|
|
73
|
+
if (into) link(into, slot);
|
|
74
|
+
return slot.value;
|
|
75
|
+
}
|
|
76
|
+
/** Run a reader that is not a query (its answer is not kept: a generated module's load, say):
|
|
77
|
+
* what it reads through `cx`, and through any query it reads while it runs, is recorded in
|
|
78
|
+
* `reads`. `cx` records even after the reader's first await; a query read then is not. */
|
|
79
|
+
watch(reader) {
|
|
80
|
+
const reads = {
|
|
81
|
+
deps: [],
|
|
82
|
+
tail: 0
|
|
83
|
+
};
|
|
84
|
+
const outer = this.#current;
|
|
85
|
+
this.#current = reads;
|
|
86
|
+
try {
|
|
87
|
+
return {
|
|
88
|
+
value: reader({ get: (query, arg) => this.#read(query, arg, reads) }),
|
|
89
|
+
reads
|
|
90
|
+
};
|
|
91
|
+
} finally {
|
|
92
|
+
this.#current = outer;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Whether anything a watched reader read is different now (each is checked, and computed again
|
|
96
|
+
* if what it read changed: an answer that comes out the same has not moved). */
|
|
97
|
+
moved(reads) {
|
|
98
|
+
try {
|
|
99
|
+
return !this.#deps_unchanged(reads);
|
|
100
|
+
} catch {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Give an input a value. False (and no new revision) when it equals the one it had. */
|
|
105
|
+
set(query, arg, value) {
|
|
106
|
+
return this.#set_input(erase(query), arg, value);
|
|
107
|
+
}
|
|
108
|
+
/** Read an input again from the outside world, if anything read it: whether it changed. */
|
|
109
|
+
refresh(typed, arg) {
|
|
110
|
+
const query = erase(typed);
|
|
111
|
+
if (!this.#find(query, arg)) return false;
|
|
112
|
+
return this.#set_input(query, arg, query.run(this, arg));
|
|
113
|
+
}
|
|
114
|
+
/** Whether anything read this input or answer (and it is still remembered). */
|
|
115
|
+
holds(query, arg) {
|
|
116
|
+
return this.#find(erase(query), arg) !== void 0;
|
|
117
|
+
}
|
|
118
|
+
/** Whether `query(arg)` is different now from what it was at revision `since` (one not held
|
|
119
|
+
* is computed now, as of the current revision). */
|
|
120
|
+
changed_since(typed, arg, since) {
|
|
121
|
+
return this.#fresh(this.#slot_of(erase(typed), arg)).changed > since;
|
|
122
|
+
}
|
|
123
|
+
/** Whether any derived answer held now is different from what it was at revision `since`
|
|
124
|
+
* (each is checked, and computed again if what it read changed). */
|
|
125
|
+
answers_changed_since(since) {
|
|
126
|
+
for (const [slot] of this.#held.entries()) {
|
|
127
|
+
if (slot.query.kind === "input" || slot.verified === LET_GO) continue;
|
|
128
|
+
try {
|
|
129
|
+
if (this.#fresh(slot).changed > since) return true;
|
|
130
|
+
} catch {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
/** Read every input anything read again from the outside world (a new session starts from what
|
|
137
|
+
* is there now, not from what an earlier one saw): whether any changed. */
|
|
138
|
+
reread() {
|
|
139
|
+
let moved = false;
|
|
140
|
+
for (const [query, keyed] of this.#table) {
|
|
141
|
+
if (query.kind !== "input") continue;
|
|
142
|
+
for (const slot of keyed.values()) if (this.#set_input(query, slot.arg, query.run(this, slot.arg))) moved = true;
|
|
143
|
+
}
|
|
144
|
+
return moved;
|
|
145
|
+
}
|
|
146
|
+
#let_go(slot) {
|
|
147
|
+
if (slot.verified === RUNNING) {
|
|
148
|
+
slot.verified = RUNNING_LET_GO;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const keyed = this.#table.get(slot.query);
|
|
152
|
+
if (keyed?.get(slot.key) === slot) keyed.delete(slot.key);
|
|
153
|
+
slot.verified = LET_GO;
|
|
154
|
+
}
|
|
155
|
+
#find(query, arg) {
|
|
156
|
+
return this.#table.get(query)?.get(query.key(arg));
|
|
157
|
+
}
|
|
158
|
+
#slot_of(query, arg) {
|
|
159
|
+
let keyed = this.#last_keyed;
|
|
160
|
+
if (query !== this.#last_query) {
|
|
161
|
+
const had = this.#table.get(query);
|
|
162
|
+
if (had === void 0) this.#table.set(query, keyed = /* @__PURE__ */ new Map());
|
|
163
|
+
else keyed = had;
|
|
164
|
+
this.#last_query = query;
|
|
165
|
+
this.#last_keyed = keyed;
|
|
166
|
+
}
|
|
167
|
+
const key = query.key(arg);
|
|
168
|
+
let slot = keyed.get(key);
|
|
169
|
+
if (slot === void 0) {
|
|
170
|
+
slot = {
|
|
171
|
+
query,
|
|
172
|
+
arg,
|
|
173
|
+
key,
|
|
174
|
+
value: void 0,
|
|
175
|
+
changed: NO_VALUE,
|
|
176
|
+
verified: MUST_RUN,
|
|
177
|
+
deps: [],
|
|
178
|
+
tail: 0
|
|
179
|
+
};
|
|
180
|
+
keyed.set(key, slot);
|
|
181
|
+
if (query.kind === "derived") this.#held.set(slot, slot);
|
|
182
|
+
}
|
|
183
|
+
return slot;
|
|
184
|
+
}
|
|
185
|
+
#fresh(slot) {
|
|
186
|
+
const v = slot.verified;
|
|
187
|
+
if (v === this.#revision) return slot;
|
|
188
|
+
this.#held.get(slot);
|
|
189
|
+
if (v >= 0 && (slot.query.kind === "input" || this.#deps_unchanged(slot))) slot.verified = this.#revision;
|
|
190
|
+
else this.#compute(slot);
|
|
191
|
+
return slot;
|
|
192
|
+
}
|
|
193
|
+
#deps_unchanged(root) {
|
|
194
|
+
const held = this.#held;
|
|
195
|
+
let node = root;
|
|
196
|
+
let i = 0;
|
|
197
|
+
let below;
|
|
198
|
+
descend: for (;;) {
|
|
199
|
+
const deps = node.deps;
|
|
200
|
+
let same = true;
|
|
201
|
+
for (; i < deps.length; i++) {
|
|
202
|
+
const d = deps[i];
|
|
203
|
+
const s = d.slot;
|
|
204
|
+
const v = s.verified;
|
|
205
|
+
if (v !== this.#revision) {
|
|
206
|
+
if (v === LET_GO) {
|
|
207
|
+
same = false;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
held.get(s);
|
|
211
|
+
if (v < 0) this.#compute(s);
|
|
212
|
+
else if (s.query.kind === "input") s.verified = this.#revision;
|
|
213
|
+
else {
|
|
214
|
+
(below ??= []).push(node, i);
|
|
215
|
+
node = s;
|
|
216
|
+
i = 0;
|
|
217
|
+
continue descend;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (s.changed !== d.seen) {
|
|
221
|
+
same = false;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
for (;;) {
|
|
226
|
+
if (node === root) return same;
|
|
227
|
+
const slot = node;
|
|
228
|
+
if (same) slot.verified = this.#revision;
|
|
229
|
+
else this.#compute(slot);
|
|
230
|
+
i = below.pop();
|
|
231
|
+
node = below.pop();
|
|
232
|
+
const d = node.deps[i];
|
|
233
|
+
if (d?.slot !== slot || slot.changed !== d.seen) {
|
|
234
|
+
same = false;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
i++;
|
|
238
|
+
continue descend;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
#compute(slot) {
|
|
243
|
+
if (slot.verified === RUNNING || slot.verified === RUNNING_LET_GO) throw new Error(`query cycle: ${slot.query.name} ${slot.key}`);
|
|
244
|
+
const outer = this.#current;
|
|
245
|
+
this.#current = slot;
|
|
246
|
+
slot.tail = 0;
|
|
247
|
+
slot.verified = RUNNING;
|
|
248
|
+
let value;
|
|
249
|
+
try {
|
|
250
|
+
value = slot.query.run(this, slot.arg);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
const let_go_now = slot.verified === RUNNING_LET_GO;
|
|
253
|
+
slot.verified = MUST_RUN;
|
|
254
|
+
if (let_go_now) this.#let_go(slot);
|
|
255
|
+
else if (slot.changed === NO_VALUE) this.#held.delete(slot);
|
|
256
|
+
throw e;
|
|
257
|
+
} finally {
|
|
258
|
+
this.#current = outer;
|
|
259
|
+
}
|
|
260
|
+
if (slot.deps.length !== slot.tail) slot.deps.length = slot.tail;
|
|
261
|
+
if (slot.verified === RUNNING_LET_GO) {
|
|
262
|
+
slot.verified = MUST_RUN;
|
|
263
|
+
this.#let_go(slot);
|
|
264
|
+
} else slot.verified = this.#revision;
|
|
265
|
+
if (slot.changed !== NO_VALUE && slot.query.equal(slot.value, value)) return;
|
|
266
|
+
slot.value = value;
|
|
267
|
+
slot.changed = this.#revision;
|
|
268
|
+
}
|
|
269
|
+
#set_input(query, arg, value) {
|
|
270
|
+
if (query.kind !== "input") throw new Error(`query ${query.name} is not an input`);
|
|
271
|
+
const had = this.#find(query, arg);
|
|
272
|
+
if (had && query.equal(had.value, value)) return false;
|
|
273
|
+
const revision = ++this.#revision;
|
|
274
|
+
const slot = had ?? this.#slot_of(query, arg);
|
|
275
|
+
slot.value = value;
|
|
276
|
+
slot.changed = revision;
|
|
277
|
+
slot.verified = revision;
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
#read(typed, arg, into) {
|
|
281
|
+
const slot = this.#fresh(this.#slot_of(typed, arg));
|
|
282
|
+
if (into) link(into, slot);
|
|
283
|
+
return slot.value;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
function link(frame, slot) {
|
|
287
|
+
const deps = frame.deps;
|
|
288
|
+
const i = frame.tail++;
|
|
289
|
+
if (i < deps.length) {
|
|
290
|
+
const d = deps[i];
|
|
291
|
+
if (d.slot === slot) d.seen = slot.changed;
|
|
292
|
+
else deps[i] = {
|
|
293
|
+
slot,
|
|
294
|
+
seen: slot.changed
|
|
295
|
+
};
|
|
296
|
+
} else deps.push({
|
|
297
|
+
slot,
|
|
298
|
+
seen: slot.changed
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/** Structural equality over what answers are made of: primitives, arrays, plain objects, Maps and
|
|
302
|
+
* Sets (in order: an answer's order is part of it). */
|
|
303
|
+
function same(a, b) {
|
|
304
|
+
if (Object.is(a, b)) return true;
|
|
305
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
306
|
+
if (Array.isArray(a)) {
|
|
307
|
+
if (!Array.isArray(b) || a.length !== b.length) return false;
|
|
308
|
+
for (let i = 0; i < a.length; i++) if (!same(a[i], b[i])) return false;
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
if (a instanceof Map || a instanceof Set) {
|
|
312
|
+
if (a.constructor !== b.constructor) return false;
|
|
313
|
+
return same([...a], [...b]);
|
|
314
|
+
}
|
|
315
|
+
if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b) || Array.isArray(b)) return false;
|
|
316
|
+
const ka = Object.keys(a);
|
|
317
|
+
const kb = Object.keys(b);
|
|
318
|
+
if (ka.length !== kb.length) return false;
|
|
319
|
+
for (let i = 0; i < ka.length; i++) {
|
|
320
|
+
const k = ka[i];
|
|
321
|
+
if (k !== kb[i]) return false;
|
|
322
|
+
if (!same(a[k], b[k])) return false;
|
|
323
|
+
}
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
export { Queries, derived, input, same };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The component-import line for a generated module — a NAMED export (`import { Header as X } from
|
|
3
|
+
* '@barrel'`, a marked named import) or a plain default (`import X from './X.svelte'`, a
|
|
4
|
+
* `.svelte` file or a package default). `exportName` is undefined/`'default'` for the default case.
|
|
5
|
+
*/
|
|
6
|
+
export declare function component_import_line(local: string, spec: string, exportName?: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The island ENTRY module — a JS re-export of the real component, loaded on both client hydrate and
|
|
9
|
+
* server render. The transportables import registers every `[ogygia.wire]` codec before props decode,
|
|
10
|
+
* so an island receiving a transportable prop never needs to import the class itself. Shared by the
|
|
11
|
+
* `.svelte` host and the `.ts` registry (a `wake:` mark) so a mountable binding is built the same way
|
|
12
|
+
* from either.
|
|
13
|
+
*/
|
|
14
|
+
export declare function island_entry_source(componentPath: string, iid: string, exportName?: string): string;
|
|
15
|
+
/** Where an island entry's foreign-hydrate exports begin (compiler/driver.ts cuts from here). */
|
|
16
|
+
export declare const FOREIGN_HYDRATE_MARK = "// og:foreign-hydrate\n";
|
|
17
|
+
/**
|
|
18
|
+
* The island WRAPPER (`.svelte`) — a MOUNTABLE component that renders `<ogygia-region>` on its wake
|
|
19
|
+
* schedule. Placing it (`<C/>`, `<svelte:component this={C}/>`) emits the shell; the island's JS is
|
|
20
|
+
* fetched only when the shell wakes (e.g. `wake: 'visible'` → on scroll-into-view). Shared by the
|
|
21
|
+
* `.svelte` host and the `.ts` registry. `entry_url` is the resolved client/dev module URL the caller
|
|
22
|
+
* computes (ctx-dependent). Plain JavaScript, whatever the host's lang: every host that marks the
|
|
23
|
+
* component this way shares this one module (test/region-identity-canonical.test.ts).
|
|
24
|
+
*/
|
|
25
|
+
export declare function island_wrapper_source(iid: string, componentPath: string, entryPath: string, strategy: string, options: Record<string, unknown> | undefined, exportName: string | undefined, entry_url: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* The island wrapper's CLIENT leg (a csr=true-capable host imports it; Kit hydrates the island
|
|
28
|
+
* inline as a normal component). The SSR wrapper imports the component statically — it must
|
|
29
|
+
* render. The client wrapper must NOT: Kit links a route's `node.stylesheets` and preloads from the
|
|
30
|
+
* page's STATIC client graph, so a registry of N marked blocks imported by a csr=true route linked
|
|
31
|
+
* every block's CSS + chunk on every page (a newsroom page: 172 stylesheets for 4 islands). The
|
|
32
|
+
* component therefore comes through `lazy_entry_source` — a top-level-await module that imports
|
|
33
|
+
* the real entry only for the islands this document RENDERED (the SSR stamped a
|
|
34
|
+
* `<meta name="ogygia-kit-island">` per rendered island), so Kit still hydrates them in place with
|
|
35
|
+
* the component in hand, and a block nobody rendered costs nothing. Mounted fresh on a Kit
|
|
36
|
+
* client-side navigation (no SSR, no stamp), the wrapper loads the entry on demand and renders once
|
|
37
|
+
* it lands — a client render, so no hydration to mismatch.
|
|
38
|
+
*/
|
|
39
|
+
export declare function island_wrapper_client_source(iid: string, lazyPath: string, strategy: string, options: Record<string, unknown> | undefined, entry_url: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* The client wrapper's component source (`lazyEntryVirtualId`). Decides ONCE, at module
|
|
42
|
+
* evaluation — before Kit hydrates, because Kit awaits the page node's import and a top-level
|
|
43
|
+
* await holds it. The two facts it reads are the document's own: `documentIsCsrTrue()` (the ONE
|
|
44
|
+
* csr fact Region reads on both legs) and the `<meta name="ogygia-kit-island">` stamp Region
|
|
45
|
+
* emits per rendered inline island (context.ts `claim_kit_island`).
|
|
46
|
+
* - not a Kit-hydrated document (the runtime woke this island's parent; no stamp exists there):
|
|
47
|
+
* import the entry now — a nested island must be in hand when its parent hydrates;
|
|
48
|
+
* - a Kit document that rendered this island: import the entry now, Kit hydrates it in place;
|
|
49
|
+
* - a Kit document that did NOT render it (an unrendered registry block): `undefined`, nothing
|
|
50
|
+
* fetched, nothing linked — `load()` is the on-demand path a client-side navigation takes.
|
|
51
|
+
* `entry_url` is the same string Region bakes into the stamp (`__entry`), on both legs.
|
|
52
|
+
*/
|
|
53
|
+
export declare function lazy_entry_source(entryPath: string, entry_url: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Build the held-region descriptor shared by the `.svelte` and `.ts` paths. It ALWAYS carries a
|
|
56
|
+
* client chunk + `__module` (the region MIGHT be woken); when used statically the chunk is simply
|
|
57
|
+
* never fetched (HTML only at runtime). Two marker flavors feed it:
|
|
58
|
+
* - `wake: 'x'` → bakes `__hydrate: 'x'` — `region(C, props)` wakes on that schedule.
|
|
59
|
+
* - `region: 'raw'` → bakes NO schedule — `region(C, props, { wake })` sets it at the call.
|
|
60
|
+
* `region()` reads `opts.wake ?? binding.__hydrate`, so a baked schedule is the default and the call
|
|
61
|
+
* can override. `kind` is always `'hydrate'` so the chunk is emitted; `server:true` — the endpoint
|
|
62
|
+
* renders the HTML either way.
|
|
63
|
+
*/
|
|
64
|
+
export declare function make_region_binding(opts: {
|
|
65
|
+
iid: string;
|
|
66
|
+
componentPath: string;
|
|
67
|
+
entryPath: string;
|
|
68
|
+
hostPath: string;
|
|
69
|
+
moduleUrl: string;
|
|
70
|
+
/** baked wake schedule from a `wake:` mark; absent for `region: 'raw'` (schedule set at the call) */
|
|
71
|
+
hydrate?: string;
|
|
72
|
+
/** rootMargin baked when `hydrate` is `'visible'` */
|
|
73
|
+
hydrateMargin?: string;
|
|
74
|
+
/** named export to pull (a marked named import); undefined → default import */
|
|
75
|
+
exportName?: string;
|
|
76
|
+
identity: string;
|
|
77
|
+
}): {
|
|
78
|
+
id: string;
|
|
79
|
+
virtualPath: string;
|
|
80
|
+
source: string;
|
|
81
|
+
bindingPath: string;
|
|
82
|
+
bindingSsrSource: string;
|
|
83
|
+
bindingClientSource: string;
|
|
84
|
+
hostPath: string;
|
|
85
|
+
componentPath: string;
|
|
86
|
+
server: boolean;
|
|
87
|
+
kind: string;
|
|
88
|
+
held: boolean;
|
|
89
|
+
lakes: never[];
|
|
90
|
+
identity: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The complete island record for a `wake:` mark — the ONE emitter shared by the `.svelte` host (a
|
|
94
|
+
* placed `import X with { wake }`) and the `.ts` registry (a `wake:` mark handed to a renderer). The
|
|
95
|
+
* binding it produces is BOTH mountable (placing it, incl. via `<svelte:component>`, renders the
|
|
96
|
+
* `<ogygia-region>` shell that fetches the island JS only on its schedule) AND holdable (the descriptor
|
|
97
|
+
* fields ride on the wrapper, so `region(C)` still works). Threading both paths through here is what
|
|
98
|
+
* keeps `.svelte` and `.ts` `wake:` byte-identical — a `.ts` `wake: 'visible'` is exactly a `.svelte`
|
|
99
|
+
* `wake: 'visible'`. Callers own the host-specific import rewrite; this owns the record.
|
|
100
|
+
* `moduleUrl` is the resolved client/dev module URL.
|
|
101
|
+
*/
|
|
102
|
+
export declare function make_wake_island(opts: {
|
|
103
|
+
iid: string;
|
|
104
|
+
componentPath: string;
|
|
105
|
+
entryPath: string;
|
|
106
|
+
wrapperPath: string;
|
|
107
|
+
moduleUrl: string;
|
|
108
|
+
strategy: string;
|
|
109
|
+
options?: Record<string, unknown>;
|
|
110
|
+
exportName?: string;
|
|
111
|
+
hostPath: string;
|
|
112
|
+
identity: string;
|
|
113
|
+
/**
|
|
114
|
+
* A `.ts` registry / remote binding, which may be handed to `region()` and CROSS the wire (a live
|
|
115
|
+
* or remote region): it needs a server-manifest entry (`server`) so its endpoint can render it, and
|
|
116
|
+
* the `held` mark that pulls in the live/morph runtime. A `.svelte` placed island never crosses, so
|
|
117
|
+
* it stays `server:false`. Either way the binding is the SAME mountable wrapper — only the manifest
|
|
118
|
+
* flags differ, which is also why the two carry distinct identities (an endpoint vs none).
|
|
119
|
+
*/
|
|
120
|
+
held?: boolean;
|
|
121
|
+
}): {
|
|
122
|
+
kind: string;
|
|
123
|
+
lakes: never[];
|
|
124
|
+
identity: string;
|
|
125
|
+
strategy: string;
|
|
126
|
+
keep: unknown;
|
|
127
|
+
held?: boolean;
|
|
128
|
+
id: string;
|
|
129
|
+
virtualPath: string;
|
|
130
|
+
wrapperPath: string;
|
|
131
|
+
wrapperSource: string;
|
|
132
|
+
wrapperClientSource: string;
|
|
133
|
+
lazyPath: string;
|
|
134
|
+
lazySource: string;
|
|
135
|
+
bindingPath: string;
|
|
136
|
+
bindingSsrSource: string;
|
|
137
|
+
bindingClientSource: string;
|
|
138
|
+
source: string;
|
|
139
|
+
hostPath: string;
|
|
140
|
+
componentPath: string;
|
|
141
|
+
server: boolean;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The SERVER-island wrapper (`.svelte`) — `render: 'deferred'`: a hole whose HTML is fetched on the
|
|
145
|
+
* `wake` schedule. `__defer` carries the fetch schedule; `__cacheTtl` (when signed) sets the hole's
|
|
146
|
+
* response cache; a deferred island that ALSO hydrates carries `__hydrate` + `__module` (its client
|
|
147
|
+
* entry URL). `module_url` is the resolved client/dev entry URL (used only when it hydrates).
|
|
148
|
+
* @param component false for the client leg, which imports no component: a hole ships no JS.
|
|
149
|
+
*/
|
|
150
|
+
export declare function server_wrapper_source(iid: string, componentPath: string, entryPath: string, options: Record<string, unknown> | undefined, exportName: string | undefined, module_url: string, component?: boolean): string;
|
|
151
|
+
/**
|
|
152
|
+
* The LAKE wrapper (`.svelte`) — `render: page, wake: none`: a frozen region inside a hydrated island.
|
|
153
|
+
* Every lake hands Region its props (`__props`): its identity (`data-og-lake`) is a fingerprint of
|
|
154
|
+
* them. A `swr` lake also carries an endpoint (`__when`) to remount on its schedule; `cache`/`empty`
|
|
155
|
+
* are wrapper-only. Static `<OgygiaLakeInner>` (not dynamic) preserves the LAKE-ENVELOPE; the client
|
|
156
|
+
* build swaps that import for the render-nothing stub.
|
|
157
|
+
*/
|
|
158
|
+
export declare function lake_wrapper_source(iid: string, componentPath: string, options: Record<string, unknown> | undefined, exportName: string | undefined): string;
|
|
159
|
+
/** Rewrite `$app/{state,stores,navigation}` string literals to absolute shim paths. */
|
|
160
|
+
export declare const APP_SHIM_IMPORT: RegExp;
|
|
161
|
+
/**
|
|
162
|
+
* Rewrite a lake binding's import to the render-nothing placeholder (client island modules only).
|
|
163
|
+
* Default imports are repointed; named imports drop that specifier (and keep siblings) then add a
|
|
164
|
+
* default import of the placeholder under the same local name.
|
|
165
|
+
*
|
|
166
|
+
* @internal Used by the plugin client emit and unit tests.
|
|
167
|
+
*/
|
|
168
|
+
export declare function rewrite_lake_import_to_placeholder(src: string, local: string, placeholder: string): string;
|