@farm.js/islx 0.0.3 → 0.0.5

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.
@@ -0,0 +1,503 @@
1
+ import { i as transformActions, r as hasModuleDirective, t as ActionCompileError } from "./actions-Eutk6UzT.mjs";
2
+ import { t as ISLAND_STRATEGIES } from "./schedule-CjoybS3b.mjs";
3
+ import { randomBytes } from "node:crypto";
4
+ import path from "node:path";
5
+ import { walk } from "estree-walker";
6
+ import MagicString from "magic-string";
7
+ import { analyze } from "periscopic";
8
+ import { readFile, readdir, writeFile } from "node:fs/promises";
9
+ // src/compiler/client.ts
10
+ /**
11
+ * The `"use client"` compiler. In the server build, every component a `"use client"` module
12
+ * exports renders as an island: its server HTML, and its props for the browser. The browser build
13
+ * keeps the module as it is.
14
+ *
15
+ * A component is an export named in PascalCase (`Chart`, not `COLORS` or `useChart`) that is not
16
+ * a literal value, or the default export. Other exports (hooks, constants, helpers) stay as they
17
+ * are on both sides.
18
+ *
19
+ * When an island hydrates comes from the module's `hydrate` export:
20
+ *
21
+ * export const hydrate = "visible"; // every component in the file
22
+ * export const hydrate = { Chart: "visible", Legend: "idle" }; // per component; others "load"
23
+ */
24
+ const FUNCTION_TYPES = /* @__PURE__ */ new Set([
25
+ "FunctionDeclaration",
26
+ "FunctionExpression",
27
+ "ArrowFunctionExpression"
28
+ ]);
29
+ function isComponentName(name) {
30
+ return /^[A-Z]/.test(name) && /[a-z]/.test(name);
31
+ }
32
+ const VALUE_TYPES = /* @__PURE__ */ new Set([
33
+ "Literal",
34
+ "ArrayExpression",
35
+ "ObjectExpression",
36
+ "TemplateLiteral",
37
+ "UnaryExpression",
38
+ "BinaryExpression"
39
+ ]);
40
+ /** Reads the `hydrate` export: a strategy for every component, or one per component. */
41
+ function readStrategies(program, fail) {
42
+ const byName = /* @__PURE__ */ new Map();
43
+ const check = (value, node) => {
44
+ if (typeof value !== "string" || !ISLAND_STRATEGIES.includes(value)) fail(`hydrate must be one of ${ISLAND_STRATEGIES.map((s) => `"${s}"`).join(", ")}`, node);
45
+ return value;
46
+ };
47
+ for (const node of program.body ?? []) {
48
+ if (node.type !== "ExportNamedDeclaration" || node.declaration?.type !== "VariableDeclaration") continue;
49
+ for (const declarator of node.declaration.declarations ?? []) {
50
+ if (declarator.id?.type !== "Identifier" || declarator.id.name !== "hydrate") continue;
51
+ let init = declarator.init;
52
+ while (init && (init.type === "TSAsExpression" || init.type === "TSSatisfiesExpression")) init = init.expression;
53
+ if (init?.type === "Literal") return {
54
+ all: check(init.value, init),
55
+ byName
56
+ };
57
+ if (init?.type === "ObjectExpression") {
58
+ for (const property of init.properties ?? []) {
59
+ const key = property.key?.type === "Identifier" ? property.key.name : property.key?.value;
60
+ if (property.type !== "Property" || property.computed || typeof key !== "string" || property.value?.type !== "Literal") fail("hydrate must be a string, or an object of strings: { Chart: \"visible\" }", property);
61
+ byName.set(key, check(property.value.value, property.value));
62
+ }
63
+ return { byName };
64
+ }
65
+ fail("hydrate must be written as a literal: \"visible\", or { Chart: \"visible\" }", declarator);
66
+ }
67
+ }
68
+ return { byName };
69
+ }
70
+ /** Wraps a `"use client"` module's components as islands, or returns null for any other module. */
71
+ function transformClientModule(options) {
72
+ const { code, id, root } = options;
73
+ if (!hasModuleDirective(code, options.directive ?? "use client")) return null;
74
+ const file = id.split("?", 1)[0];
75
+ const relative = path.relative(root, file).split(path.sep).join("/");
76
+ const program = options.parse(code);
77
+ const fail = (message, node) => {
78
+ throw new ActionCompileError(message, file, code, node.start);
79
+ };
80
+ const strategies = readStrategies(program, fail);
81
+ const strategyOf = (name) => {
82
+ const configured = options.strategy?.(name);
83
+ if (configured !== void 0 && !ISLAND_STRATEGIES.includes(configured)) throw new Error(`islx: strategy for ${name} must be one of ${ISLAND_STRATEGIES.join(", ")}`);
84
+ return configured ?? strategies.byName.get(name) ?? strategies.all ?? "load";
85
+ };
86
+ const output = new MagicString(code);
87
+ const wrapped = [];
88
+ for (const node of program.body ?? []) if (node.type === "ExportNamedDeclaration" && !node.source && node.exportKind !== "type") {
89
+ const declaration = node.declaration;
90
+ if (declaration) {
91
+ const names = declaration.type === "VariableDeclaration" ? declaration.declarations.flatMap((d) => d.id?.type === "Identifier" && !(d.init && VALUE_TYPES.has(d.init.type)) ? [d.id.name] : []) : declaration.id?.name ? [declaration.id.name] : [];
92
+ const declared = declaration.type === "VariableDeclaration" ? declaration.declarations.length : names.length;
93
+ const components = names.filter(isComponentName);
94
+ if (components.length === 0 || String(declaration.type).startsWith("TS")) continue;
95
+ if (components.length !== declared) fail("Export components and other values in separate statements", declaration);
96
+ output.remove(node.start, declaration.start);
97
+ for (const name of components) wrapped.push({
98
+ local: name,
99
+ exportName: name
100
+ });
101
+ continue;
102
+ }
103
+ const kept = [];
104
+ for (const specifier of node.specifiers ?? []) {
105
+ const exported = specifier.exported?.name ?? specifier.exported?.value;
106
+ const local = specifier.local?.name ?? specifier.local?.value;
107
+ if (specifier.exportKind !== "type" && (isComponentName(exported) || exported === "default")) wrapped.push({
108
+ local,
109
+ exportName: exported
110
+ });
111
+ else kept.push(output.slice(specifier.start, specifier.end));
112
+ }
113
+ output.overwrite(node.start, node.end, kept.length > 0 ? `export { ${kept.join(", ")} };` : "");
114
+ } else if (node.type === "ExportDefaultDeclaration") {
115
+ const declaration = node.declaration;
116
+ if (FUNCTION_TYPES.has(declaration.type) || declaration.type === "ClassDeclaration" || declaration.type === "ClassExpression") {
117
+ if (declaration.id?.name) {
118
+ output.remove(node.start, declaration.start);
119
+ wrapped.push({
120
+ local: declaration.id.name,
121
+ exportName: "default"
122
+ });
123
+ } else {
124
+ output.overwrite(node.start, declaration.start, "const $$islx_default = ");
125
+ wrapped.push({
126
+ local: "$$islx_default",
127
+ exportName: "default"
128
+ });
129
+ }
130
+ } else if (declaration.type === "Identifier" || declaration.type.endsWith("Expression")) {
131
+ output.overwrite(node.start, declaration.start, "const $$islx_default = ");
132
+ if (!code.slice(declaration.end, node.end).includes(";")) output.appendLeft(declaration.end, ";");
133
+ wrapped.push({
134
+ local: "$$islx_default",
135
+ exportName: "default"
136
+ });
137
+ }
138
+ }
139
+ if (wrapped.length === 0) return null;
140
+ const runtime = options.runtime ?? "@farm.js/islx/react";
141
+ const src = options.reference(relative);
142
+ const lines = [...wrapped.map(({ local, exportName }, index) => {
143
+ return `const $$islx_island_${index} = $$islx_island(${local}, ${src}, ${JSON.stringify(exportName)}, ${JSON.stringify(strategyOf(exportName === "default" ? "default" : exportName))});`;
144
+ }), `export { ${wrapped.map(({ exportName }, index) => `$$islx_island_${index} as ${exportName}`).join(", ")} };`];
145
+ const imports = [`import { createIsland as $$islx_island } from ${JSON.stringify(runtime)};`, ...(options.sideEffects ?? []).map((module) => `import ${JSON.stringify(module)};`)];
146
+ output.prepend(`${imports.join("\n")}\n`);
147
+ output.append(`\n${lines.join("\n")}\n`);
148
+ return {
149
+ code: output.toString(),
150
+ map: output.generateMap({
151
+ hires: true,
152
+ source: file
153
+ }),
154
+ islands: wrapped.map(({ exportName }) => ({
155
+ exportName,
156
+ strategy: strategyOf(exportName)
157
+ }))
158
+ };
159
+ }
160
+ // src/vite.ts
161
+ /**
162
+ * @farm.js/islx/vite: islx for Vite 6 and later (the Environment API).
163
+ *
164
+ * import react from "@vitejs/plugin-react";
165
+ * import { islx } from "@farm.js/islx/vite";
166
+ * export default defineConfig({ plugins: [react(), islx()] });
167
+ *
168
+ * - Server environments: `"use client"` components render as islands, `"use server"` exports
169
+ * and inline actions register.
170
+ * - The client environment: `"use server"` modules become references; inline actions are
171
+ * refused; the browser entry hydrates islands.
172
+ * - `vite build` builds the server first, which finds the client components pages use, then the
173
+ * browser with exactly those (plus `clientComponents.include`), each in a chunk of its own that
174
+ * the browser entry imports when an island needs it. An island names its module by its path
175
+ * from the root; the server build learns the entry's URL once the browser build has named it.
176
+ */
177
+ const RUNTIME_ID = "virtual:islx/runtime";
178
+ /** @internal The browser entry, for a framework whose own entry imports it. */
179
+ const ENTRY_ID = "virtual:islx/client-entry";
180
+ const CLIENT_HOOKS_ID = "virtual:islx/hooks-client";
181
+ const SERVER_HOOKS_ID = "virtual:islx/hooks-server";
182
+ const BROWSER_GLOBALS = /* @__PURE__ */ new Set([
183
+ "window",
184
+ "document",
185
+ "location",
186
+ "history",
187
+ "navigator",
188
+ "screen",
189
+ "localStorage",
190
+ "sessionStorage",
191
+ "alert",
192
+ "confirm",
193
+ "prompt",
194
+ "requestAnimationFrame",
195
+ "cancelAnimationFrame",
196
+ "requestIdleCallback",
197
+ "cancelIdleCallback",
198
+ "IntersectionObserver",
199
+ "MutationObserver",
200
+ "ResizeObserver",
201
+ "HTMLElement",
202
+ "Element",
203
+ "Node",
204
+ "CustomEvent",
205
+ "Event",
206
+ "matchMedia",
207
+ "getComputedStyle",
208
+ "innerWidth",
209
+ "innerHeight",
210
+ "scrollX",
211
+ "scrollY",
212
+ "self"
213
+ ]);
214
+ /**
215
+ * The source of a hooks module made from callbacks. Each callback is copied as written, so it
216
+ * must not use anything from where it was written: an outside variable, an import.
217
+ */
218
+ function serializeHooks(hooks, where, parse) {
219
+ const entries = [];
220
+ for (const [name, value] of Object.entries(hooks)) {
221
+ if (value === void 0) continue;
222
+ if (typeof value !== "function") throw new Error(`islx: hooks.${where}.${name} must be a function`);
223
+ const source = Function.prototype.toString.call(value);
224
+ if (source.includes("[native code]")) throw new Error(`islx: hooks.${where}.${name} must be written in the config, not a built-in or bound function`);
225
+ const expression = parse("hook.js", `(${source});`).errors.length === 0;
226
+ entries.push(expression ? `${JSON.stringify(name)}: ${source}` : source);
227
+ }
228
+ const code = `export default {\n${entries.join(",\n")}\n};\n`;
229
+ const program = parse("hooks.js", code);
230
+ const { globals } = analyze(program);
231
+ const outside = [...globals.keys()].filter((name) => where === "client" ? !(name in globalThis) && !BROWSER_GLOBALS.has(name) : BROWSER_GLOBALS.has(name) || !(name in globalThis));
232
+ let imports = false;
233
+ walk(program, { enter(node) {
234
+ if (node.type === "ImportExpression") imports = true;
235
+ } });
236
+ if (outside.length > 0 || imports) {
237
+ const what = imports ? "`import()`" : outside.map((name) => `\`${name}\``).join(", ");
238
+ throw new Error(`islx: hooks.${where} uses ${what}, which does not exist where the hook runs: hooks written in the config are copied into the ${where === "client" ? "browser" : "server"} build as source. Use a global${where === "client" ? " (window.analytics)" : ""}, or put the hooks in a module and pass its path: hooks: { ${where}: "./src/islx.${where}.ts" }.`);
239
+ }
240
+ return code;
241
+ }
242
+ /** Stand for the browser entry's URL, and the files each client module needs, in the server
243
+ * build until the browser build names them. */
244
+ const ENTRY_PLACEHOLDER = "__islx_client_entry_url__";
245
+ const MODULES_PLACEHOLDER = "__islx_client_modules__";
246
+ const SCRIPT = /\.[cm]?[jt]sx?$/;
247
+ async function createParser() {
248
+ const withErrors = (result) => Object.assign(result.program, { errors: result.errors ?? [] });
249
+ const vite = await import("vite");
250
+ if (typeof vite.parseSync === "function") return (file, code) => withErrors(vite.parseSync(file, code));
251
+ try {
252
+ const oxc = await import("oxc-parser");
253
+ return (file, code) => withErrors(oxc.parseSync(file, code));
254
+ } catch {
255
+ throw new Error("@farm.js/islx/vite needs Vite 8, or oxc-parser installed with an older Vite");
256
+ }
257
+ }
258
+ /** A tiny glob matcher: `**`, `*` and `?`, on paths from the root. */
259
+ function globToRegExp(glob) {
260
+ let pattern = "";
261
+ for (let index = 0; index < glob.length; index++) {
262
+ const char = glob[index];
263
+ if (char === "*" && glob[index + 1] === "*") {
264
+ pattern += glob[index + 2] === "/" ? "(?:.*/)?" : ".*";
265
+ index += glob[index + 2] === "/" ? 2 : 1;
266
+ } else if (char === "*") pattern += "[^/]*";
267
+ else if (char === "?") pattern += "[^/]";
268
+ else pattern += char.replace(/[.+^${}()|[\]\\]/g, "\\$&");
269
+ }
270
+ return new RegExp(`^${pattern.replace(/^\.\//, "")}$`);
271
+ }
272
+ async function listFiles(root, directory = root) {
273
+ const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);
274
+ const files = [];
275
+ for (const entry of entries) {
276
+ if (entry.name === "node_modules" || entry.name.startsWith(".") || entry.name === "dist") continue;
277
+ const full = path.join(directory, entry.name);
278
+ if (entry.isDirectory()) files.push(...await listFiles(root, full));
279
+ else if (SCRIPT.test(entry.name)) files.push(full);
280
+ }
281
+ return files;
282
+ }
283
+ async function listOutput(directory) {
284
+ const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);
285
+ const files = [];
286
+ for (const entry of entries) {
287
+ const full = path.join(directory, entry.name);
288
+ if (entry.isDirectory()) files.push(...await listOutput(full));
289
+ else if (/\.[cm]?js$/.test(entry.name)) files.push(full);
290
+ }
291
+ return files;
292
+ }
293
+ const toPosix = (value) => value.split(path.sep).join("/");
294
+ const RESERVED_DIRECTIVES = /* @__PURE__ */ new Set(["use strict", "use asm"]);
295
+ /** The directives to use, refusing ones that would make a file mean two things. */
296
+ function resolveDirectives(directives = {}) {
297
+ const client = directives.client ?? "use client";
298
+ const server = directives.server ?? "use server";
299
+ for (const [kind, value] of [["client", client], ["server", server]]) if (typeof value !== "string" || !/^[\w-]+( [\w-]+)*$/.test(value) || RESERVED_DIRECTIVES.has(value)) throw new Error(`islx: directives.${kind} must be a plain directive such as "use island", not ${JSON.stringify(value)}`);
300
+ if (client === server) throw new Error(`islx: directives.client and directives.server are both ${JSON.stringify(client)}`);
301
+ return {
302
+ client,
303
+ server
304
+ };
305
+ }
306
+ function islx(options = {}, host = {}) {
307
+ const directives = resolveDirectives(options.directives);
308
+ let config;
309
+ let parse;
310
+ let preamble = false;
311
+ const include = (options.clientComponents?.include ?? []).map(globToRegExp);
312
+ const exclude = (options.clientComponents?.exclude ?? []).map(globToRegExp);
313
+ /** Client modules the server build rendered, by path from the root. */
314
+ const discovered = /* @__PURE__ */ new Set();
315
+ /** The browser entry's URL, once the browser build named it. */
316
+ let entryUrl;
317
+ /** The files each client module needs, once the browser build named them. */
318
+ const moduleFiles = {};
319
+ /** Whether the browser build ran first (a framework that orders the build). */
320
+ let clientBuilt = false;
321
+ const buildKey = randomBytes(32).toString("base64url");
322
+ const isServer = (name) => options.serverEnvironments ? options.serverEnvironments.includes(name) : name !== "client";
323
+ const relativeOf = (id) => toPosix(path.relative(config.root, id.split("?", 1)[0]));
324
+ const excluded = (relative) => exclude.some((pattern) => pattern.test(relative));
325
+ const isBuild = () => config.command === "build";
326
+ const clientInputs = async () => {
327
+ const inputs = new Set(discovered);
328
+ if (include.length > 0) for (const file of await listFiles(config.root)) {
329
+ const relative = relativeOf(file);
330
+ if (!include.some((pattern) => pattern.test(relative)) || excluded(relative)) continue;
331
+ if ((await readFile(file, "utf8")).includes("use client")) inputs.add(relative);
332
+ }
333
+ return [...inputs].sort();
334
+ };
335
+ return [
336
+ {
337
+ name: "islx",
338
+ enforce: "pre",
339
+ sharedDuringBuild: true,
340
+ config(user) {
341
+ const clientBuild = user.environments?.client?.build;
342
+ const input = clientBuild?.rollupOptions?.input;
343
+ return {
344
+ builder: user.builder ?? {},
345
+ environments: { client: {
346
+ optimizeDeps: { include: [
347
+ "react",
348
+ "react/jsx-runtime",
349
+ "react/jsx-dev-runtime",
350
+ "react-dom",
351
+ "react-dom/client"
352
+ ] },
353
+ build: {
354
+ outDir: clientBuild?.outDir ?? "dist/client",
355
+ rollupOptions: { input: host.frameworkEntry ? input : {
356
+ ...typeof input === "string" ? { index: input } : Array.isArray(input) ? Object.fromEntries(input.map((entry, index) => [`input${index}`, entry])) : input,
357
+ "islx-entry": ENTRY_ID
358
+ } }
359
+ }
360
+ } }
361
+ };
362
+ },
363
+ async configResolved(resolved) {
364
+ config = resolved;
365
+ parse = await createParser();
366
+ preamble = resolved.plugins.some((plugin) => plugin.name === "vite:react-virtual-preamble");
367
+ },
368
+ resolveId(id) {
369
+ if (id === RUNTIME_ID || id === "virtual:islx/client-entry" || id === CLIENT_HOOKS_ID || id === SERVER_HOOKS_ID) return `\0${id}`;
370
+ },
371
+ async load(id) {
372
+ if (id === `\0${RUNTIME_ID}`) {
373
+ const entry = host.frameworkEntry ? void 0 : !isBuild() ? `${config.base}@id/__x00__${ENTRY_ID}` : clientBuilt ? entryUrl : ENTRY_PLACEHOLDER;
374
+ const modules = !isBuild() ? "{}" : clientBuilt ? JSON.stringify(moduleFiles) : `JSON.parse(${JSON.stringify(MODULES_PLACEHOLDER)})`;
375
+ return [
376
+ ...host.frameworkRender ? [`import "@farm.js/islx/react/server";`] : [],
377
+ `import { setBuildDefaults, setServerHooks } from "@farm.js/islx/server";`,
378
+ `import hooks from ${JSON.stringify(SERVER_HOOKS_ID)};`,
379
+ `setBuildDefaults({ entry: ${JSON.stringify(entry)}, key: ${JSON.stringify(buildKey)}, modules: ${modules} });`,
380
+ `setServerHooks(hooks);`
381
+ ].join("\n");
382
+ }
383
+ if (id === `\0${CLIENT_HOOKS_ID}` || id === `\0${SERVER_HOOKS_ID}`) {
384
+ const where = id === `\0${CLIENT_HOOKS_ID}` ? "client" : "server";
385
+ const hooks = options.hooks?.[where];
386
+ if (hooks === void 0) return "export default undefined;";
387
+ if (typeof hooks === "string") return `export { default } from ${JSON.stringify(path.resolve(config.root, hooks))};`;
388
+ return serializeHooks(hooks, where, parse);
389
+ }
390
+ if (id === `\0virtual:islx/client-entry`) {
391
+ const load = isBuild() ? `const modules = {\n${(await clientInputs()).map((relative) => ` ${JSON.stringify(relative)}: () => import(${JSON.stringify(path.resolve(config.root, relative))}),`).join("\n")}\n};\nconst load = (src) => modules[src] ? modules[src]() : Promise.reject(new Error("islx: no client module " + src));` : `const root = new URL(${JSON.stringify(`file://${toPosix(config.root)}/`)});\nconst load = (src) => import(/* @vite-ignore */ src.startsWith("../") ? "/@fs" + new URL(src, root).pathname : ${JSON.stringify(config.base)} + src);`;
392
+ return [
393
+ ...preamble && !isBuild() ? [`import "@vitejs/plugin-react/preamble";`] : [],
394
+ `import { createHydrationRuntime, refreshDocument, scheduleHydration, swapDocument } from "@farm.js/islx/react/client";`,
395
+ `import { enhanceForms, setActionNavigator, setClientHooks, startNavigation, navigate } from "@farm.js/islx/client";`,
396
+ `import hooks from ${JSON.stringify(CLIENT_HOOKS_ID)};`,
397
+ `setClientHooks(hooks);`,
398
+ load,
399
+ `const runtime = createHydrationRuntime({ load, schedule: scheduleHydration });`,
400
+ `setActionNavigator({ refresh: () => refreshDocument(runtime), navigate: (href) => navigate(href) });`,
401
+ `enhanceForms();`,
402
+ ...options.navigation === false ? [] : [`startNavigation({ swap: (next) => swapDocument(runtime, next), viewTransition: ${typeof options.navigation === "object" && options.navigation.viewTransition === true} });`],
403
+ `runtime.hydrate(document);`,
404
+ `export { runtime };`
405
+ ].join("\n");
406
+ }
407
+ },
408
+ transform(code, id) {
409
+ if (id.startsWith("\0") || !SCRIPT.test(id.split("?", 1)[0])) return null;
410
+ const library = id.includes("/node_modules/");
411
+ const clientDirective = library ? "use client" : directives.client;
412
+ if (!code.includes(clientDirective) && (library || !code.includes(directives.server))) return null;
413
+ const file = id.split("?", 1)[0];
414
+ const server = isServer(this.environment.name);
415
+ const relative = relativeOf(file);
416
+ const parseFile = (source) => parse(file, source);
417
+ if (server && !excluded(relative)) {
418
+ const island = transformClientModule({
419
+ code,
420
+ id: file,
421
+ root: config.root,
422
+ parse: parseFile,
423
+ reference: (relative) => {
424
+ discovered.add(relative);
425
+ return JSON.stringify(relative);
426
+ },
427
+ sideEffects: [RUNTIME_ID],
428
+ directive: clientDirective
429
+ });
430
+ if (island) {
431
+ if (!library) transformActions({
432
+ code,
433
+ id: file,
434
+ root: config.root,
435
+ environment: "client",
436
+ parse: parseFile,
437
+ directive: directives.server
438
+ });
439
+ return {
440
+ code: island.code,
441
+ map: island.map
442
+ };
443
+ }
444
+ }
445
+ if (library) return null;
446
+ const actions = transformActions({
447
+ code,
448
+ id: file,
449
+ root: config.root,
450
+ environment: server ? "server" : "client",
451
+ parse: parseFile,
452
+ directive: directives.server
453
+ });
454
+ if (!actions) return null;
455
+ return {
456
+ code: server ? `import ${JSON.stringify(RUNTIME_ID)};\n${actions.code}` : actions.code,
457
+ map: server ? null : actions.map
458
+ };
459
+ }
460
+ },
461
+ {
462
+ name: "islx:reload",
463
+ apply: "serve",
464
+ hotUpdate({ file, modules, server }) {
465
+ if (!isServer(this.environment.name) || modules.length === 0) return;
466
+ const client = server.environments.client;
467
+ if (client?.moduleGraph.getModulesByFile(file)?.size) return;
468
+ client?.hot.send({ type: "full-reload" });
469
+ }
470
+ },
471
+ {
472
+ name: "islx:build",
473
+ sharedDuringBuild: true,
474
+ async buildApp(builder) {
475
+ if (host.frameworkBuild) return;
476
+ const servers = Object.values(builder.environments).filter((environment) => isServer(environment.name));
477
+ for (const environment of servers) await builder.build(environment);
478
+ await builder.build(builder.environments.client);
479
+ if (!entryUrl) throw new Error("islx: the browser build did not emit the islx entry");
480
+ for (const environment of servers) {
481
+ const outDir = path.resolve(config.root, environment.config.build.outDir);
482
+ for (const file of await listOutput(outDir)) {
483
+ const source = await readFile(file, "utf8");
484
+ if (!source.includes(ENTRY_PLACEHOLDER) && !source.includes(MODULES_PLACEHOLDER)) continue;
485
+ const modules = JSON.stringify(JSON.stringify(moduleFiles)).slice(1, -1);
486
+ await writeFile(file, source.replaceAll(ENTRY_PLACEHOLDER, entryUrl).replaceAll(MODULES_PLACEHOLDER, modules));
487
+ }
488
+ }
489
+ },
490
+ generateBundle(_options, bundle) {
491
+ if (this.environment.name !== "client") return;
492
+ const url = (fileName) => `${config.base}${fileName}`;
493
+ for (const chunk of Object.values(bundle)) {
494
+ if (chunk.type !== "chunk" || !chunk.facadeModuleId) continue;
495
+ if (chunk.isEntry && chunk.facadeModuleId === `\0virtual:islx/client-entry`) entryUrl = url(chunk.fileName);
496
+ else if (chunk.isDynamicEntry && !chunk.facadeModuleId.startsWith("\0")) moduleFiles[relativeOf(chunk.facadeModuleId)] = [chunk.fileName, ...chunk.imports].map(url);
497
+ }
498
+ clientBuilt = true;
499
+ }
500
+ }
501
+ ];
502
+ }
503
+ export { serializeHooks as i, islx as n, resolveDirectives as r, ENTRY_ID as t };
@@ -24,6 +24,11 @@ declare const TREE_SCRIPT_TYPE = "f/tree";
24
24
  declare const CHUNK_SCRIPT_TYPE = "f/chunk";
