brumate 0.2.0 → 0.3.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-D-IdPy7B.d.ts → boot-C25Sa6vq.d.ts} +5 -2
- package/dist/cli.js +2 -2
- package/dist/{client-C0UCNL3J.js → client-BD6XT-s5.js} +435 -110
- package/dist/client-BD6XT-s5.js.map +1 -0
- package/dist/{client-MD0ZmcFR.d.ts → client-D0CqSxoO.d.ts} +114 -8
- package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
- package/dist/cookies-BzllthiF.js.map +1 -0
- package/dist/{defer-D0bo1Gqx.js → defer-BbD7JQhj.js} +6 -2
- package/dist/defer-BbD7JQhj.js.map +1 -0
- package/dist/devtools-CQgD7NPB.js +623 -0
- package/dist/devtools-CQgD7NPB.js.map +1 -0
- package/dist/devtools-panel-BVB-W5q4.js +1930 -0
- package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
- package/dist/events-CSs7OwIC.js +85 -0
- package/dist/events-CSs7OwIC.js.map +1 -0
- package/dist/{files-Bnn1JqHx.js → files-BXSSrQgc.js} +18 -5
- package/dist/files-BXSSrQgc.js.map +1 -0
- package/dist/forms-Bg-CwGqX.js +406 -0
- package/dist/forms-Bg-CwGqX.js.map +1 -0
- package/dist/forms-Cl21hkHt.d.ts +281 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +269 -0
- package/dist/highlight.js.map +1 -0
- package/dist/{html-y1q7-t7D.d.ts → html-Bq1rFxX_.d.ts} +36 -4
- package/dist/{html-bHZbkK-h.js → html-mNTKzaDD.js} +79 -8
- package/dist/html-mNTKzaDD.js.map +1 -0
- package/dist/index.d.ts +47 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BJtACnQp.js → inspect-BHpOw1LF.js} +625 -48
- package/dist/inspect-BHpOw1LF.js.map +1 -0
- package/dist/{loader-B18i3_-T.js → loader-Dos_3NP0.js} +5 -4
- package/dist/loader-Dos_3NP0.js.map +1 -0
- package/dist/{navigate-BwuZveDF.js → navigate-O78d_zGN.js} +45 -2
- package/dist/navigate-O78d_zGN.js.map +1 -0
- package/dist/{produce-D4K7qpaL.d.ts → produce-D0V0ICkz.d.ts} +45 -3
- package/dist/{produce-CWfJ4byV.js → produce-Doc91GkX.js} +113 -6
- package/dist/produce-Doc91GkX.js.map +1 -0
- package/dist/{rpc-B-Zkn6Ch.js → rpc-ygMRPmN4.js} +20 -10
- package/dist/rpc-ygMRPmN4.js.map +1 -0
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +188 -3
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.d.ts +15 -0
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- 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 +5 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +38 -2
- package/dist/runtime/signals.js +12 -2
- 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/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/{server-BqfM95r1.js → server-CxVDYE_V.js} +776 -121
- package/dist/server-CxVDYE_V.js.map +1 -0
- package/dist/{server-BA9SJ2Vm.d.ts → server-DuFYRXrd.d.ts} +284 -15
- package/dist/{static-loader-BzE9SRaj.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
- package/dist/{static-loader-DOygOFj5.js → static-loader-nZssh66R.js} +168 -51
- package/dist/static-loader-nZssh66R.js.map +1 -0
- package/dist/{stream-JaMHMdBD.js → stream-DCYZO4IF.js} +89 -10
- package/dist/stream-DCYZO4IF.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +8 -1
- package/dist/vite.js +170 -20
- package/dist/vite.js.map +1 -1
- package/forms/forms.brm.ts +141 -0
- package/package.json +31 -2
- package/dist/client-C0UCNL3J.js.map +0 -1
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/defer-D0bo1Gqx.js.map +0 -1
- package/dist/devtools-C50VH8gZ.js +0 -113
- package/dist/devtools-C50VH8gZ.js.map +0 -1
- package/dist/devtools-panel-AYjfwPhj.js +0 -435
- package/dist/devtools-panel-AYjfwPhj.js.map +0 -1
- package/dist/events-BKWRqtMg.js +0 -52
- package/dist/events-BKWRqtMg.js.map +0 -1
- package/dist/files-Bnn1JqHx.js.map +0 -1
- package/dist/html-bHZbkK-h.js.map +0 -1
- package/dist/inspect-BJtACnQp.js.map +0 -1
- package/dist/loader-B18i3_-T.js.map +0 -1
- package/dist/navigate-BwuZveDF.js.map +0 -1
- package/dist/produce-CWfJ4byV.js.map +0 -1
- package/dist/rpc-B-Zkn6Ch.js.map +0 -1
- package/dist/server-BqfM95r1.js.map +0 -1
- package/dist/static-loader-DOygOFj5.js.map +0 -1
- package/dist/stream-JaMHMdBD.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-BD6XT-s5.js","names":["spreadText","id"],"sources":["../src/runtime/client.ts"],"sourcesContent":["import { trustedHTML } from './trusted.ts';\nimport { loadOnce } from './skew.ts';\nimport {\n VOID_ELEMENTS,\n actionAttributes,\n attributeText,\n insertValue,\n bindEntry,\n handlerEntry,\n spread as spreadText,\n textValue,\n} from './html.ts';\nimport type { NavigationReport } from './navigate.ts';\nimport type { SerialEntry } from './values.ts';\nimport type { Raw } from './html.ts';\nimport {\n Binding,\n CHILDREN,\n ElementReference,\n FunctionReference,\n ITEM,\n ITEM_SLOT,\n MODULE,\n OWNER,\n PREFIX,\n SOURCE,\n SlotReference,\n isAsyncIterable,\n isBinding,\n isSlotReference,\n useSerialEntry,\n parseId,\n stateValues,\n} from './shared.ts';\nimport type { PackedState, PageState, ScopeId, ScopeState } from './shared.ts';\nimport { ROUTE_KEY } from './context.ts';\nexport { navigationContext, routeContext } from './context.ts';\nimport type { Context as ContextValue, Route } from './context.ts';\n\nexport {\n affix,\n attribute,\n classAttribute,\n escape,\n mergeAttributes,\n onAttribute,\n raw,\n vars,\n} from './html.ts';\nexport type { Raw } from './html.ts';\nexport { produce } from './produce.ts';\n// For `client-routes.ts`, which reads the core with `import()`.\nexport { ElementReference, FunctionReference, unbind } from './shared.ts';\nexport { createContext } from './context.ts';\n\ntype Update = [kind: number, name: string];\n\n/** The entry of a compiled client module. */\nexport interface ClientModule {\n id: string;\n /** Prop names to slot indices. `*` is the slot of a props object. */\n props: Record<string, number>;\n /** Scope kind, then slot, to the updates that read it. */\n g: Record<number, Record<number, Update[]>>;\n /**\n * Imports a part of the module. A module without it holds every part\n * itself, as a small component's module does.\n */\n load?: (part: string) => Promise<Part>;\n /** Server function ID to the memos that call it, as scope kind and update, for `refresh`. */\n refresh?: Record<string, Update[]>;\n /**\n * The `#try` blocks that catch errors of client code, by the scope kinds\n * inside their bodies: the kind of the scope that holds the block, the\n * anchor of the block, the render functions of the body and the `#catch`\n * body, and the kinds of both bodies.\n */\n t?: Record<\n number,\n [owner: number, anchor: number, body: string, fallback: string, kinds: number[]]\n >;\n}\n\n/** A part of a client module: one client root, or the updates. */\nexport type Part = Record<string, unknown>;\n\n/** The part that holds an export: `h<n>` and `c<n>` have their own, the rest are in `update`. */\nfunction partOf(name: string): string {\n return /^[hct]\\d/.test(name) ? name : 'update';\n}\n\n/** The instance of a scope in the page. */\nexport interface Scope {\n id: ScopeId;\n /** The scope's ID in the compiled component. */\n k: number;\n p?: Scope;\n /** The component ID, for a component's root scope. */\n m?: string;\n s: unknown[];\n /** The item of a list item scope. */\n i?: unknown;\n c?: Record<number, ScopeId>;\n /** The scope that rendered a component's root scope. */\n o?: Scope;\n /** For children that a component inserted, the scope where they are, for contexts. */\n t?: Scope;\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 /** The slots of a parent that the bound props of a component write, by the slot of the prop. */\n /**\n * What the bound props write, by the slot of the prop: a slot of a parent,\n * or the setter of `$bind(name, fn)`, as a function or a reference.\n */\n b?: Record<number, unknown>;\n children: Set<Scope>;\n /** The `b-root` of the render that the server rendered the scope in. */\n r?: string;\n cleanups?: Map<string, () => void>;\n keys?: Map<number, unknown>;\n /** Set while the scope is the body of an `#offscreen` block that is hidden. */\n h?: HiddenBody;\n /** Effects and `$client` callbacks to run when the `#offscreen` body around the scope shows. */\n w?: Set<string>;\n}\n\nexport interface CoreOptions {\n /** The exports of the serial entry, for the values of the app in the page state. */\n serial?: SerialEntry;\n /**\n * Imports the client module of a component. Undefined for a component that\n * has no client code, which a build leaves out.\n */\n load: (id: string) => Promise<ClientModule> | undefined;\n /** Imports a part of a module, once for each part, as the loader preloads it. */\n loadPart?: (module: ClientModule, part: string) => Promise<Part>;\n /** Adds event listeners for the `b-on` attributes in new markup. */\n listen: (root: ParentNode) => void;\n /** Tells the loader that the markup that `listen` scanned is in the page now. */\n inserted?: () => void;\n /** The URL prefix of server function calls. Defaults to `/_brumate`. */\n rpc?: string;\n /** The ID of the build of the page, for skew protection. Calls send it, and a deploy is noticed. */\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. `scope` is the ID of the scope\n * that the code belongs to, when it has one.\n */\n onError?: (error: unknown, info: { scope?: ScopeId }) => void;\n}\n\n// The core keeps only what every page needs: it reads the state, runs handlers and updates.\n// Each helper that compiled code calls is an export of its own, so a build leaves out the ones\n// that no component calls. Features that change how the core reads the page, such as client\n// navigation and hot updates, live in their own modules and set `hooks` when they load.\n\nlet options: CoreOptions;\n/** The URL prefix of server function calls, from the options. */\nexport let rpcPrefix = '/_brumate';\n/** The ID of the build of the page, from the loader. Undefined on the dev server. */\nexport let build: string | undefined;\n\n/**\n * Tells the page that the site changed since it loaded: a call answered 409\n * with another build, or the code of a handler is gone. The loader then\n * loads the next page in full, and an app can save a draft first.\n */\nexport function skew(reason: 'call' | 'code' | 'defer'): void {\n document.dispatchEvent(new CustomEvent('brumate:skew', { detail: reason }));\n}\n/** The scopes of the page, by ID. */\nexport const scopes: Map<ScopeId, Scope> = new Map();\n\n/** What modules of optional features add to the core. See `client-routes.ts` and `hot`. */\nexport const hooks: {\n /** Changes a state record before its scopes are added, such as for a page that navigation added. */\n record?: (script: Element, state: PageState) => PageState;\n /** Runs after the scopes of a state record are added. */\n added?: (added: Scope[]) => void;\n} = {};\n\n/** What the devtools overlay hears from the core. It is set only in development. */\nexport interface DevtoolsHooks {\n /** The core started, with the scopes of the page, and a way to write a slot, as a handler does. */\n attach?(core: {\n scopes: Map<ScopeId, Scope>;\n set: (scope: Scope, slot: number, value: unknown) => void;\n /** Runs the code of a reference for an element, as an event or a trigger does. */\n handle?: (element: Element, ref: string, event?: Event) => Promise<unknown>;\n }): void;\n /** A handler starts for an event. */\n handler?(ref: string, element: Element, event?: Event): void;\n /** A part of a component's client code loaded. */\n part?(component: string, name: string): void;\n /**\n * A handler ran: when its event came, when its code was ready and the\n * handlers before it had started, when the call returned, and what it\n * returned, which is a promise for an async handler.\n */\n handled?(run: {\n ref: string;\n element: Element;\n event?: string;\n begun: number;\n ready: number;\n end: number;\n result: unknown;\n }): void;\n /** The updates of a write ran: how many, and how long they took with their effects. */\n updated?(count: number, start: number, end: number): void;\n /**\n * Code of a component starts to load: its entry, or a part, and why.\n * `done` settles when it has loaded.\n */\n load?(component: string, part: string, reason: string, done: Promise<unknown>): void;\n /** The loader asks the server for the body of a `#defer` block. */\n defer?(template: Element, done: Promise<unknown>): void;\n /** A slot got a new value. */\n write?(scope: Scope, slot: number, value: unknown): void;\n /**\n * An effect or a `$client` callback, by its name in the update code, ran\n * and took `time` milliseconds, or its cleanup ran.\n */\n effect?(scope: Scope, name: string, kind: 'run' | 'cleanup', time: number): void;\n /** A client navigation changed the page: the routes that stayed, and those it replaced. */\n navigated?(report: NavigationReport): void;\n}\n\n/** The global key of the devtools hooks. */\nexport const DEVTOOLS: unique symbol = Symbol.for('brumate.devtools');\n\n/**\n * True on the dev server, which has the devtools. A Vite build replaces it\n * with `false`, so the calls of the devtools hooks are left out. Without\n * Vite, `import.meta.env` is undefined, and the hooks are off.\n */\nconst DEV = (import.meta as { env?: { DEV?: boolean } }).env?.DEV;\n\nfunction devtools(): DevtoolsHooks | undefined {\n return (globalThis as Record<symbol, DevtoolsHooks | undefined>)[DEVTOOLS];\n}\nconst modules = new Map<string, ClientModule>();\nconst loading = new Map<string, Promise<ClientModule>>();\nconst parts = new Map<string, Promise<Part>>();\nconst loadedParts = new Map<string, Part>();\nconst comments = new Map<string, Comment>();\nconst elements = new Map<string, Element>();\n// Scopes that the client creates get negative IDs, so they never match IDs\n// from state records that the server streams later.\nlet nextId = -1;\n\n// Records of one render share references through an array, so a later record can settle a\n// promise of an earlier one. Each render on the page has its own array, by its `b-root`.\nconst refs = new Map<string, unknown[]>();\n\n/**\n * A state record: its script, and its code, which seroval wrote. The code\n * takes the references of its render and the functions that make brumate's\n * values, and returns the value of the record.\n */\ntype StateRecord = [\n script: HTMLScriptElement | null,\n code: (refs: unknown[], values: typeof stateValues) => unknown,\n];\n\n/**\n * The records that ran before the core started, or while it stopped. Each\n * state script hands its record to `push`, which the core replaces while it\n * runs, so it reads later records at once.\n */\nfunction stateQueue(): StateRecord[] {\n const global = globalThis as { $brm?: StateRecord[] };\n return (global.$brm ??= []);\n}\n\n/** Reads the records that later state scripts hand over. Set while the core runs. */\nfunction pushRecords(...added: StateRecord[]): number {\n for (const record of added) {\n readRecord(record);\n }\n return 0;\n}\n\n/**\n * Reads a state record. The first record holds the page state, and later\n * records settle the promises in it.\n */\nfunction readRecord([script, code]: StateRecord): void {\n // A record of a page that navigation replaced before the core started.\n if (!script?.isConnected) {\n return;\n }\n const root = script.getAttribute('b-root') ?? '0';\n if (!refs.has(root)) {\n refs.set(root, []);\n }\n const decoded = code(refs.get(root)!, stateValues);\n // Records with scopes: the page state, and the state of each `#loading` body.\n if (script.hasAttribute('b-scopes')) {\n const unpacked = unpackState(decoded as PackedState);\n const added = addScopes(hooks.record ? hooks.record(script, unpacked) : unpacked, root);\n if (writes > 0) {\n refresh(added);\n }\n }\n}\n\n/**\n * Updates scopes that the server rendered before values changed on the\n * client, such as the body of a `#loading` block that streams in after an\n * event. Effects do not run: they run only when a value changes. With\n * `memosOnly`, as for scopes that the client just rendered with its values,\n * only the memos run, so the ones that load start.\n */\nfunction refresh(added: Scope[], memosOnly = false): void {\n // The scopes of each module, which load it once.\n const byModule = new Map<string, Scope[]>();\n for (const scope of added) {\n const id = rootOf(scope).m;\n if (!id) {\n continue;\n }\n const list = byModule.get(id);\n if (list) {\n list.push(scope);\n } else {\n byModule.set(id, [scope]);\n }\n }\n for (const [id, list] of byModule) {\n void loadModule(id, 'state').then(async (module) => {\n // The names of the updates of each kind of scope, memos first, so the other updates read\n // their new values.\n const byKind = new Map<number, string[]>();\n for (const scope of list) {\n if (!byKind.has(scope.k)) {\n byKind.set(scope.k, refreshNames(module, scope.k, memosOnly));\n }\n }\n let any = false;\n for (const names of byKind.values()) {\n any ||= names.length > 0;\n }\n if (!any) {\n return;\n }\n const updates = await loadPart(module, 'update', 'state');\n for (const scope of list) {\n for (const name of byKind.get(scope.k)!) {\n if (scopes.has(scope.id)) {\n (updates[name] as (scope: Scope) => void)(scope);\n }\n }\n }\n });\n }\n}\n\n/** The names of the updates of a kind of scope that `refresh` runs, memos first. */\nfunction refreshNames(module: ClientModule, kind: number, memosOnly: boolean): string[] {\n const memos = new Set<string>();\n const others = new Set<string>();\n for (const slots of Object.values(module.g)) {\n for (const entries of Object.values(slots)) {\n for (const [entryKind, name] of entries) {\n if (entryKind !== kind || name[0] === 'e') {\n continue;\n }\n if (name[0] === 'm') {\n memos.add(name);\n } else if (!memosOnly) {\n others.add(name);\n }\n }\n }\n }\n return [...memos, ...others];\n}\n\n/** Reads the groups of scope records back into one record per scope. See `PackedState`. */\nfunction unpackState(state: PackedState): PageState {\n // Items to take from the list in a slot of another record, once every record is read.\n const taken: [records: ScopeState[], source: ScopeId, slot: number, first: number][] = [];\n for (const group of state.g ?? []) {\n const [k, base, flags] = group as number[];\n const count = group[3] as number;\n let at = 4;\n const m = flags & MODULE ? (group[at++] as string) : undefined;\n const source: ScopeState[] | undefined = flags & SOURCE ? [] : undefined;\n if (source) {\n taken.push([source, group[at++] as ScopeId, group[at++] as number, flags & ITEM_SLOT]);\n }\n // Scopes inside a `#loading` body: their IDs are this prefix and a number.\n const prefix = flags & PREFIX ? (group[at++] as string) : '';\n const id = (n: number): ScopeId => (prefix ? prefix + n : n);\n // The first slot of a taken item is not written. The gap before the slots holds its place.\n const skip = source && flags & ITEM_SLOT ? 1 : 0;\n let n = flags & (OWNER | PREFIX) ? 0 : base;\n while (at < group.length) {\n n += group[at++] as number;\n const s = group.slice(at - skip, (at += count - skip));\n const record: ScopeState = flags & OWNER ? { k, o: id(n - base) } : { k, p: base };\n record.s = s;\n if (m !== undefined) {\n record.m = m;\n }\n if (source) {\n source.push(record);\n } else if (flags & ITEM_SLOT) {\n record.i = s[0];\n } else if (flags & ITEM) {\n record.i = group[at++];\n }\n if (flags & CHILDREN) {\n record.c = group[at++] as Record<number, ScopeId>;\n }\n state[id(n)] = record;\n }\n }\n delete state.g;\n for (const [records, source, slot, first] of taken) {\n // An array, or a Set, whose order the state keeps.\n const values = Array.from(state[source]!.s![slot] as Iterable<unknown>);\n for (let n = 0; n < records.length; n++) {\n const record = records[n]!;\n record.i = values[n];\n if (first) {\n record.s![0] = values[n];\n }\n }\n }\n return state;\n}\n\nfunction addScopes(state: PageState, root: string): Scope[] {\n const added: Scope[] = [];\n for (const [key, record] of Object.entries(state)) {\n const id = parseId(key);\n const scope: Scope = {\n id,\n k: record.k ?? 0,\n m: record.m,\n s: record.s ?? [],\n i: record.i,\n c: record.c,\n v: record.v,\n x: record.x,\n b: record.b,\n children: new Set(),\n r: root,\n };\n scopes.set(id, scope);\n added.push(scope);\n }\n for (const scope of added) {\n const record = state[scope.id]!;\n if (record.p !== undefined) {\n scope.p = scopes.get(record.p);\n scope.p?.children.add(scope);\n treeChanges++;\n }\n if (record.o !== undefined) {\n scope.o = scopes.get(record.o);\n }\n if (record.t !== undefined) {\n scope.t = scopes.get(record.t);\n }\n }\n const seen = new Set<object>();\n for (const scope of added) {\n // A provided value can hold functions, which a component that reads the context calls.\n for (const key of Object.keys(scope.v ?? {})) {\n scope.v![key] = callable(scope.v![key], seen);\n }\n for (let i = 0; i < scope.s.length; i++) {\n const value = callable(scope.s[i], seen);\n scope.s[i] = value;\n // A value that a later state record settles replaces its promise.\n if (value instanceof Promise) {\n void value.then((result) => {\n settled.set(value, result);\n if (scope.s[i] === value) {\n set(scope, i, result);\n }\n });\n }\n }\n }\n hooks.added?.(added);\n return added;\n}\n\n/**\n * Indexes the markers of markup that others insert, such as streamed\n * `#loading` bodies and the pages that navigation adds, so `findComment` can\n * take its records at once.\n */\nlet markerObserver: MutationObserver | undefined;\n\n/** Stops reading state records and markers that arrive later. Later records wait for `init`. */\nexport function dispose(): void {\n const queue = stateQueue();\n if (queue.push === pushRecords) {\n // The array's own `push` again, so records wait in it.\n delete (queue as { push?: unknown }).push;\n }\n markerObserver?.disconnect();\n markerObserver = undefined;\n}\n\n/**\n * Stops reading, before client navigation replaces only some routes. The\n * server renders the new routes with its current values, so only the writes\n * that come after count for the records that stream in later.\n */\nexport function leaveRoutes(): void {\n dispose();\n writes = 0;\n}\n\n/**\n * Removes the scopes of a render, by its `b-root`, with the scopes inside\n * them. Their cleanups run, and their memos no longer load. Its markup\n * stays. `brumate/testing` calls it when a mounted component unmounts.\n */\nexport function removeRoot(root: string): void {\n const inside = (scope: Scope): boolean => {\n for (let current: Scope | undefined = scope; current; current = current.p ?? current.o) {\n if (current.r === root) {\n return true;\n }\n }\n return false;\n };\n // Deleting from a map while iterating it is safe.\n for (const scope of scopes.values()) {\n if (inside(scope)) {\n removeScope(scope);\n }\n }\n refs.delete(root);\n for (const cache of [comments, elements]) {\n for (const [key, node] of cache) {\n if (!node.isConnected) {\n cache.delete(key);\n }\n }\n }\n}\n\n/**\n * Forgets the code of components that changed on the dev server, so the next\n * event or update loads the new code. Their state stays. `brumate/hot` calls it.\n */\nexport function forget(ids: string[]): void {\n for (const id of ids) {\n modules.delete(id);\n loading.delete(id);\n // Deleting the entry that a loop is at is safe for a Map.\n for (const key of parts.keys()) {\n if (key.startsWith(`${id}:`)) {\n parts.delete(key);\n loadedParts.delete(key);\n }\n }\n }\n}\n\n/** The values of the signals of components whose markup changed, for when the page renders again. */\nconst remounts = new Map<\n string,\n { after: Record<number, string[]>; values: Record<string, unknown>[] }\n>();\n\n/**\n * Keeps the values of the signals of each instance of a component, by\n * name, before the page renders again with its new markup. `brumate/hot` calls it.\n */\nexport function remount(\n detail: {\n id: string;\n before: Record<number, string[]>;\n after: Record<number, string[]>;\n signals: string[];\n }[],\n): void {\n hooks.added = restoreRemounts;\n for (const { id, before, after, signals } of detail) {\n const names = new Set(signals);\n const instances = [...scopes.values()].filter((scope) => scope.m === id);\n remounts.set(id, {\n after,\n // The signals of the script of the component. Signals of blocks, such as of a `#for`\n // body, start again.\n values: instances.map((root) => {\n const values: Record<string, unknown> = {};\n (before[root.k] ?? []).forEach((name, slot) => {\n if (names.has(name)) {\n values[name] = root.s[slot];\n }\n });\n return values;\n }),\n });\n }\n}\n\n/** Writes back the values of signals that `onRemount` kept, into the instances of the new page. */\nfunction restoreRemounts(added: Scope[]): void {\n for (const [id, { after, values }] of remounts) {\n const instances = added.filter((scope) => scope.m === id);\n if (instances.length === 0) {\n continue;\n }\n remounts.delete(id);\n instances.forEach((root, index) => {\n const saved = values[index];\n (after[root.k] ?? []).forEach((name, slot) => {\n if (saved && name in saved) {\n set(root, slot, saved[name]);\n }\n });\n });\n }\n}\n\n/**\n * Forgets the page, before another page replaces it. Cleanups run. Loaded\n * modules and parts stay, so the next page does not load them again. Only\n * client navigation calls it.\n */\nexport function leavePage(): void {\n dispose();\n for (const scope of scopes.values()) {\n for (const cleanup of scope.cleanups?.values() ?? []) {\n cleanup();\n }\n }\n scopes.clear();\n comments.clear();\n elements.clear();\n unindexed.length = 0;\n rendered.length = 0;\n pendingEffects.clear();\n hiding = undefined;\n loads.clear();\n loadingSlots.clear();\n for (const memoController of memoControllers.values()) {\n memoController.abort();\n }\n memoControllers.clear();\n renderedLoads.clear();\n for (const { timer } of timers.values()) {\n clearTimeout(timer);\n }\n timers.clear();\n // The next page reuses scope IDs, so a guess left here would match its memos.\n guesses?.map.clear();\n nextId = -1;\n refs.clear();\n writes = 0;\n // Calls of the old page that are still out no longer count for its guesses.\n calling = 0;\n callEpoch++;\n lastHandler = Promise.resolve();\n}\n\n/** Reads the page state. The loader calls it once, before the first handler. */\nexport function init(value: CoreOptions): void {\n options = value;\n if (value.serial) {\n useSerialEntry(value.serial);\n }\n rpcPrefix = value.rpc ?? '/_brumate';\n build = value.build;\n const queue = stateQueue();\n // Records that are still streaming settle their promises when their scripts run.\n queue.push = pushRecords;\n for (const record of queue.splice(0)) {\n readRecord(record);\n }\n markerObserver = new MutationObserver(indexAdded);\n markerObserver.observe(document, { childList: true, subtree: true });\n // The whole document, because `#head` content is in the head.\n indexMarkers(document.documentElement);\n watchTitles(document);\n if (DEV) {\n devtools()?.attach?.({ scopes, set, handle });\n }\n}\n\n/**\n * The handlers that the core makes from references, with their references,\n * so a spread in markup that the browser renders passes them on in `b-on`,\n * as a spread on the server does.\n */\nconst handlerReferences = new WeakMap<object, FunctionReference>();\n\n/** The modifiers that the wrappers of `brumate/events` put on a handler. */\nconst MODIFIERS = Symbol.for('brumate.modifiers');\n\n/**\n * Renders an object of attributes. With `on`, a handler in it that the core\n * made from a reference goes into `on` as a `b-on` entry, with the scope and\n * the arguments of its reference and the modifiers of its wrappers.\n */\nexport function spread(attributes: Record<string, unknown>, on?: string[]): string {\n if (on) {\n for (const [name, value] of Object.entries(attributes)) {\n const reference =\n /^on[A-Z]/.test(name) && typeof value === 'function'\n ? handlerReferences.get(value)\n : undefined;\n if (reference) {\n on.push(\n handlerEntry(name, reference.ref, reference.scope, reference.modifiers, reference.args),\n );\n }\n // A binding that a rest prop passed on writes its slot, or calls its setter.\n if ((name === 'value' || name === 'checked') && isBinding(value)) {\n on.push(bindEntry(name, value.ref, setterReference(value.set)));\n }\n }\n }\n return spreadText(attributes);\n}\n\n/** The reference of the setter of a binding: as the state has it, or of a handler that the core made. */\nfunction setterReference(set: unknown): FunctionReference | undefined {\n if (set instanceof FunctionReference) {\n return set;\n }\n return typeof set === 'function' ? handlerReferences.get(set) : undefined;\n}\n\n/** Replaces function references with functions that call them. */\nfunction callable(value: unknown, seen: Set<object>): unknown {\n if (value instanceof FunctionReference) {\n if (isTemplate(value.ref)) {\n return templateReference(value.ref, scopes.get(value.scope));\n }\n const handler = (...args: unknown[]): unknown =>\n call(value.ref, scopes.get(value.scope), [...(value.args ?? []), ...args]);\n handlerReferences.set(handler, value);\n return handler;\n }\n if (typeof value === 'object' && value !== null && !seen.has(value)) {\n seen.add(value);\n const prototype = Object.getPrototypeOf(value);\n if (Array.isArray(value) || prototype === Object.prototype || prototype === null) {\n const record = value as Record<string, unknown>;\n for (const key of Object.keys(record)) {\n record[key] = callable(record[key], seen);\n }\n }\n }\n return value;\n}\n\n/**\n * Why the core loads code, for the Loading tab of the devtools: an event,\n * a call of a function prop, a template, the scopes of a state record, a\n * write, an error, a reset of `#try`, or a prop of a child.\n */\nexport type LoadReason =\n | 'event'\n | 'call'\n | 'template'\n | 'state'\n | 'write'\n | 'error'\n | 'reset'\n | 'prop';\n\nexport function loadModule(id: string, reason: LoadReason = 'write'): Promise<ClientModule> {\n let promise = loading.get(id);\n if (!promise) {\n // A component without client code has nothing to update.\n promise = Promise.resolve(options.load(id)).then((loaded) => {\n const module = loaded ?? { id, props: {}, g: {} };\n modules.set(id, module);\n return module;\n });\n loading.set(id, promise);\n if (DEV) {\n devtools()?.load?.(id, 'entry', reason, promise);\n }\n }\n return promise;\n}\n\nexport function loadPart(\n module: ClientModule,\n name: string,\n reason: LoadReason = 'write',\n): Promise<Part> {\n const key = `${module.id}:${name}`;\n let promise = parts.get(key);\n if (!promise) {\n let loaded: Promise<Part>;\n if (!module.load) {\n loaded = Promise.resolve(module as unknown as Part);\n } else {\n loaded = options.loadPart ? options.loadPart(module, name) : module.load(name);\n }\n promise = loaded.then((part) => {\n loadedParts.set(key, part);\n if (DEV) {\n devtools()?.part?.(module.id, name);\n }\n return part;\n });\n parts.set(key, promise);\n if (DEV) {\n devtools()?.load?.(module.id, module.load ? name : 'all', reason, promise);\n }\n }\n return promise;\n}\n\ntype Handler = (scope: Scope | undefined, ...args: unknown[]) => unknown;\n\n/** Waits forever once the page loads again, so no error shows before it goes. */\nlet reloading: Promise<never> | undefined;\n\nasync function resolve(ref: string, reason: LoadReason): Promise<Handler> {\n const [id, name] = ref.split('#') as [string, string];\n try {\n const module = await loadModule(id, reason);\n const part = await loadPart(module, partOf(name), reason);\n return part[name] as Handler;\n } catch (error) {\n // After a deploy, the files of a build can be gone. The page loads again, with the new code,\n // once for each build. Any other error, such as a module that throws, goes to `#try`.\n const next = await serverBuild();\n if (!reloading && next !== undefined && loadOnce(next)) {\n skew('code');\n location.reload();\n reloading = new Promise(() => {});\n }\n if (reloading) {\n return reloading;\n }\n throw error;\n }\n}\n\n/**\n * Asks the server for its build, after the code of a handler failed to\n * load. Returns it when it is not the build of the page. Undefined without\n * a build, when the request fails, or when the builds are the same.\n */\nasync function serverBuild(): Promise<string | undefined> {\n if (build === undefined) {\n return undefined;\n }\n try {\n const response = await fetch(`${rpcPrefix}/`, {\n method: 'POST',\n headers: { 'x-brumate-build': build },\n });\n const current = response.headers.get('x-brumate-build');\n return current !== null && current !== build ? current : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function call(ref: string, scope: Scope | undefined, args: unknown[]): Promise<unknown> {\n return (await resolve(ref, 'call'))(scope, ...args);\n}\n\n/** True for a reference to a `#template` that a component got as a prop, such as `Page#t3`. */\nfunction isTemplate(ref: string): boolean {\n return /#t\\d/.test(ref);\n}\n\n/** The code of templates that is still loading. Updates wait for it, since a render cannot. */\nconst loadingTemplates = new Set<Promise<unknown>>();\n\n/**\n * A `#template` of another component, which renders at once, as markup does.\n * Its code starts to load when the page state is read, and updates wait for it.\n */\nfunction templateReference(ref: string, scope: Scope | undefined): (...args: unknown[]) => unknown {\n let render: Handler | undefined;\n // A template that fails to load stops holding up updates too, and its error is reported.\n const code: Promise<unknown> = resolve(ref, 'template')\n .then((handler) => {\n render = handler;\n })\n .finally(() => loadingTemplates.delete(code));\n loadingTemplates.add(code);\n return (...args) => (render ? render(scope, ...args) : '');\n}\n\n// The handler of the previous event, once it has started.\nlet lastHandler: Promise<unknown> = Promise.resolve();\n\n/**\n * Keeps `currentTarget` on an event. The handler runs after the event has\n * finished dispatching, when the browser has already cleared it.\n */\nfunction withTarget(event: Event, element: Element): Event {\n return new Proxy(event, {\n get(target, key) {\n if (key === 'currentTarget') {\n return element;\n }\n const value: unknown = Reflect.get(target, key);\n return typeof value === 'function' ? value.bind(target) : value;\n },\n });\n}\n\n/**\n * Runs the handler `ref` for an element. The scope comes from the element's\n * `b-b` anchor, or from the nearest element around it that has one, which\n * the compiler checks is in the same scope.\n */\nexport function handle(element: Element, entry: string, event?: Event): Promise<unknown> {\n // A handler that a spread passed on, such as `Parent#h1@3`, runs in the scope of its owner.\n // A handler that `$handler` made has its arguments after another `@`.\n const [ref, owner, encoded] = entry.split('@') as [string, string | undefined, string?];\n const bound = encoded ? (JSON.parse(decodeURIComponent(encoded)) as unknown[]) : [];\n const anchor = owner ?? element.closest('[b-b]')?.getAttribute('b-b')?.split(':')[0];\n const scope = anchor ? scopes.get(parseId(anchor)) : undefined;\n // A `<window>` or `<document>` listener in a hidden `#offscreen` body does not run.\n if (scope && hiding?.hidden(scope) && element.hasAttribute('b-listen')) {\n return Promise.resolve();\n }\n // `value=$bind(name)` on an element: the core writes the slot of the name, `hops` parents up\n // from the element's scope, from the value of the element, or whether a box is checked.\n // `value=$bind(name, fn)`: the setter takes the value of the element. A ref names its scope\n // after `@`, so the prefix is `$set:`.\n if (ref.startsWith('$set:')) {\n const field = element as HTMLInputElement;\n return call(ref.slice(5), scope, [\n /^(checkbox|radio)$/i.test(field.type) ? field.checked : field.value,\n ]);\n }\n if (ref.startsWith('$bind#')) {\n const [hops = 0, slot = 0] = ref.slice(6).split('.').map(Number);\n let target = scope;\n for (let hop = 0; hop < hops; hop++) {\n target = target?.p;\n }\n const field = element as HTMLInputElement;\n if (target) {\n set(target, slot, /^(checkbox|radio)$/i.test(field.type) ? field.checked : field.value);\n }\n return Promise.resolve();\n }\n const args = event ? [...bound, withTarget(event, element)] : bound;\n const begun = DEV ? performance.now() : 0;\n if (DEV) {\n devtools()?.handler?.(ref, element, event);\n }\n // Parts load in parallel, but handlers start in the order of their events,\n // so an input handler runs before the submit handler of a later event.\n const loaded = resolve(ref, 'event');\n const started = lastHandler\n .then(() => loaded)\n .then((handler) => {\n if (!DEV) {\n return { value: handler(scope, ...args) };\n }\n const ready = performance.now();\n const value = handler(scope, ...args);\n devtools()?.handled?.({\n ref,\n element,\n event: event?.type,\n begun,\n ready,\n end: performance.now(),\n result: value,\n });\n return { value };\n });\n lastHandler = started.catch(() => {});\n // An error of the handler, or of the promise that an async one returns, goes to the nearest\n // `#try` around its scope.\n return started\n .then((result) => result.value)\n .catch((error: unknown) => {\n fail(scope, error);\n });\n}\n\n/**\n * Reports an error of client code: a handler, an effect, a `$client`\n * callback or a memo that loads. It renders the `#catch` body of the nearest\n * `#try` around the scope of the code, through the parents and the owners of\n * scopes. Without one, the page gets a `brumate:error` event on `window`,\n * with the error and the scope, and the error is logged.\n */\nexport function fail(scope: Scope | undefined, error: unknown): void {\n options.onError?.(error, { scope: scope?.id });\n void (async () => {\n for (let current = scope; current; current = current.p ?? current.o) {\n const id = rootOf(current).m;\n if (!id) {\n continue;\n }\n // oxlint-disable-next-line no-await-in-loop -- Each scope can belong to another component.\n const module = await loadModule(id, 'error');\n const entry = module.t?.[current.k];\n if (!entry) {\n continue;\n }\n // The scope that holds the block, which the anchor of the block counts from.\n let owner = current.p;\n while (owner && owner.k !== entry[0]) {\n owner = owner.p;\n }\n if (owner) {\n // oxlint-disable-next-line no-await-in-loop -- The first `#try` found catches the error.\n await catchInto(owner, module, entry, error);\n return;\n }\n }\n window.dispatchEvent(new CustomEvent('brumate:error', { detail: { error, scope } }));\n console.error(error);\n })();\n}\n\n/** Renders the `#catch` body of a `#try` with an error, in place of what the block shows. */\nasync function catchInto(\n owner: Scope,\n module: ClientModule,\n [, anchor, , fallback, kinds]: NonNullable<ClientModule['t']>[number],\n error: unknown,\n): Promise<void> {\n const updates = await loadPart(module, 'update', 'error');\n const start = findComment(`b${owner.id}:${anchor}`);\n if (!start) {\n return;\n }\n const end = rangeEnd(start);\n disposeKinds(owner, kinds);\n clear(start, end);\n insertHTML(end, (updates[fallback] as (parent: Scope, error: unknown) => string)(owner, error));\n}\n\n/** Returns the instance of a scope by its ID. */\nexport function scopeOf(id: ScopeId): Scope | undefined {\n return scopes.get(id);\n}\n\n// Slots\n\n// oxlint-disable-next-line typescript/no-explicit-any -- Slots hold any value.\nexport function get(scope: Scope, slot: number): any {\n const value = scope.s[slot];\n // A value that the server still streams. A memo that reads it waits for it.\n if (computing > 0 && value instanceof Promise) {\n throw new NotReady(value);\n }\n if (value instanceof ElementReference) {\n const element = findElement(value.scope, value.anchor);\n if (element) {\n scope.s[slot] = element;\n }\n return element ?? undefined;\n }\n return value;\n}\n\n// The number of writes since the page loaded, so scopes that stream in later know to update.\nlet writes = 0;\n\n/**\n * Writes a slot from code of a component. A prop that a parent bound with\n * `$bind` writes the parent's slot too, through any number of levels, and\n * the parent's update of the prop then finds the value already there. A\n * binding with a setter, `$bind(name, fn)`, calls it in place of the write,\n * and the parent's update of the prop writes the value that it keeps.\n */\nexport function set<T>(scope: Scope, slot: number, value: T): T {\n const bound = scope.b?.[slot];\n if (bound === undefined || isSlotReference(bound)) {\n writeSlot(scope, slot, value);\n const target = bound && scopes.get(bound.scope);\n if (target) {\n set(target, bound.slot, value);\n }\n } else if (bound instanceof FunctionReference) {\n void call(bound.ref, scopes.get(bound.scope), [...(bound.args ?? []), value]);\n } else if (typeof bound === 'function') {\n void bound(value);\n }\n return value;\n}\n\n/** Writes a slot, and updates what reads it. */\nfunction writeSlot(scope: Scope, slot: number, value: unknown): void {\n if (!Object.is(scope.s[slot], value)) {\n writes++;\n scope.s[slot] = value;\n if (DEV) {\n devtools()?.write?.(scope, slot, value);\n }\n trigger(scope, slot);\n }\n}\n\n/** What `$bind(name)` passes a child, in markup that the browser renders. */\nexport function binding<T>(\n value: T,\n scope: Scope | ScopeId,\n slot: number,\n set?: unknown,\n): Binding<T> {\n return new Binding(\n value,\n new SlotReference(typeof scope === 'object' ? scope.id : scope, slot),\n set,\n );\n}\n\n/**\n * Records the props that a parent bound with `$bind`, among the props that a\n * component the browser renders writes: `slots` has the slot of each, by its name.\n */\nexport function bindings(\n scope: Scope | ScopeId,\n props: Record<string, unknown>,\n slots: Record<string, number>,\n): void {\n const target = typeof scope === 'object' ? scope : scopes.get(scope);\n for (const [name, slot] of Object.entries(slots)) {\n const value = props[name];\n if (target && isBinding(value)) {\n (target.b ??= {})[slot] = value.target;\n }\n }\n}\n\n/**\n * The names of a call of a module function, for its shared code. Each ref\n * is a slot of `scope`, `[scope, slot]` for a slot of another scope, or\n * `[value]` for a value that does not change, such as a literal argument.\n */\nexport function cells(scope: Scope, links: unknown[], names: string[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n names.forEach((name, index) => {\n const ref = links[index];\n let owner = scope;\n let slot: number;\n if (typeof ref === 'number') {\n slot = ref;\n } else if ((ref as unknown[]).length === 2) {\n [owner, slot] = ref as [Scope, number];\n } else {\n Object.defineProperty(result, name, { get: () => (ref as unknown[])[0], set: () => {} });\n return;\n }\n Object.defineProperty(result, name, {\n get: () => get(owner, slot),\n set: (value: unknown) => set(owner, slot, value),\n });\n });\n return result;\n}\n\n// The latest load of each async memo, by `<scope>:<slot>`, so older results are dropped.\nconst loads = new Map<string, number>();\n// Numbers loads across all memos, so a load is never numbered like an older one still in flight.\nlet loadCount = 0;\nconst loadingSlots = new Set<string>();\n\n/** Marks a memo as loading. Its readers update the first time, so `$isPending` becomes true. */\nfunction startLoading(scope: Scope, slot: number, key: string): void {\n if (!loadingSlots.has(key)) {\n loadingSlots.add(key);\n trigger(scope, slot);\n }\n}\n\n/** The timers of debounced and throttled memos, by `scope:slot`, with when each last computed. */\nconst timers = new Map<string, { timer?: ReturnType<typeof setTimeout>; last: number }>();\n\n/**\n * Computes a memo of `$debounced` after its value stops changing for `ms`,\n * or one of `$throttled` at most once every `ms`, with the last value after\n * the wait. The memo is pending while it waits.\n */\nexport function timed(\n scope: Scope,\n slot: number,\n ms: number,\n throttle: boolean,\n compute: () => unknown,\n): void {\n const key = `${scope.id}:${slot}`;\n const state = timers.get(key) ?? { last: -Infinity };\n timers.set(key, state);\n const run = (): void => {\n state.timer = undefined;\n state.last = Date.now();\n // A scope that left the page computes no more.\n if (scopes.get(scope.id) === scope) {\n memo(scope, slot, compute);\n }\n };\n const since = Date.now() - state.last;\n if (throttle && state.timer === undefined && since >= ms) {\n run();\n return;\n }\n if (!throttle) {\n clearTimeout(state.timer);\n state.timer = undefined;\n }\n state.timer ??= setTimeout(run, throttle ? ms - since : ms);\n startLoading(scope, slot, key);\n}\n\n/** True for a promise, or any object with a `then` method. */\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as PromiseLike<unknown>).then === 'function'\n );\n}\n\n/**\n * Writes the result of an async memo when it arrives. Until then the slot\n * keeps its value, and `pending` is true. Only the latest load is written.\n */\nexport function asyncMemo(scope: Scope, slot: number, promise: Promise<unknown>): void {\n const key = `${scope.id}:${slot}`;\n const load = ++loadCount;\n loads.set(key, load);\n startLoading(scope, slot, key);\n const settle = (value?: unknown, failed = false): void => {\n if (loads.get(key) !== load) {\n return;\n }\n loadingSlots.delete(key);\n if (!failed && !Object.is(scope.s[slot], value)) {\n set(scope, slot, value);\n } else {\n trigger(scope, slot);\n }\n };\n const failed = (error: unknown): void => {\n // A newer load of the memo aborted this one. The memo keeps its value, and the error goes\n // to the nearest `#try` around the memo.\n if (loads.get(key) === load) {\n fail(scope, error);\n settle(undefined, true);\n }\n };\n promise.then((value) => {\n if (!isAsyncIterable(value)) {\n settle(value);\n return;\n }\n // A stream, such as a server function that yields: the memo takes each\n // value, and is pending until the first arrives. A newer load stops it.\n void (async () => {\n try {\n for await (const item of value) {\n if (loads.get(key) !== load) {\n break;\n }\n if (loadingSlots.has(key)) {\n settle(item);\n } else if (!Object.is(scope.s[slot], item)) {\n set(scope, slot, item);\n }\n }\n } catch (error) {\n failed(error);\n }\n })();\n }, failed);\n}\n\n/** Thrown when a memo reads a value that is still loading. */\nclass NotReady extends Error {\n readonly source: Promise<unknown>;\n\n constructor(source: Promise<unknown>) {\n super('The value is still loading');\n this.source = source;\n }\n}\n\n// More than 0 while a memo computes, so reading a value that is still loading stops it.\nlet computing = 0;\n\n/** Aborts the server function calls of a memo's compute, by memo key. */\nconst memoControllers = new Map<string, AbortController>();\n/** The key of the memo that computes, if any. */\nlet memoKey: string | undefined;\n\n/** The signal for server function calls while a memo computes. It is made on the first call. */\nfunction memoSignal(): AbortSignal | undefined {\n if (memoKey === undefined) {\n return undefined;\n }\n let controller = memoControllers.get(memoKey);\n if (!controller) {\n controller = new AbortController();\n memoControllers.set(memoKey, controller);\n }\n return controller.signal;\n}\n\n/**\n * Computes a memo. A promise loads, and the memo keeps its value until it\n * settles. A memo that reads a value that is still loading keeps its value\n * too, and is pending until that value arrives and the memo computes again.\n */\nexport function memo(scope: Scope, slot: number, compute: () => unknown): void {\n const key = `${scope.id}:${slot}`;\n // A guess stays while its source has not changed, such as when a value the server streamed arrives.\n if (guesses?.same(key)) {\n return;\n }\n const rendered = scope.s[slot];\n if (renderedLoads.delete(key) && isThenable(rendered)) {\n asyncMemo(scope, slot, Promise.resolve(rendered));\n return;\n }\n let value: unknown;\n // Server function calls of the last compute are aborted, because their answers are out of date.\n memoControllers.get(key)?.abort();\n memoControllers.delete(key);\n const outer = memoKey;\n memoKey = key;\n computing++;\n try {\n value = compute();\n } catch (error) {\n if (!(error instanceof NotReady)) {\n throw error;\n }\n startLoading(scope, slot, key);\n return;\n } finally {\n computing--;\n memoKey = outer;\n }\n if (isThenable(value) || isAsyncIterable(value)) {\n asyncMemo(scope, slot, Promise.resolve(value));\n return;\n }\n // The values it read have arrived, so it is no longer pending.\n const waited = loadingSlots.delete(key);\n loads.delete(key);\n // An optimistic value that computes again follows its source, and drops its guess.\n guesses?.map.delete(key);\n if (!Object.is(scope.s[slot], value)) {\n set(scope, slot, value);\n } else if (waited) {\n trigger(scope, slot);\n }\n}\n\ninterface Guesses {\n /** Optimistic values that hold a guess, with the slot that each goes back to. */\n map: Map<string, { scope: Scope; slot: number; source?: [Scope, number]; base?: unknown }>;\n same: (key: string) => boolean;\n reset: () => void;\n}\n\n/**\n * The guesses of `$optimistic` values. The first `guess` sets it, so the\n * code that reads guesses is left out of a build that makes none.\n */\nlet guesses: Guesses | undefined;\n/** The values of promises that the server streamed, so a guess knows its source did not change. */\nconst settled = new WeakMap<Promise<unknown>, unknown>();\n\n/** True while the source of a guess holds the value it had when the guess was made. */\nfunction sameSource(key: string): boolean {\n const entry = guesses!.map.get(key);\n if (!entry?.source) {\n return false;\n }\n const current = entry.source[0].s[entry.source[1]];\n return (\n Object.is(current, entry.base) ||\n (entry.base instanceof Promise && settled.get(entry.base) === current)\n );\n}\n/** Server calls that have not finished, from forms and from `rpc`. */\nlet calling = 0;\n/** Counts the pages that client navigation left, so calls of an old page are not counted down. */\nlet callEpoch = 0;\n\n/**\n * Writes a guess into an optimistic value. It goes back to its source when\n * the source changes, which computes it again, or when every server call of\n * the page finishes, such as after a post failed.\n */\nexport function guess<T>(\n scope: Scope,\n slot: number,\n ...rest: [value: T] | [sourceScope: Scope, sourceSlot: number, value: T]\n): T {\n const value = rest.at(-1) as T;\n const source = rest.length === 3 ? ([rest[0], rest[1]] as [Scope, number]) : undefined;\n const base = source && source[0].s[source[1]];\n guesses ??= { map: new Map(), same: sameSource, reset: resetGuesses };\n guesses.map.set(`${scope.id}:${slot}`, { scope, slot, source, base });\n return set(scope, slot, value);\n}\n\n/** Counts a server call, and puts guesses back when the last one finishes. */\nexport function track<T>(request: Promise<T>): Promise<T> {\n calling++;\n const epoch = callEpoch;\n const done = (): void => {\n if (epoch !== callEpoch) {\n return;\n }\n calling--;\n // Waits a task, so memos that the answer refreshed start to load first.\n setTimeout(() => calling || guesses?.reset(), 0);\n };\n request.then(done, done);\n return request;\n}\n\nfunction resetGuesses(): void {\n for (const [key, { scope, slot, source }] of guesses!.map) {\n // A source that loads again, such as a refreshed list, resets the guess when it arrives.\n if (source && pending(source[0], source[1])) {\n continue;\n }\n guesses!.map.delete(key);\n if (source && scopes.has(scope.id) && !Object.is(scope.s[slot], source[0].s[source[1]])) {\n set(scope, slot, source[0].s[source[1]]);\n }\n }\n}\n\n/** True while a new value of a memo loads, or while the server still streams its value. */\nexport function pending(scope: Scope, slot: number): boolean {\n return loadingSlots.has(`${scope.id}:${slot}`) || scope.s[slot] instanceof Promise;\n}\n\n/** `x++`, `x--`, `++x` and `--x`. */\nexport function update(scope: Scope, slot: number, delta: number, prefix: boolean): number {\n const previous = get(scope, slot) as number;\n set(scope, slot, previous + delta);\n return prefix ? previous + delta : previous;\n}\n\nfunction rootOf(scope: Scope): Scope {\n let current = scope;\n while (current.p) {\n current = current.p;\n }\n return current;\n}\n\nfunction trigger(scope: Scope, slot: number): void {\n const id = rootOf(scope).m!;\n const module = modules.get(id);\n const updates = loadedParts.get(`${id}:update`);\n if (module && updates && loadingTemplates.size === 0) {\n run(module, updates, scope, slot);\n return;\n }\n // The first write to a component loads its update code. Later writes wait in order, and\n // for the templates that the updates can render.\n const loading = loadModule(id).then(async (loaded) => {\n if (loaded.g[scope.k]?.[slot]) {\n const code = await loadPart(loaded, 'update');\n await Promise.allSettled(loadingTemplates);\n run(loaded, code, scope, slot);\n }\n });\n loadingUpdates.add(loading);\n void loading.finally(() => loadingUpdates.delete(loading));\n}\n\n/** The updates that wait for their code. */\nconst loadingUpdates = new Set<Promise<unknown>>();\n\n/**\n * Resolves when the updates of the writes so far have run, including those\n * whose code is loading. `transition` of `brumate/events` waits for it.\n */\nexport async function updated(): Promise<void> {\n while (loadingUpdates.size > 0) {\n // oxlint-disable-next-line no-await-in-loop -- An update can start more loads.\n await Promise.allSettled(loadingUpdates);\n }\n}\n\n(globalThis as { [key: symbol]: unknown })[Symbol.for('brumate.updated')] = updated;\n\n// Effects wait until every other update of a write has run, and run once each.\nconst pendingEffects = new Map<string, () => void>();\nlet running = 0;\nlet flushing = false;\n/** Counts changes to the scope tree, so `run` knows when the descendants it found are out of date. */\nlet treeChanges = 0;\n\n/** The updates that ran since the outermost `run` started, and when it started, for the devtools. */\nlet updateCount = 0;\nlet updateStart = 0;\n\nfunction run(module: ClientModule, updates: Part, scope: Scope, slot: number): void {\n if (DEV && running === 0) {\n updateCount = 0;\n updateStart = performance.now();\n }\n running++;\n // The descendants of each kind, found once while the tree does not change.\n let found: Map<number, Scope[]> | undefined;\n let foundAt = treeChanges;\n try {\n for (const [kind, name] of module.g[scope.k]?.[slot] ?? []) {\n const fn = updates[name] as (scope: Scope) => void;\n if (kind === scope.k) {\n runUpdate(fn, name, scope);\n continue;\n }\n if (foundAt !== treeChanges) {\n found = undefined;\n foundAt = treeChanges;\n }\n found ??= new Map();\n let targets = found.get(kind);\n if (!targets) {\n targets = descendants(scope, kind);\n found.set(kind, targets);\n }\n for (const target of targets) {\n runUpdate(fn, name, target);\n }\n }\n } finally {\n running--;\n }\n if (running === 0) {\n flushEffects();\n if (DEV) {\n devtools()?.updated?.(updateCount, updateStart, performance.now());\n }\n }\n}\n\n/** Runs an update on a scope. An effect waits until the other updates have run. */\nfunction runUpdate(fn: (scope: Scope) => void, name: string, target: Scope): void {\n if (DEV) {\n updateCount++;\n }\n if (name[0] === 'e') {\n pendingEffects.set(`${target.id}:${name}`, () => {\n if (scopes.has(target.id)) {\n fn(target);\n }\n });\n } else {\n fn(target);\n }\n}\n\n/**\n * Runs the effects that writes scheduled, in the order they were first\n * scheduled. Writes in an effect schedule more effects, which run after.\n */\nfunction flushEffects(): void {\n if (flushing) {\n return;\n }\n flushing = true;\n try {\n // A map iterator also visits entries that are added while it runs.\n for (const [key, runEffect] of pendingEffects) {\n pendingEffects.delete(key);\n runEffect();\n }\n } finally {\n flushing = false;\n }\n}\n\nexport function descendants(scope: Scope, kind: number, result: Scope[] = []): Scope[] {\n for (const child of scope.children) {\n if (child.k === kind) {\n result.push(child);\n }\n descendants(child, kind, result);\n }\n return result;\n}\n\nfunction destroy(scope: Scope): void {\n if (scope.children.size > 0) {\n for (const child of Array.from(scope.children)) {\n destroy(child);\n }\n }\n // The content of a `#portal` is elsewhere in the page, so it is removed by its markers.\n const start = portals > 0 ? comments.get(`P${scope.id}`) : undefined;\n if (start?.isConnected) {\n const end = rangeEnd(start);\n clear(start, end);\n start.remove();\n end.remove();\n }\n removeScope(scope);\n sweepIndexes();\n}\n\n/**\n * Removes a scope from the page: its cleanups run, and its memo state goes,\n * so a load that settles later is not written. Its markup stays.\n */\nexport function removeScope(scope: Scope): void {\n if (scope.cleanups) {\n for (const cleanup of scope.cleanups.values()) {\n cleanup();\n }\n }\n // The state of the slots that load or wait, which most scopes, such as rows of a list, have not.\n const waiting =\n memoControllers.size + timers.size + loads.size + loadingSlots.size + (guesses?.map.size ?? 0);\n for (let slot = 0; waiting > 0 && slot < scope.s.length; slot++) {\n const key = `${scope.id}:${slot}`;\n memoControllers.get(key)?.abort();\n memoControllers.delete(key);\n clearTimeout(timers.get(key)?.timer);\n timers.delete(key);\n loads.delete(key);\n loadingSlots.delete(key);\n guesses?.map.delete(key);\n }\n if (scope.h) {\n hiding?.bodies.delete(scope.h);\n }\n scopes.delete(scope.id);\n scope.p?.children.delete(scope);\n treeChanges++;\n}\n\nfunction disposeKinds(scope: Scope, kinds: number[]): void {\n for (const child of Array.from(scope.children)) {\n if (kinds.includes(child.k)) {\n destroy(child);\n }\n }\n}\n\n// DOM\n\nconst MARKER = /^[btilP]-?\\d/;\n\nfunction markerKey(data: string): string {\n return data[0] === 'b' ? data.split(':').slice(0, 2).join(':') : data;\n}\n\nconst SCOPE_MARKER = /^[tb](-?[\\d.]+):/;\n\n/** True for markup that names a scope from the server: a `b-b` or marker with an ID that is not negative. */\nconst SERVER_SCOPES = /b-b=\"\\d|<!--[tb]\\d/;\n\n/** The scopes that the client made since the last insert, which the next insert holds. */\nconst rendered: Scope[] = [];\n\n/** How many `#portal` markers the page has had, so a scope looks for its own only when any have. */\nlet portals = 0;\n\n/**\n * Indexes the markers and the bound elements under `root`, so that updates find them without a\n * search of the page. A search for each row of a long list takes time that grows with the list.\n * With `ids`, it also collects the IDs of the scopes that the markup names. The IDs of scopes\n * that the client made are negative.\n */\nfunction indexMarkers(root: Node, ids?: Set<ScopeId>, withElements = true): void {\n // The query finds the bound elements in native code, and the walk visits only comments, so\n // the code here runs for each marker, not for each node of a long list.\n if (withElements) {\n indexElements(root, ids);\n }\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n const data = (node as Comment).data;\n if (!MARKER.test(data)) {\n continue;\n }\n comments.set(markerKey(data), node as Comment);\n if (data[0] === 'P') {\n portals++;\n }\n const match = ids && SCOPE_MARKER.exec(data);\n if (match) {\n ids!.add(parseId(match[1]!));\n }\n }\n}\n\n/** The size of the indexes at which they next drop the nodes that left the page. */\nlet sweepAt = 4096;\n\n/**\n * Drops the nodes that left the page from the indexes, once they have grown to twice their size\n * after the last sweep, so a list that the client fills and empties again does not keep its old\n * rows. A node that comes back is indexed again when it is inserted.\n */\nfunction sweepIndexes(): void {\n if (comments.size + elements.size < sweepAt) {\n return;\n }\n for (const [key, node] of comments) {\n if (!node.isConnected) {\n comments.delete(key);\n }\n }\n for (const [key, node] of elements) {\n if (!node.isConnected) {\n elements.delete(key);\n }\n }\n sweepAt = Math.max(4096, 2 * (comments.size + elements.size));\n}\n\nfunction indexElements(root: Node, ids?: Set<ScopeId>): void {\n if (root.nodeType === 1) {\n indexElement(root as Element, ids);\n }\n if (root.nodeType === 1 || root.nodeType === 9 || root.nodeType === 11) {\n for (const element of (root as ParentNode).querySelectorAll('[b-b]')) {\n indexElement(element, ids);\n }\n }\n}\n\n/**\n * The nodes that inserts of the client put in the page, from the first to the last of each,\n * whose bound elements are not indexed yet. A list that the client creates is often never\n * updated row by row, so its elements are indexed when an update first needs one of them.\n */\nconst unindexed: [first: Node, last: Node][] = [];\n\nfunction indexInserts(): void {\n for (const [first, last] of unindexed.splice(0)) {\n if (first.isConnected) {\n for (let node: Node | null = first; node; node = node.nextSibling) {\n indexElements(node);\n if (node === last) {\n break;\n }\n }\n } else if (last.isConnected) {\n // The first nodes left the page, such as the first rows of a list that were removed, so\n // the walk goes back from the last node, past the start of the insert if it must.\n for (let node: Node | null = last; node; node = node.previousSibling) {\n indexElements(node);\n }\n }\n }\n}\n\nfunction indexElement(element: Element, ids?: Set<ScopeId>): void {\n const key = element.getAttribute('b-b');\n if (key === null) {\n return;\n }\n elements.set(key, element);\n ids?.add(parseId(key.slice(0, key.indexOf(':'))));\n}\n\n/** Indexes the markers in the nodes that mutation records added. */\nfunction indexAdded(records: MutationRecord[]): void {\n for (const record of records) {\n for (const node of record.addedNodes) {\n if (node.nodeType === 1) {\n indexMarkers(node);\n } else if (node.nodeType === 8 && MARKER.test((node as Comment).data)) {\n const data = (node as Comment).data;\n comments.set(markerKey(data), node as Comment);\n if (data[0] === 'P') {\n portals++;\n }\n }\n }\n }\n}\n\n/**\n * Finds a marker in the page. Returns undefined when the markup is not in\n * the page, such as `children` inside a block that is closed. Updates to it\n * do nothing, and it updates when the client inserts it again.\n */\nfunction findComment(key: string): Comment | undefined {\n let comment = comments.get(key);\n if (!comment?.isConnected) {\n // The index has every marker in the page once it reads the records that\n // are waiting. Before the core starts, or between pages, it reads the page.\n if (markerObserver) {\n indexAdded(markerObserver.takeRecords());\n } else {\n indexMarkers(document.documentElement);\n }\n comment = comments.get(key);\n }\n return comment?.isConnected ? comment : undefined;\n}\n\nfunction findElement(scope: ScopeId, anchor: number): Element | null {\n const key = `${scope}:${anchor}`;\n let element = elements.get(key);\n if (!element?.isConnected) {\n // As for markers: once the core starts, the index has every bound element in the page,\n // with those of the inserts that are waiting.\n if (markerObserver) {\n indexAdded(markerObserver.takeRecords());\n indexInserts();\n element = elements.get(key);\n }\n // An insert whose first node left the page, such as the first row of a list that was\n // removed, has elements that the walk did not reach.\n if (!element?.isConnected) {\n element = document.querySelector(`[b-b=\"${key}\"]`) ?? undefined;\n if (element) {\n elements.set(key, element);\n }\n }\n }\n return element?.isConnected ? element : null;\n}\n\n/** Returns the marker that ends the range that `start` opens. */\nfunction rangeEnd(start: Comment): Comment {\n let depth = 0;\n for (let node = start.nextSibling; node; node = node.nextSibling) {\n if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (data[0] === '/') {\n if (depth === 0) {\n return node as Comment;\n }\n depth--;\n } else if (MARKER.test(data)) {\n depth++;\n }\n }\n }\n throw new Error(`Missing end marker for <!--${start.data}-->`);\n}\n\nfunction clear(start: Node, end: Node): void {\n if (start.nextSibling === end || !start.nextSibling) {\n return;\n }\n // One removal of the whole range, which costs less than one for each node of a long list.\n const range = document.createRange();\n range.setStartAfter(start);\n range.setEndBefore(end);\n range.deleteContents();\n}\n\n/**\n * Inserts rendered HTML before a node, or at the end of a parent, and runs\n * the work that waits for it.\n */\nfunction insertHTML(before: Node | { parent: ParentNode }, html: string): void {\n const template = document.createElement('template');\n template.innerHTML = trustedHTML(html);\n const fragment = template.content;\n // Markers that others inserted first, so the new markers win over them.\n if (markerObserver) {\n indexAdded(markerObserver.takeRecords());\n }\n // The scopes that the renders since the last insert made, whose markup this is.\n const client = rendered.splice(0);\n // Markup from the server, such as `children`, names scopes with IDs that are not negative.\n // Only then are the elements of the insert read for them now.\n const fromServer = SERVER_SCOPES.test(html);\n const ids = fromServer ? new Set<ScopeId>() : undefined;\n indexMarkers(fragment, ids, fromServer);\n options.listen(fragment);\n watchTitles(fragment);\n const server: Scope[] = [];\n for (const id of ids ?? []) {\n const scope = typeof id === 'number' && id < 0 ? undefined : scopes.get(id);\n if (scope) {\n server.push(scope);\n }\n }\n if (!fromServer && fragment.firstChild) {\n unindexed.push([fragment.firstChild, fragment.lastChild!]);\n // Many inserts that no update read are indexed at once, so they do not hold their nodes.\n if (unindexed.length > 256) {\n indexInserts();\n }\n }\n // The nodes of the insert, when hidden `#offscreen` markup can contain them.\n const added = hiding?.bodies.size ? [...fragment.childNodes] : undefined;\n if ('parent' in before) {\n before.parent.append(fragment);\n } else {\n before.parentNode!.insertBefore(fragment, before);\n }\n if (added) {\n hiding!.added(added);\n }\n // The records of this insert, whose markers are indexed and whose handlers listen already.\n markerObserver?.takeRecords();\n options.inserted?.();\n for (const fn of afterInsert.splice(0)) {\n fn();\n }\n // HTML from the server, such as `children`, can be older than the values on the client.\n if (server.length > 0) {\n refresh(server);\n }\n // Scopes that the client just rendered have its values, but the memos that load start here.\n const live = client.filter((scope) => scopes.has(scope.id));\n if (live.length > 0) {\n refresh(live, true);\n }\n}\n\n/**\n * Renders a `#portal` body into its target, between markers with its scope\n * ID. `kinds` names the body, so a new target first removes it from the old one.\n */\nexport function portalTo(\n scope: Scope,\n target: unknown,\n render: Render,\n kinds: number[] = [],\n): void {\n disposeKinds(scope, kinds);\n const element = typeof target === 'string' ? document.querySelector(target) : target;\n if (!(element instanceof Element)) {\n return;\n }\n // The body's scope is the first scope that the render creates.\n const id = nextId;\n insertHTML({ parent: element }, `<!--P${id}-->${render(scope)}<!--/P-->`);\n}\n\n/** Writes an inserted value between `<!--t…-->` and `<!--/t-->`. */\nexport function text(scope: Scope, anchor: number, value: unknown): void {\n const start = findComment(`t${scope.id}:${anchor}`);\n if (start) {\n write(start.parentNode!, start.nextSibling, rangeEnd(start), value);\n }\n}\n\n/** Writes an inserted value that is the whole content of the element with the anchor. */\nexport function content(scope: Scope, anchor: number, value: unknown): void {\n const element = findElement(scope.id, anchor);\n if (element) {\n write(element, element.firstChild, null, value);\n }\n}\n\n/**\n * Writes the text of an element whose content is text, such as a `<textarea>`\n * or a `<title>`. A `<textarea>` gets the value too, as `value` does on an\n * `<input>`, so a change replaces what the user typed.\n */\nexport function writeText(scope: Scope, anchor: number, value: unknown): void {\n const element = findElement(scope.id, anchor);\n if (element) {\n const written = textValue(value);\n // Each is written only when it differs, as a write of the same text still notifies observers.\n if (element.textContent !== written) {\n element.textContent = written;\n }\n if (element instanceof HTMLTextAreaElement && element.value !== written) {\n element.value = written;\n }\n }\n}\n\n/**\n * Replaces the nodes of `parent` from `first` up to `end`, or to its last\n * child, with a value. A text node that stays a text node keeps its node.\n */\nfunction write(\n parent: Node & ParentNode,\n first: ChildNode | null,\n end: Node | null,\n value: unknown,\n): void {\n if (\n (typeof value === 'string' || typeof value === 'number') &&\n first?.nodeType === 3 &&\n first.nextSibling === end\n ) {\n // Hidden text keeps its new value for when it shows.\n const saved = hiding?.nodes.get(first);\n const text = String(value);\n if (saved) {\n saved.v = text;\n } else if ((first as Text).data !== text) {\n // The same text again changes nothing, and a write would still notify observers.\n (first as Text).data = text;\n }\n return;\n }\n while (first && first !== end) {\n const next = first.nextSibling;\n first.remove();\n first = next;\n }\n insertHTML(end ?? { parent }, insertValue(value));\n}\n\n/** The `value` and `checked` that updates last wrote to each field. */\nconst fieldValues = new WeakMap<Element, Map<string, unknown>>();\n\nfunction setAttribute(element: Element, name: string, value: unknown): void {\n if (isBinding(value)) {\n value = value.value;\n }\n // A write of the same value changes nothing on screen, yet it still costs a style check and\n // notifies observers, so each write is skipped when the element already has the value.\n if (name === 'value' || name === 'checked') {\n const field = element as unknown as Record<string, unknown>;\n const next = name === 'checked' ? Boolean(value) : String(value ?? '');\n // The field takes the value when it differs from the value that updates wrote last, not each\n // time an update runs, so what the user typed or checked stays while the value stays, such\n // as the posted values of a form that validation reads again. Before the first write, the\n // field is compared as it is now.\n const written = fieldValues.get(element) ?? new Map<string, unknown>();\n fieldValues.set(element, written);\n const before = written.has(name) ? written.get(name) : field[name];\n written.set(name, next);\n if (!Object.is(before, next) && field[name] !== next) {\n field[name] = next;\n }\n }\n const written = attributeText(name, value);\n if (element.getAttribute(name) === (written ?? null)) {\n return;\n }\n if (written === undefined) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, written);\n }\n if (name === 'style') {\n hiding?.styled(element);\n }\n}\n\nexport function attr(scope: Scope, anchor: number, name: string, value: unknown): void {\n const element = findElement(scope.id, anchor);\n if (element) {\n setAttribute(element, name, value);\n }\n}\n\n/** The attributes that the last update of a spread wrote, so the next one removes those it drops. */\nconst spreadNames = new WeakMap<Element, Set<string>>();\n\nexport function attrs(\n scope: Scope,\n anchor: number,\n values: Record<string, unknown>,\n own: string[] = [],\n): void {\n const element = findElement(scope.id, anchor);\n if (element) {\n // The first update in the browser takes the attributes that are not the element's own, nor\n // those of brumate, as the ones that the server's spread wrote.\n if (!spreadNames.has(element)) {\n spreadNames.set(\n element,\n new Set(\n element\n .getAttributeNames()\n .filter((name) => !own.includes(name) && !/^(b-|data-prefetch$)/.test(name)),\n ),\n );\n }\n const names = new Set<string>();\n for (const [name, value] of Object.entries(values)) {\n if (name !== 'children' && !/^on[A-Z]/.test(name)) {\n names.add(name);\n setAttribute(element, name, value);\n }\n }\n for (const name of spreadNames.get(element) ?? []) {\n if (!names.has(name)) {\n setAttribute(element, name, undefined);\n }\n }\n spreadNames.set(element, names);\n }\n}\n\ntype Render = (parent: Scope, item?: unknown, index?: number) => string;\n\n/** Shows the branch at `index` of `#if` or `#switch`, or nothing for -1. */\nexport function branch(\n scope: Scope,\n anchor: number,\n index: number,\n renders: (Render | undefined)[],\n kinds: number[],\n): void {\n const start = findComment(`b${scope.id}:${anchor}`);\n if (!start) {\n return;\n }\n if (Number(start.data.split(':')[2]) === index) {\n return;\n }\n const end = rangeEnd(start);\n disposeKinds(scope, kinds);\n clear(start, end);\n start.data = `b${scope.id}:${anchor}:${index}`;\n const render = renders[index];\n if (render) {\n insertHTML(end, render(scope));\n }\n}\n\n/** Renders the body of `#key` again when its value changes. */\nexport function rekey(\n scope: Scope,\n anchor: number,\n value: unknown,\n render: Render,\n kinds: number[],\n): void {\n scope.keys ??= new Map();\n if (scope.keys.has(anchor) && Object.is(scope.keys.get(anchor), value)) {\n return;\n }\n scope.keys.set(anchor, value);\n const start = findComment(`b${scope.id}:${anchor}`);\n if (!start) {\n return;\n }\n const end = rangeEnd(start);\n disposeKinds(scope, kinds);\n clear(start, end);\n insertHTML(end, render(scope));\n}\n\n/**\n * Renders the body of a `#try` block again, for its `reset` function. If the\n * body throws, the fallback renders again with the error.\n */\nexport async function reset(\n scope: Scope,\n anchor: number,\n id: string,\n body: string,\n fallback: string,\n kinds: number[],\n): Promise<void> {\n const updates = await loadPart(await loadModule(id, 'reset'), 'update', 'reset');\n const start = findComment(`b${scope.id}:${anchor}`);\n if (!start) {\n return;\n }\n const end = rangeEnd(start);\n disposeKinds(scope, kinds);\n clear(start, end);\n let html: string;\n try {\n html = (updates[body] as Render)(scope);\n } catch (error) {\n // Scopes that the body created before it threw.\n disposeKinds(scope, kinds);\n afterInsert.length = 0;\n html = (updates[fallback] as (parent: Scope, error: unknown) => string)(scope, error);\n }\n insertHTML(end, html);\n}\n\n/**\n * Renders the body of a `#client` block once, in place of its fallback.\n * `kinds` are the scope IDs inside the fallback, whose instances go.\n */\nexport function fill(scope: Scope, anchor: number, render: Render, kinds: number[] = []): void {\n const start = findComment(`b${scope.id}:${anchor}`);\n // A block that rendered its body has a third number.\n if (!start || start.data.split(':').length > 2) {\n return;\n }\n start.data += ':1';\n const end = rangeEnd(start);\n disposeKinds(scope, kinds);\n clear(start, end);\n insertHTML(end, render(scope));\n}\n\n/**\n * Shows or hides the body of an `#offscreen` block. A body that the page\n * does not have yet renders the first time it shows. `kind` is the body's\n * scope ID in the compiled component.\n */\nexport function offscreen(\n scope: Scope,\n anchor: number,\n value: unknown,\n render: Render,\n kind: number,\n): void {\n const start = findComment(`b${scope.id}:${anchor}`);\n if (!start) {\n return;\n }\n const visible = Boolean(value);\n // 1 for a body that shows, 0 for one that is hidden, and -1 for one that has not rendered.\n const state = start.data.split(':')[2];\n if (visible ? state === '1' : state !== '1') {\n return;\n }\n start.data = `b${scope.id}:${anchor}:${visible ? 1 : 0}`;\n const end = rangeEnd(start);\n if (state === '-1') {\n insertHTML(end, render(scope));\n return;\n }\n let body: Scope | undefined;\n for (const child of scope.children) {\n if (child.k === kind) {\n body = child;\n }\n }\n if (body) {\n hiding ??= createHiding();\n if (visible) {\n hiding.show(body);\n } else {\n hiding.hide(body, start, end);\n }\n }\n}\n\n/** A hidden `#offscreen` body: its scope, and the ranges of its markup and of its portals. */\nexport interface HiddenBody {\n scope: Scope;\n ranges: [start: Comment, end: Comment][];\n}\n\n/**\n * What a hidden node had before it was hidden: `n` hidden bodies that hide\n * it, and the text of a text node, or the inline `display` of an element\n * with its priority and whether it had a `style` attribute.\n */\ninterface Saved {\n n: number;\n v: string;\n p?: string;\n a?: boolean;\n}\n\ninterface Hiding {\n bodies: Set<HiddenBody>;\n nodes: WeakMap<Node, Saved>;\n hide: (body: Scope, start: Comment, end: Comment) => void;\n show: (body: Scope) => void;\n /** True for a scope in a hidden body. */\n hidden: (scope: Scope) => boolean;\n /** Keeps an effect for when its body shows, and returns true, if its scope is hidden. */\n paused: (scope: Scope, name: string) => boolean;\n /** Hides the nodes that an insert added to hidden markup. */\n added: (nodes: Node[]) => void;\n /** Keeps an element hidden after its `style` attribute changed. */\n styled: (element: Element) => void;\n}\n\n/**\n * The code of hidden `#offscreen` bodies. The first body that hides sets it\n * up, so the core of a page without one only checks that it is not there.\n * A body is hidden with an inline `display: none !important` on each element\n * at its top level, which no stylesheet overrides, and empty text for each\n * text node. The nodes stay in the page, so form fields, focus and media\n * keep their state.\n */\nlet hiding: Hiding | undefined;\n\n/** True for a scope that is `ancestor` or inside it, also through the owner of a component. */\nfunction within(scope: Scope, ancestor: Scope): boolean {\n for (let current: Scope | undefined = scope; current; current = current.p ?? current.o) {\n if (current === ancestor) {\n return true;\n }\n }\n return false;\n}\n\n/** True for a scope in a hidden `#offscreen` body. */\nfunction hidden(scope: Scope): boolean {\n for (let current: Scope | undefined = scope; current; current = current.p ?? current.o) {\n if (current.h) {\n return true;\n }\n }\n return false;\n}\n\n/** The nodes between two markers. */\nfunction between([start, end]: [Comment, Comment]): Node[] {\n const result: Node[] = [];\n for (let node = start.nextSibling; node && node !== end; node = node.nextSibling) {\n result.push(node);\n }\n return result;\n}\n\n/** The inline style of an element, which an element that is not HTML or SVG may not have. */\nfunction display(element: Element): CSSStyleDeclaration | undefined {\n return (element as HTMLElement).style;\n}\n\nfunction createHiding(): Hiding {\n const bodies = new Set<HiddenBody>();\n const nodes = new WeakMap<Node, Saved>();\n const hideNode = (node: Node): void => {\n const saved = nodes.get(node);\n if (saved) {\n saved.n++;\n return;\n }\n if (node.nodeType === 3) {\n nodes.set(node, { n: 1, v: (node as Text).data });\n (node as Text).data = '';\n return;\n }\n const style = node.nodeType === 1 ? display(node as Element) : undefined;\n if (style) {\n nodes.set(node, {\n n: 1,\n v: style.getPropertyValue('display'),\n p: style.getPropertyPriority('display'),\n a: (node as Element).hasAttribute('style'),\n });\n style.setProperty('display', 'none', 'important');\n }\n };\n const showNode = (node: Node): void => {\n const saved = nodes.get(node);\n if (!saved || --saved.n > 0) {\n return;\n }\n nodes.delete(node);\n if (node.nodeType === 3) {\n (node as Text).data = saved.v;\n return;\n }\n const element = node as Element;\n const style = display(element)!;\n if (saved.v) {\n style.setProperty('display', saved.v, saved.p);\n } else {\n style.removeProperty('display');\n }\n if (!saved.a && element.getAttribute('style') === '') {\n element.removeAttribute('style');\n }\n };\n return {\n bodies,\n nodes,\n hidden,\n hide(body, start, end) {\n const record: HiddenBody = { scope: body, ranges: [[start, end]] };\n body.h = record;\n bodies.add(record);\n const inside = [...scopes.values()].filter((scope) => within(scope, body));\n for (const scope of inside) {\n // The content of a `#portal` in the body, elsewhere in the page.\n const portal = comments.get(`P${scope.id}`);\n if (portal?.isConnected) {\n record.ranges.push([portal, rangeEnd(portal)]);\n }\n }\n for (const range of record.ranges) {\n between(range).forEach(hideNode);\n }\n // Effects and `$client` callbacks that ran stop, and run again when the body shows.\n for (const scope of inside) {\n for (const [name, cleanup] of scope.cleanups ?? []) {\n cleanup();\n (scope.w ??= new Set()).add(name);\n }\n scope.cleanups?.clear();\n }\n },\n show(body) {\n const record = body.h;\n if (!record) {\n return;\n }\n body.h = undefined;\n bodies.delete(record);\n for (const range of record.ranges) {\n if (range[0].isConnected) {\n between(range).forEach(showNode);\n }\n }\n for (const scope of scopes.values()) {\n if (scope.w && within(scope, body) && !hidden(scope)) {\n const ref = `${rootOf(scope).m}#`;\n for (const name of scope.w) {\n void call(ref + name, scope, []);\n }\n scope.w = undefined;\n }\n }\n },\n paused(scope, name) {\n if (bodies.size === 0 || !hidden(scope)) {\n return false;\n }\n (scope.w ??= new Set()).add(name);\n return true;\n },\n added(added) {\n for (const node of added) {\n for (const record of bodies) {\n for (const [start, end] of record.ranges) {\n if (\n node.parentNode === start.parentNode &&\n start.compareDocumentPosition(node) & 4 &&\n node.compareDocumentPosition(end) & 4\n ) {\n hideNode(node);\n }\n }\n // A `#portal` that renders in a hidden body, whose nodes follow its marker.\n const data = node.nodeType === 8 ? (node as Comment).data : '';\n const scope = /^P-?[\\d.]+$/.test(data) ? scopes.get(parseId(data.slice(1))) : undefined;\n if (scope && within(scope, record.scope)) {\n record.ranges.push([node as Comment, rangeEnd(node as Comment)]);\n }\n }\n }\n },\n styled(element) {\n const saved = nodes.get(element);\n const style = display(element);\n if (saved && style) {\n saved.v = style.getPropertyValue('display');\n saved.p = style.getPropertyPriority('display');\n saved.a = element.hasAttribute('style');\n style.setProperty('display', 'none', 'important');\n }\n },\n };\n}\n\ninterface Item {\n scope: Scope;\n /** The first and last node of the item, which are the same node for one element. */\n first: Node;\n last: Node;\n /** The place of the item in the list before the update. */\n position: number;\n /** True for an item whose key is in the new list. */\n kept: boolean;\n /** True for a kept item that stays in place. */\n still: boolean;\n}\n\nconst ITEM_MARKER = /^i(-?[\\d.]+)$/;\n\n/** Updates the items of `#for` or `#repeat`, keeping the elements of items whose keys stay. */\n/** The items of a `#for` list: an array as it is, since `list` only reads it, or any iterable as an array. */\nexport function listOf(value: Iterable<unknown> | ArrayLike<unknown>): unknown[] {\n return Array.isArray(value) ? value : Array.from(value);\n}\n\nexport function list(\n scope: Scope,\n anchor: number,\n items: unknown[],\n key: (item: unknown, index: number) => unknown,\n render: Render,\n assign: (scope: Scope, item: unknown, index: number) => void,\n fallback: Render | undefined,\n fallbackKinds: number[],\n): void {\n const start = findComment(`b${scope.id}:${anchor}`);\n if (!start) {\n return;\n }\n const end = rangeEnd(start);\n const previous = new Map<unknown, Item>();\n let others: Node[] | undefined;\n let position = 0;\n for (let node = start.nextSibling; node && node !== end;) {\n // An item between `<!--i…-->` and `<!--/i-->`, or one element whose `b-b` names the scope.\n let data: string | undefined;\n let id: string | undefined;\n if (node.nodeType === 8) {\n data = (node as Comment).data;\n id = ITEM_MARKER.exec(data)?.[1];\n } else if (node.nodeType === 1) {\n const bound = (node as Element).getAttribute('b-b');\n id = bound === null ? undefined : bound.slice(0, bound.indexOf(':'));\n }\n const item = id === undefined ? undefined : scopes.get(parseId(id));\n let last: Node = node;\n // The elements of the fallback have scopes of its kinds.\n if (item && (data !== undefined || (item.p === scope && !fallbackKinds.includes(item.k)))) {\n if (data !== undefined) {\n last = rangeEnd(node as Comment);\n }\n previous.set(key(item.i, position), {\n scope: item,\n first: node,\n last,\n position: position++,\n kept: false,\n still: false,\n });\n } else {\n (others ??= []).push(node);\n }\n node = last.nextSibling;\n }\n\n const count = items.length;\n if (count === 0) {\n if (previous.size === 0 && others) {\n return;\n }\n for (const item of previous.values()) {\n destroy(item.scope);\n }\n clear(start, end);\n if (fallback) {\n insertHTML(end, fallback(scope));\n }\n return;\n }\n\n disposeKinds(scope, fallbackKinds);\n if (others) {\n for (const node of others) {\n node.parentNode?.removeChild(node);\n }\n }\n const parent = end.parentNode!;\n // The key of each item, and the items that stay, in the new order. A key that repeats keeps\n // its item once, as below.\n const keys: unknown[] = Array.from({ length: count });\n const kept: Item[] = [];\n for (let index = 0; index < count; index++) {\n const id = (keys[index] = key(items[index], index));\n const item = previous.get(id);\n if (item && !item.kept) {\n item.kept = true;\n kept.push(item);\n }\n }\n // The items that stay in place: the longest run of them that keeps the old order. Only the\n // others move, because moving a node restarts its animations and drops its focus.\n markInPlace(kept);\n // When no item stays, the old ones go first, in one removal, and the new ones go in after.\n if (kept.length === 0 && previous.size > 0) {\n for (const item of previous.values()) {\n destroy(item.scope);\n }\n previous.clear();\n clear(start, end);\n }\n // The first node after the items placed so far.\n let cursor: Node = start.nextSibling!;\n // New items next to each other go into the page with one insert.\n let added = '';\n for (let index = 0; index < count; index++) {\n const id = keys[index];\n const item = previous.get(id);\n if (!item) {\n added += render(scope, items[index], index);\n continue;\n }\n // Before the item's updates run, so they see the new items before it.\n if (added) {\n insertHTML(cursor, added);\n added = '';\n }\n previous.delete(id);\n // Slots that keep their values do not trigger updates.\n assign(item.scope, items[index], index);\n if (item.still) {\n // The nodes between the cursor and the item belong to items that move or go.\n cursor = item.last.nextSibling!;\n } else {\n for (let node = item.first; ;) {\n const next = node.nextSibling;\n parent.insertBefore(node, cursor);\n if (node === item.last) {\n break;\n }\n node = next!;\n }\n }\n }\n if (added) {\n insertHTML(cursor, added);\n }\n for (const item of previous.values()) {\n destroy(item.scope);\n for (let node: Node | null = item.first; node;) {\n const next: Node | null = node === item.last ? null : node.nextSibling;\n node.parentNode?.removeChild(node);\n node = next;\n }\n }\n}\n\n/**\n * Marks the items of a list that keep their places: the longest run of `kept`, the items that\n * stay in their new order, whose old positions go up.\n */\nfunction markInPlace(kept: Item[]): void {\n let sorted = true;\n for (let index = 1; index < kept.length; index++) {\n if (kept[index - 1]!.position > kept[index]!.position) {\n sorted = false;\n break;\n }\n }\n if (sorted) {\n for (const item of kept) {\n item.still = true;\n }\n return;\n }\n // `tails[length - 1]` is the index of the item that ends the run of that length with the\n // lowest position, and `before` links each item to the item before it in its run.\n const tails: number[] = [];\n const before: number[] = [];\n for (let index = 0; index < kept.length; index++) {\n const position = kept[index]!.position;\n let low = 0;\n let high = tails.length;\n while (low < high) {\n const middle = (low + high) >> 1;\n if (kept[tails[middle]!]!.position < position) {\n low = middle + 1;\n } else {\n high = middle;\n }\n }\n before[index] = low > 0 ? tails[low - 1]! : -1;\n tails[low] = index;\n }\n for (let index = tails.at(-1) ?? -1; index >= 0; index = before[index]!) {\n kept[index]!.still = true;\n }\n}\n\n/** Sets a style variable on the top-level elements of a component instance. */\nexport function setVar(scope: Scope, name: string, value: unknown): void {\n const css = value === null || value === undefined || value === false ? '' : String(value);\n for (const element of document.querySelectorAll<HTMLElement>(`[b-v=\"${scope.id}\"]`)) {\n if (element.style.getPropertyValue(name) !== css) {\n element.style.setProperty(name, css);\n }\n }\n}\n\n/** The scope that provides a context to `scope`: itself or the nearest one above it. */\nfunction findProvider(scope: Scope, key: string): Scope | undefined {\n // Children that a component inserted find their contexts where they are, through `t`.\n for (\n let current: Scope | undefined = scope;\n current;\n current = current.t ?? current.p ?? current.o\n ) {\n if (current.v && key in current.v) {\n return current;\n }\n }\n return undefined;\n}\n\n/** Writes a provided value, and the slot of every scope that reads it from this provider. */\nexport function updateContext(scope: Scope, context: ContextValue<unknown>, value: unknown): void {\n scope.v ??= {};\n scope.v[context.key] = value;\n for (const target of scopes.values()) {\n const slot = target.x?.[context.key];\n if (slot !== undefined && findProvider(target, context.key) === scope) {\n set(target, slot, value);\n }\n }\n}\n\n/** Sets the title of the page. */\nexport function title(value: unknown): void {\n setTitle(value === null || value === undefined ? '' : String(value));\n}\n\n/**\n * Sets `document.title`, which writes the first `<title>` of the document.\n * The head gets a `<title>` of its own first, so a `<title>` in markup keeps its text.\n */\nfunction setTitle(text: string): void {\n if (!document.head.querySelector('title:not([b-t])')) {\n document.head.prepend(document.createElement('title'));\n }\n document.title = text;\n}\n\n/** Watches the `<title>` elements of markup, once one is in the page. */\nlet titleObserver: MutationObserver | undefined;\n\nconst PAGE_TITLE = 'title[b-t]';\n\n/** True when a node is or holds a `<title>` of markup. */\nfunction holdsTitle(node: Node): boolean {\n return node instanceof Element && (node.matches(PAGE_TITLE) || !!node.querySelector(PAGE_TITLE));\n}\n\n/** Gives the page the text of its last `<title>` in markup. Without one, the title stays. */\nfunction syncTitle(): void {\n const titles = document.querySelectorAll(PAGE_TITLE);\n const last = titles[titles.length - 1];\n if (last && document.title !== last.textContent) {\n setTitle(last.textContent ?? '');\n }\n}\n\n/**\n * Starts to follow the `<title>` elements of markup, when `root` has one. A\n * block that adds or removes one, or a change of its text, sets the title.\n */\nfunction watchTitles(root: ParentNode): void {\n if (titleObserver || !root.querySelector(PAGE_TITLE)) {\n return;\n }\n titleObserver = new MutationObserver((records) => {\n for (const record of records) {\n const target = record.target instanceof Element ? record.target : record.target.parentElement;\n if (\n target?.closest(PAGE_TITLE) ||\n [...record.addedNodes].some(holdsTitle) ||\n [...record.removedNodes].some(holdsTitle)\n ) {\n syncTitle();\n return;\n }\n }\n });\n titleObserver.observe(document, { childList: true, subtree: true, characterData: true });\n}\n\n/** Writes a prop of a child component. */\n// The keys that the spreads of child components passed last, by the child's scope and anchor.\nconst spreadKeys = new WeakMap<Scope, Map<number, Set<string>>>();\n\n/**\n * Updates the props of a child component from a spread. A key that the\n * spread passed before and no longer has becomes undefined. `after` names\n * the props after the spread, which win over it.\n */\nexport function spreadProps(\n scope: Scope,\n anchor: number,\n value: Record<string, unknown> | null | undefined,\n after: string[],\n): void {\n const byAnchor = spreadKeys.get(scope) ?? new Map<number, Set<string>>();\n spreadKeys.set(scope, byAnchor);\n const before = byAnchor.get(anchor) ?? new Set();\n const keys = new Set(Object.keys(value ?? {}).filter((key) => !after.includes(key)));\n byAnchor.set(anchor, keys);\n for (const key of keys) {\n prop(scope, anchor, key, value![key]);\n }\n for (const key of before) {\n if (!keys.has(key)) {\n prop(scope, anchor, key, undefined);\n }\n }\n}\n\nexport function prop(scope: Scope, anchor: number, name: string, value: unknown): void {\n // A prop that the parent binds passes its value. The child keeps the slot it writes from its render.\n if (isBinding(value)) {\n value = value.value;\n }\n const id = scope.c?.[anchor];\n const child = id === undefined ? undefined : scopes.get(id);\n if (!child?.m) {\n return;\n }\n const apply = (module: ClientModule): void => {\n const slot = module.props[name];\n if (slot !== undefined) {\n // A promise loads as an async memo does: the prop keeps its value, and is pending until it settles.\n if (isThenable(value)) {\n asyncMemo(child, slot, Promise.resolve(value));\n } else {\n // The parent's value. A bound prop does not write it back.\n writeSlot(child, slot, value);\n }\n return;\n }\n const all = module.props['*'];\n if (all !== undefined) {\n set(child, all, { ...(get(child, all) as object), [name]: value });\n }\n };\n const module = modules.get(child.m);\n if (module) {\n apply(module);\n } else {\n void loadModule(child.m, 'prop').then(apply);\n }\n}\n\n/** Runs an effect or a `$client` callback, after the cleanup of its previous run. */\nexport function effect(scope: Scope, name: string, callback: () => unknown): void {\n // In a hidden `#offscreen` body, it runs when the body shows.\n if (hiding?.paused(scope, name)) {\n return;\n }\n scope.cleanups ??= new Map();\n scope.cleanups.get(name)?.();\n let cleanup: unknown;\n const start = DEV ? performance.now() : 0;\n try {\n cleanup = callback();\n } catch (error) {\n // The error goes to the nearest `#try` around the effect. The effect runs again on the next change.\n fail(scope, error);\n }\n // An entry without a cleanup too, so a hidden `#offscreen` body knows what to run again.\n let stored = typeof cleanup === 'function' ? (cleanup as () => void) : noop;\n if (DEV) {\n devtools()?.effect?.(scope, name, 'run', performance.now() - start);\n // Each way that a cleanup runs calls this function: the next run, a removed scope, a hidden\n // `#offscreen` body, or a page that navigation leaves.\n const own = stored;\n stored = () => {\n devtools()?.effect?.(scope, name, 'cleanup', 0);\n own();\n };\n }\n scope.cleanups.set(name, stored);\n}\n\nfunction noop(): void {}\n\n/** Renders the attributes of a form or button that posts to a server function. */\nexport function action(name: string, id: string, method?: string, result?: string): string {\n return actionAttributes(rpcPrefix, name, id, method, result, build);\n}\n\n/**\n * Sends a form of an `$action`. The code is in `rpc.ts`, which every server\n * call loads, so the core holds only this.\n */\nexport function submitAction(form: HTMLFormElement, submitter: HTMLElement | null): void {\n void import('./rpc.ts').then((module) => module.sendAction(form, submitter));\n}\n\n/** Calls a server function. */\nexport async function rpc(id: string, args: unknown[]): Promise<unknown> {\n // Read before the import, while the memo that calls it computes.\n const signal = memoSignal();\n return track(import('./rpc.ts').then((module) => module.call(rpcPrefix, id, args, signal)));\n}\n\n// Rendering on the client\n\n/** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */\nexport function insert(value: unknown, _ctx?: unknown, scope?: Scope | ScopeId): string {\n return value instanceof Children ? value.render(resolveScope(scope)) : insertValue(value);\n}\n\n/** Children that render where they are inserted, and the scopes that they find contexts from. */\nconst insertedChildren: { from: Scope | undefined; at: Scope }[] = [];\n\n/**\n * Children of a component that the client renders. They render where the\n * component inserts them, so they read the contexts that it provides. `from`\n * is the scope of the markup that wrote them.\n */\nclass Children {\n private readonly from: Scope | undefined;\n private readonly html: () => string;\n\n constructor(from: Scope | ScopeId | undefined, html: () => string) {\n this.from = resolveScope(from);\n this.html = html;\n }\n\n render(at: Scope | undefined): string {\n if (!at) {\n return this.html();\n }\n const entry = { from: this.from, at };\n insertedChildren.push(entry);\n try {\n return this.html();\n } finally {\n insertedChildren.splice(insertedChildren.indexOf(entry), 1);\n }\n }\n}\n\n/** The children of a component that the client renders. See `Children`. */\nexport function children(from: Scope | ScopeId | undefined, html: () => string): Children {\n return new Children(from, html);\n}\n\n/** A component's client render function, from its `?brumate-render` module. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Components take any props.\nexport type Component<P = any> = (props: P) => string;\n\nfunction resolveScope(scope: Scope | ScopeId | undefined): Scope | undefined {\n if (typeof scope === 'object') {\n return scope;\n }\n return scope === undefined ? undefined : scopes.get(scope);\n}\n\n/**\n * Renders a child component on the client. With `scope` and `anchor`,\n * records the child's scope so the parent can update its props.\n */\nexport function component<P>(\n Child: Component<P>,\n props: P,\n _ctx?: unknown,\n scope?: Scope | number,\n anchor?: number,\n): string {\n const parent = resolveScope(scope);\n if (parent && anchor !== undefined) {\n parent.c ??= {};\n parent.c[anchor] = nextId;\n }\n if (parent) {\n setOwner(parent);\n }\n return Child(props);\n}\n\nexport function dynamic(\n tag: unknown,\n attributes: Record<string, unknown>,\n inner: Raw | Children | undefined,\n _ctx?: unknown,\n scope?: Scope | number,\n): string {\n if (typeof tag === 'function') {\n return component(\n tag as Component,\n inner ? { ...attributes, children: inner } : attributes,\n undefined,\n scope,\n );\n }\n const name = String(tag);\n const open = `<${name}${spreadText(attributes)}>`;\n return VOID_ELEMENTS.has(name)\n ? open\n : `${open}${inner ? insert(inner, undefined, scope) : ''}</${name}>`;\n}\n\n/** Work that waits until rendered markup is in the page. */\nexport const afterInsert: (() => void)[] = [];\n\n/** The scope that renders the next component, which becomes its owner. */\nlet owner: Scope | undefined;\n\n// The helpers below are what the server's render context does, for markup that the client\n// renders. Each is an export of its own, so a build keeps only those that its components call.\n\n/** Creates a scope for markup that the client renders, and returns its ID. */\nexport function createScope(kind: number, parent?: Scope | ScopeId, module?: string): number {\n const id = nextId--;\n const parentScope = resolveScope(parent);\n const created: Scope = { id, k: kind, p: parentScope, m: module, s: [], children: new Set() };\n rendered.push(created);\n if (module !== undefined && owner) {\n created.o = owner;\n owner = undefined;\n }\n // A scope at the top of children that are inserted elsewhere finds its contexts there.\n const up = created.o ?? parentScope;\n for (let index = insertedChildren.length - 1; index >= 0; index--) {\n if (insertedChildren[index]!.from === up) {\n created.t = insertedChildren[index]!.at;\n break;\n }\n }\n parentScope?.children.add(created);\n treeChanges++;\n scopes.set(id, created);\n return id;\n}\n\n/**\n * The ID that `$id()` makes, as the server does. Client scope IDs are\n * negative, so they differ from the server's.\n */\nexport function makeId(scope: Scope | ScopeId, index: number): string {\n return `b${String(resolveScope(scope)!.id).replace(/\\./g, '_')}-${index}`;\n}\n\n/** Sets the owner of the next component's root scope. */\nexport function setOwner(scope: Scope | ScopeId): void {\n owner = resolveScope(scope);\n}\n\n/** Provides a value of a context to the scopes inside `scope`. */\nexport function provideValue<T>(context: ContextValue<T>, value: T, scope: Scope | ScopeId): void {\n const target = resolveScope(scope)!;\n target.v ??= {};\n target.v[context.key] = value;\n}\n\n/** Reads a context, and records its slot so that changes to the provided value reach it. */\nexport function consumeContext<T>(\n context: ContextValue<T>,\n scope: Scope | ScopeId,\n slot?: number,\n): T {\n const target = resolveScope(scope)!;\n if (slot !== undefined) {\n target.x ??= {};\n target.x[context.key] = slot;\n }\n const provider = findProvider(target, context.key);\n if (provider) {\n return provider.v![context.key] as T;\n }\n if (context.key === ROUTE_KEY && !globals.has(ROUTE_KEY)) {\n globals.set(ROUTE_KEY, currentRoute());\n }\n return (globals.has(context.key) ? globals.get(context.key) : context.defaultValue) as T;\n}\n\n/** The values of the contexts that the runtime provides to the whole page, by key. */\nconst globals = new Map<string, unknown>();\n\n/** The route of the page: `location`, and the params of the route from the last page state. */\nfunction currentRoute(): Route {\n const records = document.querySelectorAll('script[b-state][b-params]');\n const params = records[records.length - 1]?.getAttribute('b-params');\n const url = new URL(location.href);\n return { url, search: url.searchParams, params: params ? JSON.parse(params) : {} };\n}\n\n/**\n * Writes a context that the runtime provides to the whole page, and the\n * slot of every scope that reads it without a provider above it.\n */\nexport function setGlobal(key: string, value: unknown): void {\n globals.set(key, value);\n for (const target of scopes.values()) {\n const slot = target.x?.[key];\n if (slot !== undefined && !findProvider(target, key)) {\n set(target, slot, value);\n }\n }\n}\n\n/** Reads the route of the page again, after navigation changed it. */\nexport function updateRoute(): void {\n setGlobal(ROUTE_KEY, currentRoute());\n}\n\n/**\n * Slots that the render of a component in the browser filled with a promise,\n * by `scope:slot`. The first compute of their memo takes that promise\n * instead of calling again, so a server function is called once per row.\n */\nconst renderedLoads = new Set<string>();\n\nexport function setSlots(id: ScopeId, values: unknown[]): void {\n scopes.get(id)!.s = values;\n // A render function computes a memo that loads as a promise, which the first compute of the\n // memo takes. Its failure is the memo's to report, not an unhandled rejection.\n for (let slot = 0; slot < values.length; slot++) {\n const value = values[slot];\n if (isThenable(value)) {\n renderedLoads.add(`${id}:${slot}`);\n Promise.resolve(value).catch(noop);\n }\n }\n}\n\nexport function setItem(id: ScopeId, value: unknown): void {\n scopes.get(id)!.i = value;\n}\n\nexport function elementAt(scope: ScopeId, anchor: number): ElementReference {\n return new ElementReference(scope, anchor);\n}\n\n/**\n * Warns in development that the browser renders a `#defer` block of a\n * component, such as inside a `#client` body of its parent. Only the server\n * renders the body, so the fallback stays.\n */\nexport function deferInBrowser(id: string): void {\n if (DEV) {\n console.warn(\n `${id} renders a #defer block in the browser, so it shows its fallback only. Render the component in markup that the server renders.`,\n );\n }\n}\n\n/** Adds the markup of a `#head` block to the document's head. */\nexport function addHead(html: string): void {\n afterInsert.push(() => insertHTML({ parent: document.head }, html));\n}\n\n/** Adds the markup of a `#portal` block at the end of the page, after the markup around it. */\nexport function addPortal(html: string): void {\n afterInsert.push(() => insertHTML({ parent: document.body }, html));\n}\n\n/** Adds a component's stylesheet to the page, if the server did not. */\nexport function addStyle(id: string, css: string): string {\n if (!document.querySelector(`style[b-style=\"${id}\"]`)) {\n const sheet = document.createElement('style');\n sheet.setAttribute('b-style', id);\n sheet.textContent = css;\n document.head.append(sheet);\n }\n return '';\n}\n\n/** A function prop rendered on the client calls the parent's exported handler. */\nexport function handlerProp(\n value: unknown,\n ref: string,\n scope: Scope | number,\n bound: unknown[] = [],\n modifiers?: string[],\n): unknown {\n // A template renders at once, and the client has its code already.\n if (typeof value !== 'function' || isTemplate(ref)) {\n return value;\n }\n const instance = resolveScope(scope);\n const handler = (...args: unknown[]): unknown => call(ref, instance, [...bound, ...args]);\n // A spread of markup that the browser renders passes it on, with the modifiers of its wrappers.\n // A scope that is not in the page yet has its ID in `scope`.\n handlerReferences.set(\n handler,\n new FunctionReference(\n ref,\n instance?.id ?? (scope as ScopeId),\n bound.length > 0 ? bound : undefined,\n modifiers ?? (value as { [MODIFIERS]?: string[] })[MODIFIERS],\n ),\n );\n return handler;\n}\n\n/**\n * What the loader calls. It is one export, so the loader's import of the core\n * names one export, and a build keeps the rest only when components call them.\n */\nexport const loader: {\n init: typeof init;\n handle: typeof handle;\n dispose: typeof dispose;\n submitAction: typeof submitAction;\n setGlobal: typeof setGlobal;\n updateRoute: typeof updateRoute;\n} = { init, handle, dispose, submitAction, setGlobal, updateRoute };\n"],"mappings":";;;;;;AAuFA,SAAS,OAAO,MAAsB;CACpC,OAAO,WAAW,KAAK,IAAI,IAAI,OAAO;AACxC;AAsEA,IAAI;;AAEJ,IAAW,YAAY;;AAEvB,IAAW;;;;;;AAOX,SAAgB,KAAK,QAAyC;CAC5D,SAAS,cAAc,IAAI,YAAY,gBAAgB,EAAE,QAAQ,OAAO,CAAC,CAAC;AAC5E;;AAEA,MAAa,yBAA8B,IAAI,IAAI;;AAGnD,MAAa,QAKT,CAAC;;AAkDL,MAAa,WAA0B,OAAO,IAAI,kBAAkB;;;;;;AAOpE,MAAM,MAAO,YAA4C,KAAK;AAE9D,SAAS,WAAsC;CAC7C,OAAQ,WAAyD;AACnE;AACA,MAAM,0BAAU,IAAI,IAA0B;AAC9C,MAAM,0BAAU,IAAI,IAAmC;AACvD,MAAM,wBAAQ,IAAI,IAA2B;A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,MAAM,aAAa,WAAW,EAAE;EAChC,MAAM,cAAc;EACpB,SAAS,KAAK,OAAO,KAAK;CAC5B;CACA,OAAO;AACT;;AAGA,SAAgB,YACd,OACA,KACA,OACA,QAAmB,CAAC,GACpB,WACS;CAET,IAAI,OAAO,UAAU,cAAc,WAAW,GAAG,GAC/C,OAAO;CAET,MAAM,WAAW,aAAa,KAAK;CACnC,MAAM,WAAW,GAAG,SAA6B,KAAK,KAAK,UAAU,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;CAGxF,kBAAkB,IAChB,SACA,IAAI,kBACF,KACA,UAAU,MAAO,OACjB,MAAM,SAAS,IAAI,QAAQ,KAAA,GAC3B,aAAc,MAAqC,UACrD,CACF;CACA,OAAO;AACT;;;;;AAMA,MAAa,SAOT;CAAE;CAAM;CAAQ;CAAS;CAAc;CAAW;AAAY"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { r as SerialEntry } from "./values-B8C7CLvG.js";
|
|
2
|
+
import { t as Raw } from "./html-Bq1rFxX_.js";
|
|
3
|
+
import { n as Binding, o as PageState, r as ElementReference, s as ScopeId } from "./produce-D0V0ICkz.js";
|
|
3
4
|
import { t as Context } from "./context-btHuB01Z.js";
|
|
5
|
+
//#region src/runtime/navigate.d.ts
|
|
6
|
+
/** What the devtools learn of a navigation. See `DevtoolsHooks.navigated`. */
|
|
7
|
+
interface NavigationReport {
|
|
8
|
+
url: string;
|
|
9
|
+
/** `push` for a link, `traverse` for the back and forward buttons, `form` for a form or a reload. */
|
|
10
|
+
kind: "push" | "traverse" | "form";
|
|
11
|
+
/** The routes that stayed, by their keys, when only some routes were replaced. */
|
|
12
|
+
kept: string[];
|
|
13
|
+
/** The slots whose route was replaced, with the keys of the old and the new route. */
|
|
14
|
+
replaced: {
|
|
15
|
+
slot: string;
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
}[];
|
|
19
|
+
/** True when the whole page was replaced. */
|
|
20
|
+
full: boolean;
|
|
21
|
+
/** How much the IDs of the new page moved, when they did not start where this page asked. */
|
|
22
|
+
shift?: number;
|
|
23
|
+
/** When the navigation started, and how long it took until the page changed. */
|
|
24
|
+
start: number;
|
|
25
|
+
time: number;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
4
28
|
//#region src/runtime/client.d.ts
|
|
5
29
|
type Update = [kind: number, name: string];
|
|
6
30
|
/** The entry of a compiled client module. */
|
|
@@ -47,6 +71,12 @@ interface Scope {
|
|
|
47
71
|
v?: Record<string, unknown>;
|
|
48
72
|
/** The slots that hold the contexts that the scope reads, by context key. */
|
|
49
73
|
x?: Record<string, number>;
|
|
74
|
+
/** The slots of a parent that the bound props of a component write, by the slot of the prop. */
|
|
75
|
+
/**
|
|
76
|
+
* What the bound props write, by the slot of the prop: a slot of a parent,
|
|
77
|
+
* or the setter of `$bind(name, fn)`, as a function or a reference.
|
|
78
|
+
*/
|
|
79
|
+
b?: Record<number, unknown>;
|
|
50
80
|
children: Set<Scope>;
|
|
51
81
|
/** The `b-root` of the render that the server rendered the scope in. */
|
|
52
82
|
r?: string;
|
|
@@ -58,13 +88,19 @@ interface Scope {
|
|
|
58
88
|
w?: Set<string>;
|
|
59
89
|
}
|
|
60
90
|
interface CoreOptions {
|
|
91
|
+
/** The exports of the serial entry, for the values of the app in the page state. */
|
|
92
|
+
serial?: SerialEntry;
|
|
61
93
|
/**
|
|
62
94
|
* Imports the client module of a component. Undefined for a component that
|
|
63
95
|
* has no client code, which a build leaves out.
|
|
64
96
|
*/
|
|
65
97
|
load: (id: string) => Promise<ClientModule> | undefined;
|
|
98
|
+
/** Imports a part of a module, once for each part, as the loader preloads it. */
|
|
99
|
+
loadPart?: (module: ClientModule, part: string) => Promise<Part>;
|
|
66
100
|
/** Adds event listeners for the `b-on` attributes in new markup. */
|
|
67
101
|
listen: (root: ParentNode) => void;
|
|
102
|
+
/** Tells the loader that the markup that `listen` scanned is in the page now. */
|
|
103
|
+
inserted?: () => void;
|
|
68
104
|
/** The URL prefix of server function calls. Defaults to `/_brumate`. */
|
|
69
105
|
rpc?: string;
|
|
70
106
|
/** The ID of the build of the page, for skew protection. Calls send it, and a deploy is noticed. */
|
|
@@ -103,13 +139,45 @@ interface DevtoolsHooks {
|
|
|
103
139
|
attach?(core: {
|
|
104
140
|
scopes: Map<ScopeId, Scope>;
|
|
105
141
|
set: (scope: Scope, slot: number, value: unknown) => void;
|
|
142
|
+
/** Runs the code of a reference for an element, as an event or a trigger does. */
|
|
143
|
+
handle?: (element: Element, ref: string, event?: Event) => Promise<unknown>;
|
|
106
144
|
}): void;
|
|
107
145
|
/** A handler starts for an event. */
|
|
108
146
|
handler?(ref: string, element: Element, event?: Event): void;
|
|
109
147
|
/** A part of a component's client code loaded. */
|
|
110
148
|
part?(component: string, name: string): void;
|
|
149
|
+
/**
|
|
150
|
+
* A handler ran: when its event came, when its code was ready and the
|
|
151
|
+
* handlers before it had started, when the call returned, and what it
|
|
152
|
+
* returned, which is a promise for an async handler.
|
|
153
|
+
*/
|
|
154
|
+
handled?(run: {
|
|
155
|
+
ref: string;
|
|
156
|
+
element: Element;
|
|
157
|
+
event?: string;
|
|
158
|
+
begun: number;
|
|
159
|
+
ready: number;
|
|
160
|
+
end: number;
|
|
161
|
+
result: unknown;
|
|
162
|
+
}): void;
|
|
163
|
+
/** The updates of a write ran: how many, and how long they took with their effects. */
|
|
164
|
+
updated?(count: number, start: number, end: number): void;
|
|
165
|
+
/**
|
|
166
|
+
* Code of a component starts to load: its entry, or a part, and why.
|
|
167
|
+
* `done` settles when it has loaded.
|
|
168
|
+
*/
|
|
169
|
+
load?(component: string, part: string, reason: string, done: Promise<unknown>): void;
|
|
170
|
+
/** The loader asks the server for the body of a `#defer` block. */
|
|
171
|
+
defer?(template: Element, done: Promise<unknown>): void;
|
|
111
172
|
/** A slot got a new value. */
|
|
112
173
|
write?(scope: Scope, slot: number, value: unknown): void;
|
|
174
|
+
/**
|
|
175
|
+
* An effect or a `$client` callback, by its name in the update code, ran
|
|
176
|
+
* and took `time` milliseconds, or its cleanup ran.
|
|
177
|
+
*/
|
|
178
|
+
effect?(scope: Scope, name: string, kind: "run" | "cleanup", time: number): void;
|
|
179
|
+
/** A client navigation changed the page: the routes that stayed, and those it replaced. */
|
|
180
|
+
navigated?(report: NavigationReport): void;
|
|
113
181
|
}
|
|
114
182
|
/** The global key of the devtools hooks. */
|
|
115
183
|
declare const DEVTOOLS: unique symbol;
|
|
@@ -150,8 +218,20 @@ declare function remount(detail: {
|
|
|
150
218
|
declare function leavePage(): void;
|
|
151
219
|
/** Reads the page state. The loader calls it once, before the first handler. */
|
|
152
220
|
declare function init(value: CoreOptions): void;
|
|
153
|
-
|
|
154
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Renders an object of attributes. With `on`, a handler in it that the core
|
|
223
|
+
* made from a reference goes into `on` as a `b-on` entry, with the scope and
|
|
224
|
+
* the arguments of its reference and the modifiers of its wrappers.
|
|
225
|
+
*/
|
|
226
|
+
declare function spread(attributes: Record<string, unknown>, on?: string[]): string;
|
|
227
|
+
/**
|
|
228
|
+
* Why the core loads code, for the Loading tab of the devtools: an event,
|
|
229
|
+
* a call of a function prop, a template, the scopes of a state record, a
|
|
230
|
+
* write, an error, a reset of `#try`, or a prop of a child.
|
|
231
|
+
*/
|
|
232
|
+
type LoadReason = "event" | "call" | "template" | "state" | "write" | "error" | "reset" | "prop";
|
|
233
|
+
declare function loadModule(id: string, reason?: LoadReason): Promise<ClientModule>;
|
|
234
|
+
declare function loadPart(module: ClientModule, name: string, reason?: LoadReason): Promise<Part>;
|
|
155
235
|
/**
|
|
156
236
|
* Runs the handler `ref` for an element. The scope comes from the element's
|
|
157
237
|
* `b-b` anchor, or from the nearest element around it that has one, which
|
|
@@ -169,7 +249,21 @@ declare function fail(scope: Scope | undefined, error: unknown): void;
|
|
|
169
249
|
/** Returns the instance of a scope by its ID. */
|
|
170
250
|
declare function scopeOf(id: ScopeId): Scope | undefined;
|
|
171
251
|
declare function get(scope: Scope, slot: number): any;
|
|
252
|
+
/**
|
|
253
|
+
* Writes a slot from code of a component. A prop that a parent bound with
|
|
254
|
+
* `$bind` writes the parent's slot too, through any number of levels, and
|
|
255
|
+
* the parent's update of the prop then finds the value already there. A
|
|
256
|
+
* binding with a setter, `$bind(name, fn)`, calls it in place of the write,
|
|
257
|
+
* and the parent's update of the prop writes the value that it keeps.
|
|
258
|
+
*/
|
|
172
259
|
declare function set<T>(scope: Scope, slot: number, value: T): T;
|
|
260
|
+
/** What `$bind(name)` passes a child, in markup that the browser renders. */
|
|
261
|
+
declare function binding<T>(value: T, scope: Scope | ScopeId, slot: number, set?: unknown): Binding<T>;
|
|
262
|
+
/**
|
|
263
|
+
* Records the props that a parent bound with `$bind`, among the props that a
|
|
264
|
+
* component the browser renders writes: `slots` has the slot of each, by its name.
|
|
265
|
+
*/
|
|
266
|
+
declare function bindings(scope: Scope | ScopeId, props: Record<string, unknown>, slots: Record<string, number>): void;
|
|
173
267
|
/**
|
|
174
268
|
* The names of a call of a module function, for its shared code. Each ref
|
|
175
269
|
* is a slot of `scope`, `[scope, slot]` for a slot of another scope, or
|
|
@@ -205,6 +299,11 @@ declare function track<T>(request: Promise<T>): Promise<T>;
|
|
|
205
299
|
declare function pending(scope: Scope, slot: number): boolean;
|
|
206
300
|
/** `x++`, `x--`, `++x` and `--x`. */
|
|
207
301
|
declare function update(scope: Scope, slot: number, delta: number, prefix: boolean): number;
|
|
302
|
+
/**
|
|
303
|
+
* Resolves when the updates of the writes so far have run, including those
|
|
304
|
+
* whose code is loading. `transition` of `brumate/events` waits for it.
|
|
305
|
+
*/
|
|
306
|
+
declare function updated(): Promise<void>;
|
|
208
307
|
declare function descendants(scope: Scope, kind: number, result?: Scope[]): Scope[];
|
|
209
308
|
/**
|
|
210
309
|
* Removes a scope from the page: its cleanups run, and its memo state goes,
|
|
@@ -255,6 +354,8 @@ interface HiddenBody {
|
|
|
255
354
|
ranges: [start: Comment, end: Comment][];
|
|
256
355
|
}
|
|
257
356
|
/** Updates the items of `#for` or `#repeat`, keeping the elements of items whose keys stay. */
|
|
357
|
+
/** The items of a `#for` list: an array as it is, since `list` only reads it, or any iterable as an array. */
|
|
358
|
+
declare function listOf(value: Iterable<unknown> | ArrayLike<unknown>): unknown[];
|
|
258
359
|
declare function list(scope: Scope, anchor: number, items: unknown[], key: (item: unknown, index: number) => unknown, render: Render, assign: (scope: Scope, item: unknown, index: number) => void, fallback: Render | undefined, fallbackKinds: number[]): void;
|
|
259
360
|
/** Sets a style variable on the top-level elements of a component instance. */
|
|
260
361
|
declare function setVar(scope: Scope, name: string, value: unknown): void;
|
|
@@ -262,7 +363,12 @@ declare function setVar(scope: Scope, name: string, value: unknown): void;
|
|
|
262
363
|
declare function updateContext(scope: Scope, context: Context<unknown>, value: unknown): void;
|
|
263
364
|
/** Sets the title of the page. */
|
|
264
365
|
declare function title(value: unknown): void;
|
|
265
|
-
/**
|
|
366
|
+
/**
|
|
367
|
+
* Updates the props of a child component from a spread. A key that the
|
|
368
|
+
* spread passed before and no longer has becomes undefined. `after` names
|
|
369
|
+
* the props after the spread, which win over it.
|
|
370
|
+
*/
|
|
371
|
+
declare function spreadProps(scope: Scope, anchor: number, value: Record<string, unknown> | null | undefined, after: string[]): void;
|
|
266
372
|
declare function prop(scope: Scope, anchor: number, name: string, value: unknown): void;
|
|
267
373
|
/** Runs an effect or a `$client` callback, after the cleanup of its previous run. */
|
|
268
374
|
declare function effect(scope: Scope, name: string, callback: () => unknown): void;
|
|
@@ -336,7 +442,7 @@ declare function addPortal(html: string): void;
|
|
|
336
442
|
/** Adds a component's stylesheet to the page, if the server did not. */
|
|
337
443
|
declare function addStyle(id: string, css: string): string;
|
|
338
444
|
/** A function prop rendered on the client calls the parent's exported handler. */
|
|
339
|
-
declare function handlerProp(value: unknown, ref: string, scope: Scope | number): unknown;
|
|
445
|
+
declare function handlerProp(value: unknown, ref: string, scope: Scope | number, bound?: unknown[], modifiers?: string[]): unknown;
|
|
340
446
|
/**
|
|
341
447
|
* What the loader calls. It is one export, so the loader's import of the core
|
|
342
448
|
* names one export, and a build keeps the rest only when components call them.
|
|
@@ -350,5 +456,5 @@ declare const loader: {
|
|
|
350
456
|
updateRoute: typeof updateRoute;
|
|
351
457
|
};
|
|
352
458
|
//#endregion
|
|
353
|
-
export {
|
|
354
|
-
//# sourceMappingURL=client-
|
|
459
|
+
export { offscreen as $, dispose as A, updated as At, handlerProp as B, children as C, text as Ct, createScope as D, update as Dt, content as E, track as Et, fill as F, leaveRoutes as G, init as H, forget as I, loadModule as J, list as K, get as L, effect as M, NavigationReport as Mt, elementAt as N, deferInBrowser as O, updateContext as Ot, fail as P, memo as Q, guess as R, cells as S, submitAction as St, consumeContext as T, title as Tt, insert as U, hooks as V, leavePage as W, loader as X, loadPart as Y, makeId as Z, attrs as _, setSlots as _t, DevtoolsHooks as a, remount as at, branch as b, spread as bt, Part as c, reset as ct, addHead as d, scopeOf as dt, pending as et, addPortal as f, scopes as ft, attr as g, setOwner as gt, asyncMemo as h, setItem as ht, DEVTOOLS as i, rekey as it, dynamic as j, writeText as jt, descendants as k, updateRoute as kt, Scope as l, rpc as lt, afterInsert as m, setGlobal as mt, Component as n, prop as nt, HiddenBody as o, removeRoot as ot, addStyle as p, set as pt, listOf as q, CoreOptions as r, provideValue as rt, LoadReason as s, removeScope as st, ClientModule as t, portalTo as tt, action as u, rpcPrefix as ut, binding as v, setVar as vt, component as w, timed as wt, build as x, spreadProps as xt, bindings as y, skew as yt, handle as z };
|
|
460
|
+
//# sourceMappingURL=client-D0CqSxoO.d.ts.map
|
|
@@ -49,6 +49,7 @@ function getCookies(event) {
|
|
|
49
49
|
}
|
|
50
50
|
/** Sets a cookie on the response of an event. See `RequestEvent.setCookie`. */
|
|
51
51
|
function setCookie(event, name, value, options = {}) {
|
|
52
|
+
event.personal = true;
|
|
52
53
|
const secure = options.secure ?? new URL(event.request.url).protocol === "https:";
|
|
53
54
|
event.headers.append("set-cookie", serializeCookie(name, value, {
|
|
54
55
|
...options,
|
|
@@ -172,4 +173,4 @@ function toNodeHeaders(headers) {
|
|
|
172
173
|
//#endregion
|
|
173
174
|
export { serializeCookie as a, parseCookies as i, deleteCookie as n, setCookie as o, getCookies as r, toNodeHeaders as s, createSession as t };
|
|
174
175
|
|
|
175
|
-
//# sourceMappingURL=cookies-
|
|
176
|
+
//# sourceMappingURL=cookies-BzllthiF.js.map
|