brumate 0.6.2 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/check.d.ts +3 -3
- package/dist/{boot-DkbcqdUz.d.ts → boot-CMy0f_iC.d.ts} +2 -2
- package/dist/cli.js +77 -6
- package/dist/cli.js.map +1 -1
- package/dist/{client-C3vRNuLi.js → client-Bm0XbjHr.js} +274 -113
- package/dist/client-Bm0XbjHr.js.map +1 -0
- package/dist/{client-CqGDbWd_.d.ts → client-DnFF9_lv.d.ts} +40 -14
- package/dist/{client-routes-BtGpYCef.js → client-routes-BmPvNr4s.js} +10 -1
- package/dist/client-routes-BmPvNr4s.js.map +1 -0
- package/dist/{context-btHuB01Z.d.ts → context-BNgBXVUQ.d.ts} +7 -5
- package/dist/{context-CTiSzQRc.js → context-CU4Fpn5a.js} +10 -13
- package/dist/context-CU4Fpn5a.js.map +1 -0
- package/dist/{defer-M18UKyfG.js → defer-BWwxv7Qf.js} +2 -2
- package/dist/{defer-M18UKyfG.js.map → defer-BWwxv7Qf.js.map} +1 -1
- package/dist/{devtools-D9Q7a41M.js → devtools-Cl6AhENB.js} +4 -4
- package/dist/{devtools-D9Q7a41M.js.map → devtools-Cl6AhENB.js.map} +1 -1
- package/dist/{devtools-panel-DTQtljeA.js → devtools-panel-DLIeWcAj.js} +32 -9
- package/dist/devtools-panel-DLIeWcAj.js.map +1 -0
- package/dist/events-LgLdp1R7.js.map +1 -1
- package/dist/{features-CbgII-o7.js → features-DwMYKBIC.js} +6 -2
- package/dist/features-DwMYKBIC.js.map +1 -0
- package/dist/{files-DtDH5AR4.js → files-BuQvpBwF.js} +94 -3
- package/dist/files-BuQvpBwF.js.map +1 -0
- package/dist/{html-t1JpkODI.js → html-Cf5uKhLs.js} +3 -3
- package/dist/html-Cf5uKhLs.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-Bonq6EJO.js → inspect-BSHv1_25.js} +2739 -2080
- package/dist/inspect-BSHv1_25.js.map +1 -0
- package/dist/{loader-C-S3yzep.js → loader-BPNSRA2A.js} +5 -5
- package/dist/{loader-C-S3yzep.js.map → loader-BPNSRA2A.js.map} +1 -1
- package/dist/{rpc-C_znDZ_w.js → rpc-DqfCaYgF.js} +3 -3
- package/dist/{rpc-C_znDZ_w.js.map → rpc-DqfCaYgF.js.map} +1 -1
- package/dist/runtime/bundles.d.ts +1 -1
- package/dist/runtime/bundles.js +2 -0
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +5 -5
- package/dist/runtime/context.d.ts +2 -2
- package/dist/runtime/context.js +1 -1
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.d.ts +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +1 -1
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +4 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +43 -5
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -0
- package/dist/runtime/store.js +1 -0
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{search-params-CM1RWR2P.js → search-params-C64liRBj.js} +34 -9
- package/dist/search-params-C64liRBj.js.map +1 -0
- package/dist/{server-dP_ucRiJ.d.ts → server-0rS5vUW1.d.ts} +37 -10
- package/dist/{server-BcT9icQ4.js → server-BVObWh-w.js} +132 -16
- package/dist/server-BVObWh-w.js.map +1 -0
- package/dist/{shared-CzbnWkVA.d.ts → shared-CuJdWifz.d.ts} +16 -3
- package/dist/{signals-BwD4u22K.d.ts → signals-DBnq9QRW.d.ts} +46 -6
- package/dist/{static-loader-DysAET-w.d.ts → static-loader-BYbXVJDY.d.ts} +2 -2
- package/dist/{static-loader-Bt2WDkY1.js → static-loader-V4V1Oy6G.js} +13 -5
- package/dist/static-loader-V4V1Oy6G.js.map +1 -0
- package/dist/store-BIBAYZo-.js +293 -0
- package/dist/store-BIBAYZo-.js.map +1 -0
- package/dist/store-xlTzAM_r.d.ts +171 -0
- package/dist/{stream-DRjx0keF.js → stream-RXLadXx1.js} +90 -4
- package/dist/stream-RXLadXx1.js.map +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +128 -13
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +349 -79
- package/package.json +5 -1
- package/skills/brumate/SKILL.md +1 -1
- package/skills/brumate/references/errors.md +127 -9
- package/skills/brumate/references/signals.md +37 -30
- package/skills/brumate/references/state.md +3 -2
- package/dist/client-C3vRNuLi.js.map +0 -1
- package/dist/client-routes-BtGpYCef.js.map +0 -1
- package/dist/context-CTiSzQRc.js.map +0 -1
- package/dist/devtools-panel-DTQtljeA.js.map +0 -1
- package/dist/features-CbgII-o7.js.map +0 -1
- package/dist/files-DtDH5AR4.js.map +0 -1
- package/dist/html-t1JpkODI.js.map +0 -1
- package/dist/inspect-Bonq6EJO.js.map +0 -1
- package/dist/search-params-CM1RWR2P.js.map +0 -1
- package/dist/server-BcT9icQ4.js.map +0 -1
- package/dist/static-loader-Bt2WDkY1.js.map +0 -1
- package/dist/stream-DRjx0keF.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as Bridged, n as Store, r as bridge, i as canSet, a as findStored, o as isBridged, s as isContext, c as isContract, l as isForeignStore, u as isStore, d as nameBridge, f as sameData, p as sendStore, m as sentForeignStore, h as setBridgeLoader, g as store } from "../store-BIBAYZo-.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Vt as EntryMiddleware, Yt as ServerErrorHandler, f as RenderOptions, n as Component } from "../server-
|
|
1
|
+
import { qt as ClientModule } from "../client-DnFF9_lv.js";
|
|
2
|
+
import { Vt as EntryMiddleware, Yt as ServerErrorHandler, f as RenderOptions, n as Component } from "../server-0rS5vUW1.js";
|
|
3
3
|
//#region src/runtime/testing.d.ts
|
|
4
4
|
/** The middleware of files of server functions, by function ID. */
|
|
5
5
|
type FileMiddleware = Record<string, EntryMiddleware>;
|
package/dist/runtime/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as handleRequest, x as render } from "../server-
|
|
2
|
-
import { t as start } from "../loader-
|
|
1
|
+
import { d as handleRequest, x as render } from "../server-BVObWh-w.js";
|
|
2
|
+
import { t as start } from "../loader-BPNSRA2A.js";
|
|
3
3
|
//#region src/runtime/nodes.ts
|
|
4
4
|
const VOID = /* @__PURE__ */ new Set([
|
|
5
5
|
"area",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { b as ownValue, t as Internal, x as raw } from "./html-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { b as ownValue, t as Internal, x as raw } from "./html-Cf5uKhLs.js";
|
|
2
|
+
import { a as HAS_CHILDREN, h as HAS_STORES, i as HAS_BRIDGES, n as HAS_BINDINGS } from "./features-DwMYKBIC.js";
|
|
3
|
+
import { n as Store, t as Bridged } from "./store-BIBAYZo-.js";
|
|
4
|
+
import { o as routeContext } from "./context-CU4Fpn5a.js";
|
|
4
5
|
//#region src/runtime/shared.ts
|
|
5
6
|
/** The plugins of values of the app, by tag, which the entry `src/serial.ts` exports. */
|
|
6
7
|
const valuePlugins = /* @__PURE__ */ new Map();
|
|
@@ -234,8 +235,31 @@ const stateValues = {
|
|
|
234
235
|
const plugin = valuePlugins.get(tag);
|
|
235
236
|
if (!plugin) throw new Error(`No plugin reads the value "${tag}". Export it in the plugins of the serial entry, src/serial.ts`);
|
|
236
237
|
return plugin.fromData(data);
|
|
237
|
-
}
|
|
238
|
+
},
|
|
239
|
+
s: HAS_STORES ? (value, scope, site, slot) => {
|
|
240
|
+
const made = new Store(value);
|
|
241
|
+
if (scope !== void 0) {
|
|
242
|
+
made.o = slot === void 0 ? [scope, site] : [
|
|
243
|
+
scope,
|
|
244
|
+
site,
|
|
245
|
+
slot
|
|
246
|
+
];
|
|
247
|
+
madeStores.push(made);
|
|
248
|
+
}
|
|
249
|
+
return made;
|
|
250
|
+
} : unused,
|
|
251
|
+
g: HAS_BRIDGES ? (snapshot, id, writable) => new Bridged(void 0, void 0, id, snapshot, writable === 1) : unused
|
|
238
252
|
};
|
|
253
|
+
/**
|
|
254
|
+
* The stores of providers that the page state made, until the core links them to their scopes:
|
|
255
|
+
* a store of `$toStore(signal)` writes the signal of its provider.
|
|
256
|
+
*/
|
|
257
|
+
const madeStores = [];
|
|
258
|
+
/** The value of a `$gate`, which cannot be a promise or a stream. A throw is held like a memo error. */
|
|
259
|
+
function gateValue(value) {
|
|
260
|
+
if (value !== null && typeof value === "object" && typeof value.then === "function" || isAsyncIterable(value)) throw new TypeError("The value of $gate is a promise or a stream. Use $memo for a value that loads");
|
|
261
|
+
return value;
|
|
262
|
+
}
|
|
239
263
|
/** True for a value that `for await` reads, such as the result of an async generator. */
|
|
240
264
|
function isAsyncIterable(value) {
|
|
241
265
|
return value !== null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function";
|
|
@@ -263,6 +287,7 @@ const SCOPE_IDS = {
|
|
|
263
287
|
l: "id",
|
|
264
288
|
v: "map",
|
|
265
289
|
x: "none",
|
|
290
|
+
z: "none",
|
|
266
291
|
s: "values",
|
|
267
292
|
c: "ids",
|
|
268
293
|
b: "map",
|
|
@@ -409,10 +434,10 @@ function readParam(search, name, options) {
|
|
|
409
434
|
}
|
|
410
435
|
/** The text of a value in the URL, or null for the default, which leaves the parameter out. */
|
|
411
436
|
function writeParam(value, options) {
|
|
412
|
-
const own =
|
|
413
|
-
return own ===
|
|
437
|
+
const own = formatParam(value, options);
|
|
438
|
+
return own === formatParam(options?.default, options) ? null : own;
|
|
414
439
|
}
|
|
415
|
-
function
|
|
440
|
+
function formatParam(value, options) {
|
|
416
441
|
if (value === null || value === void 0) return null;
|
|
417
442
|
return options?.serialize ? options.serialize(value) : String(value);
|
|
418
443
|
}
|
|
@@ -421,6 +446,6 @@ function searchParam(context, name, options) {
|
|
|
421
446
|
return readParam(context.consume(routeContext, 0).search, name, options);
|
|
422
447
|
}
|
|
423
448
|
//#endregion
|
|
424
|
-
export {
|
|
449
|
+
export { onSerialOptions as C, unbind as D, stateValues as E, useSerialEntry as O, mergeHandlers as S, parseId as T, isAsyncIterable as _, Binding as a, isSlotReference as b, ElementReference as c, PARTS as d, PropPromise as f, gateValue as g, addEntryHandlers as h, produce as i, FunctionReference as l, SlotReference as m, searchParam as n, CHILDREN_REF as o, SCOPE_IDS as p, writeParam as r, ChildrenReference as s, readParam as t, MemoError as u, isBinding as v, onValuePlugin as w, madeStores as x, isPropWrapper as y };
|
|
425
450
|
|
|
426
|
-
//# sourceMappingURL=search-params-
|
|
451
|
+
//# sourceMappingURL=search-params-C64liRBj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-params-C64liRBj.js","names":[],"sources":["../src/runtime/shared.ts","../src/runtime/produce.ts","../src/runtime/search-params.ts"],"sourcesContent":["// Values and types that the server and the browser share. It does not import\n// seroval, so the core, which reads the page state without it, stays small.\n// The plugins that write and read these values are in `serial.ts`.\n\nimport { HAS_BINDINGS, HAS_BRIDGES, HAS_CHILDREN, HAS_STORES } from './features.ts';\nimport { Internal, ownValue, raw } from './html.ts';\nimport type { Raw } from './html.ts';\nimport { Bridged, Store } from './store.ts';\nimport type { SerialEntry, ValuePlugin } from './values.ts';\n\n/** The plugins of values of the app, by tag, which the entry `src/serial.ts` exports. */\nconst valuePlugins = new Map<string, ValuePlugin>();\nconst pluginListeners: ((plugin: ValuePlugin) => void)[] = [];\n/** The options of the entry, which the serializer reads when it loads. */\nlet entryOptions: Omit<SerialEntry, 'plugins'> = {};\nconst optionListeners: ((options: Omit<SerialEntry, 'plugins'>) => void)[] = [];\n\n/**\n * Takes the exports of the serial entry: its plugins and the options that it\n * changes. The server and the loader call it before the first value is\n * written or read.\n */\nexport function useSerialEntry(entry: SerialEntry): void {\n const { plugins = [], ...options } = entry;\n if (options.disabledFeatures !== undefined || options.depthLimit !== undefined) {\n entryOptions = options;\n for (const listener of optionListeners) {\n listener(options);\n }\n }\n registerValues(plugins);\n}\n\n/** Calls `listener` with the options of the entry, now and when they change. */\nexport function onSerialOptions(listener: (options: Omit<SerialEntry, 'plugins'>) => void): void {\n optionListeners.push(listener);\n listener(entryOptions);\n}\n\n/** Adds plugins of values of the app. */\nfunction registerValues(plugins: readonly ValuePlugin[]): void {\n for (const plugin of plugins) {\n if (valuePlugins.get(plugin.tag) === plugin) {\n continue;\n }\n valuePlugins.set(plugin.tag, plugin);\n for (const listener of pluginListeners) {\n listener(plugin);\n }\n }\n}\n\n/** Calls `listener` for each plugin of the app, those added so far and those added later. */\nexport function onValuePlugin(listener: (plugin: ValuePlugin) => void): void {\n pluginListeners.push(listener);\n for (const plugin of valuePlugins.values()) {\n listener(plugin);\n }\n}\n\n/**\n * The ID of a scope or of a `#loading` boundary. The rest of the page numbers\n * its scopes from the base of the render, such as `3`. A `#loading` body\n * numbers its own from 0 after the ID of its boundary and a dot, such as\n * `5.0` and `5.1`, so its IDs do not depend on when its data arrives.\n */\nexport type ScopeId = number | string;\n\n/** Reads a scope or boundary ID from markup. */\nexport function parseId(text: string): ScopeId {\n return /^-?\\d+$/.test(text) ? Number(text) : text;\n}\n\n/** Adds a number to an ID. An ID inside a boundary moves with its boundary. */\nexport function shiftId(id: ScopeId, by: number): ScopeId {\n if (typeof id === 'number') {\n return id + by;\n }\n const dot = id.indexOf('.');\n return `${Number(id.slice(0, dot)) + by}${id.slice(dot)}`;\n}\n\n/** An element that the server rendered. The client finds it by its anchor. */\nexport class ElementReference {\n readonly scope: ScopeId;\n readonly anchor: number;\n\n constructor(scope: ScopeId, anchor: number) {\n this.scope = scope;\n this.anchor = anchor;\n }\n}\n\n/** A client function: an export of a client module, and the scope it reads. */\n/** The key of the reference of children on the server, which the page state sends. */\nexport const CHILDREN_REF: unique symbol = Symbol.for('brumate.children') as never;\n\n/**\n * The children of a component in the page state: the export that renders them in the browser,\n * such as `Page_1a2b#n0`, and the scope that they were written in. Each insert renders them\n * again, with new scopes, as the body of a block does.\n */\nexport class ChildrenReference {\n readonly ref: string;\n readonly scope: ScopeId;\n /** The scope and the anchor of the insert where the server rendered them, if it did. */\n at: ScopeId | undefined;\n anchor: number | undefined;\n\n constructor(ref: string, scope: ScopeId, at?: ScopeId, anchor?: number) {\n this.ref = ref;\n this.scope = scope;\n this.at = at;\n this.anchor = anchor;\n }\n}\n\nexport class FunctionReference {\n /** `<component id>#<export name>`. */\n readonly ref: string;\n readonly scope: ScopeId;\n /** The arguments of a handler that `$handler` made, which come before the event. */\n readonly args: unknown[] | undefined;\n /** The modifiers of the wrappers of a handler, such as `prevent`, for the `b-on` of a spread. */\n readonly modifiers: string[] | undefined;\n\n constructor(ref: string, scope: ScopeId, args?: unknown[] | null, modifiers?: string[]) {\n this.ref = ref;\n this.scope = scope;\n this.args = args ?? undefined;\n this.modifiers = modifiers;\n }\n}\n\n/** The handlers that a merged handler calls, in order. A symbol of the registry. */\nexport const PARTS: unique symbol = Symbol.for('brumate.parts');\n\n// oxlint-disable-next-line typescript/no-explicit-any -- Handlers take any event.\ntype Handler = (...args: any[]) => unknown;\n\n/**\n * One handler that calls each of `handlers` in order, with the same arguments. A prop holds one\n * handler per event, and the browser takes one `b-on` entry for each part. Merged handlers in\n * `handlers` give their parts, so the list stays flat.\n */\nexport function mergeHandlers(handlers: Handler[]): Handler {\n const parts: Handler[] = [];\n for (const handler of handlers) {\n parts.push(...((handler as { [PARTS]?: Handler[] })[PARTS] ?? [handler]));\n }\n return Object.assign(\n (...args: unknown[]): void => {\n for (const part of parts) {\n part(...args);\n }\n },\n { [PARTS]: parts },\n );\n}\n\n/**\n * Adds a handler prop, such as `onClick`, for each entry of the scoped `b-on` of a dynamic tag\n * that names a component. `make` makes the handler of a reference. A handler of the same event in\n * `props`, such as a rest prop passed on, is merged with it and runs first.\n */\nexport function addEntryHandlers(\n props: Record<string, unknown>,\n entries: unknown,\n scope: ScopeId | undefined,\n make: (reference: FunctionReference) => Handler,\n): void {\n for (const entry of (ownValue('b-on', entries) as string | undefined)?.split(' ') ?? []) {\n const [event, target] = entry.split('=') as [string, string];\n const [name, ...modifiers] = event.split(':') as [string, ...string[]];\n const [ref, at] = target.split('@') as [string, string?];\n const handler = make(\n new FunctionReference(\n ref,\n /^\\d+$/.test(at ?? '') ? Number(at) : (at ?? scope!),\n undefined,\n modifiers.length > 0 ? modifiers : undefined,\n ),\n );\n const key = `on${name[0]!.toUpperCase()}${name.slice(1)}`;\n const before = props[key];\n props[key] =\n typeof before === 'function' ? mergeHandlers([before as Handler, handler]) : handler;\n }\n}\n\n// Brands of bindings and slot references, under keys of the registry, so two copies of the\n// runtime, such as a component's and the render context's, know each other's.\nconst BINDING = Symbol.for('brumate.binding');\nconst SLOT = Symbol.for('brumate.slot');\n\n/** A slot of a scope, which a write of a bound prop goes to. */\nexport class SlotReference {\n readonly scope: ScopeId;\n readonly slot: number;\n\n constructor(scope: ScopeId, slot: number) {\n this.scope = scope;\n this.slot = slot;\n }\n}\n\n(SlotReference.prototype as unknown as Record<symbol, boolean>)[SLOT] = true;\n\n/** True for a slot reference of any copy of the runtime. */\nexport function isSlotReference(value: unknown): value is SlotReference {\n return typeof value === 'object' && value !== null && SLOT in value;\n}\n\n/** True for a binding of any copy of the runtime. */\nexport function isBinding(value: unknown): value is Binding {\n return typeof value === 'object' && value !== null && BINDING in value;\n}\n\n/**\n * What `$bind(name)` passes a child: the value of the name, and its slot,\n * which the child's writes of the prop go to.\n */\nexport class Binding<T = unknown> {\n readonly value: T;\n readonly ref: SlotReference;\n /** The function of `$bind(name, fn)`, which a write calls in place of writing the slot. */\n readonly set: unknown;\n\n constructor(value: T, ref: SlotReference, set?: unknown) {\n this.value = value;\n this.ref = ref;\n this.set = set;\n }\n\n /** What a write of the bound prop goes to: the setter, or else the slot. */\n get target(): unknown {\n return this.set ?? this.ref;\n }\n}\n\n(Binding.prototype as unknown as Record<symbol, boolean>)[BINDING] = true;\n\n/**\n * The props that a component destructures, with the values of their\n * bindings. `names` are the props that it destructures by name: the others,\n * which a rest prop holds, keep their bindings, so a spread passes them on.\n * Without `names`, every binding gives its value. `omit` are props that a rest\n * leaves out, because another `$props()` call of the component names them.\n */\nexport function unbind(\n props: Record<string, unknown>,\n names?: readonly string[],\n omit?: readonly string[],\n sink?: PropSink,\n): Record<string, unknown> {\n let result: Record<string, unknown> | undefined;\n // The props that another `$props()` call of the component names, which a rest leaves out.\n if (omit) {\n result = { ...props };\n for (const key of omit) {\n delete result[key];\n }\n props = result;\n }\n for (const key of names ?? Object.keys(props)) {\n const value = props[key];\n if (sink && value instanceof Promise) {\n (sink.props ??= []).push(value);\n }\n if (isBinding(value)) {\n result ??= { ...props };\n result[key] = value.value;\n }\n }\n return result ?? props;\n}\n\n/**\n * What the slot of a memo holds while its compute throws or its promise rejects, and a memo that\n * failed on the server holds from the page state. Each read of the slot throws the error.\n */\nexport class MemoError {\n readonly error: unknown;\n\n constructor(error: unknown) {\n this.error = error;\n }\n}\n\n/**\n * A promise that a parent passed as a prop. It stays a promise in the child, so `await` and\n * `then` work on it. The page state holds it in this wrapper, so the browser knows the slot is\n * a prop and does not replace the promise with its value, as it does for a memo that streams.\n */\nexport class PropPromise {\n readonly promise: Promise<unknown>;\n\n constructor(promise: Promise<unknown>) {\n this.promise = promise;\n (this as Record<symbol, unknown>)[PROP_WRAPPER] = true;\n }\n}\n\n// Symbol.for, so copies of the runtime agree on the marks.\nconst PROP_WRAPPER = Symbol.for('brumate.propWrapper');\n\n/** A scope that collects the promise props that its component receives. */\nexport interface PropSink {\n props?: Promise<unknown>[] | undefined;\n}\n\n/** True for the wrapper that holds a promise prop in the page state. */\nexport function isPropWrapper(value: unknown): value is PropPromise {\n return typeof value === 'object' && value !== null && PROP_WRAPPER in value;\n}\n\n/** A component, which the compiler marks with its ID. */\nexport type ComponentValue = ((...args: never[]) => unknown) & { brumateId: string };\n\n/** The value of a feature that the build turned off, which no page state of it holds. */\nfunction unused(): never {\n throw new Error('The page state holds a value of a feature that no component of the build uses');\n}\n\n/**\n * Makes the values of brumate's plugins. A state record calls them as `$b`,\n * with one letter each, and the plugins read nodes of server function calls\n * with them too, so both give the same values.\n */\nexport const stateValues: {\n /** An element that the server rendered, by its scope and anchor. */\n e: (scope: ScopeId, anchor: number) => ElementReference;\n /** A client function, by its reference and scope. */\n f: (\n ref: string,\n scope: ScopeId,\n args?: unknown[] | null,\n modifiers?: string[],\n ) => FunctionReference;\n /** The parts of a merged handler, which `callable` makes one handler of. */\n m: (parts: FunctionReference[]) => FunctionReference[];\n /** A value of an attribute that brumate writes, such as the scope attribute of a style. */\n i: (value: unknown) => Internal;\n /** HTML that the client may insert again. */\n r: (html: string) => Raw;\n /** Children, by the export that renders them and their scope. */\n n: (ref: string, scope: ScopeId, at?: ScopeId, anchor?: number) => ChildrenReference;\n /**\n * A component, such as the value of a dynamic tag. The client gets a\n * function with the same ID that renders nothing. The client code that\n * changes the value uses the component's render module instead.\n */\n c: (id: string) => ComponentValue;\n /** A slot of a scope, which a bound prop writes. */\n l: (scope: ScopeId, slot: number) => SlotReference;\n /** A binding that a rest prop holds, with its value and its slot. */\n b: (value: unknown, scope: ScopeId, slot: number, set?: unknown) => Binding;\n /** A promise prop. See `PropPromise`. */\n q: (promise: Promise<unknown>) => PropPromise;\n /** The error of a memo that failed on the server. See `MemoError`. */\n x: (error: unknown) => MemoError;\n /** A value of the app, which a plugin of the entry makes from its data. */\n u: (tag: string, data: unknown) => unknown;\n /** A store, with its value, and where `$toStore` made it. See `madeStores`. */\n s: (value: unknown, scope?: ScopeId, site?: number, slot?: number) => Store<unknown>;\n /** A store of `bridge()`, with the data of the server and the name of its bridge. */\n g: (snapshot: unknown, id: string, writable?: number) => Bridged<unknown, unknown>;\n} = {\n e: (scope, anchor) => new ElementReference(scope, anchor),\n f: (ref, scope, args, modifiers) => new FunctionReference(ref, scope, args, modifiers),\n m: (parts) => Object.assign(parts, { [PARTS]: parts }),\n i: (value) => new Internal(value),\n r: raw,\n n: HAS_CHILDREN\n ? (ref, scope, at, anchor) => new ChildrenReference(ref, scope, at, anchor)\n : unused,\n c: (id) => Object.assign(() => '', { brumateId: id }),\n l: (scope, slot) => new SlotReference(scope, slot),\n b: HAS_BINDINGS\n ? (value, scope, slot, set) => new Binding(value, new SlotReference(scope, slot), set)\n : unused,\n q: (promise) => new PropPromise(promise),\n x: (error) => new MemoError(error),\n u: (tag, data) => {\n const plugin = valuePlugins.get(tag);\n if (!plugin) {\n throw new Error(\n `No plugin reads the value \"${tag}\". Export it in the plugins of the serial entry, src/serial.ts`,\n );\n }\n return plugin.fromData(data);\n },\n s: HAS_STORES\n ? (value, scope, site, slot) => {\n const made = new Store(value);\n if (scope !== undefined) {\n made.o = slot === undefined ? [scope, site!] : [scope, site!, slot];\n madeStores.push(made);\n }\n return made;\n }\n : unused,\n g: HAS_BRIDGES\n ? (snapshot, id, writable) =>\n new Bridged<unknown, unknown>(undefined, undefined, id, snapshot, writable === 1)\n : unused,\n};\n\n/**\n * The stores of providers that the page state made, until the core links them to their scopes:\n * a store of `$toStore(signal)` writes the signal of its provider.\n */\nexport const madeStores: Store<unknown>[] = [];\n\n/** The value of a `$gate`, which cannot be a promise or a stream. A throw is held like a memo error. */\nexport function gateValue<T>(value: T): T {\n if (\n (value !== null &&\n typeof value === 'object' &&\n typeof (value as { then?: unknown }).then === 'function') ||\n isAsyncIterable(value)\n ) {\n throw new TypeError(\n 'The value of $gate is a promise or a stream. Use $memo for a value that loads',\n );\n }\n return value;\n}\n\n/** True for a value that `for await` reads, such as the result of an async generator. */\nexport function isAsyncIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as AsyncIterable<unknown>)[Symbol.asyncIterator] === 'function'\n );\n}\n\n/**\n * A read of `$store`: the key of the context, or the index of the source in the exports `z` of\n * the component; the slot; the key of the store in the value of the context; and 1 when `let`\n * writes the store.\n */\nexport type StoreRead = [from: string | number, slot: number, path?: string, write?: 1];\n\n/** The state of one scope in the page. */\nexport interface ScopeState {\n /** The scope's ID in the compiled component. */\n k?: number;\n /** The ID of the scope that contains this one. Component root scopes have none. */\n p?: ScopeId;\n /** The component ID of a component's root scope. */\n m?: string;\n /** The item of a list item scope. */\n i?: unknown;\n /** The scope that rendered a component's root scope, for finding contexts. */\n o?: ScopeId;\n /**\n * For a scope of children that a component inserted, the scope where they\n * are, which contexts are found from in place of `p` and `o`.\n */\n t?: ScopeId;\n /** For a component that passes its children on, the scope where they are finally inserted. */\n f?: ScopeId;\n /** For the scope of a template, the scope where it was called, which errors go to. */\n l?: ScopeId;\n /** The values that the scope provides, by context key. */\n v?: Record<string, unknown>;\n /** The slots that hold the contexts that the scope reads, by context key. */\n x?: Record<string, number>;\n /**\n * The slots that hold the values of stores that `$store` reads: the key of the context, the\n * slot, and the key of the context value that holds the store, when it is not the value.\n */\n z?: StoreRead[];\n /** Slot values, in the order of the scope's layout. */\n s?: unknown[];\n /** The scope IDs of child components, by anchor index. */\n c?: Record<number, ScopeId>;\n /**\n * What the bound props of a component write, by the slot of the prop: a\n * slot of a parent, or the function of `$bind(name, fn)`.\n */\n b?: Record<number, unknown>;\n /**\n * The setters of `ref=$bind(x, fn)` that reached an element through rest props, by the anchor\n * of the element. The client calls each once on resume.\n */\n r?: Record<number, unknown>;\n}\n\n/** The state of a page, by scope ID. */\nexport type PageState = Record<ScopeId, ScopeState>;\n\n/**\n * The flags of a group of scope records in `PackedState`:\n * - `ITEM_SLOT`: the item of each scope is its first slot.\n * - `ITEM`: each scope has its item after its slots.\n * - `CHILDREN`: each scope has its child components after that.\n * - `OWNER`: the scopes are component root scopes. `base` is the distance from the scope that\n * rendered each one, `o`, to the scope, and the first gap is from 0. Otherwise `base` is the\n * parent, `p`, of every scope.\n * - `MODULE`: the group has the component ID of its scopes after its header.\n * - `SOURCE`: the scopes are the items of a list whose list is a slot of an enclosing scope.\n * The header then has that scope's ID and the slot's index, and the items are not written:\n * the item of the scope at position `n` in the group is the value at `n` of the list, or of\n * `Array.from` of a Set. With `ITEM_SLOT`, each scope writes its slots after the first.\n * - `PREFIX`: the scopes are inside a `#loading` body. The header ends with the prefix of\n * their IDs, such as `5.`, and the gaps count the numbers after it.\n */\nexport const ITEM_SLOT = 1;\nexport const ITEM = 2;\nexport const CHILDREN = 4;\nexport const OWNER = 8;\nexport const MODULE = 16;\nexport const SOURCE = 32;\nexport const PREFIX = 64;\n\n/**\n * The page state as the server writes it. Records of scopes that share their\n * kind, their parent or owner, and their shape are in one group of `g`,\n * such as the items of a list, instead of one object each. A group is a flat\n * array: `[kind, base, flags, slotCount, module?, source?, sourceSlot?, prefix?, ...scopes]`, and each scope\n * is its ID as the gap from the one before it (the first from `base`), its\n * slots, and then its item and its child components, as `flags` says.\n */\nexport type PackedState = PageState & { g?: unknown[][] };\n\n/**\n * How a field of a state record holds scope IDs:\n * - `none`: no ID.\n * - `id`: the value is an ID.\n * - `ids`: an object whose values are IDs.\n * - `value`: a value that may hold references, such as an item.\n * - `values`: an array of such values.\n * - `map`: an object whose values are such values.\n */\nexport type FieldKind = 'none' | 'id' | 'ids' | 'value' | 'values' | 'map';\n\n/**\n * A table of the fields of a state record and the reference classes that hold\n * a scope ID, which each keep it in `scope`. Code that moves the IDs reads it.\n * A new field of `ScopeState` fails to compile until it is in `fields`, and\n * `holders` are the classes that keep references in their own fields, such as\n * `Binding`, whose `ref` and `set` hold IDs. `scope-ids.test.ts` parses this\n * file and fails for any class in it, of any shape, that is not in\n * `references` or `holders` or in the test's list of classes without IDs.\n * It checks class names only, so a person decides which list a new class\n * belongs in.\n */\nexport const SCOPE_IDS: {\n fields: Record<keyof ScopeState, FieldKind>;\n references: readonly (abstract new (...args: never[]) => { scope: ScopeId })[];\n holders: readonly (abstract new (...args: never[]) => object)[];\n} = {\n fields: {\n k: 'none',\n p: 'id',\n m: 'none',\n i: 'value',\n o: 'id',\n t: 'id',\n f: 'id',\n l: 'id',\n v: 'map',\n x: 'none',\n z: 'none',\n s: 'values',\n c: 'ids',\n b: 'map',\n r: 'map',\n },\n references: [ElementReference, FunctionReference, ChildrenReference, SlotReference],\n holders: [Binding],\n};\n","const DRAFT = Symbol('brumate.draft');\n\ninterface DraftState {\n base: Record<PropertyKey, unknown>;\n /** A shallow copy, made on the first change. */\n copy: Record<PropertyKey, unknown> | undefined;\n parent: DraftState | undefined;\n /** Drafts of the objects inside, by key. */\n children: Map<PropertyKey, DraftState & { proxy: object }>;\n modified: boolean;\n}\n\n/** Plain objects and arrays can be drafted. Other values, such as `Map`, are used as they are. */\nfunction isDraftable(value: unknown): value is Record<PropertyKey, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (Array.isArray(value)) {\n return true;\n }\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction latest(state: DraftState): Record<PropertyKey, unknown> {\n return state.copy ?? state.base;\n}\n\n/** Copies an object and its parents on the first change. */\nfunction prepare(state: DraftState): Record<PropertyKey, unknown> {\n for (\n let current: DraftState | undefined = state;\n current && !current.modified;\n current = current.parent\n ) {\n current.modified = true;\n current.copy = (\n Array.isArray(current.base) ? [...current.base] : { ...current.base }\n ) as Record<PropertyKey, unknown>;\n }\n return state.copy!;\n}\n\nfunction getDraftState(value: unknown): DraftState | undefined {\n return typeof value === 'object' && value !== null\n ? ((value as Record<PropertyKey, unknown>)[DRAFT] as DraftState | undefined)\n : undefined;\n}\n\nfunction createDraft(\n base: Record<PropertyKey, unknown>,\n parent: DraftState | undefined,\n): DraftState & { proxy: object } {\n const state = {\n base,\n copy: undefined,\n parent,\n children: new Map(),\n modified: false,\n } as DraftState & {\n proxy: object;\n };\n // An empty target, so the draft can report the keys of the copy.\n const target = Array.isArray(base) ? [] : Object.create(Object.getPrototypeOf(base));\n state.proxy = new Proxy(target, {\n get(_, key) {\n if (key === DRAFT) {\n return state;\n }\n const source = latest(state);\n const value = source[key];\n if (!Object.hasOwn(source, key) || !isDraftable(value) || value !== state.base[key]) {\n return value;\n }\n let child = state.children.get(key);\n if (!child) {\n child = createDraft(value, state);\n state.children.set(key, child);\n }\n return child.proxy;\n },\n set(_, key, value) {\n const source = latest(state);\n if (Object.is(source[key], value) && Object.hasOwn(source, key)) {\n return true;\n }\n prepare(state)[key] = value;\n state.children.delete(key);\n return true;\n },\n deleteProperty(_, key) {\n if (Object.hasOwn(latest(state), key)) {\n delete prepare(state)[key];\n state.children.delete(key);\n }\n return true;\n },\n has(_, key) {\n return key in latest(state);\n },\n ownKeys() {\n return Reflect.ownKeys(latest(state));\n },\n getOwnPropertyDescriptor(_, key) {\n const descriptor = Reflect.getOwnPropertyDescriptor(latest(state), key);\n if (descriptor && key !== 'length') {\n descriptor.configurable = true;\n descriptor.writable = true;\n }\n return descriptor;\n },\n defineProperty(_, key, descriptor) {\n prepare(state);\n return Reflect.defineProperty(state.copy!, key, descriptor);\n },\n });\n return state;\n}\n\n/** Returns the final value of a draft: the base if nothing changed, or a new object that shares what did not. */\nfunction finalize(state: DraftState): unknown {\n if (!state.modified) {\n // A child can change without its parent being copied yet.\n for (const child of state.children.values()) {\n if (child.modified) {\n prepare(state);\n break;\n }\n }\n if (!state.modified) {\n return state.base;\n }\n }\n const copy = state.copy!;\n for (const [key, child] of state.children) {\n if (copy[key] === child.base) {\n copy[key] = finalize(child);\n }\n }\n // Drafts can also be assigned to other keys, such as when an array is reordered.\n for (const key of Reflect.ownKeys(copy)) {\n const draft = getDraftState(copy[key]);\n if (draft) {\n copy[key] = finalize(draft);\n }\n }\n return copy;\n}\n\n/**\n * Returns a changed copy of a value. The recipe changes a draft as if it\n * were the value. Objects that it does not change keep their identity, and\n * if it changes nothing, the value itself is returned. A recipe can also\n * return a new value. Only plain objects and arrays are drafted.\n */\nexport function produce<T>(base: T, recipe: (draft: T) => T | void): T {\n if (!isDraftable(base)) {\n const result = recipe(base);\n return result === undefined ? base : result;\n }\n const state = createDraft(base, undefined);\n const result = recipe(state.proxy as T);\n if (result !== undefined && result !== state.proxy) {\n return resolve(result, new Set()) as T;\n }\n return finalize(state) as T;\n}\n\n/** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */\nfunction resolve(value: unknown, seen: Set<unknown>): unknown {\n const draft = getDraftState(value);\n if (draft) {\n return finalize(draft);\n }\n if (!isDraftable(value) || seen.has(value)) {\n return value;\n }\n seen.add(value);\n for (const key of Reflect.ownKeys(value)) {\n value[key] = resolve(value[key], seen);\n }\n return value;\n}\n","// `$searchParam`: the value of a parameter of the query string. The server and the browser read\n// it the same way, and the browser writes it back with `client/search.ts`.\nimport type { SearchParamOptions } from './signals.ts';\nimport { routeContext } from './context.ts';\nimport type { Context } from './context.ts';\n\n/** The value of a parameter in a query string: its text parsed, or the default when it is absent. */\nexport function readParam(\n search: URLSearchParams,\n name: string,\n options?: SearchParamOptions<unknown>,\n): unknown {\n const text = search.get(name);\n if (text === null) {\n return options?.default ?? null;\n }\n return options?.parse ? options.parse(text) : text;\n}\n\n/** The text of a value in the URL, or null for the default, which leaves the parameter out. */\nexport function writeParam(value: unknown, options?: SearchParamOptions<unknown>): string | null {\n const own = formatParam(value, options);\n return own === formatParam(options?.default, options) ? null : own;\n}\n\nfunction formatParam(value: unknown, options?: SearchParamOptions<unknown>): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n return options?.serialize ? options.serialize(value) : String(value);\n}\n\n/** `$searchParam` on the server: the parameter of the request's URL. */\nexport function searchParam(\n context: { consume<T>(context: Context<T>, scope: number): T },\n name: string,\n options?: SearchParamOptions<unknown>,\n): unknown {\n return readParam(context.consume(routeContext, 0).search, name, options);\n}\n"],"mappings":";;;;;;AAWA,MAAM,+BAAe,IAAI,IAAyB;AACl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AgB,UACd,QACA,MACA,SACS;CACT,MAAM,OAAO,OAAO,IAAI,IAAI;CAC5B,IAAI,SAAS,MACX,OAAO,SAAS,WAAW;CAE7B,OAAO,SAAS,QAAQ,QAAQ,MAAM,IAAI,IAAI;AAChD;;AAGA,SAAgB,WAAW,OAAgB,SAAsD;CAC/F,MAAM,MAAM,YAAY,OAAO,OAAO;CACtC,OAAO,QAAQ,YAAY,SAAS,SAAS,OAAO,IAAI,OAAO;AACjE;AAEA,SAAS,YAAY,OAAgB,SAAsD;CACzF,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B,OAAO;CAET,OAAO,SAAS,YAAY,QAAQ,UAAU,KAAK,IAAI,OAAO,KAAK;AACrE;;AAGA,SAAgB,YACd,SACA,MACA,SACS;CACT,OAAO,UAAU,QAAQ,QAAQ,cAAc,CAAC,CAAC,CAAC,QAAQ,MAAM,OAAO;AACzE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as Context$1 } from "./context-
|
|
2
|
-
import { a as PageState, c as ScopeId, i as PackedState, l as ScopeState,
|
|
3
|
-
import {
|
|
1
|
+
import { t as Context$1 } from "./context-BNgBXVUQ.js";
|
|
2
|
+
import { a as PageState, c as ScopeId, i as PackedState, l as ScopeState, m as Raw, n as ElementReference, o as PropSink, t as Binding } from "./shared-CuJdWifz.js";
|
|
3
|
+
import { a as Store } from "./store-xlTzAM_r.js";
|
|
4
|
+
import { M as SearchParamOptions } from "./signals-DBnq9QRW.js";
|
|
4
5
|
import { t as StandardSchemaV1 } from "./standard-schema-BNY82yX3.js";
|
|
5
6
|
import { f as Intent, v as SubmissionResult } from "./forms-j1xPAR14.js";
|
|
6
7
|
//#region src/runtime/cookies.d.ts
|
|
@@ -916,6 +917,8 @@ declare class Context {
|
|
|
916
917
|
private rpcPrefix;
|
|
917
918
|
/** The ID of the build, for forms that post to server functions. See `RenderOptions`. */
|
|
918
919
|
build: string | undefined;
|
|
920
|
+
/** The Content Security Policy nonce of the render, for the `<style>` elements. */
|
|
921
|
+
nonce: string | undefined;
|
|
919
922
|
/** True in development, where a memo that failed or a `#catch` sends its error to the browser. */
|
|
920
923
|
development: boolean;
|
|
921
924
|
/** Results of server functions that a form posted to this page, for `$action`. */
|
|
@@ -998,11 +1001,34 @@ declare class Context {
|
|
|
998
1001
|
/** Provides a value of a context to the scopes inside `scope`. */
|
|
999
1002
|
provide<T>(context: Context$1<T>, value: T, scope: ScopeId): void;
|
|
1000
1003
|
/**
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
* when the provided value changes.
|
|
1004
|
+
* `$toStore(value)` in a provided value: a store of the value, which the page state sends with
|
|
1005
|
+
* the scope and the site that made it, and the slot of the signal that its `set` writes.
|
|
1004
1006
|
*/
|
|
1005
|
-
|
|
1007
|
+
toStore<T>(value: T, scope: ScopeId, site: number, slot?: number): Store<T>;
|
|
1008
|
+
/**
|
|
1009
|
+
* `$store(source)`: the value of the store, and a record of its slot, so the browser subscribes
|
|
1010
|
+
* the slot when the scope resumes. With no `link`, or with a `fallback`, the source is a context:
|
|
1011
|
+
* the browser finds its store again by the key of the context, with `path` for a key of its
|
|
1012
|
+
* value. Otherwise, and when the fallback gave the store, the browser runs the source `link` of
|
|
1013
|
+
* the component's exports `z`. `sent` names the value that holds the store when the page sends
|
|
1014
|
+
* it, such as a prop, where only a store of `brumate/store` crosses. The last argument is
|
|
1015
|
+
* `sent` for a source and the fallback for a context, which never come together.
|
|
1016
|
+
*/
|
|
1017
|
+
consumeStore<T>(source: unknown, scope: ScopeId, slot: number, path?: string, link?: number, write?: boolean, last?: string | (() => unknown)): T;
|
|
1018
|
+
/**
|
|
1019
|
+
* Reads a context from the nearest scope above `scope` that provides it. With a fallback, a
|
|
1020
|
+
* read without a provider gives the fallback, or what it returns when it is a function, in
|
|
1021
|
+
* place of the error. With `slot`, records which slot holds it, which only `$route()` and
|
|
1022
|
+
* `$navigation()` pass, so the client can update them when navigation changes them. A provided
|
|
1023
|
+
* value is read once.
|
|
1024
|
+
*/
|
|
1025
|
+
consume<T>(context: Context$1<T>, scope: ScopeId, ...rest: [fallback?: unknown, slot?: number]): T;
|
|
1026
|
+
/**
|
|
1027
|
+
* The nearest scope above `scope` that provides the key. A scope reads the contexts of the
|
|
1028
|
+
* scopes above it, not its own, so a component can read a context and provide it again to the
|
|
1029
|
+
* scopes inside it.
|
|
1030
|
+
*/
|
|
1031
|
+
private findProvider;
|
|
1006
1032
|
/** The ID that the next call to `scope()` returns. */
|
|
1007
1033
|
peek(): ScopeId;
|
|
1008
1034
|
/** Marks the render so far, such as before a `#try` body, for `restore`. */
|
|
@@ -1380,8 +1406,9 @@ interface RenderOptions {
|
|
|
1380
1406
|
*/
|
|
1381
1407
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
1382
1408
|
/**
|
|
1383
|
-
* A Content Security Policy nonce for the inline scripts
|
|
1384
|
-
* records, and the scripts that swap in `#loading` bodies
|
|
1409
|
+
* A Content Security Policy nonce for the inline scripts (the state
|
|
1410
|
+
* records, and the scripts that swap in `#loading` bodies) and the
|
|
1411
|
+
* `<style>` elements of components.
|
|
1385
1412
|
*/
|
|
1386
1413
|
nonce?: string;
|
|
1387
1414
|
/**
|
|
@@ -1617,4 +1644,4 @@ declare function handleRoute(tree: RouteNode, request: Request, options?: RouteO
|
|
|
1617
1644
|
declare function spread(attributes: Record<string, unknown>, on?: string[], names?: boolean): string | Promise<string>;
|
|
1618
1645
|
//#endregion
|
|
1619
1646
|
export { idempotent as $, defineMiddleware as $t, handleRoute as A, safeParse as At, renderToStream as B, searchParam as Bt, attribute as C, parseSubmission as Ct, component as D, fieldErrors as Dt, children as E, ValidationIssue as Et, memo as F, MiddlewareLoader as Ft, start as G, RequestEvent as Gt, settled as H, Locals as Ht, packState as I, RouteMatch as It, streamParts as J, ServerError as Jt, stateScript as K, RequestEventOptions as Kt, read as L, RouteNode as Lt, insert as M, Handler as Mt, isCrossSite as N, Loader as Nt, dynamic as O, parse as Ot, lazy as P, Middleware as Pt, IdempotentOptions as Q, dedupe as Qt, ready as R, RouteView as Rt, actionResult as S, SuccessfulSubmission as St, caught as T, ValidationError as Tt, spacerTag as U, Redirect as Ut, setClientBundles as V, EntryMiddleware as Vt, spread as W, RequestCall as Wt, wait as X, ServerErrorInfo as Xt, streamState as Y, ServerErrorHandler as Yt, waitAll as Z, ServerErrorKind as Zt, ScopeEntry as _, FailedSubmission as _t, DocumentOptions as a, Session as an, setCacheStore as at, StreamOptions as b, Submission as bt, Mark as c, parseCookies as cn, RateLimitConfig as ct, PageCache as d, RateLimitOptions as dt, getEvent as en, CacheStore as et, RenderOptions as f, RateLimitStore as ft, RouteOptions as g, rateLimit as gt, RevealOrder as h, configureRateLimit as ht, DeferTarget as i, CookieOptions as in, revalidate as it, inlineBodies as j, EndpointLoader as jt, handleRequest as k, parseForm as kt, Memo as l, serializeCookie as ln, RateLimitError as lt, RequestOptions as m, clientAddress as mt, Component as n, redirect as nn, cached as nt, ItemSource as o, SessionOptions as on, storageStore as ot, RenderResult as p, Window as pt, stateValue as q, RequestKind as qt, Context as r, withEvent as rn, memoryStore as rt, Lazy as s, createSession as sn, RateLimit as st, ClientBundles as t, isRedirect as tn, CachedOptions as tt, NotReady as u, toNodeHeaders as un, RateLimitMiddleware as ut, StateAttributes as v, IntentSubmission as vt, binding as w, ParseResult as wt, action as x, SubmissionOptions as xt, StateMap as y, ReplyOptions as yt, render as z, matchRoute as zt };
|
|
1620
|
-
//# sourceMappingURL=server-
|
|
1647
|
+
//# sourceMappingURL=server-0rS5vUW1.d.ts.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { n as closesParagraph, r as firstTag } from "./nesting-DA5vJw9X.js";
|
|
2
2
|
import { n as MODIFIERS } from "./events-LgLdp1R7.js";
|
|
3
|
-
import { C as spread$1, S as rawHTML, a as attribute$1, b as ownValue, d as escapeAttribute, f as handlerEntry, g as isRaw, n as VOID_ELEMENTS, p as insertValue, r as actionAttributes, s as bindEntry, u as escape, v as onAttribute, w as styleElement } from "./html-
|
|
3
|
+
import { C as spread$1, S as rawHTML, a as attribute$1, b as ownValue, d as escapeAttribute, f as handlerEntry, g as isRaw, n as VOID_ELEMENTS, p as insertValue, r as actionAttributes, s as bindEntry, u as escape, v as onAttribute, w as styleElement } from "./html-Cf5uKhLs.js";
|
|
4
4
|
import { n as deleteCookie, o as setCookie, r as getCookies } from "./cookies-Cnbf4w-S.js";
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
5
|
+
import { a as callPlugins, c as syncPlugins, i as BridgeDataError, l as functionReferences, o as plugins, r as toChunkStream, s as serialOptions, t as STREAM_TYPE } from "./stream-RXLadXx1.js";
|
|
6
|
+
import { a as findStored, l as isForeignStore, m as sentForeignStore, n as Store, u as isStore } from "./store-BIBAYZo-.js";
|
|
7
|
+
import { T as parseId, _ as isAsyncIterable, a as Binding, b as isSlotReference, c as ElementReference, d as PARTS, f as PropPromise, h as addEntryHandlers, l as FunctionReference, m as SlotReference, o as CHILDREN_REF, s as ChildrenReference, u as MemoError, v as isBinding } from "./search-params-C64liRBj.js";
|
|
7
8
|
import { n as serverSecrets } from "./secrets-BxagsJxJ.js";
|
|
8
|
-
import "./context-
|
|
9
|
+
import { i as missingContext } from "./context-CU4Fpn5a.js";
|
|
9
10
|
import { a as applyIntent, d as formatPath, f as getAt, m as groupIssues, r as INTENT, u as formValues, v as parseIntent, y as parsePath } from "./forms-nXK7-Lv_.js";
|
|
10
11
|
import { crossSerialize, crossSerializeStream, fromJSON, toJSON } from "seroval";
|
|
11
12
|
//#region src/runtime/request.ts
|
|
@@ -1210,6 +1211,20 @@ function idempotent(fn, options = {}) {
|
|
|
1210
1211
|
}
|
|
1211
1212
|
//#endregion
|
|
1212
1213
|
//#region src/runtime/server.ts
|
|
1214
|
+
/**
|
|
1215
|
+
* Refuses a store that is not of `brumate/store` in a provided value, or in a key of it: the page
|
|
1216
|
+
* state cannot send it, and the browser would not know when it changes. At module level it works.
|
|
1217
|
+
*/
|
|
1218
|
+
function refuseForeignStore(key, value) {
|
|
1219
|
+
let foreign = isForeignStore(value);
|
|
1220
|
+
if (!foreign && typeof value === "object" && value !== null && !isStore(value)) {
|
|
1221
|
+
for (const item of Object.values(value)) if (isForeignStore(item)) {
|
|
1222
|
+
foreign = true;
|
|
1223
|
+
break;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
if (foreign) throw new Error(`The context "${key}" holds a store that is not of brumate/store. Make it with $toStore or store(), wrap it with bridge(), or read it at module level with $store`);
|
|
1227
|
+
}
|
|
1213
1228
|
/** What `$bind(name)` passes a child: the value of the name, and the scope and slot it writes. */
|
|
1214
1229
|
function binding(value, scope, slot, set) {
|
|
1215
1230
|
return new Binding(value, new SlotReference(scope, slot), set);
|
|
@@ -1373,6 +1388,8 @@ var Context = class Context {
|
|
|
1373
1388
|
rpcPrefix = "/_brumate";
|
|
1374
1389
|
/** The ID of the build, for forms that post to server functions. See `RenderOptions`. */
|
|
1375
1390
|
build;
|
|
1391
|
+
/** The Content Security Policy nonce of the render, for the `<style>` elements. */
|
|
1392
|
+
nonce;
|
|
1376
1393
|
/** True in development, where a memo that failed or a `#catch` sends its error to the browser. */
|
|
1377
1394
|
development = false;
|
|
1378
1395
|
/** Results of server functions that a form posted to this page, for `$action`. */
|
|
@@ -1589,6 +1606,7 @@ var Context = class Context {
|
|
|
1589
1606
|
}
|
|
1590
1607
|
/** Provides a value of a context to the scopes inside `scope`. */
|
|
1591
1608
|
provide(context, value, scope) {
|
|
1609
|
+
refuseForeignStore(context.key, value);
|
|
1592
1610
|
const node = this.find(scope);
|
|
1593
1611
|
node.values ??= /* @__PURE__ */ new Map();
|
|
1594
1612
|
node.values.set(context.key, value);
|
|
@@ -1597,21 +1615,80 @@ var Context = class Context {
|
|
|
1597
1615
|
record.v[context.key] = value;
|
|
1598
1616
|
}
|
|
1599
1617
|
/**
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1602
|
-
|
|
1618
|
+
* `$toStore(value)` in a provided value: a store of the value, which the page state sends with
|
|
1619
|
+
* the scope and the site that made it, and the slot of the signal that its `set` writes.
|
|
1620
|
+
*/
|
|
1621
|
+
toStore(value, scope, site, slot) {
|
|
1622
|
+
const made = new Store(value);
|
|
1623
|
+
made.o = slot === void 0 ? [scope, site] : [
|
|
1624
|
+
scope,
|
|
1625
|
+
site,
|
|
1626
|
+
slot
|
|
1627
|
+
];
|
|
1628
|
+
made.r = slot === void 0;
|
|
1629
|
+
return made;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* `$store(source)`: the value of the store, and a record of its slot, so the browser subscribes
|
|
1633
|
+
* the slot when the scope resumes. With no `link`, or with a `fallback`, the source is a context:
|
|
1634
|
+
* the browser finds its store again by the key of the context, with `path` for a key of its
|
|
1635
|
+
* value. Otherwise, and when the fallback gave the store, the browser runs the source `link` of
|
|
1636
|
+
* the component's exports `z`. `sent` names the value that holds the store when the page sends
|
|
1637
|
+
* it, such as a prop, where only a store of `brumate/store` crosses. The last argument is
|
|
1638
|
+
* `sent` for a source and the fallback for a context, which never come together.
|
|
1639
|
+
*/
|
|
1640
|
+
consumeStore(source, scope, slot, path, link, write, last) {
|
|
1641
|
+
let ref = link;
|
|
1642
|
+
let value = source;
|
|
1643
|
+
let key;
|
|
1644
|
+
if (link === void 0 || typeof last === "function") {
|
|
1645
|
+
key = source.key;
|
|
1646
|
+
const provider = this.findProvider(key, scope);
|
|
1647
|
+
if (provider) {
|
|
1648
|
+
ref = key;
|
|
1649
|
+
value = provider.values.get(key);
|
|
1650
|
+
} else if (typeof last === "function") value = last();
|
|
1651
|
+
else throw missingContext(key);
|
|
1652
|
+
}
|
|
1653
|
+
const found = findStored(value, path, write, key);
|
|
1654
|
+
if (typeof last === "string" && isForeignStore(found)) {
|
|
1655
|
+
let owner = this.record(scope);
|
|
1656
|
+
while (owner && owner.m === void 0 && owner.p !== void 0) owner = this.ownRecord(owner.p);
|
|
1657
|
+
throw sentForeignStore(owner?.m ?? "a component", last);
|
|
1658
|
+
}
|
|
1659
|
+
if (slot >= 0) {
|
|
1660
|
+
let entry = [ref, slot];
|
|
1661
|
+
if (write) entry = [
|
|
1662
|
+
ref,
|
|
1663
|
+
slot,
|
|
1664
|
+
path,
|
|
1665
|
+
1
|
|
1666
|
+
];
|
|
1667
|
+
else if (path !== void 0) entry = [
|
|
1668
|
+
ref,
|
|
1669
|
+
slot,
|
|
1670
|
+
path
|
|
1671
|
+
];
|
|
1672
|
+
(this.record(scope).z ??= []).push(entry);
|
|
1673
|
+
}
|
|
1674
|
+
return found.get();
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Reads a context from the nearest scope above `scope` that provides it. With a fallback, a
|
|
1678
|
+
* read without a provider gives the fallback, or what it returns when it is a function, in
|
|
1679
|
+
* place of the error. With `slot`, records which slot holds it, which only `$route()` and
|
|
1680
|
+
* `$navigation()` pass, so the client can update them when navigation changes them. A provided
|
|
1681
|
+
* value is read once.
|
|
1603
1682
|
*/
|
|
1604
|
-
consume(context, scope,
|
|
1683
|
+
consume(context, scope, ...rest) {
|
|
1684
|
+
const [fallback, slot] = rest;
|
|
1605
1685
|
if (slot !== void 0) {
|
|
1606
1686
|
const record = this.record(scope);
|
|
1607
1687
|
record.x ??= {};
|
|
1608
1688
|
record.x[context.key] = slot;
|
|
1609
1689
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
if (node?.values?.has(context.key)) return node.values.get(context.key);
|
|
1613
|
-
id = node?.parent;
|
|
1614
|
-
}
|
|
1690
|
+
const provider = this.findProvider(context.key, scope);
|
|
1691
|
+
if (provider) return provider.values.get(context.key);
|
|
1615
1692
|
if (context.key === "brumate.route") {
|
|
1616
1693
|
const url = new URL(this.root.event?.request.url ?? "http://localhost/");
|
|
1617
1694
|
return {
|
|
@@ -1620,7 +1697,21 @@ var Context = class Context {
|
|
|
1620
1697
|
params: this.root.params
|
|
1621
1698
|
};
|
|
1622
1699
|
}
|
|
1623
|
-
|
|
1700
|
+
if (context.key === "brumate.navigation") return { pending: false };
|
|
1701
|
+
if (rest.length !== 1) throw missingContext(context.key);
|
|
1702
|
+
return typeof fallback === "function" ? fallback() : fallback;
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* The nearest scope above `scope` that provides the key. A scope reads the contexts of the
|
|
1706
|
+
* scopes above it, not its own, so a component can read a context and provide it again to the
|
|
1707
|
+
* scopes inside it.
|
|
1708
|
+
*/
|
|
1709
|
+
findProvider(key, scope) {
|
|
1710
|
+
for (let id = this.find(scope)?.parent; id !== void 0;) {
|
|
1711
|
+
const node = this.find(id);
|
|
1712
|
+
if (node?.values?.has(key)) return node;
|
|
1713
|
+
id = node?.parent;
|
|
1714
|
+
}
|
|
1624
1715
|
}
|
|
1625
1716
|
/** The ID that the next call to `scope()` returns. */
|
|
1626
1717
|
peek() {
|
|
@@ -1881,7 +1972,7 @@ var Context = class Context {
|
|
|
1881
1972
|
if (styles.has(id)) return "";
|
|
1882
1973
|
styles.add(id);
|
|
1883
1974
|
this.undo.push(() => styles.delete(id));
|
|
1884
|
-
return styleElement(id, css);
|
|
1975
|
+
return styleElement(id, css, this.root.nonce);
|
|
1885
1976
|
}
|
|
1886
1977
|
/** Adds the markup of a `#head` block. */
|
|
1887
1978
|
head(html) {
|
|
@@ -2396,6 +2487,7 @@ function holds(value, target, seen = /* @__PURE__ */ new Set()) {
|
|
|
2396
2487
|
* browser, which names the value and its component.
|
|
2397
2488
|
*/
|
|
2398
2489
|
function unsendable(error, ctx) {
|
|
2490
|
+
if (error instanceof BridgeDataError) return bridgeDataError(error, ctx);
|
|
2399
2491
|
const secret = secretErrors.get(error);
|
|
2400
2492
|
const target = secret ?? error.value;
|
|
2401
2493
|
if (target === void 0) return error instanceof Error ? error : new Error(String(error));
|
|
@@ -2415,6 +2507,29 @@ function unsendable(error, ctx) {
|
|
|
2415
2507
|
}
|
|
2416
2508
|
return error instanceof Error ? error : new Error(String(error));
|
|
2417
2509
|
}
|
|
2510
|
+
/**
|
|
2511
|
+
* The error of a store of `bridge()` whose `get` gives data that cannot be sent: it names the
|
|
2512
|
+
* store, and the context or the prop that gives it to the browser.
|
|
2513
|
+
*/
|
|
2514
|
+
function bridgeDataError(error, ctx) {
|
|
2515
|
+
const id = error.value.id;
|
|
2516
|
+
const hash = id?.lastIndexOf("#") ?? -1;
|
|
2517
|
+
const name = id === void 0 ? "a bridge" : `"${id.slice(hash + 1)}" of bridge() in ${id.slice(7, hash)}`;
|
|
2518
|
+
const reason = (error.cause instanceof Error ? error.cause.message : String(error.cause)).split("\n")[0].replace(/\.$/, "");
|
|
2519
|
+
return new Error(`The store ${name} gives data from get that cannot be sent to the browser (${reason}), and ${bridgeSite(error, ctx)} sends it. Return plain data from get, such as numbers, strings, arrays and objects`, { cause: error });
|
|
2520
|
+
}
|
|
2521
|
+
/** Where a bridged store is given to the browser: a context, or the prop or value of a component. */
|
|
2522
|
+
function bridgeSite(error, ctx) {
|
|
2523
|
+
for (const { record, names } of ctx.scopes) {
|
|
2524
|
+
for (const [key, value] of Object.entries(record.v ?? {})) if (holds(value, error.value)) return `the context "${key}"`;
|
|
2525
|
+
for (const [slot, value] of (record.s ?? []).entries()) if (holds(value, error.value)) {
|
|
2526
|
+
let owner = record;
|
|
2527
|
+
while (owner && owner.m === void 0 && owner.p !== void 0) owner = ctx.ownRecord(owner.p);
|
|
2528
|
+
return `the prop or value "${names?.[slot] ?? `slot ${slot}`}" in ${owner?.m ?? "a component"}`;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
return "the page state";
|
|
2532
|
+
}
|
|
2418
2533
|
/** The secret that each error of `secretError` found. The error does not hold it, so a log does not show it. */
|
|
2419
2534
|
const secretErrors = /* @__PURE__ */ new WeakMap();
|
|
2420
2535
|
/** The code of each secret as seroval writes a string: in double quotes, escaped. */
|
|
@@ -2819,6 +2934,7 @@ async function render(Root, props, options = {}) {
|
|
|
2819
2934
|
if (options.actions) ctx.actions = options.actions;
|
|
2820
2935
|
if (options.params) ctx.params = options.params;
|
|
2821
2936
|
ctx.build = options.build;
|
|
2937
|
+
ctx.nonce = options.nonce;
|
|
2822
2938
|
ctx.development = options.dev === true;
|
|
2823
2939
|
if (options.defer) ctx.target = { ...options.defer };
|
|
2824
2940
|
ctx.inOrder = !options.defer && rendersInOrder(options.inOrder ?? "bots", options.request ?? options.event?.request);
|
|
@@ -4042,4 +4158,4 @@ function spread(attributes, on, names) {
|
|
|
4042
4158
|
//#endregion
|
|
4043
4159
|
export { dedupe as $, streamParts as A, ValidationError as B, setClientBundles as C, start as D, spread as E, RateLimitError as F, matchRoute as G, parse as H, clientAddress as I, revalidate as J, cached as K, configureRateLimit as L, wait as M, waitAll as N, stateScript as O, idempotent as P, ServerError as Q, rateLimit as R, renderToStream as S, spacerTag as T, parseForm as U, fieldErrors as V, safeParse as W, storageStore as X, setCacheStore as Y, RequestEvent as Z, memo as _, attribute as a, ready as b, children as c, handleRequest as d, defineMiddleware as et, handleRoute as f, lazy as g, isCrossSite as h, actionResult as i, withEvent as it, streamState as j, stateValue as k, component as l, insert as m, NotReady as n, isRedirect as nt, binding as o, inlineBodies as p, memoryStore as q, action as r, redirect as rt, caught as s, Context as t, getEvent as tt, dynamic as u, packState as v, settled as w, render as x, read as y, parseSubmission as z };
|
|
4044
4160
|
|
|
4045
|
-
//# sourceMappingURL=server-
|
|
4161
|
+
//# sourceMappingURL=server-BVObWh-w.js.map
|