25
25
  /** The element around server HTML inside a server tree. */
26
26
  declare const HTML_ELEMENT = "f-html";
27
+ /**
28
+ * The script type of a promise's outcome, written when it settles: `{"v":value}`, or `{"e":1}` for
29
+ * a rejection. Its `name` attribute names the promise.
30
+ */
31
+ declare const PROMISE_SCRIPT_TYPE = "f/promise";
27
32
  /** The script type of React's form state after a `useActionState` form post, for hydration. */
28
33
  declare const FORM_STATE_SCRIPT_TYPE = "f/form-state";
29
34
  /** The reserved JSON key whose value is a tag. */
@@ -38,6 +43,11 @@ declare const REFERENCE_TAG = "r";
38
43
  declare const SLOT_TAG = "s";
39
44
  /** `{"$":"a","v":id}` or `{"$":"a","v":id,"b":sealed}`: a server action. */
40
45
  declare const ACTION_TAG = "a";
46
+ /**
47
+ * `{"$":"T","v":name}`: a promise an island receives, settled by the `f/promise` script `name`.
48
+ * (Inside a server tree, `{"$":"P","v":value}` is a promise that resolved already.)
49
+ */
50
+ declare const PROMISE_TAG = "T";
41
51
  /** `{"$":"o","v":{…}}`: app data that has its own `$` key. */
