brumate 0.4.3 → 0.5.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/dist/{boot-D3NjfyUX.d.ts → boot-Difa0qdg.d.ts} +2 -8
- package/dist/cli.js +2 -2
- package/dist/{client-DNva05jp.d.ts → client-DvsU9qxG.d.ts} +107 -23
- package/dist/{client-AXNULmRZ.js → client-glvRglTB.js} +1000 -370
- package/dist/client-glvRglTB.js.map +1 -0
- package/dist/{defer-D3YMPgkX.js → defer-CNYYG-A5.js} +2 -2
- package/dist/{defer-D3YMPgkX.js.map → defer-CNYYG-A5.js.map} +1 -1
- package/dist/{devtools-BiP5fDiB.js → devtools-D8EioKXs.js} +4 -4
- package/dist/{devtools-BiP5fDiB.js.map → devtools-D8EioKXs.js.map} +1 -1
- package/dist/{devtools-panel-EQhLm39H.js → devtools-panel-BKmBqkau.js} +2 -2
- package/dist/{devtools-panel-EQhLm39H.js.map → devtools-panel-BKmBqkau.js.map} +1 -1
- package/dist/{features-CHY5Ekku.js → features-D5kLyihb.js} +19 -2
- package/dist/features-D5kLyihb.js.map +1 -0
- package/dist/{files-BUjvEO_o.js → files-ClQJlDcB.js} +2 -2
- package/dist/{files-BUjvEO_o.js.map → files-ClQJlDcB.js.map} +1 -1
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -1
- package/dist/{inspect-BvPTZs6k.js → inspect-B8i6R3mZ.js} +877 -132
- package/dist/inspect-B8i6R3mZ.js.map +1 -0
- package/dist/{loader-DgMk6p9M.js → loader-DB0i9MwD.js} +4 -4
- package/dist/{loader-DgMk6p9M.js.map → loader-DB0i9MwD.js.map} +1 -1
- package/dist/{navigate-CfOr-TRF.js → navigate-BcV1qkkx.js} +2 -2
- package/dist/navigate-BcV1qkkx.js.map +1 -0
- package/dist/{produce-DS-dQaUX.js → produce-Cq6KKi7b.js} +2 -2
- package/dist/{produce-DS-dQaUX.js.map → produce-Cq6KKi7b.js.map} +1 -1
- package/dist/{rpc-Bxv7DYGe.js → rpc-BHlxmeWe.js} +5 -5
- package/dist/rpc-BHlxmeWe.js.map +1 -0
- package/dist/runtime/bundles.d.ts +9 -0
- package/dist/runtime/bundles.js +60 -0
- package/dist/runtime/bundles.js.map +1 -0
- package/dist/runtime/client.d.ts +2 -2
- package/dist/runtime/client.js +3 -3
- package/dist/runtime/devtools.d.ts +1 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +4 -4
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{server-BXMH3Z9T.d.ts → server-CAwIqrXl.d.ts} +44 -5
- package/dist/{server-O_rC-RRL.js → server-Doy5HR7r.js} +106 -17
- package/dist/server-Doy5HR7r.js.map +1 -0
- package/dist/{static-loader-BiUaZaag.d.ts → static-loader-9Nc1GvF0.d.ts} +2 -2
- package/dist/{static-loader-U_x-ctJI.js → static-loader-D0ARlMxM.js} +3 -26
- package/dist/static-loader-D0ARlMxM.js.map +1 -0
- package/dist/{stream-JGRPr7u5.js → stream-BdhzvPQO.js} +2 -2
- package/dist/{stream-JGRPr7u5.js.map → stream-BdhzvPQO.js.map} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +129 -51
- package/dist/vite.js.map +1 -1
- package/package.json +5 -1
- package/skills/brumate/references/errors.md +39 -5
- package/dist/client-AXNULmRZ.js.map +0 -1
- package/dist/features-CHY5Ekku.js.map +0 -1
- package/dist/inspect-BvPTZs6k.js.map +0 -1
- package/dist/navigate-CfOr-TRF.js.map +0 -1
- package/dist/rpc-Bxv7DYGe.js.map +0 -1
- package/dist/server-O_rC-RRL.js.map +0 -1
- package/dist/static-loader-U_x-ctJI.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LoaderOptions } from "./boot-
|
|
1
|
+
import { t as LoaderOptions } from "./boot-Difa0qdg.js";
|
|
2
2
|
//#region src/runtime/static-loader.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* `start` for a site that loads every page with a full page load, as with
|
|
@@ -8,4 +8,4 @@ import { t as LoaderOptions } from "./boot-D3NjfyUX.js";
|
|
|
8
8
|
declare function startWithoutNavigation(options: LoaderOptions): () => void;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { startWithoutNavigation as t };
|
|
11
|
-
//# sourceMappingURL=static-loader-
|
|
11
|
+
//# sourceMappingURL=static-loader-9Nc1GvF0.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as HAS_LATE_MARKUP, l as HAS_LISTENERS, r as HAS_BLOCKS, t as HAS_ACTIONS } from "./features-D5kLyihb.js";
|
|
2
2
|
//#region src/runtime/boot.ts
|
|
3
3
|
/** True on the dev server. A Vite build replaces it with `false`, so the devtools calls go. */
|
|
4
4
|
const DEV = import.meta.env?.DEV;
|
|
@@ -56,17 +56,6 @@ function boot(options, navigate) {
|
|
|
56
56
|
promise?.catch(() => modules.delete(id));
|
|
57
57
|
return promise;
|
|
58
58
|
};
|
|
59
|
-
const partLoads = /* @__PURE__ */ new Map();
|
|
60
|
-
const loadPart = (module, part) => {
|
|
61
|
-
const key = `${module.id}#${part}`;
|
|
62
|
-
let promise = partLoads.get(key);
|
|
63
|
-
if (!promise) {
|
|
64
|
-
promise = module.load(part);
|
|
65
|
-
partLoads.set(key, promise);
|
|
66
|
-
promise.catch(() => partLoads.delete(key));
|
|
67
|
-
}
|
|
68
|
-
return promise;
|
|
69
|
-
};
|
|
70
59
|
let serialLoad;
|
|
71
60
|
const loadSerial = () => {
|
|
72
61
|
serialLoad ??= options.serial?.();
|
|
@@ -77,7 +66,6 @@ function boot(options, navigate) {
|
|
|
77
66
|
client.init({
|
|
78
67
|
...options,
|
|
79
68
|
load: loadModule,
|
|
80
|
-
loadPart,
|
|
81
69
|
listen: scanInsert,
|
|
82
70
|
inserted,
|
|
83
71
|
serial
|
|
@@ -213,7 +201,7 @@ function boot(options, navigate) {
|
|
|
213
201
|
run(template, ref);
|
|
214
202
|
return;
|
|
215
203
|
}
|
|
216
|
-
const done = import("./defer-
|
|
204
|
+
const done = import("./defer-CNYYG-A5.js").then((module) => module.loadDeferred(template));
|
|
217
205
|
if (DEV) devtools()?.defer?.(template, done);
|
|
218
206
|
};
|
|
219
207
|
const near = template.getAttribute("b-near");
|
|
@@ -279,17 +267,6 @@ function boot(options, navigate) {
|
|
|
279
267
|
observer?.takeRecords();
|
|
280
268
|
};
|
|
281
269
|
loadCore().catch(() => {});
|
|
282
|
-
const bundled = /* @__PURE__ */ new Set();
|
|
283
|
-
const loadBundles = () => {
|
|
284
|
-
for (const script of document.querySelectorAll("script[b-state]")) for (const [, id] of script.textContent?.matchAll(/\bm:"([^"]+)"/g) ?? []) if (!bundled.has(id)) {
|
|
285
|
-
bundled.add(id);
|
|
286
|
-
options.loadBundle?.(id)?.catch(() => {});
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
if (options.loadBundle) {
|
|
290
|
-
loadBundles();
|
|
291
|
-
if (document.readyState === "loading") listen(document, "DOMContentLoaded", loadBundles);
|
|
292
|
-
}
|
|
293
270
|
return () => {
|
|
294
271
|
stopped = true;
|
|
295
272
|
observer?.disconnect();
|
|
@@ -310,4 +287,4 @@ function startWithoutNavigation(options) {
|
|
|
310
287
|
//#endregion
|
|
311
288
|
export { boot as n, importCore as r, startWithoutNavigation as t };
|
|
312
289
|
|
|
313
|
-
//# sourceMappingURL=static-loader-
|
|
290
|
+
//# sourceMappingURL=static-loader-D0ARlMxM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-loader-D0ARlMxM.js","names":[],"sources":["../src/runtime/boot.ts","../src/runtime/static-loader.ts"],"sourcesContent":["// The loader's code that every page runs. `loader.ts` adds client navigation,\n// and `static-loader.ts` starts it without, so a site that turns navigation\n// off does not have its code, or the parts of the core that only it uses, in\n// its bundle.\n//\n// This file keeps its arrow functions and its Array methods, for size: the loader ships to every\n// page, and the function declarations and loops measured 20 to 50 bytes of gzip larger.\n\nimport { HAS_ACTIONS, HAS_BLOCKS, HAS_LATE_MARKUP, HAS_LISTENERS } from './features.ts';\nimport type * as Client from './client.ts';\nimport type { ClientModule, DevtoolsHooks } from './client.ts';\nimport type { SerialEntry } from './values.ts';\n\n/** True on the dev server. A Vite build replaces it with `false`, so the devtools calls go. */\nconst DEV = (import.meta as { env?: { DEV?: boolean } }).env?.DEV;\n\n/** The hooks of the devtools overlay, under the same key as the core's. */\nfunction devtools(): DevtoolsHooks | undefined {\n return (globalThis as Record<symbol, DevtoolsHooks | undefined>)[Symbol.for('brumate.devtools')];\n}\n\nexport interface LoaderOptions {\n /**\n * Imports the client module of a component, by component ID. Undefined for\n * a component that has no client code.\n */\n load: (id: string) => Promise<ClientModule> | undefined;\n /** The URL prefix of server function calls. */\n rpc?: string;\n /** Imports the serial entry, which the core takes before it reads the page state. */\n serial?: () => Promise<SerialEntry>;\n /**\n * Loads pages without a full page load: links to the same origin, the back\n * and forward buttons, forms that post to a server function, and redirects\n * from server functions to the same origin. Defaults to true.\n */\n navigate?: boolean | NavigateOptions;\n /**\n * The ID of the build of the page, for skew protection. The Vite plugin\n * sets it. Calls send it, and a page of another build, or a call that\n * answers 409 after a deploy, makes the next navigation a full page load.\n */\n build?: string;\n /**\n * Receives every error of client code first: of a handler, an effect, a\n * `$client` callback or a memo that loads, such as for a reporting\n * service. `scope` is the ID of the scope that the code belongs to. The\n * error then renders the `#catch` body of the nearest `#try`, or the page\n * gets a `brumate:error` event on `window` and the error is logged.\n */\n onError?: (error: unknown, info: { scope?: number | string }) => void;\n}\n\nexport interface NavigateOptions {\n /**\n * Swaps the page inside a view transition, where the browser has them.\n * CSS can tell links, the back and forward buttons and forms apart with\n * the types `push`, `traverse` and `form`. A redirect from a server\n * function has the type `form`.\n */\n transition?: boolean;\n /**\n * After a navigation, moves the focus to the first `<h1>` of the routes\n * that changed, or to `<main>`, as a full page load starts it at the top.\n * Defaults to true.\n */\n focus?: boolean;\n}\n\ninterface Entry {\n raw: string;\n type: string;\n modifiers: string[];\n ref: string;\n}\n\n// Parsed `b-on` values, so repeated events do not parse them again.\nconst parsed = new Map<string, Entry[]>();\n\nexport function entries(element: Element): Entry[] {\n const value = element.getAttribute('b-on') ?? '';\n return (parsed.get(value) ??\n parsed\n .set(\n value,\n value\n .split(' ')\n .filter(Boolean)\n .map((entry) => {\n const [name, ref] = entry.split('=') as [string, string];\n const [type, ...modifiers] = name.split(':') as [string, ...string[]];\n return { raw: entry, type, modifiers, ref };\n }),\n )\n .get(value))!;\n}\n\n/** The functions of the core that the loader calls. */\nexport type Core = (typeof Client)['loader'];\n\n/**\n * Imports the core. It reads one export by name, so a build keeps only it and\n * the helpers that compiled components call.\n */\nlet corePromise: Promise<Core> | undefined;\nexport const importCore = (): Promise<Core> =>\n (corePromise ??= import('./client.ts').then(\n (client) => client.loader,\n (error: unknown) => {\n // A load that fails can start again, such as after the network comes back.\n corePromise = undefined;\n throw error;\n },\n ));\n\n/** Runs a function when the browser is idle. */\nconst idle = (fn: () => void): unknown => (window.requestIdleCallback ?? setTimeout)(fn);\n\n/** What the loader gives the code that loads pages without a full page load. */\nexport interface Navigation {\n options: LoaderOptions;\n listen: (\n target: EventTarget,\n type: string,\n listener: (event: Event) => void,\n flags?: AddEventListenerOptions | boolean,\n ) => void;\n core: () => Promise<Core> | undefined;\n /** Starts the core, or returns the one that runs. */\n start: () => Promise<Core>;\n scan: (root: ParentNode) => void;\n}\n\n/**\n * Starts resuming the page. Listens to the events in `b-on` attributes\n * and loads `brumate/client` and the component's module on the first one.\n * `navigate` adds client navigation, and returns how to import the core.\n * Returns a function that removes the listeners and stops the core.\n */\nexport function boot(\n options: LoaderOptions,\n navigate?: (navigation: Navigation) => () => Promise<Core>,\n): () => void {\n let core: Promise<Core> | undefined;\n // Once stopped, the loader starts nothing, also from markup that the core inserts later with the\n // hooks that this loader gave it. A new loader can reuse the IDs of client scopes, so a stale\n // start would run in a scope of the new page.\n let stopped = false;\n /** The event types that the document listens to, and whether each listener is passive. */\n const types = new Map<string, boolean>();\n const removers: (() => void)[] = [];\n const listen = (\n target: EventTarget,\n type: string,\n listener: (event: Event) => void,\n flags?: AddEventListenerOptions | boolean,\n ): void => {\n target.addEventListener(type, listener, flags);\n removers.push(() => target.removeEventListener(type, listener, flags));\n };\n\n // Client navigation imports the core with the code that reads the pages it adds.\n let load = importCore;\n // The modules that the loader asked for, which the core takes, so a handler whose\n // code loaded runs without another `import()`. In Chrome, an `import()` of a module that is\n // loaded already still resolves in a task of its own, which can wait for the next frame.\n const modules = new Map<string, Promise<ClientModule> | undefined>();\n const loadModule = (id: string): Promise<ClientModule> | undefined => {\n if (modules.has(id)) {\n return modules.get(id);\n }\n const promise = options.load(id);\n modules.set(id, promise);\n // A load that fails can start again, such as after the network comes back.\n promise?.catch(() => modules.delete(id));\n return promise;\n };\n // The serial entry loads with the core, so the core can make the values of the app.\n let serialLoad: Promise<SerialEntry> | undefined;\n const loadSerial = (): Promise<SerialEntry> | undefined => {\n serialLoad ??= options.serial?.();\n serialLoad?.catch(() => (serialLoad = undefined));\n return serialLoad;\n };\n const loadCore = (): Promise<Core> =>\n (core ??= Promise.all([load(), loadSerial()]).then(([client, serial]) => {\n client.init({ ...options, load: loadModule, listen: scanInsert, inserted, serial });\n return client;\n }));\n\n // The devtools panel asks for the core when it opens, so it can show the page before any event.\n listen(document, 'brumate:core', () => void loadCore());\n\n const run = (element: Element, ref: string, event?: Event): void => {\n if (stopped) {\n return;\n }\n void loadCore().then((client) => client.handle(element, ref, event));\n };\n\n /**\n * A key of `prevent` matches its `event.key` while only the modifier that it names is held. A\n * key alone matches while Ctrl, Meta and Alt are up, so the shortcuts of the browser, such as\n * Cmd+Left or Alt+Left, keep their default. `Mod+` is Ctrl or Meta. Shift does not count.\n */\n const keyMatches = (key: string, event: KeyboardEvent): boolean => {\n const plus = key.indexOf('+', 1);\n const modifier = plus > 0 ? key.slice(0, plus) : '';\n if ((event.key === ' ' ? 'Space' : event.key) !== (plus > 0 ? key.slice(plus + 1) : key)) {\n return false;\n }\n switch (modifier) {\n case 'Mod':\n return (event.ctrlKey || event.metaKey) && !event.altKey;\n case 'Ctrl':\n return event.ctrlKey && !event.metaKey && !event.altKey;\n case 'Meta':\n return event.metaKey && !event.ctrlKey && !event.altKey;\n case 'Alt':\n return event.altKey && !event.ctrlKey && !event.metaKey;\n default:\n return !event.ctrlKey && !event.metaKey && !event.altKey;\n }\n };\n\n const apply = (event: Event, element: Element, entry: Entry): boolean => {\n for (const modifier of entry.modifiers) {\n // `prevent(ArrowDown,Enter)` prevents only these keys, by `event.key`. A key that commits\n // or moves within the text of an input method, such as Enter while it composes, is the\n // input method's, so it keeps its default.\n if (\n modifier === 'prevent' ||\n (modifier.startsWith('prevent(') &&\n !(event as KeyboardEvent).isComposing &&\n modifier\n .slice(8, -1)\n .split(',')\n .some((key) => keyMatches(key, event as KeyboardEvent)))\n ) {\n event.preventDefault();\n }\n }\n if (entry.modifiers.includes('once')) {\n element.setAttribute(\n 'b-on',\n entries(element)\n .map((item) => item.raw)\n .filter((raw) => raw !== entry.raw)\n .join(' '),\n );\n }\n run(element, entry.ref, event);\n return entry.modifiers.includes('stop');\n };\n\n /**\n * Handlers run as if each element had its own listener: those with\n * `capture` from the outside in, then the others from the target outwards.\n * An event that does not bubble, such as `focus`, reaches only the others\n * of its target. `stop` ends the event where it is.\n */\n const onEvent = (event: Event): void => {\n // The checks of `cancelWhen`, from the target up, run before any handler.\n for (let node = event.target as Node | null; node; node = node.parentNode) {\n for (const [type, check] of cancels.get(node as Element) ?? []) {\n if (type !== event.type) {\n continue;\n }\n let cancel = false;\n try {\n cancel = check(event);\n } catch (error) {\n // A check that throws cancels nothing, and the other checks and the handlers still run.\n console.error(error);\n }\n if (cancel) {\n event.preventDefault();\n return;\n }\n }\n }\n const path: Element[] = [];\n for (\n let node = event.target as Node | null;\n node && node !== document;\n node = node.parentNode\n ) {\n if (node.nodeType === 1 && (node as Element).hasAttribute('b-on')) {\n path.push(node as Element);\n }\n }\n const phase = (elements: Element[], capture: boolean): boolean => {\n for (const element of elements) {\n let stop = false;\n for (const entry of entries(element)) {\n if (\n entry.type === event.type &&\n entry.modifiers.includes('capture') === capture &&\n apply(event, element, entry)\n ) {\n stop = true;\n }\n }\n if (stop) {\n event.stopPropagation();\n return true;\n }\n }\n return false;\n };\n if (!phase([...path].reverse(), true)) {\n phase(event.bubbles ? path : path.filter((element) => element === event.target), false);\n }\n };\n\n // The checks of `cancelWhen`, by element. `events.ts` reaches them through a symbol of the registry.\n const cancels = new WeakMap<Node, Set<[string, (event: Event) => boolean]>>();\n (globalThis as { [key: symbol]: unknown })[Symbol.for('brumate.cancel')] = (\n element: Element,\n type: string,\n check: (event: Event) => boolean,\n ): (() => void) => {\n const entry: [string, typeof check] = [type, check];\n let set = cancels.get(element);\n if (!set) {\n cancels.set(element, (set = new Set()));\n }\n set.add(entry);\n delegate(type, false);\n return () => void set.delete(entry);\n };\n\n /** True for an entry that prevents the default action, which a passive listener cannot do. */\n const prevents = (entry: Entry): boolean =>\n entry.modifiers.some((modifier) => modifier.startsWith('prevent'));\n\n /**\n * Listens to an event type on the document. The listener is passive, so\n * scrolling does not wait for it, until an entry of the type prevents. `click` and `submit` never\n * scroll, so they are never passive: a `prevent` that is written after load cancels them.\n */\n const delegate = (type: string, cancel: boolean): void => {\n const prevent = cancel || type === 'click' || type === 'submit';\n const passive = types.get(type);\n if (passive === false || (passive === true && !prevent)) {\n return;\n }\n if (passive) {\n document.removeEventListener(type, onEvent, true);\n }\n types.set(type, !prevent);\n listen(document, type, onEvent, { capture: true, passive: !prevent });\n };\n\n // Templates are started once, even when markup is scanned again.\n const started = new WeakSet<Element>();\n const select = (root: ParentNode, selector: string): Element[] => {\n const found: Element[] = [];\n const add = (element: Element): void => {\n if (element.tagName === 'TEMPLATE') {\n if (started.has(element)) {\n return;\n }\n started.add(element);\n }\n found.push(element);\n };\n if ((root as Element).matches?.(selector)) {\n add(root as Element);\n }\n for (const element of root.querySelectorAll(selector)) {\n add(element);\n }\n return found;\n };\n\n // The values of `b-on` whose event types the document listens to already. The rows of a\n // list repeat the same few values.\n const delegated = new Set<string>();\n const onElement = (element: Element): void => {\n const value = element.getAttribute('b-on')!;\n if (!delegated.has(value)) {\n delegated.add(value);\n for (const entry of entries(element)) {\n delegate(entry.type, prevents(entry));\n }\n }\n };\n const onListener = (template: Element): void => {\n const target = template.getAttribute('b-listen') === 'window' ? window : document;\n for (const entry of entries(template)) {\n // Markup that is gone, such as a page that navigation replaced, no longer listens.\n listen(\n target,\n entry.type,\n (event) => {\n if (template.isConnected) {\n apply(event, template, entry);\n }\n },\n { capture: entry.modifiers.includes('capture'), passive: !prevents(entry) },\n );\n }\n };\n // A `#defer` block whose body the server sends in the same response, with `b-hole`, waits for it.\n const onBlock = (root: ParentNode, template: Element): void => {\n const client = template.getAttribute('b-client');\n const [trigger, ref] = (client ?? template.getAttribute('b-defer')!).split(\n client ? '=' : ':',\n ) as [string, string];\n // A `#defer` block asks the server for its body, with a module that only it needs.\n const go = (): void => {\n if (client) {\n run(template, ref);\n return;\n }\n const done = import('./defer.ts').then((module) => module.loadDeferred(template));\n if (DEV) {\n devtools()?.defer?.(template, done);\n }\n };\n // The element that a `$client` callback reads through `ref` (`b-b`), or that a component\n // forwards to its signal (`b-r`), or the one after the marker.\n // Other markers can follow it, and a template has no box, so it is never in view.\n const near = template.getAttribute('b-near');\n let after = template.nextElementSibling;\n while (after?.tagName === 'TEMPLATE') {\n after = after.nextElementSibling;\n }\n const selector = `[b-b=\"${near}\"],[b-r=\"${near}\"]`;\n const next =\n (near && (root.querySelector(selector) ?? document.querySelector(selector))) || after;\n if (trigger === 'idle') {\n idle(go);\n } else if (trigger === 'visible' && next && typeof IntersectionObserver !== 'undefined') {\n const observer = new IntersectionObserver((records) => {\n if (records.some((record) => record.isIntersecting)) {\n observer.disconnect();\n go();\n }\n });\n observer.observe(next);\n } else {\n go();\n }\n };\n const SCANNED = '[b-on],template[b-listen],template[b-client],template[b-defer]';\n // One query of the markup for everything that the loader starts. The blocks start after the\n // rest, as they did when each kind had its own query.\n const scan = (root: ParentNode): void => {\n if (stopped) {\n return;\n }\n const blocks: Element[] = [];\n for (const element of select(root, SCANNED)) {\n if (element.tagName === 'TEMPLATE') {\n if (HAS_LISTENERS && element.hasAttribute('b-listen')) {\n onListener(element);\n } else if (\n HAS_BLOCKS &&\n (element.hasAttribute('b-client') ||\n (element.hasAttribute('b-defer') && !element.hasAttribute('b-hole')))\n ) {\n blocks.push(element);\n }\n continue;\n }\n if (element.hasAttribute('b-on')) {\n onElement(element);\n }\n }\n for (const template of blocks) {\n onBlock(root, template);\n }\n };\n\n // A form of an `$action` sends its data with `fetch`, and the core writes the result into the page.\n listen(document, 'submit', (event) => {\n const form = event.target as HTMLFormElement;\n if (!HAS_ACTIONS || event.defaultPrevented || !form.hasAttribute?.('b-result')) {\n return;\n }\n event.preventDefault();\n const submitter = (event as SubmitEvent).submitter;\n void loadCore().then((client) => client.submitAction(form, submitter));\n });\n\n if (navigate) {\n load = navigate({ options, listen, core: () => core, start: loadCore, scan });\n } else {\n // A hot update whose markup changed loads the page again.\n listen(document, 'brumate:reload', () => location.reload());\n }\n\n scan(document);\n // Markup that streams in later, such as a `#loading` body, has handlers too.\n const scanAdded = (records: MutationRecord[]): void => {\n for (const record of records) {\n for (const node of record.addedNodes) {\n if (node.nodeType === 1) {\n scan(node as Element);\n }\n }\n }\n };\n // Without markup that others insert, the core scans all that comes into the page. The rest of\n // the page that the browser reads after an `async` script starts is scanned when it ends.\n const observer = HAS_LATE_MARKUP ? new MutationObserver(scanAdded) : undefined;\n observer?.observe(document, { childList: true, subtree: true });\n if (!HAS_LATE_MARKUP && document.readyState === 'loading') {\n listen(document, 'DOMContentLoaded', () => scan(document));\n }\n // The core scans the markup that it inserts before the insert, so the records of the insert\n // are dropped instead of scanned again. The markup that others inserted first is scanned\n // first.\n const scanInsert = (root: ParentNode): void => {\n if (observer) {\n scanAdded(observer.takeRecords());\n }\n scan(root);\n };\n const inserted = (): void => {\n observer?.takeRecords();\n };\n\n // The core starts at once and loads the code of the components on the page, so a call of a\n // function of another component, such as a function prop, runs at once and in order.\n void loadCore().catch(() => {});\n return () => {\n stopped = true;\n observer?.disconnect();\n for (const remove of removers.splice(0)) {\n remove();\n }\n void core?.then((client) => client.dispose());\n };\n}\n","// The loader without client navigation, for `navigate: false`. It is a module\n// of its own, so a bundle that starts it has no import of the navigation code,\n// and keeps none of the core's exports that only navigation reads.\n\nimport { boot } from './boot.ts';\nimport type { LoaderOptions } from './boot.ts';\n\nexport type { LoaderOptions } from './boot.ts';\n\n/**\n * `start` for a site that loads every page with a full page load, as with\n * `navigate: false`. A bundle that only calls it leaves out the code of\n * client navigation.\n */\nexport function startWithoutNavigation(options: LoaderOptions): () => void {\n return boot(options);\n}\n"],"mappings":";;;AAcA,MAAM,MAAO,YAA4C,KAAK;;AAG9D,SAAS,WAAsC;CAC7C,OAAQ,WAAyD,OAAO,IAAI,kBAAkB;AAChG;AA0DA,MAAM,yBAAS,IAAI,IAAqB;AAExC,SAAgB,QAAQ,SAA2B;CACjD,MAAM,QAAQ,QAAQ,aAAa,MAAM,KAAK;CAC9C,OAAQ,OAAO,IAAI,KAAK,KACtB,OACG,IACC,OACA,MACG,MAAM,GAAG,CAAC,CACV,OAAO,OAAO,CAAC,CACf,KAAK,UAAU;EACd,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM,GAAG;EACnC,MAAM,CAAC,MAAM,GAAG,aAAa,KAAK,MAAM,GAAG;EAC3C,OAAO;GAAE,KAAK;GAAO;GAAM;GAAW;EAAI;CAC5C,CAAC,CACL,CAAC,CACA,IAAI,KAAK;AAChB;;;;;AASA,IAAI;AACJ,MAAa,mB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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as MODIFIERS } from "./events-LgLdp1R7.js";
|
|
2
2
|
import { S as rawHTML, g as isRaw, h as isInternal } from "./html-t1JpkODI.js";
|
|
3
|
-
import { a as ElementReference, c as PARTS, g as isSlotReference, h as isPropWrapper, m as isBinding, r as CHILDREN_REF, v as onSerialOptions, x as stateValues, y as onValuePlugin } from "./produce-
|
|
3
|
+
import { a as ElementReference, c as PARTS, g as isSlotReference, h as isPropWrapper, m as isBinding, r as CHILDREN_REF, v as onSerialOptions, x as stateValues, y as onValuePlugin } from "./produce-Cq6KKi7b.js";
|
|
4
4
|
import { Feature, Stream, createPlugin, fromCrossJSON, toCrossJSONStream } from "seroval";
|
|
5
5
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ImageDataPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin } from "seroval-plugins/web";
|
|
6
6
|
//#region src/runtime/calls.ts
|
|
@@ -531,4 +531,4 @@ async function fromChunkStream(stream) {
|
|
|
531
531
|
//#endregion
|
|
532
532
|
export { plugins as a, functionReferences as c, callPlugins as i, fromChunkStream as n, serialOptions as o, toChunkStream as r, syncPlugins as s, STREAM_TYPE as t };
|
|
533
533
|
|
|
534
|
-
//# sourceMappingURL=stream-
|
|
534
|
+
//# sourceMappingURL=stream-BdhzvPQO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-JGRPr7u5.js","names":[],"sources":["../src/runtime/calls.ts","../src/runtime/serial.ts","../src/runtime/stream.ts"],"sourcesContent":["// Values that only server function calls and their serialization use. They are\n// not in `shared.ts`, which the core imports, so a page's core does not hold them.\n\nimport type { FunctionReference } from './shared.ts';\n\n/**\n * Client functions that the server passes on, such as function props, with\n * their references. Kept under a symbol of the registry, so two copies of the\n * runtime, such as a component's and the render context's, share it.\n */\nexport const functionReferences: WeakMap<object, FunctionReference> = ((\n globalThis as Record<symbol, WeakMap<object, FunctionReference> | undefined>\n)[Symbol.for('brumate.functionReferences')] ??= new WeakMap());\n\n/**\n * True for a file or a blob. One from another frame, or another DOM, is an\n * instance of another `Blob` class, so its methods tell instead.\n */\nexport function isBlob(value: unknown): value is Blob {\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n return true;\n }\n const blob = value as Partial<Blob> | null;\n return (\n typeof blob === 'object' &&\n blob !== null &&\n typeof blob.size === 'number' &&\n typeof blob.type === 'string' &&\n typeof blob.arrayBuffer === 'function' &&\n typeof blob.slice === 'function'\n );\n}\n","// The seroval plugins of brumate's values. The server writes the page state\n// with them as code, and server function calls as JSON, which both sides\n// read with them. The core does not import this module: a state record\n// is code that makes its values with `stateValues`, so seroval loads in the\n// browser only with the first server function call.\n\nimport { Feature, createPlugin } from 'seroval';\nimport {\n AbortSignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n RequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n} from 'seroval-plugins/web';\nimport type {\n Plugin,\n SerovalNode,\n StreamParsePluginContext,\n SyncParsePluginContext,\n} from 'seroval';\nimport { type Internal, isInternal, isRaw, rawHTML } from './html.ts';\nimport type { Raw } from './html.ts';\nimport { functionReferences, isBlob } from './calls.ts';\nimport { MODIFIERS } from './events.ts';\nimport {\n CHILDREN_REF,\n ElementReference,\n PARTS,\n isBinding,\n isPropWrapper,\n isSlotReference,\n onSerialOptions,\n onValuePlugin,\n stateValues,\n} from './shared.ts';\nimport type { ChildrenReference, MemoError, PropPromise, ScopeId } from './shared.ts';\nimport type { ValuePlugin } from './values.ts';\nimport type { Binding, SlotReference } from './shared.ts';\nimport type { ComponentValue } from './shared.ts';\n\ntype ReferenceNode = { a: SerovalNode; b: SerovalNode; c?: SerovalNode; d?: SerovalNode };\n\n/** Serializes the parts of a node that are set, joined as call arguments. */\nfunction serializeParts(\n parts: (SerovalNode | undefined)[],\n ctx: { serialize(node: SerovalNode): string },\n): string {\n const written: string[] = [];\n for (const part of parts) {\n if (part !== undefined) {\n written.push(ctx.serialize(part));\n }\n }\n return written.join(',');\n}\n\n/**\n * Returns the parse functions of a plugin. `read` returns the values of the\n * node by key, and each mode parses them in that order, so the nodes match.\n */\nfunction parsers<T, K extends string>(\n read: (value: T) => Record<K, unknown>,\n): Plugin<T, Record<K, SerovalNode>>['parse'] {\n type N = Record<K, SerovalNode>;\n function parse(value: T, ctx: SyncParsePluginContext | StreamParsePluginContext): N {\n const node = read(value) as Record<string, unknown>;\n for (const key in node) {\n node[key] = ctx.parse(node[key]);\n }\n return node as N;\n }\n return {\n sync: parse,\n stream: parse,\n async: async (value, ctx) => {\n const node = read(value) as Record<string, unknown>;\n for (const key in node) {\n // oxlint-disable-next-line no-await-in-loop -- In order, as the other modes parse, so the IDs match.\n node[key] = await ctx.parse(node[key]);\n }\n return node as N;\n },\n };\n}\n\n// In the page state, each value is a call of `stateValues`, which the code of a record gets as `$b`.\n\n// No plugin here matches a plain object, so each one sets skipPlainObjects and seroval\n// does not run its test on object literals. Raw HTML is a class instance for this reason.\nconst ElementPlugin = createPlugin<ElementReference, ReferenceNode>({\n tag: 'brumate/element',\n skipPlainObjects: true,\n test: (value) => value instanceof ElementReference,\n parse: parsers((value) => ({ a: value.scope, b: value.anchor })),\n serialize: (node, ctx) => `$b.e(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.e(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n});\n\nconst SlotPlugin = createPlugin<SlotReference, ReferenceNode>({\n tag: 'brumate/slot',\n skipPlainObjects: true,\n test: (value) => isSlotReference(value),\n parse: parsers((value) => ({ a: value.scope, b: value.slot })),\n serialize: (node, ctx) => `$b.l(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.l(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n});\n\n/** A binding that a rest prop holds: its value, and the scope and the slot it writes. */\nconst BindingPlugin = createPlugin<Binding, ReferenceNode>({\n tag: 'brumate/binding',\n skipPlainObjects: true,\n test: (value) => isBinding(value),\n parse: parsers((value) => {\n const node: Record<string, unknown> = { a: value.value, b: value.ref.scope, c: value.ref.slot };\n // The setter of `$bind(name, fn)`.\n if (value.set !== undefined) {\n node.d = value.set;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.b(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.b(\n ctx.deserialize(node.a),\n ctx.deserialize<number>(node.b!),\n ctx.deserialize<number>(node.c!),\n node.d === undefined ? undefined : ctx.deserialize(node.d),\n ),\n});\n\nconst FunctionPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/function',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && functionReferences.has(value),\n parse: parsers((value) => {\n const reference = functionReferences.get(value)!;\n // The arguments of a handler that `$handler` made go with it.\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The modifiers of its wrappers, so a spread in markup that the browser renders writes them.\n const modifiers = (value as { [MODIFIERS]?: string[] })[MODIFIERS];\n if (reference.args !== undefined || modifiers) {\n node.c = reference.args ?? null;\n }\n if (modifiers) {\n node.d = modifiers;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.f(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.f(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<number>(node.b),\n node.c === undefined ? undefined : ctx.deserialize<unknown[] | null>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<string[]>(node.d),\n ),\n});\n\n/** A handler that merges the handlers of one event, as the parts that refer to client functions. */\nconst MergedPlugin = createPlugin<object, { a: SerovalNode }>({\n tag: 'brumate/merged',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && PARTS in value,\n parse: parsers((value) => {\n const parts: object[] = [];\n for (const part of (value as { [PARTS]: object[] })[PARTS]) {\n if (functionReferences.has(part)) {\n parts.push(part);\n }\n }\n return { a: parts };\n }),\n serialize: (node, ctx) => `$b.m(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.m(ctx.deserialize(node.a)),\n});\n\n/**\n * A value of an attribute that brumate writes, which a live rest prop can hold. The ones that\n * reach the page state are the scoped style attribute and `b-v`. The error \"holds a Internal\"\n * no longer catches any other, so a new one needs a check of its own.\n */\nconst InternalPlugin = createPlugin<Internal, { a: SerovalNode }>({\n tag: 'brumate/internal',\n skipPlainObjects: true,\n test: (value) => isInternal(value),\n parse: parsers((value) => ({ a: value.value })),\n serialize: (node, ctx) => `$b.i(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.i(ctx.deserialize(node.a)),\n});\n\n/** Children of a component, as the export that renders them in the browser. */\nconst ChildrenPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/children',\n skipPlainObjects: true,\n test: (value) => typeof value === 'object' && value !== null && CHILDREN_REF in value,\n parse: parsers((value) => {\n const reference = (value as { [CHILDREN_REF]: ChildrenReference })[CHILDREN_REF];\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The scope and the anchor of the insert where the server rendered them.\n if (reference.at !== undefined) {\n node.c = reference.at;\n node.d = reference.anchor;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.n(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.n(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<ScopeId>(node.b!),\n node.c === undefined ? undefined : ctx.deserialize<ScopeId>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<number>(node.d),\n ),\n});\n\n/**\n * A memo that failed on the server. The page state holds its error, so a read in the browser\n * throws it, as a memo that failed there. The server writes the error that is safe to send. See\n * `stateValue`.\n */\nconst MemoErrorPlugin = createPlugin<MemoError, { e: SerovalNode }>({\n tag: 'brumate/memo-error',\n skipPlainObjects: true,\n // The server marks the errors it holds, so the copies of the runtime agree on them.\n test: (value) =>\n typeof value === 'object' && value !== null && Symbol.for('brumate.held') in value,\n parse: parsers((value) => ({ e: value.error })),\n serialize: (node, ctx) => `$b.x(${ctx.serialize(node.e)})`,\n deserialize: (node, ctx) => stateValues.x(ctx.deserialize(node.e)),\n});\n\n/** A promise prop in the page state. See `PropPromise`. */\nconst PropPromisePlugin = createPlugin<PropPromise, { p: SerovalNode }>({\n tag: 'brumate/prop-promise',\n skipPlainObjects: true,\n test: isPropWrapper,\n parse: parsers((value) => ({ p: value.promise })),\n serialize: (node, ctx) => `$b.q(${ctx.serialize(node.p)})`,\n deserialize: (node, ctx) => stateValues.q(ctx.deserialize(node.p)),\n});\n\n/** HTML, such as the `children` of a component, so the client can insert it again. */\nconst RawPlugin = createPlugin<Raw, { h: SerovalNode }>({\n tag: 'brumate/raw',\n skipPlainObjects: true,\n test: isRaw,\n parse: parsers((value) => ({ h: rawHTML(value) })),\n serialize: (node, ctx) => `$b.r(${ctx.serialize(node.h)})`,\n deserialize: (node, ctx) => stateValues.r(ctx.deserialize<string>(node.h)),\n});\n\n/** A component in the page state, such as the value of a dynamic tag. See `stateValues.c`. */\nconst ComponentPlugin = createPlugin<ComponentValue, { c: SerovalNode }>({\n tag: 'brumate/component',\n skipPlainObjects: true,\n test: (value) =>\n typeof value === 'function' && typeof (value as Partial<ComponentValue>).brumateId === 'string',\n parse: parsers((value) => ({ c: value.brumateId })),\n serialize: (node, ctx) => `$b.c(${ctx.serialize(node.c)})`,\n deserialize: (node, ctx) => stateValues.c(ctx.deserialize<string>(node.c)),\n});\n\n/**\n * The index of a file or a blob, and what a part of multipart form data does\n * not keep: the type (an empty one arrives as `application/octet-stream`),\n * whether the value was a blob or a file (every part arrives as a file), and\n * the name (some characters are escaped) and `lastModified` of a file. Calls\n * from pages before these fields send only the index.\n */\ntype UploadNode = { i: SerovalNode; t?: SerovalNode; n?: SerovalNode; l?: SerovalNode };\n\nfunction isFile(value: Blob): value is File {\n const file = value as Partial<File>;\n return typeof file.name === 'string' && typeof file.lastModified === 'number';\n}\n\n/**\n * Files and blobs, which go only in the arguments of a call, as parts of\n * multipart form data named `file<index>`. The node holds the index. The\n * call passes `sent`, which gets each blob, and the server passes the form\n * that it `received`, whose files the indexes read. Without them, as in the\n * page state and in the answer of a call, a blob throws.\n */\nexport function uploadPlugin(sent?: Blob[], received?: FormData): Plugin<Blob, UploadNode> {\n return createPlugin<Blob, UploadNode>({\n tag: 'brumate/upload',\n skipPlainObjects: true,\n test: isBlob,\n // Only the fields that are set go in the node, so `K` names just the index.\n parse: parsers<Blob, 'i'>((value) => {\n if (!sent) {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n }\n const index = sent.push(value) - 1;\n if (isFile(value)) {\n return { i: index, t: value.type, n: value.name, l: value.lastModified };\n }\n return { i: index, t: value.type };\n }) as Plugin<Blob, UploadNode>['parse'],\n serialize: () => {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n },\n deserialize: (node, ctx) => {\n const file = received?.get(`file${ctx.deserialize<number>(node.i)}`);\n if (!(file instanceof Blob)) {\n throw new TypeError('A file of the call is missing');\n }\n // A page before the metadata fields sends only the index.\n if (node.t === undefined) {\n return file;\n }\n const type = ctx.deserialize(node.t);\n if (typeof type !== 'string') {\n throw new TypeError('A file of the call is malformed');\n }\n // The new blob or file refers to the bytes of the part instead of copying them.\n if (node.n === undefined) {\n return new Blob([file], { type });\n }\n const name = ctx.deserialize(node.n);\n const lastModified = node.l === undefined ? undefined : ctx.deserialize(node.l);\n if (typeof name !== 'string' || typeof lastModified !== 'number') {\n throw new TypeError('A file of the call is malformed');\n }\n return new File([file], name, { type, lastModified });\n },\n });\n}\n\n/**\n * The plugin of `AbortSignal` from seroval-plugins, which sends whether the\n * signal aborted and its reason. The one of seroval-plugins waits for a live\n * signal to abort, so a call with one would not be sent, and a page or an\n * answer with one would not end.\n */\nconst SignalPlugin: typeof AbortSignalPlugin = {\n ...AbortSignalPlugin,\n parse: {\n sync: AbortSignalPlugin.parse.sync,\n stream: AbortSignalPlugin.parse.sync,\n async: async (value, ctx) => (value.aborted ? { reason: await ctx.parse(value.reason) } : {}),\n },\n};\n\n/**\n * The plugin of `Request` from seroval-plugins, whose body streams in the\n * stream mode. A request with a stream body needs `duplex: 'half'`, or its\n * constructor throws, so the plugin adds it.\n */\nconst BodyRequestPlugin: typeof RequestPlugin = {\n ...RequestPlugin,\n serialize: (node, ctx) =>\n `new Request(${ctx.serialize(node.url)},Object.assign(${ctx.serialize(node.options)},{duplex:\"half\"}))`,\n deserialize: (node, ctx) =>\n new Request(\n ctx.deserialize(node.url) as string,\n {\n ...(ctx.deserialize(node.options) as RequestInit),\n duplex: 'half',\n } as RequestInit,\n ),\n};\n\n/** The plugins after the plugin of uploads, which a call makes for its files. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nconst valuePlugins: Plugin<any, any>[] = [\n ElementPlugin,\n SlotPlugin,\n BindingPlugin,\n FunctionPlugin,\n MergedPlugin,\n InternalPlugin,\n MemoErrorPlugin,\n PropPromisePlugin,\n ChildrenPlugin,\n RawPlugin,\n ComponentPlugin,\n // The web values of seroval-plugins. Requests and responses need the async or stream modes,\n // so a page state or a call result that holds one streams. The plugin of uploads takes files\n // and blobs, so those of seroval-plugins, which would put their bytes in the JSON, are left out.\n SignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n BodyRequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n];\n\n/**\n * The plugins of a call with files: `sent` gets the files that the call\n * sends, and `received` is the form that the server got them in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport function callPlugins(sent?: Blob[], received?: FormData): Plugin<any, any>[] {\n return [uploadPlugin(sent, received), ...valuePlugins];\n}\n\n/** The plugins of the page state, of answers and of calls without files. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const plugins: Plugin<any, any>[] = callPlugins();\n\n/**\n * Stops a sync mode at a value that only streams: an async iterable, such\n * as a `ReadableStream`. seroval writes one in a sync mode as a stream that\n * never gets its values, without an error.\n */\nconst StreamGuardPlugin = createPlugin<object, Record<string, never>>({\n tag: 'brumate/stream-guard',\n test: (value) =>\n (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||\n (typeof value === 'object' && value !== null && Symbol.asyncIterator in value),\n parse: {\n sync: () => {\n throw new Error('A stream needs the async or stream mode');\n },\n },\n serialize: () => '',\n deserialize: () => ({}),\n});\n\n/**\n * The plugins for the sync modes, which must throw for a value that only\n * streams, so the page state streams instead, and a call with a stream in\n * its arguments is not shared with another. The guard comes first, so it\n * takes a `ReadableStream` before the plugin of `ReadableStream`, which the\n * plugins of `Request` and `Response` bring in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const syncPlugins: Plugin<any, any>[] = [StreamGuardPlugin, ...plugins];\n\n/**\n * The seroval plugin of a plugin of the app. The page state writes its value\n * as `$b.u(tag, data)`, so the record does not need the class in scope.\n */\nfunction appPlugin(plugin: ValuePlugin): Plugin<unknown, { d: SerovalNode }> {\n return createPlugin<unknown, { d: SerovalNode }>({\n tag: `app:${plugin.tag}`,\n test: plugin.test,\n parse: parsers((value) => ({ d: plugin.toData(value) })),\n serialize: (node, ctx) => `$b.u(${JSON.stringify(plugin.tag)},${ctx.serialize(node.d)})`,\n deserialize: (node, ctx) => plugin.fromData(ctx.deserialize(node.d)),\n });\n}\n\n// The plugins of the app come before brumate's, in each list, as the entry adds them. The\n// plugin of uploads stays first in a call, and the guard of streams first in the sync modes.\nonValuePlugin((plugin) => {\n const added = appPlugin(plugin);\n valuePlugins.unshift(added);\n plugins.splice(1, 0, added);\n syncPlugins.splice(2, 0, added);\n});\n\n/**\n * Features that are off in both directions:\n *\n * - Errors keep their name and message only. A stack trace would show the\n * server's files and code to the browser.\n * - Regular expressions are not sent. A pattern from a client could take\n * the server a long time to match, and reading one is refused as well.\n */\nconst BRUMATE_DISABLED = Feature.ErrorPrototypeStack | Feature.RegExp;\n\nexport let disabledFeatures: number = BRUMATE_DISABLED;\nlet depthLimit: number | undefined;\n\n/** The options of every call of seroval: the features that are off, and the depth limit of the entry. */\nexport function serialOptions(): { disabledFeatures: number; depthLimit?: number } {\n return depthLimit === undefined ? { disabledFeatures } : { disabledFeatures, depthLimit };\n}\n\nonSerialOptions((options) => {\n disabledFeatures = options.disabledFeatures ?? BRUMATE_DISABLED;\n depthLimit = options.depthLimit;\n // oxlint-disable-next-line no-bitwise -- The features are flags.\n const enabled = BRUMATE_DISABLED & ~disabledFeatures;\n if (enabled !== 0) {\n console.warn(\n `The serial entry turns on ${enabled & Feature.RegExp ? 'RegExp' : 'ErrorPrototypeStack'}, which brumate turns off: ${enabled & Feature.RegExp ? 'a pattern from a client can take the server a long time to match' : 'a stack shows the files and code of the server to the browser'}.`,\n );\n }\n});\n","// The answer of a server function, as a stream of seroval chunks. Promises\n// and async iterables in the answer settle as their chunks arrive.\n//\n// Each chunk is a 12-byte header with the size of its data in bytes, as 8\n// hex digits, and the data: `;0x0000001f;{...}`. The reader knows how many\n// bytes to wait for, and can refuse a chunk that is too large.\n\nimport { Stream, fromCrossJSON, toCrossJSONStream } from 'seroval';\nimport type { SerovalNode } from 'seroval';\nimport { serialOptions, plugins } from './serial.ts';\n\nconst HEADER_SIZE = 12;\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** The content type of a stream of chunks. */\nexport const STREAM_TYPE = 'application/x-brumate-stream';\n\n/** One chunk: its header and its data, in one array. */\nfunction chunk(text: string): Uint8Array {\n const data = encoder.encode(text);\n const result = new Uint8Array(HEADER_SIZE + data.length);\n encoder.encodeInto(`;0x${data.length.toString(16).padStart(8, '0')};`, result);\n result.set(data, HEADER_SIZE);\n return result;\n}\n\n/** Serializes a value as a stream of chunks. */\nexport function toChunkStream(\n value: unknown,\n onCancel?: (reason: unknown) => void,\n): ReadableStream<Uint8Array> {\n let cancelled = false;\n return new ReadableStream({\n start(controller) {\n toCrossJSONStream(value, {\n refs: new Map(),\n plugins,\n ...serialOptions(),\n onParse(node) {\n if (!cancelled) {\n controller.enqueue(chunk(JSON.stringify(node)));\n }\n },\n onDone() {\n if (!cancelled) {\n controller.close();\n }\n },\n onError(error) {\n if (!cancelled) {\n controller.error(error);\n }\n },\n });\n },\n // The reader went away, such as a browser that aborted the call.\n cancel(reason) {\n cancelled = true;\n onCancel?.(reason);\n },\n });\n}\n\n/** Reads chunks of a stream, buffering only the bytes of the chunk it waits for. */\nclass ChunkReader {\n private readonly reader: ReadableStreamDefaultReader<Uint8Array>;\n private pieces: Uint8Array[] = [];\n private length = 0;\n private done = false;\n\n constructor(stream: ReadableStream<Uint8Array>) {\n this.reader = stream.getReader();\n }\n\n private async fill(size: number): Promise<void> {\n while (this.length < size && !this.done) {\n // oxlint-disable-next-line no-await-in-loop -- Pieces arrive in order.\n const piece = await this.reader.read();\n if (piece.done) {\n this.done = true;\n } else {\n this.pieces.push(piece.value);\n this.length += piece.value.length;\n }\n }\n }\n\n private take(size: number): Uint8Array {\n const result = new Uint8Array(size);\n let offset = 0;\n while (offset < size) {\n const piece = this.pieces[0]!;\n const count = Math.min(piece.length, size - offset);\n result.set(piece.subarray(0, count), offset);\n offset += count;\n if (count === piece.length) {\n this.pieces.shift();\n } else {\n this.pieces[0] = piece.subarray(count);\n }\n }\n this.length -= size;\n return result;\n }\n\n /** The data of the next chunk, or undefined at the end of the stream. */\n async next(): Promise<string | undefined> {\n await this.fill(HEADER_SIZE);\n if (this.length === 0) {\n return undefined;\n }\n const head = this.length < HEADER_SIZE ? '' : decoder.decode(this.take(HEADER_SIZE));\n const match = /^;0x([0-9a-f]{8});$/.exec(head);\n if (!match) {\n throw new Error('The answer of a server function is not a stream of chunks');\n }\n const size = Number.parseInt(match[1]!, 16);\n await this.fill(size);\n if (this.length < size) {\n throw new Error('The answer of a server function ended in the middle of a chunk');\n }\n return decoder.decode(this.take(size));\n }\n\n cancel(reason: unknown): void {\n this.done = true;\n void this.reader.cancel(reason).catch(() => {});\n }\n}\n\nfunction ignore(): void {}\n\n/**\n * The refs of a stream. A promise in the answer can fail with nothing that\n * reads it, such as a field the caller ignores, so its failure is claimed\n * here. Code that awaits it still sees the failure.\n */\nclass Refs extends Map<number, unknown> {\n override set(id: number, value: unknown): this {\n if (value instanceof Promise) {\n value.catch(ignore);\n }\n return super.set(id, value);\n }\n}\n\n/**\n * Fails the promises and async iterables that still wait for a chunk, when\n * the stream ends early. Failing a settled one does nothing.\n */\nfunction failPending(refs: Refs, error: unknown): void {\n for (const value of refs.values()) {\n try {\n // The deserializer makes a Stream. A LiveStream comes only from user code, and its producer fails it.\n if (value instanceof Stream) {\n value.throw(error);\n } else if (value !== null && typeof value === 'object') {\n const resolver = value as { p?: unknown; f?: unknown };\n if (resolver.p instanceof Promise && typeof resolver.f === 'function') {\n resolver.p.catch(ignore);\n (resolver.f as (error: unknown) => void)(error);\n }\n }\n } catch {\n // A value that a plugin made, which has no such methods.\n }\n }\n}\n\n/**\n * Reads the first chunk of a stream as the value, and the rest in the\n * background, so the promises and async iterables in it settle as their\n * chunks arrive.\n */\nexport async function fromChunkStream(stream: ReadableStream<Uint8Array>): Promise<unknown> {\n const reader = new ChunkReader(stream);\n const refs = new Refs();\n function read(data: string): unknown {\n return fromCrossJSON(JSON.parse(data) as SerovalNode, { refs, plugins, ...serialOptions() });\n }\n const first = await reader.next();\n if (first === undefined) {\n throw new Error('The answer of a server function is empty');\n }\n const value = read(first);\n void (async () => {\n try {\n for (;;) {\n // oxlint-disable-next-line no-await-in-loop -- Chunks arrive in order.\n const data = await reader.next();\n if (data === undefined) {\n break;\n }\n read(data);\n }\n failPending(refs, new Error('The answer of a server function ended early'));\n } catch (error) {\n reader.cancel(error);\n failPending(refs, error);\n }\n })();\n return value;\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,qBAA0D,WAErE,OAAO,IAAI,4BAA4B,uBAAO,IAAI,QAAQ;;;;;AAM5D,SAAgB,OAAO,OAA+B;CACpD,IAAI,OAAO,SAAS,eAAe,iBAAiB,MAClD,OAAO;CAET,MAAM,OAAO;CACb,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,gBAAgB,cAC5B,OAAO,KAAK,UAAU;AAE1B;;;;ACmBA,SAAS,eACP,OACA,KACQ;CACR,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,KAAA,GACX,QAAQ,KAAK,IAAI,UAAU,IAAI,CAAC;CAGpC,OAAO,QAAQ,KAAK,GAAG;AACzB;;;;;AAMA,SAAS,QACP,MAC4C;CAE5C,SAAS,MAAM,OAAU,KAA2D;EAClF,MAAM,OAAO,KAAK,KAAK;EACvB,KAAK,MAAM,OAAO,MAChB,KAAK,OAAO,IAAI,MAAM,KAAK,IAAI;EAEjC,OAAO;CACT;CACA,OAAO;EACL,MAAM;EACN,QAAQ;EACR,OAAO,OAAO,OAAO,QAAQ;GAC3B,MAAM,OAAO,KAAK,KAAK;GACvB,KAAK,MAAM,OAAO,MAEhB,KAAK,OAAO,MAAM,IAAI,MAAM,KAAK,IAAI;GAEvC,OAAO;EACT;CACF;AACF;AAMA,MAAM,gBAAgB,aAA8C;CAClE,KAAK;CACL,kBAAkB;CAClB,OAAO,UAAU,iBAAiB;CAClC,OAAO,SAAS,WAAW;EAAE,GAAG,MAAM;EAAO,GAAG,MAAM;CAAO,EAAE;CAC/D,YAAY,M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tC,IAAa,IAAY,OAAsB;EAC7C,IAAI,iBAAiB,SACnB,MAAM,MAAM,MAAM;EAEpB,OAAO,MAAM,IAAI,IAAI,KAAK;CAC5B;AACF;;;;;AAMA,SAAS,YAAY,MAAY,OAAsB;CACrD,KAAK,MAAM,SAAS,KAAK,OAAO,GAC9B,IAAI;EAEF,IAAI,iBAAiB,QACnB,MAAM,MAAM,KAAK;OACZ,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;GACtD,MAAM,WAAW;GACjB,IAAI,SAAS,aAAa,WAAW,OAAO,SAAS,MAAM,YAAY;IACrE,SAAS,EAAE,MAAM,MAAM;IACvB,SAAU,EAA+B,KAAK;GAChD;EACF;CACF,QAAQ,CAER;AAEJ;;;;;;AAOA,eAAsB,gBAAgB,QAAsD;CAC1F,MAAM,SAAS,IAAI,YAAY,MAAM;CACrC,MAAM,OAAO,IAAI,KAAK;CACtB,SAAS,KAAK,MAAuB;EACnC,OAAO,cAAc,KAAK,MAAM,IAAI,GAAkB;GAAE;GAAM;GAAS,GAAG,cAAc;EAAE,CAAC;CAC7F;CACA,MAAM,QAAQ,MAAM,OAAO,KAAK;CAChC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,0CAA0C;CAE5D,MAAM,QAAQ,KAAK,KAAK;CACxB,CAAM,YAAY;EAChB,IAAI;GACF,SAAS;IAEP,MAAM,OAAO,MAAM,OAAO,KAAK;IAC/B,IAAI,SAAS,KAAA,GACX;IAEF,KAAK,IAAI;GACX;GACA,YAAY,sBAAM,IAAI,MAAM,6CAA6C,CAAC;EAC5E,SAAS,OAAO;GACd,OAAO,OAAO,KAAK;GACnB,YAAY,MAAM,KAAK;EACzB;CACF,EAAA,CAAG;CACH,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"stream-BdhzvPQO.js","names":[],"sources":["../src/runtime/calls.ts","../src/runtime/serial.ts","../src/runtime/stream.ts"],"sourcesContent":["// Values that only server function calls and their serialization use. They are\n// not in `shared.ts`, which the core imports, so a page's core does not hold them.\n\nimport type { FunctionReference } from './shared.ts';\n\n/**\n * Client functions that the server passes on, such as function props, with\n * their references. Kept under a symbol of the registry, so two copies of the\n * runtime, such as a component's and the render context's, share it.\n */\nexport const functionReferences: WeakMap<object, FunctionReference> = ((\n globalThis as Record<symbol, WeakMap<object, FunctionReference> | undefined>\n)[Symbol.for('brumate.functionReferences')] ??= new WeakMap());\n\n/**\n * True for a file or a blob. One from another frame, or another DOM, is an\n * instance of another `Blob` class, so its methods tell instead.\n */\nexport function isBlob(value: unknown): value is Blob {\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n return true;\n }\n const blob = value as Partial<Blob> | null;\n return (\n typeof blob === 'object' &&\n blob !== null &&\n typeof blob.size === 'number' &&\n typeof blob.type === 'string' &&\n typeof blob.arrayBuffer === 'function' &&\n typeof blob.slice === 'function'\n );\n}\n","// The seroval plugins of brumate's values. The server writes the page state\n// with them as code, and server function calls as JSON, which both sides\n// read with them. The core does not import this module: a state record\n// is code that makes its values with `stateValues`, so seroval loads in the\n// browser only with the first server function call.\n\nimport { Feature, createPlugin } from 'seroval';\nimport {\n AbortSignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n RequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n} from 'seroval-plugins/web';\nimport type {\n Plugin,\n SerovalNode,\n StreamParsePluginContext,\n SyncParsePluginContext,\n} from 'seroval';\nimport { type Internal, isInternal, isRaw, rawHTML } from './html.ts';\nimport type { Raw } from './html.ts';\nimport { functionReferences, isBlob } from './calls.ts';\nimport { MODIFIERS } from './events.ts';\nimport {\n CHILDREN_REF,\n ElementReference,\n PARTS,\n isBinding,\n isPropWrapper,\n isSlotReference,\n onSerialOptions,\n onValuePlugin,\n stateValues,\n} from './shared.ts';\nimport type { ChildrenReference, MemoError, PropPromise, ScopeId } from './shared.ts';\nimport type { ValuePlugin } from './values.ts';\nimport type { Binding, SlotReference } from './shared.ts';\nimport type { ComponentValue } from './shared.ts';\n\ntype ReferenceNode = { a: SerovalNode; b: SerovalNode; c?: SerovalNode; d?: SerovalNode };\n\n/** Serializes the parts of a node that are set, joined as call arguments. */\nfunction serializeParts(\n parts: (SerovalNode | undefined)[],\n ctx: { serialize(node: SerovalNode): string },\n): string {\n const written: string[] = [];\n for (const part of parts) {\n if (part !== undefined) {\n written.push(ctx.serialize(part));\n }\n }\n return written.join(',');\n}\n\n/**\n * Returns the parse functions of a plugin. `read` returns the values of the\n * node by key, and each mode parses them in that order, so the nodes match.\n */\nfunction parsers<T, K extends string>(\n read: (value: T) => Record<K, unknown>,\n): Plugin<T, Record<K, SerovalNode>>['parse'] {\n type N = Record<K, SerovalNode>;\n function parse(value: T, ctx: SyncParsePluginContext | StreamParsePluginContext): N {\n const node = read(value) as Record<string, unknown>;\n for (const key in node) {\n node[key] = ctx.parse(node[key]);\n }\n return node as N;\n }\n return {\n sync: parse,\n stream: parse,\n async: async (value, ctx) => {\n const node = read(value) as Record<string, unknown>;\n for (const key in node) {\n // oxlint-disable-next-line no-await-in-loop -- In order, as the other modes parse, so the IDs match.\n node[key] = await ctx.parse(node[key]);\n }\n return node as N;\n },\n };\n}\n\n// In the page state, each value is a call of `stateValues`, which the code of a record gets as `$b`.\n\n// No plugin here matches a plain object, so each one sets skipPlainObjects and seroval\n// does not run its test on object literals. Raw HTML is a class instance for this reason.\nconst ElementPlugin = createPlugin<ElementReference, ReferenceNode>({\n tag: 'brumate/element',\n skipPlainObjects: true,\n test: (value) => value instanceof ElementReference,\n parse: parsers((value) => ({ a: value.scope, b: value.anchor })),\n serialize: (node, ctx) => `$b.e(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.e(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n});\n\nconst SlotPlugin = createPlugin<SlotReference, ReferenceNode>({\n tag: 'brumate/slot',\n skipPlainObjects: true,\n test: (value) => isSlotReference(value),\n parse: parsers((value) => ({ a: value.scope, b: value.slot })),\n serialize: (node, ctx) => `$b.l(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.l(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n});\n\n/** A binding that a rest prop holds: its value, and the scope and the slot it writes. */\nconst BindingPlugin = createPlugin<Binding, ReferenceNode>({\n tag: 'brumate/binding',\n skipPlainObjects: true,\n test: (value) => isBinding(value),\n parse: parsers((value) => {\n const node: Record<string, unknown> = { a: value.value, b: value.ref.scope, c: value.ref.slot };\n // The setter of `$bind(name, fn)`.\n if (value.set !== undefined) {\n node.d = value.set;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.b(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.b(\n ctx.deserialize(node.a),\n ctx.deserialize<number>(node.b!),\n ctx.deserialize<number>(node.c!),\n node.d === undefined ? undefined : ctx.deserialize(node.d),\n ),\n});\n\nconst FunctionPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/function',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && functionReferences.has(value),\n parse: parsers((value) => {\n const reference = functionReferences.get(value)!;\n // The arguments of a handler that `$handler` made go with it.\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The modifiers of its wrappers, so a spread in markup that the browser renders writes them.\n const modifiers = (value as { [MODIFIERS]?: string[] })[MODIFIERS];\n if (reference.args !== undefined || modifiers) {\n node.c = reference.args ?? null;\n }\n if (modifiers) {\n node.d = modifiers;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.f(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.f(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<number>(node.b),\n node.c === undefined ? undefined : ctx.deserialize<unknown[] | null>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<string[]>(node.d),\n ),\n});\n\n/** A handler that merges the handlers of one event, as the parts that refer to client functions. */\nconst MergedPlugin = createPlugin<object, { a: SerovalNode }>({\n tag: 'brumate/merged',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && PARTS in value,\n parse: parsers((value) => {\n const parts: object[] = [];\n for (const part of (value as { [PARTS]: object[] })[PARTS]) {\n if (functionReferences.has(part)) {\n parts.push(part);\n }\n }\n return { a: parts };\n }),\n serialize: (node, ctx) => `$b.m(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.m(ctx.deserialize(node.a)),\n});\n\n/**\n * A value of an attribute that brumate writes, which a live rest prop can hold. The ones that\n * reach the page state are the scoped style attribute and `b-v`. The error \"holds a Internal\"\n * no longer catches any other, so a new one needs a check of its own.\n */\nconst InternalPlugin = createPlugin<Internal, { a: SerovalNode }>({\n tag: 'brumate/internal',\n skipPlainObjects: true,\n test: (value) => isInternal(value),\n parse: parsers((value) => ({ a: value.value })),\n serialize: (node, ctx) => `$b.i(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.i(ctx.deserialize(node.a)),\n});\n\n/** Children of a component, as the export that renders them in the browser. */\nconst ChildrenPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/children',\n skipPlainObjects: true,\n test: (value) => typeof value === 'object' && value !== null && CHILDREN_REF in value,\n parse: parsers((value) => {\n const reference = (value as { [CHILDREN_REF]: ChildrenReference })[CHILDREN_REF];\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The scope and the anchor of the insert where the server rendered them.\n if (reference.at !== undefined) {\n node.c = reference.at;\n node.d = reference.anchor;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.n(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.n(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<ScopeId>(node.b!),\n node.c === undefined ? undefined : ctx.deserialize<ScopeId>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<number>(node.d),\n ),\n});\n\n/**\n * A memo that failed on the server. The page state holds its error, so a read in the browser\n * throws it, as a memo that failed there. The server writes the error that is safe to send. See\n * `stateValue`.\n */\nconst MemoErrorPlugin = createPlugin<MemoError, { e: SerovalNode }>({\n tag: 'brumate/memo-error',\n skipPlainObjects: true,\n // The server marks the errors it holds, so the copies of the runtime agree on them.\n test: (value) =>\n typeof value === 'object' && value !== null && Symbol.for('brumate.held') in value,\n parse: parsers((value) => ({ e: value.error })),\n serialize: (node, ctx) => `$b.x(${ctx.serialize(node.e)})`,\n deserialize: (node, ctx) => stateValues.x(ctx.deserialize(node.e)),\n});\n\n/** A promise prop in the page state. See `PropPromise`. */\nconst PropPromisePlugin = createPlugin<PropPromise, { p: SerovalNode }>({\n tag: 'brumate/prop-promise',\n skipPlainObjects: true,\n test: isPropWrapper,\n parse: parsers((value) => ({ p: value.promise })),\n serialize: (node, ctx) => `$b.q(${ctx.serialize(node.p)})`,\n deserialize: (node, ctx) => stateValues.q(ctx.deserialize(node.p)),\n});\n\n/** HTML, such as the `children` of a component, so the client can insert it again. */\nconst RawPlugin = createPlugin<Raw, { h: SerovalNode }>({\n tag: 'brumate/raw',\n skipPlainObjects: true,\n test: isRaw,\n parse: parsers((value) => ({ h: rawHTML(value) })),\n serialize: (node, ctx) => `$b.r(${ctx.serialize(node.h)})`,\n deserialize: (node, ctx) => stateValues.r(ctx.deserialize<string>(node.h)),\n});\n\n/** A component in the page state, such as the value of a dynamic tag. See `stateValues.c`. */\nconst ComponentPlugin = createPlugin<ComponentValue, { c: SerovalNode }>({\n tag: 'brumate/component',\n skipPlainObjects: true,\n test: (value) =>\n typeof value === 'function' && typeof (value as Partial<ComponentValue>).brumateId === 'string',\n parse: parsers((value) => ({ c: value.brumateId })),\n serialize: (node, ctx) => `$b.c(${ctx.serialize(node.c)})`,\n deserialize: (node, ctx) => stateValues.c(ctx.deserialize<string>(node.c)),\n});\n\n/**\n * The index of a file or a blob, and what a part of multipart form data does\n * not keep: the type (an empty one arrives as `application/octet-stream`),\n * whether the value was a blob or a file (every part arrives as a file), and\n * the name (some characters are escaped) and `lastModified` of a file. Calls\n * from pages before these fields send only the index.\n */\ntype UploadNode = { i: SerovalNode; t?: SerovalNode; n?: SerovalNode; l?: SerovalNode };\n\nfunction isFile(value: Blob): value is File {\n const file = value as Partial<File>;\n return typeof file.name === 'string' && typeof file.lastModified === 'number';\n}\n\n/**\n * Files and blobs, which go only in the arguments of a call, as parts of\n * multipart form data named `file<index>`. The node holds the index. The\n * call passes `sent`, which gets each blob, and the server passes the form\n * that it `received`, whose files the indexes read. Without them, as in the\n * page state and in the answer of a call, a blob throws.\n */\nexport function uploadPlugin(sent?: Blob[], received?: FormData): Plugin<Blob, UploadNode> {\n return createPlugin<Blob, UploadNode>({\n tag: 'brumate/upload',\n skipPlainObjects: true,\n test: isBlob,\n // Only the fields that are set go in the node, so `K` names just the index.\n parse: parsers<Blob, 'i'>((value) => {\n if (!sent) {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n }\n const index = sent.push(value) - 1;\n if (isFile(value)) {\n return { i: index, t: value.type, n: value.name, l: value.lastModified };\n }\n return { i: index, t: value.type };\n }) as Plugin<Blob, UploadNode>['parse'],\n serialize: () => {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n },\n deserialize: (node, ctx) => {\n const file = received?.get(`file${ctx.deserialize<number>(node.i)}`);\n if (!(file instanceof Blob)) {\n throw new TypeError('A file of the call is missing');\n }\n // A page before the metadata fields sends only the index.\n if (node.t === undefined) {\n return file;\n }\n const type = ctx.deserialize(node.t);\n if (typeof type !== 'string') {\n throw new TypeError('A file of the call is malformed');\n }\n // The new blob or file refers to the bytes of the part instead of copying them.\n if (node.n === undefined) {\n return new Blob([file], { type });\n }\n const name = ctx.deserialize(node.n);\n const lastModified = node.l === undefined ? undefined : ctx.deserialize(node.l);\n if (typeof name !== 'string' || typeof lastModified !== 'number') {\n throw new TypeError('A file of the call is malformed');\n }\n return new File([file], name, { type, lastModified });\n },\n });\n}\n\n/**\n * The plugin of `AbortSignal` from seroval-plugins, which sends whether the\n * signal aborted and its reason. The one of seroval-plugins waits for a live\n * signal to abort, so a call with one would not be sent, and a page or an\n * answer with one would not end.\n */\nconst SignalPlugin: typeof AbortSignalPlugin = {\n ...AbortSignalPlugin,\n parse: {\n sync: AbortSignalPlugin.parse.sync,\n stream: AbortSignalPlugin.parse.sync,\n async: async (value, ctx) => (value.aborted ? { reason: await ctx.parse(value.reason) } : {}),\n },\n};\n\n/**\n * The plugin of `Request` from seroval-plugins, whose body streams in the\n * stream mode. A request with a stream body needs `duplex: 'half'`, or its\n * constructor throws, so the plugin adds it.\n */\nconst BodyRequestPlugin: typeof RequestPlugin = {\n ...RequestPlugin,\n serialize: (node, ctx) =>\n `new Request(${ctx.serialize(node.url)},Object.assign(${ctx.serialize(node.options)},{duplex:\"half\"}))`,\n deserialize: (node, ctx) =>\n new Request(\n ctx.deserialize(node.url) as string,\n {\n ...(ctx.deserialize(node.options) as RequestInit),\n duplex: 'half',\n } as RequestInit,\n ),\n};\n\n/** The plugins after the plugin of uploads, which a call makes for its files. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nconst valuePlugins: Plugin<any, any>[] = [\n ElementPlugin,\n SlotPlugin,\n BindingPlugin,\n FunctionPlugin,\n MergedPlugin,\n InternalPlugin,\n MemoErrorPlugin,\n PropPromisePlugin,\n ChildrenPlugin,\n RawPlugin,\n ComponentPlugin,\n // The web values of seroval-plugins. Requests and responses need the async or stream modes,\n // so a page state or a call result that holds one streams. The plugin of uploads takes files\n // and blobs, so those of seroval-plugins, which would put their bytes in the JSON, are left out.\n SignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n BodyRequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n];\n\n/**\n * The plugins of a call with files: `sent` gets the files that the call\n * sends, and `received` is the form that the server got them in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport function callPlugins(sent?: Blob[], received?: FormData): Plugin<any, any>[] {\n return [uploadPlugin(sent, received), ...valuePlugins];\n}\n\n/** The plugins of the page state, of answers and of calls without files. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const plugins: Plugin<any, any>[] = callPlugins();\n\n/**\n * Stops a sync mode at a value that only streams: an async iterable, such\n * as a `ReadableStream`. seroval writes one in a sync mode as a stream that\n * never gets its values, without an error.\n */\nconst StreamGuardPlugin = createPlugin<object, Record<string, never>>({\n tag: 'brumate/stream-guard',\n test: (value) =>\n (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||\n (typeof value === 'object' && value !== null && Symbol.asyncIterator in value),\n parse: {\n sync: () => {\n throw new Error('A stream needs the async or stream mode');\n },\n },\n serialize: () => '',\n deserialize: () => ({}),\n});\n\n/**\n * The plugins for the sync modes, which must throw for a value that only\n * streams, so the page state streams instead, and a call with a stream in\n * its arguments is not shared with another. The guard comes first, so it\n * takes a `ReadableStream` before the plugin of `ReadableStream`, which the\n * plugins of `Request` and `Response` bring in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const syncPlugins: Plugin<any, any>[] = [StreamGuardPlugin, ...plugins];\n\n/**\n * The seroval plugin of a plugin of the app. The page state writes its value\n * as `$b.u(tag, data)`, so the record does not need the class in scope.\n */\nfunction appPlugin(plugin: ValuePlugin): Plugin<unknown, { d: SerovalNode }> {\n return createPlugin<unknown, { d: SerovalNode }>({\n tag: `app:${plugin.tag}`,\n test: plugin.test,\n parse: parsers((value) => ({ d: plugin.toData(value) })),\n serialize: (node, ctx) => `$b.u(${JSON.stringify(plugin.tag)},${ctx.serialize(node.d)})`,\n deserialize: (node, ctx) => plugin.fromData(ctx.deserialize(node.d)),\n });\n}\n\n// The plugins of the app come before brumate's, in each list, as the entry adds them. The\n// plugin of uploads stays first in a call, and the guard of streams first in the sync modes.\nonValuePlugin((plugin) => {\n const added = appPlugin(plugin);\n valuePlugins.unshift(added);\n plugins.splice(1, 0, added);\n syncPlugins.splice(2, 0, added);\n});\n\n/**\n * Features that are off in both directions:\n *\n * - Errors keep their name and message only. A stack trace would show the\n * server's files and code to the browser.\n * - Regular expressions are not sent. A pattern from a client could take\n * the server a long time to match, and reading one is refused as well.\n */\nconst BRUMATE_DISABLED = Feature.ErrorPrototypeStack | Feature.RegExp;\n\nexport let disabledFeatures: number = BRUMATE_DISABLED;\nlet depthLimit: number | undefined;\n\n/** The options of every call of seroval: the features that are off, and the depth limit of the entry. */\nexport function serialOptions(): { disabledFeatures: number; depthLimit?: number } {\n return depthLimit === undefined ? { disabledFeatures } : { disabledFeatures, depthLimit };\n}\n\nonSerialOptions((options) => {\n disabledFeatures = options.disabledFeatures ?? BRUMATE_DISABLED;\n depthLimit = options.depthLimit;\n // oxlint-disable-next-line no-bitwise -- The features are flags.\n const enabled = BRUMATE_DISABLED & ~disabledFeatures;\n if (enabled !== 0) {\n console.warn(\n `The serial entry turns on ${enabled & Feature.RegExp ? 'RegExp' : 'ErrorPrototypeStack'}, which brumate turns off: ${enabled & Feature.RegExp ? 'a pattern from a client can take the server a long time to match' : 'a stack shows the files and code of the server to the browser'}.`,\n );\n }\n});\n","// The answer of a server function, as a stream of seroval chunks. Promises\n// and async iterables in the answer settle as their chunks arrive.\n//\n// Each chunk is a 12-byte header with the size of its data in bytes, as 8\n// hex digits, and the data: `;0x0000001f;{...}`. The reader knows how many\n// bytes to wait for, and can refuse a chunk that is too large.\n\nimport { Stream, fromCrossJSON, toCrossJSONStream } from 'seroval';\nimport type { SerovalNode } from 'seroval';\nimport { serialOptions, plugins } from './serial.ts';\n\nconst HEADER_SIZE = 12;\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** The content type of a stream of chunks. */\nexport const STREAM_TYPE = 'application/x-brumate-stream';\n\n/** One chunk: its header and its data, in one array. */\nfunction chunk(text: string): Uint8Array {\n const data = encoder.encode(text);\n const result = new Uint8Array(HEADER_SIZE + data.length);\n encoder.encodeInto(`;0x${data.length.toString(16).padStart(8, '0')};`, result);\n result.set(data, HEADER_SIZE);\n return result;\n}\n\n/** Serializes a value as a stream of chunks. */\nexport function toChunkStream(\n value: unknown,\n onCancel?: (reason: unknown) => void,\n): ReadableStream<Uint8Array> {\n let cancelled = false;\n return new ReadableStream({\n start(controller) {\n toCrossJSONStream(value, {\n refs: new Map(),\n plugins,\n ...serialOptions(),\n onParse(node) {\n if (!cancelled) {\n controller.enqueue(chunk(JSON.stringify(node)));\n }\n },\n onDone() {\n if (!cancelled) {\n controller.close();\n }\n },\n onError(error) {\n if (!cancelled) {\n controller.error(error);\n }\n },\n });\n },\n // The reader went away, such as a browser that aborted the call.\n cancel(reason) {\n cancelled = true;\n onCancel?.(reason);\n },\n });\n}\n\n/** Reads chunks of a stream, buffering only the bytes of the chunk it waits for. */\nclass ChunkReader {\n private readonly reader: ReadableStreamDefaultReader<Uint8Array>;\n private pieces: Uint8Array[] = [];\n private length = 0;\n private done = false;\n\n constructor(stream: ReadableStream<Uint8Array>) {\n this.reader = stream.getReader();\n }\n\n private async fill(size: number): Promise<void> {\n while (this.length < size && !this.done) {\n // oxlint-disable-next-line no-await-in-loop -- Pieces arrive in order.\n const piece = await this.reader.read();\n if (piece.done) {\n this.done = true;\n } else {\n this.pieces.push(piece.value);\n this.length += piece.value.length;\n }\n }\n }\n\n private take(size: number): Uint8Array {\n const result = new Uint8Array(size);\n let offset = 0;\n while (offset < size) {\n const piece = this.pieces[0]!;\n const count = Math.min(piece.length, size - offset);\n result.set(piece.subarray(0, count), offset);\n offset += count;\n if (count === piece.length) {\n this.pieces.shift();\n } else {\n this.pieces[0] = piece.subarray(count);\n }\n }\n this.length -= size;\n return result;\n }\n\n /** The data of the next chunk, or undefined at the end of the stream. */\n async next(): Promise<string | undefined> {\n await this.fill(HEADER_SIZE);\n if (this.length === 0) {\n return undefined;\n }\n const head = this.length < HEADER_SIZE ? '' : decoder.decode(this.take(HEADER_SIZE));\n const match = /^;0x([0-9a-f]{8});$/.exec(head);\n if (!match) {\n throw new Error('The answer of a server function is not a stream of chunks');\n }\n const size = Number.parseInt(match[1]!, 16);\n await this.fill(size);\n if (this.length < size) {\n throw new Error('The answer of a server function ended in the middle of a chunk');\n }\n return decoder.decode(this.take(size));\n }\n\n cancel(reason: unknown): void {\n this.done = true;\n void this.reader.cancel(reason).catch(() => {});\n }\n}\n\nfunction ignore(): void {}\n\n/**\n * The refs of a stream. A promise in the answer can fail with nothing that\n * reads it, such as a field the caller ignores, so its failure is claimed\n * here. Code that awaits it still sees the failure.\n */\nclass Refs extends Map<number, unknown> {\n override set(id: number, value: unknown): this {\n if (value instanceof Promise) {\n value.catch(ignore);\n }\n return super.set(id, value);\n }\n}\n\n/**\n * Fails the promises and async iterables that still wait for a chunk, when\n * the stream ends early. Failing a settled one does nothing.\n */\nfunction failPending(refs: Refs, error: unknown): void {\n for (const value of refs.values()) {\n try {\n // The deserializer makes a Stream. A LiveStream comes only from user code, and its producer fails it.\n if (value instanceof Stream) {\n value.throw(error);\n } else if (value !== null && typeof value === 'object') {\n const resolver = value as { p?: unknown; f?: unknown };\n if (resolver.p instanceof Promise && typeof resolver.f === 'function') {\n resolver.p.catch(ignore);\n (resolver.f as (error: unknown) => void)(error);\n }\n }\n } catch {\n // A value that a plugin made, which has no such methods.\n }\n }\n}\n\n/**\n * Reads the first chunk of a stream as the value, and the rest in the\n * background, so the promises and async iterables in it settle as their\n * chunks arrive.\n */\nexport async function fromChunkStream(stream: ReadableStream<Uint8Array>): Promise<unknown> {\n const reader = new ChunkReader(stream);\n const refs = new Refs();\n function read(data: string): unknown {\n return fromCrossJSON(JSON.parse(data) as SerovalNode, { refs, plugins, ...serialOptions() });\n }\n const first = await reader.next();\n if (first === undefined) {\n throw new Error('The answer of a server function is empty');\n }\n const value = read(first);\n void (async () => {\n try {\n for (;;) {\n // oxlint-disable-next-line no-await-in-loop -- Chunks arrive in order.\n const data = await reader.next();\n if (data === undefined) {\n break;\n }\n read(data);\n }\n failPending(refs, new Error('The answer of a server function ended early'));\n } catch (error) {\n reader.cancel(error);\n failPending(refs, error);\n }\n })();\n return value;\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,qBAA0D,WAErE,OAAO,IAAI,4BAA4B,uBAAO,IAAI,QAAQ;;;;;AAM5D,SAAgB,OAAO,OAA+B;CACpD,IAAI,OAAO,SAAS,eAAe,iBAAiB,MAClD,OAAO;CAET,MAAM,OAAO;CACb,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,gBAAgB,cAC5B,OAAO,KAAK,UAAU;AAE1B;;;;ACmBA,SAAS,eACP,OACA,KACQ;CACR,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,KAAA,GACX,QAAQ,KAAK,IAAI,UAAU,IAAI,CAAC;CAGpC,OAAO,QAAQ,KAAK,GAAG;AACzB;;;;;AAMA,SAAS,QACP,MAC4C;CAE5C,SAAS,MAAM,OAAU,KAA2D;EAClF,MAAM,OAAO,KAAK,KAAK;EACvB,KAAK,MAAM,OAAO,MAChB,KAAK,OAAO,IAAI,MAAM,KAAK,IAAI;EAEjC,OAAO;CACT;CACA,OAAO;EACL,MAAM;EACN,QAAQ;EACR,OAAO,OAAO,OAAO,QAAQ;GAC3B,MAAM,OAAO,KAAK,KAAK;GACvB,KAAK,MAAM,OAAO,MAEhB,KAAK,OAAO,MAAM,IAAI,MAAM,KAAK,IAAI;GAEvC,OAAO;EACT;CACF;AACF;AAMA,MA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