42
52
  declare const OBJECT_TAG = "o";
43
53
  /** `{"$":"F","v":n}`: a `FormData` argument, sent as fields of a multipart call. */
@@ -95,4 +105,4 @@ declare const MAX_HELD_VALUES = 128;
95
105
  * `{"$":"a","v":id,"b":sealed}`), or undefined for anything else.
96
106
  */
97
107
  declare function getTag(value: unknown): string | undefined;
98
- export { VALUE_SCRIPT_TYPE as A, SLOT_TAG as C, TREE_SCRIPT_TYPE as D, TAG_VALUE as E, stripRuntimeFields as F, formFieldName as M, getTag as N, VALUES_HEADER as O, readPostedAction as P, SLOT_ELEMENT as S, TAG_BOUND as T, MAX_HELD_VALUES as _, BLOB_TAG as a, REFERENCE_TAG as b, CHUNK_SCRIPT_TYPE as c, FORM_REF_PREFIX as d, FORM_STATE_SCRIPT_TYPE as f, LAYOUTS_HEADER as g, ISLAND_ELEMENT as h, ACTION_TAG as i, attachmentField as j, VALUE_KEY_PATTERN as k, FORM_DATA_TAG as l, HYDRATED_ATTRIBUTE as m, ACTION_KEY_FIELD as n, BOUND_FIELD as o, HTML_ELEMENT as p, ACTION_STALE_HEADER as r, CALL_FIELD as s, ACTION_HEADER as t, FORM_FIELD_PREFIX as u, OBJECT_TAG as v, TAG as w, RENDER_HEADER as x, PROPS_SCRIPT_TYPE as y };
108
+ export { VALUES_HEADER as A, RENDER_HEADER as C, TAG_BOUND as D, TAG as E, getTag as F, readPostedAction as I, stripRuntimeFields as L, VALUE_SCRIPT_TYPE as M, attachmentField as N, TAG_VALUE as O, formFieldName as P, REFERENCE_TAG as S, SLOT_TAG as T, MAX_HELD_VALUES as _, BLOB_TAG as a, PROMISE_TAG as b, CHUNK_SCRIPT_TYPE as c, FORM_REF_PREFIX as d, FORM_STATE_SCRIPT_TYPE as f, LAYOUTS_HEADER as g, ISLAND_ELEMENT as h, ACTION_TAG as i, VALUE_KEY_PATTERN as j, TREE_SCRIPT_TYPE as k, FORM_DATA_TAG as l, HYDRATED_ATTRIBUTE as m, ACTION_KEY_FIELD as n, BOUND_FIELD as o, HTML_ELEMENT as p, ACTION_STALE_HEADER as r, CALL_FIELD as s, ACTION_HEADER as t, FORM_FIELD_PREFIX as u, OBJECT_TAG as v, SLOT_ELEMENT as w, PROPS_SCRIPT_TYPE as x, PROMISE_SCRIPT_TYPE as y };
@@ -25,6 +25,11 @@ const TREE_SCRIPT_TYPE = "f/tree";
25
25
  const CHUNK_SCRIPT_TYPE = "f/chunk";
26
26
  /** The element around server HTML inside a server tree. */
27
27
  const HTML_ELEMENT = "f-html";
28
+ /**
29
+ * The script type of a promise's outcome, written when it settles: `{"v":value}`, or `{"e":1}` for
30
+ * a rejection. Its `name` attribute names the promise.
31
+ */
32
+ const PROMISE_SCRIPT_TYPE = "f/promise";
28
33
  /** The script type of React's form state after a `useActionState` form post, for hydration. */
29
34
  const FORM_STATE_SCRIPT_TYPE = "f/form-state";
30
35
  /** The reserved JSON key whose value is a tag. */
@@ -39,6 +44,11 @@ const REFERENCE_TAG = "r";
39
44
  const SLOT_TAG = "s";
40
45
  /** `{"$":"a","v":id}` or `{"$":"a","v":id,"b":sealed}`: a server action. */
41
46
  const ACTION_TAG = "a";
47
+ /**
48
+ * `{"$":"T","v":name}`: a promise an island receives, settled by the `f/promise` script `name`.
49
+ * (Inside a server tree, `{"$":"P","v":value}` is a promise that resolved already.)
50
+ */
51
+ const PROMISE_TAG = "T";
42
52
  /** `{"$":"o","v":{…}}`: app data that has its own `$` key. */
43
53
  const OBJECT_TAG = "o";
44
54
  /** `{"$":"F","v":n}`: a `FormData` argument, sent as fields of a multipart call. */
@@ -118,4 +128,4 @@ function getTag(value) {
118
128
  if (keys.length === 2 && "v" in value) return tag;
119
129
  if (keys.length === 3 && tag === "a" && "v" in value && "b" in value) return tag;
120
130
  }
121
- export { VALUE_SCRIPT_TYPE as A, SLOT_TAG as C, TREE_SCRIPT_TYPE as D, TAG_VALUE as E, stripRuntimeFields as F, formFieldName as M, getTag as N, VALUES_HEADER as O, readPostedAction as P, SLOT_ELEMENT as S, TAG_BOUND as T, MAX_HELD_VALUES as _, BLOB_TAG as a, REFERENCE_TAG as b, CHUNK_SCRIPT_TYPE as c, FORM_REF_PREFIX as d, FORM_STATE_SCRIPT_TYPE as f, LAYOUTS_HEADER as g, ISLAND_ELEMENT as h, ACTION_TAG as i, attachmentField as j, VALUE_KEY_PATTERN as k, FORM_DATA_TAG as l, HYDRATED_ATTRIBUTE as m, ACTION_KEY_FIELD as n, BOUND_FIELD as o, HTML_ELEMENT as p, ACTION_STALE_HEADER as r, CALL_FIELD as s, ACTION_HEADER as t, FORM_FIELD_PREFIX as u, OBJECT_TAG as v, TAG as w, RENDER_HEADER as x, PROPS_SCRIPT_TYPE as y };
131
+ export { VALUES_HEADER as A, RENDER_HEADER as C, TAG_BOUND as D, TAG as E, getTag as F, readPostedAction as I, stripRuntimeFields as L, VALUE_SCRIPT_TYPE as M, attachmentField as N, TAG_VALUE as O, formFieldName as P, REFERENCE_TAG as S, SLOT_TAG as T, MAX_HELD_VALUES as _, BLOB_TAG as a, PROMISE_TAG as b, CHUNK_SCRIPT_TYPE as c, FORM_REF_PREFIX as d, FORM_STATE_SCRIPT_TYPE as f, LAYOUTS_HEADER as g, ISLAND_ELEMENT as h, ACTION_TAG as i, VALUE_KEY_PATTERN as j, TREE_SCRIPT_TYPE as k, FORM_DATA_TAG as l, HYDRATED_ATTRIBUTE as m, ACTION_KEY_FIELD as n, BOUND_FIELD as o, HTML_ELEMENT as p, ACTION_STALE_HEADER as r, CALL_FIELD as s, ACTION_HEADER as t, FORM_FIELD_PREFIX as u, OBJECT_TAG as v, SLOT_ELEMENT as w, PROPS_SCRIPT_TYPE as x, PROMISE_SCRIPT_TYPE as y };
package/dist/client.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as emit, c as createValueStore, i as defineClientHooks, l as getValueStore, n as decodeActionReference, o as hookEventName, r as setActionNavigator, s as setClientHooks, t as createServerReference, u as valueHeaders } from "./_chunks/actions-2sTj0A2T.mjs";
2
- import { F as stripRuntimeFields, P as readPostedAction, x as RENDER_HEADER } from "./_chunks/wire-CXOodE06.mjs";
1
+ import { a as emit, c as createValueStore, i as defineClientHooks, l as getValueStore, n as decodeActionReference, o as hookEventName, r as setActionNavigator, s as setClientHooks, t as createServerReference, u as valueHeaders } from "./_chunks/actions-8RQfrM-p.mjs";
2
+ import { C as RENDER_HEADER, I as readPostedAction, L as stripRuntimeFields } from "./_chunks/wire-QEQWBr5s.mjs";
3
3
  import { i as REPLAYABLE_SELECTOR, n as PENDING_INTERACTIONS, r as PREHYDRATION_SCRIPT, t as INTERACTION_EVENT } from "./_chunks/prehydration-B1GLTLdk.mjs";
4
4
  // src/client/forms.ts
5
5
  /**
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as VALUE_SCRIPT_TYPE, C as SLOT_TAG, D as TREE_SCRIPT_TYPE, E as TAG_VALUE, F as stripRuntimeFields, M as formFieldName, N as getTag, O as VALUES_HEADER, P as readPostedAction, S as SLOT_ELEMENT, T as TAG_BOUND, _ as MAX_HELD_VALUES, a as BLOB_TAG, b as REFERENCE_TAG, c as CHUNK_SCRIPT_TYPE, d as FORM_REF_PREFIX, f as FORM_STATE_SCRIPT_TYPE, g as LAYOUTS_HEADER, h as ISLAND_ELEMENT, i as ACTION_TAG, j as attachmentField, k as VALUE_KEY_PATTERN, l as FORM_DATA_TAG, m as HYDRATED_ATTRIBUTE, n as ACTION_KEY_FIELD, o as BOUND_FIELD, p as HTML_ELEMENT, r as ACTION_STALE_HEADER, s as CALL_FIELD, t as ACTION_HEADER, u as FORM_FIELD_PREFIX, v as OBJECT_TAG, w as TAG, x as RENDER_HEADER, y as PROPS_SCRIPT_TYPE } from "./_chunks/wire-C3Rpbwl6.mjs";
1
+ import { A as VALUES_HEADER, C as RENDER_HEADER, D as TAG_BOUND, E as TAG, F as getTag, I as readPostedAction, L as stripRuntimeFields, M as VALUE_SCRIPT_TYPE, N as attachmentField, O as TAG_VALUE, P as formFieldName, S as REFERENCE_TAG, T as SLOT_TAG, _ as MAX_HELD_VALUES, a as BLOB_TAG, b as PROMISE_TAG, c as CHUNK_SCRIPT_TYPE, d as FORM_REF_PREFIX, f as FORM_STATE_SCRIPT_TYPE, g as LAYOUTS_HEADER, h as ISLAND_ELEMENT, i as ACTION_TAG, j as VALUE_KEY_PATTERN, k as TREE_SCRIPT_TYPE, l as FORM_DATA_TAG, m as HYDRATED_ATTRIBUTE, n as ACTION_KEY_FIELD, o as BOUND_FIELD, p as HTML_ELEMENT, r as ACTION_STALE_HEADER, s as CALL_FIELD, t as ACTION_HEADER, u as FORM_FIELD_PREFIX, v as OBJECT_TAG, w as SLOT_ELEMENT, x as PROPS_SCRIPT_TYPE, y as PROMISE_SCRIPT_TYPE } from "./_chunks/wire-Dipqh-EB.mjs";
2
2
  import { a as decode, c as encodeLeaf, d as plainObject, f as tagged, i as NOT_A_VALUE, l as fromBase64, n as EncodeError, o as decodeTagged, p as toBase64, r as EncodeOptions, s as encode, t as DecodeOptions, u as needsObjectTag } from "./_chunks/codec-CK8kZp4u.mjs";
3
- export { ACTION_HEADER, ACTION_KEY_FIELD, ACTION_STALE_HEADER, ACTION_TAG, BLOB_TAG, BOUND_FIELD, CALL_FIELD, CHUNK_SCRIPT_TYPE, type DecodeOptions, EncodeError, type EncodeOptions, FORM_DATA_TAG, FORM_FIELD_PREFIX, FORM_REF_PREFIX, FORM_STATE_SCRIPT_TYPE, HTML_ELEMENT, HYDRATED_ATTRIBUTE, ISLAND_ELEMENT, LAYOUTS_HEADER, MAX_HELD_VALUES, NOT_A_VALUE, OBJECT_TAG, PROPS_SCRIPT_TYPE, REFERENCE_TAG, RENDER_HEADER, SLOT_ELEMENT, SLOT_TAG, TAG, TAG_BOUND, TAG_VALUE, TREE_SCRIPT_TYPE, VALUES_HEADER, VALUE_KEY_PATTERN, VALUE_SCRIPT_TYPE, attachmentField, decode, decodeTagged, encode, encodeLeaf, formFieldName, fromBase64, getTag, needsObjectTag, plainObject, readPostedAction, stripRuntimeFields, tagged, toBase64 };
3
+ export { ACTION_HEADER, ACTION_KEY_FIELD, ACTION_STALE_HEADER, ACTION_TAG, BLOB_TAG, BOUND_FIELD, CALL_FIELD, CHUNK_SCRIPT_TYPE, type DecodeOptions, EncodeError, type EncodeOptions, FORM_DATA_TAG, FORM_FIELD_PREFIX, FORM_REF_PREFIX, FORM_STATE_SCRIPT_TYPE, HTML_ELEMENT, HYDRATED_ATTRIBUTE, ISLAND_ELEMENT, LAYOUTS_HEADER, MAX_HELD_VALUES, NOT_A_VALUE, OBJECT_TAG, PROMISE_SCRIPT_TYPE, PROMISE_TAG, PROPS_SCRIPT_TYPE, REFERENCE_TAG, RENDER_HEADER, SLOT_ELEMENT, SLOT_TAG, TAG, TAG_BOUND, TAG_VALUE, TREE_SCRIPT_TYPE, VALUES_HEADER, VALUE_KEY_PATTERN, VALUE_SCRIPT_TYPE, attachmentField, decode, decodeTagged, encode, encodeLeaf, formFieldName, fromBase64, getTag, needsObjectTag, plainObject, readPostedAction, stripRuntimeFields, tagged, toBase64 };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { A as VALUE_SCRIPT_TYPE, C as SLOT_TAG, D as TREE_SCRIPT_TYPE, E as TAG_VALUE, F as stripRuntimeFields, M as formFieldName, N as getTag, O as VALUES_HEADER, P as readPostedAction, S as SLOT_ELEMENT, T as TAG_BOUND, _ as MAX_HELD_VALUES, a as BLOB_TAG, b as REFERENCE_TAG, c as CHUNK_SCRIPT_TYPE, d as FORM_REF_PREFIX, f as FORM_STATE_SCRIPT_TYPE, g as LAYOUTS_HEADER, h as ISLAND_ELEMENT, i as ACTION_TAG, j as attachmentField, k as VALUE_KEY_PATTERN, l as FORM_DATA_TAG, m as HYDRATED_ATTRIBUTE, n as ACTION_KEY_FIELD, o as BOUND_FIELD, p as HTML_ELEMENT, r as ACTION_STALE_HEADER, s as CALL_FIELD, t as ACTION_HEADER, u as FORM_FIELD_PREFIX, v as OBJECT_TAG, w as TAG, x as RENDER_HEADER, y as PROPS_SCRIPT_TYPE } from "./_chunks/wire-CXOodE06.mjs";
2
- import { a as encode, c as needsObjectTag, d as tagged, f as toBase64, i as decodeTagged, l as plainObject, n as NOT_A_VALUE, o as encodeLeaf, r as decode, s as fromBase64, t as EncodeError } from "./_chunks/codec-DqfVYKsx.mjs";
3
- export { ACTION_HEADER, ACTION_KEY_FIELD, ACTION_STALE_HEADER, ACTION_TAG, BLOB_TAG, BOUND_FIELD, CALL_FIELD, CHUNK_SCRIPT_TYPE, EncodeError, FORM_DATA_TAG, FORM_FIELD_PREFIX, FORM_REF_PREFIX, FORM_STATE_SCRIPT_TYPE, HTML_ELEMENT, HYDRATED_ATTRIBUTE, ISLAND_ELEMENT, LAYOUTS_HEADER, MAX_HELD_VALUES, NOT_A_VALUE, OBJECT_TAG, PROPS_SCRIPT_TYPE, REFERENCE_TAG, RENDER_HEADER, SLOT_ELEMENT, SLOT_TAG, TAG, TAG_BOUND, TAG_VALUE, TREE_SCRIPT_TYPE, VALUES_HEADER, VALUE_KEY_PATTERN, VALUE_SCRIPT_TYPE, attachmentField, decode, decodeTagged, encode, encodeLeaf, formFieldName, fromBase64, getTag, needsObjectTag, plainObject, readPostedAction, stripRuntimeFields, tagged, toBase64 };
1
+ import { A as VALUES_HEADER, C as RENDER_HEADER, D as TAG_BOUND, E as TAG, F as getTag, I as readPostedAction, L as stripRuntimeFields, M as VALUE_SCRIPT_TYPE, N as attachmentField, O as TAG_VALUE, P as formFieldName, S as REFERENCE_TAG, T as SLOT_TAG, _ as MAX_HELD_VALUES, a as BLOB_TAG, b as PROMISE_TAG, c as CHUNK_SCRIPT_TYPE, d as FORM_REF_PREFIX, f as FORM_STATE_SCRIPT_TYPE, g as LAYOUTS_HEADER, h as ISLAND_ELEMENT, i as ACTION_TAG, j as VALUE_KEY_PATTERN, k as TREE_SCRIPT_TYPE, l as FORM_DATA_TAG, m as HYDRATED_ATTRIBUTE, n as ACTION_KEY_FIELD, o as BOUND_FIELD, p as HTML_ELEMENT, r as ACTION_STALE_HEADER, s as CALL_FIELD, t as ACTION_HEADER, u as FORM_FIELD_PREFIX, v as OBJECT_TAG, w as SLOT_ELEMENT, x as PROPS_SCRIPT_TYPE, y as PROMISE_SCRIPT_TYPE } from "./_chunks/wire-QEQWBr5s.mjs";
2
+ import { a as encode, c as needsObjectTag, d as tagged, f as toBase64, i as decodeTagged, l as plainObject, n as NOT_A_VALUE, o as encodeLeaf, r as decode, s as fromBase64, t as EncodeError } from "./_chunks/codec-C8to-RQW.mjs";
3
+ export { ACTION_HEADER, ACTION_KEY_FIELD, ACTION_STALE_HEADER, ACTION_TAG, BLOB_TAG, BOUND_FIELD, CALL_FIELD, CHUNK_SCRIPT_TYPE, EncodeError, FORM_DATA_TAG, FORM_FIELD_PREFIX, FORM_REF_PREFIX, FORM_STATE_SCRIPT_TYPE, HTML_ELEMENT, HYDRATED_ATTRIBUTE, ISLAND_ELEMENT, LAYOUTS_HEADER, MAX_HELD_VALUES, NOT_A_VALUE, OBJECT_TAG, PROMISE_SCRIPT_TYPE, PROMISE_TAG, PROPS_SCRIPT_TYPE, REFERENCE_TAG, RENDER_HEADER, SLOT_ELEMENT, SLOT_TAG, TAG, TAG_BOUND, TAG_VALUE, TREE_SCRIPT_TYPE, VALUES_HEADER, VALUE_KEY_PATTERN, VALUE_SCRIPT_TYPE, attachmentField, decode, decodeTagged, encode, encodeLeaf, formFieldName, fromBase64, getTag, needsObjectTag, plainObject, readPostedAction, stripRuntimeFields, tagged, toBase64 };
@@ -1,5 +1,5 @@
1
1
  import { a as scheduleHydration, i as isIslandStrategy, n as IslandStrategy, r as ScheduleOptions, t as ISLAND_STRATEGIES } from "../_chunks/schedule-Dw14dW0H.mjs";
2
- import { m as HYDRATED_ATTRIBUTE } from "../_chunks/wire-C3Rpbwl6.mjs";
2
+ import { m as HYDRATED_ATTRIBUTE } from "../_chunks/wire-Dipqh-EB.mjs";
3
3
  import { t as ValueStore } from "../_chunks/value-store-Dm-7xJ6W.mjs";
4
4
  import { a as ServerTreeLayoutOptions, c as createServerTreeLayout, g as isolateIslands, i as ServerTreeLayout, n as PAYLOAD_ONLY_ATTRIBUTE, r as ServerTreeElementOptions, s as createServerTreeElement, u as updateServerTrees, v as withinClientRoot } from "../_chunks/tree-B4RMU2UX.mjs";
5
5
  import * as React from "react";
@@ -21,6 +21,12 @@ interface HydrationOptions {
21
21
  */
22
22
  schedule: typeof scheduleHydration;
23
23
  }
24
+ /**
25
+ * Marks the Suspense boundaries under `root` that still wait once their stream has ended (the
26
+ * connection dropped) as rendered in the browser, as React does when it finds one: the next
27
+ * `hydrate()` pass starts their islands. Call it when a stream that filled `root` ends.
28
+ */
29
+ declare function endStreamedContent(root: ParentNode): void;
24
30
  /** The hydration runtime for one page. */
25
31
  declare function createHydrationRuntime(options: HydrationOptions): {
26
32
  hydrate: (scope?: ParentNode, signal?: AbortSignal) => Promise<void>;
@@ -46,4 +52,4 @@ declare function createServerHtml(runtime: Pick<HydrationRuntime, "hydrate" | "d
46
52
  declare function refreshDocument(runtime: HydrationRuntime): Promise<void>;
47
53
  /** Puts another page's body in place of this one's, and hydrates its islands. */
48
54
  declare function swapDocument(runtime: HydrationRuntime, next: Document): Promise<void>;
49
- export { HYDRATED_ATTRIBUTE, type HydrationOptions, type HydrationRuntime, ISLAND_STRATEGIES, type IslandStrategy, PAYLOAD_ONLY_ATTRIBUTE, type ScheduleOptions, type ServerTreeElementOptions, type ServerTreeLayout, type ServerTreeLayoutOptions, createHydrationRuntime, createServerHtml, createServerTreeElement, createServerTreeLayout, isIslandStrategy, isolateIslands, refreshDocument, scheduleHydration, swapDocument, updateServerTrees, withinClientRoot };
55
+ export { HYDRATED_ATTRIBUTE, type HydrationOptions, type HydrationRuntime, ISLAND_STRATEGIES, type IslandStrategy, PAYLOAD_ONLY_ATTRIBUTE, type ScheduleOptions, type ServerTreeElementOptions, type ServerTreeLayout, type ServerTreeLayoutOptions, createHydrationRuntime, createServerHtml, createServerTreeElement, createServerTreeLayout, endStreamedContent, isIslandStrategy, isolateIslands, refreshDocument, scheduleHydration, swapDocument, updateServerTrees, withinClientRoot };