brumate 0.1.1 → 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.
Files changed (136) hide show
  1. package/dist/{boot-DN1ZU8Hg.d.ts → boot-C25Sa6vq.d.ts} +27 -2
  2. package/dist/cli.js +2 -2
  3. package/dist/client-BD6XT-s5.js +1968 -0
  4. package/dist/client-BD6XT-s5.js.map +1 -0
  5. package/dist/{client-DwJInP_a.d.ts → client-D0CqSxoO.d.ts} +211 -30
  6. package/dist/{client-routes-DakuM32C.js → client-routes-JTbGtukf.js} +28 -15
  7. package/dist/client-routes-JTbGtukf.js.map +1 -0
  8. package/dist/context-CTiSzQRc.js +27 -0
  9. package/dist/context-CTiSzQRc.js.map +1 -0
  10. package/dist/context-btHuB01Z.d.ts +42 -0
  11. package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
  12. package/dist/cookies-BzllthiF.js.map +1 -0
  13. package/dist/defer-BbD7JQhj.js +56 -0
  14. package/dist/defer-BbD7JQhj.js.map +1 -0
  15. package/dist/devtools-CQgD7NPB.js +623 -0
  16. package/dist/devtools-CQgD7NPB.js.map +1 -0
  17. package/dist/devtools-panel-BVB-W5q4.js +1930 -0
  18. package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
  19. package/dist/events-CSs7OwIC.js +85 -0
  20. package/dist/events-CSs7OwIC.js.map +1 -0
  21. package/dist/{files-DdT84mPy.js → files-BXSSrQgc.js} +34 -6
  22. package/dist/files-BXSSrQgc.js.map +1 -0
  23. package/dist/forms-Bg-CwGqX.js +406 -0
  24. package/dist/forms-Bg-CwGqX.js.map +1 -0
  25. package/dist/forms-Cl21hkHt.d.ts +281 -0
  26. package/dist/highlight.d.ts +17 -0
  27. package/dist/highlight.js +269 -0
  28. package/dist/highlight.js.map +1 -0
  29. package/dist/html-Bq1rFxX_.d.ts +92 -0
  30. package/dist/html-mNTKzaDD.js +241 -0
  31. package/dist/html-mNTKzaDD.js.map +1 -0
  32. package/dist/index.d.ts +123 -30
  33. package/dist/index.js +14 -6
  34. package/dist/index.js.map +1 -1
  35. package/dist/{inspect-BPchdWbU.js → inspect-BHpOw1LF.js} +1400 -121
  36. package/dist/inspect-BHpOw1LF.js.map +1 -0
  37. package/dist/{loader-Dc9OwY5I.js → loader-Dos_3NP0.js} +47 -11
  38. package/dist/loader-Dos_3NP0.js.map +1 -0
  39. package/dist/{navigate-CzLjnoPH.js → navigate-O78d_zGN.js} +115 -13
  40. package/dist/navigate-O78d_zGN.js.map +1 -0
  41. package/dist/produce-D0V0ICkz.d.ts +114 -0
  42. package/dist/produce-Doc91GkX.js +274 -0
  43. package/dist/produce-Doc91GkX.js.map +1 -0
  44. package/dist/routes-BZNt7DSZ.d.ts +38 -0
  45. package/dist/{rpc-9fSqL_YK.js → rpc-ygMRPmN4.js} +39 -23
  46. package/dist/rpc-ygMRPmN4.js.map +1 -0
  47. package/dist/runtime/batch.d.ts +23 -0
  48. package/dist/runtime/batch.js +69 -0
  49. package/dist/runtime/batch.js.map +1 -0
  50. package/dist/runtime/client.d.ts +5 -5
  51. package/dist/runtime/client.js +5 -1345
  52. package/dist/runtime/context.d.ts +2 -2
  53. package/dist/runtime/context.js +1 -1
  54. package/dist/runtime/devtools.d.ts +191 -5
  55. package/dist/runtime/devtools.js +1 -1
  56. package/dist/runtime/env.d.ts +44 -0
  57. package/dist/runtime/env.js +61 -0
  58. package/dist/runtime/env.js.map +1 -0
  59. package/dist/runtime/events.d.ts +42 -0
  60. package/dist/runtime/events.js +1 -0
  61. package/dist/runtime/forms.d.ts +2 -0
  62. package/dist/runtime/forms.js +1 -0
  63. package/dist/runtime/gather.d.ts +25 -0
  64. package/dist/runtime/gather.js +33 -0
  65. package/dist/runtime/gather.js.map +1 -0
  66. package/dist/runtime/hot.d.ts +1 -1
  67. package/dist/runtime/html.d.ts +2 -2
  68. package/dist/runtime/html.js +1 -1
  69. package/dist/runtime/loader.d.ts +2 -2
  70. package/dist/runtime/loader.js +2 -2
  71. package/dist/runtime/routes.d.ts +2 -21
  72. package/dist/runtime/routes.js +31 -1
  73. package/dist/runtime/routes.js.map +1 -1
  74. package/dist/runtime/server.d.ts +7 -5
  75. package/dist/runtime/server.js +6 -7
  76. package/dist/runtime/signals.d.ts +60 -3
  77. package/dist/runtime/signals.js +40 -2
  78. package/dist/runtime/signals.js.map +1 -1
  79. package/dist/runtime/static-loader.d.ts +2 -2
  80. package/dist/runtime/static-loader.js +1 -1
  81. package/dist/runtime/testing.d.ts +46 -5
  82. package/dist/runtime/testing.js +240 -33
  83. package/dist/runtime/testing.js.map +1 -1
  84. package/dist/runtime/values.d.ts +2 -0
  85. package/dist/runtime/values.js +24 -0
  86. package/dist/runtime/values.js.map +1 -0
  87. package/dist/secrets-BxagsJxJ.js +23 -0
  88. package/dist/secrets-BxagsJxJ.js.map +1 -0
  89. package/dist/server-CxVDYE_V.js +3417 -0
  90. package/dist/server-CxVDYE_V.js.map +1 -0
  91. package/dist/server-DuFYRXrd.d.ts +1460 -0
  92. package/dist/skew-FRmAy9iy.js +49 -0
  93. package/dist/skew-FRmAy9iy.js.map +1 -0
  94. package/dist/standard-schema-BNY82yX3.d.ts +63 -0
  95. package/dist/{static-loader-BcFh4ebX.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
  96. package/dist/static-loader-nZssh66R.js +333 -0
  97. package/dist/static-loader-nZssh66R.js.map +1 -0
  98. package/dist/stream-DCYZO4IF.js +424 -0
  99. package/dist/stream-DCYZO4IF.js.map +1 -0
  100. package/dist/values-B8C7CLvG.d.ts +63 -0
  101. package/dist/vite.d.ts +49 -1
  102. package/dist/vite.js +598 -68
  103. package/dist/vite.js.map +1 -1
  104. package/forms/forms.brm.ts +141 -0
  105. package/package.json +45 -3
  106. package/types.d.ts +9 -1
  107. package/dist/client-routes-DakuM32C.js.map +0 -1
  108. package/dist/context-BG8KCF3v.js +0 -15
  109. package/dist/context-BG8KCF3v.js.map +0 -1
  110. package/dist/context-aeo9esY9.d.ts +0 -16
  111. package/dist/cookies-Av5WFmcf.js.map +0 -1
  112. package/dist/devtools-BKjnHrnv.js +0 -113
  113. package/dist/devtools-BKjnHrnv.js.map +0 -1
  114. package/dist/devtools-panel-AWOn0VK2.js +0 -434
  115. package/dist/devtools-panel-AWOn0VK2.js.map +0 -1
  116. package/dist/files-DdT84mPy.js.map +0 -1
  117. package/dist/html-DEeoepg3.js +0 -152
  118. package/dist/html-DEeoepg3.js.map +0 -1
  119. package/dist/html-Du8jY2Cc.d.ts +0 -53
  120. package/dist/inspect-BPchdWbU.js.map +0 -1
  121. package/dist/loader-Dc9OwY5I.js.map +0 -1
  122. package/dist/navigate-CzLjnoPH.js.map +0 -1
  123. package/dist/produce-BRGHP7e0.js +0 -126
  124. package/dist/produce-BRGHP7e0.js.map +0 -1
  125. package/dist/produce-CtZ32UGG.d.ts +0 -60
  126. package/dist/rpc-9fSqL_YK.js.map +0 -1
  127. package/dist/runtime/client.js.map +0 -1
  128. package/dist/server-BxqjLUnV.d.ts +0 -753
  129. package/dist/server-DZsgnPKS.js +0 -1615
  130. package/dist/server-DZsgnPKS.js.map +0 -1
  131. package/dist/shared-CWYOd0H3.js +0 -40
  132. package/dist/shared-CWYOd0H3.js.map +0 -1
  133. package/dist/static-loader-ClNkHZGn.js +0 -185
  134. package/dist/static-loader-ClNkHZGn.js.map +0 -1
  135. package/dist/stream-bgNCMcaA.js +0 -280
  136. package/dist/stream-bgNCMcaA.js.map +0 -1
@@ -1,6 +1,30 @@
1
- import { t as Raw } from "./html-Du8jY2Cc.js";
2
- import { a as PageState, n as ElementReference } from "./produce-CtZ32UGG.js";
3
- import { t as Context } from "./context-aeo9esY9.js";
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";
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. */
@@ -17,12 +41,19 @@ interface ClientModule {
17
41
  load?: (part: string) => Promise<Part>;
18
42
  /** Server function ID to the memos that call it, as scope kind and update, for `refresh`. */
19
43
  refresh?: Record<string, Update[]>;
44
+ /**
45
+ * The `#try` blocks that catch errors of client code, by the scope kinds
46
+ * inside their bodies: the kind of the scope that holds the block, the
47
+ * anchor of the block, the render functions of the body and the `#catch`
48
+ * body, and the kinds of both bodies.
49
+ */
50
+ t?: Record<number, [owner: number, anchor: number, body: string, fallback: string, kinds: number[]]>;
20
51
  }
21
52
  /** A part of a client module: one client root, or the updates. */
22
53
  type Part = Record<string, unknown>;
23
54
  /** The instance of a scope in the page. */
24
55
  interface Scope {
25
- id: number;
56
+ id: ScopeId;
26
57
  /** The scope's ID in the compiled component. */
27
58
  k: number;
28
59
  p?: Scope;
@@ -31,13 +62,21 @@ interface Scope {
31
62
  s: unknown[];
32
63
  /** The item of a list item scope. */
33
64
  i?: unknown;
34
- c?: Record<number, number>;
65
+ c?: Record<number, ScopeId>;
35
66
  /** The scope that rendered a component's root scope. */
36
67
  o?: Scope;
68
+ /** For children that a component inserted, the scope where they are, for contexts. */
69
+ t?: Scope;
37
70
  /** The values that the scope provides, by context key. */
38
71
  v?: Record<string, unknown>;
39
72
  /** The slots that hold the contexts that the scope reads, by context key. */
40
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>;
41
80
  children: Set<Scope>;
42
81
  /** The `b-root` of the render that the server rendered the scope in. */
43
82
  r?: string;
@@ -49,20 +88,44 @@ interface Scope {
49
88
  w?: Set<string>;
50
89
  }
51
90
  interface CoreOptions {
91
+ /** The exports of the serial entry, for the values of the app in the page state. */
92
+ serial?: SerialEntry;
52
93
  /**
53
94
  * Imports the client module of a component. Undefined for a component that
54
95
  * has no client code, which a build leaves out.
55
96
  */
56
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>;
57
100
  /** Adds event listeners for the `b-on` attributes in new markup. */
58
101
  listen: (root: ParentNode) => void;
102
+ /** Tells the loader that the markup that `listen` scanned is in the page now. */
103
+ inserted?: () => void;
59
104
  /** The URL prefix of server function calls. Defaults to `/_brumate`. */
60
105
  rpc?: string;
106
+ /** The ID of the build of the page, for skew protection. Calls send it, and a deploy is noticed. */
107
+ build?: string;
108
+ /**
109
+ * Receives every error of client code first: of a handler, an effect, a
110
+ * `$client` callback or a memo that loads. `scope` is the ID of the scope
111
+ * that the code belongs to, when it has one.
112
+ */
113
+ onError?: (error: unknown, info: {
114
+ scope?: ScopeId;
115
+ }) => void;
61
116
  }
62
117
  /** The URL prefix of server function calls, from the options. */
63
118
  declare let rpcPrefix: string;
119
+ /** The ID of the build of the page, from the loader. Undefined on the dev server. */
120
+ declare let build: string | undefined;
121
+ /**
122
+ * Tells the page that the site changed since it loaded: a call answered 409
123
+ * with another build, or the code of a handler is gone. The loader then
124
+ * loads the next page in full, and an app can save a draft first.
125
+ */
126
+ declare function skew(reason: "call" | "code" | "defer"): void;
64
127
  /** The scopes of the page, by ID. */
65
- declare const scopes: Map<number, Scope>;
128
+ declare const scopes: Map<ScopeId, Scope>;
66
129
  /** What modules of optional features add to the core. See `client-routes.ts` and `hot`. */
67
130
  declare const hooks: {
68
131
  /** Changes a state record before its scopes are added, such as for a page that navigation added. */
@@ -74,15 +137,47 @@ declare const hooks: {
74
137
  interface DevtoolsHooks {
75
138
  /** The core started, with the scopes of the page, and a way to write a slot, as a handler does. */
76
139
  attach?(core: {
77
- scopes: Map<number, Scope>;
140
+ scopes: Map<ScopeId, Scope>;
78
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>;
79
144
  }): void;
80
145
  /** A handler starts for an event. */
81
146
  handler?(ref: string, element: Element, event?: Event): void;
82
147
  /** A part of a component's client code loaded. */
83
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;
84
172
  /** A slot got a new value. */
85
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;
86
181
  }
87
182
  /** The global key of the devtools hooks. */
88
183
  declare const DEVTOOLS: unique symbol;
@@ -123,24 +218,64 @@ declare function remount(detail: {
123
218
  declare function leavePage(): void;
124
219
  /** Reads the page state. The loader calls it once, before the first handler. */
125
220
  declare function init(value: CoreOptions): void;
126
- declare function loadModule(id: string): Promise<ClientModule>;
127
- declare function loadPart(module: ClientModule, name: string): Promise<Part>;
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>;
128
235
  /**
129
236
  * Runs the handler `ref` for an element. The scope comes from the element's
130
237
  * `b-b` anchor, or from the nearest element around it that has one, which
131
238
  * the compiler checks is in the same scope.
132
239
  */
133
- declare function handle(element: Element, ref: string, event?: Event): Promise<unknown>;
240
+ declare function handle(element: Element, entry: string, event?: Event): Promise<unknown>;
241
+ /**
242
+ * Reports an error of client code: a handler, an effect, a `$client`
243
+ * callback or a memo that loads. It renders the `#catch` body of the nearest
244
+ * `#try` around the scope of the code, through the parents and the owners of
245
+ * scopes. Without one, the page gets a `brumate:error` event on `window`,
246
+ * with the error and the scope, and the error is logged.
247
+ */
248
+ declare function fail(scope: Scope | undefined, error: unknown): void;
134
249
  /** Returns the instance of a scope by its ID. */
135
- declare function scopeOf(id: number): Scope | undefined;
250
+ declare function scopeOf(id: ScopeId): Scope | undefined;
136
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
+ */
137
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;
138
267
  /**
139
268
  * The names of a call of a module function, for its shared code. Each ref
140
269
  * is a slot of `scope`, `[scope, slot]` for a slot of another scope, or
141
270
  * `[value]` for a value that does not change, such as a literal argument.
142
271
  */
143
272
  declare function cells(scope: Scope, links: unknown[], names: string[]): Record<string, unknown>;
273
+ /**
274
+ * Computes a memo of `$debounced` after its value stops changing for `ms`,
275
+ * or one of `$throttled` at most once every `ms`, with the last value after
276
+ * the wait. The memo is pending while it waits.
277
+ */
278
+ declare function timed(scope: Scope, slot: number, ms: number, throttle: boolean, compute: () => unknown): void;
144
279
  /**
145
280
  * Writes the result of an async memo when it arrives. Until then the slot
146
281
  * keeps its value, and `pending` is true. Only the latest load is written.
@@ -164,6 +299,11 @@ declare function track<T>(request: Promise<T>): Promise<T>;
164
299
  declare function pending(scope: Scope, slot: number): boolean;
165
300
  /** `x++`, `x--`, `++x` and `--x`. */
166
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>;
167
307
  declare function descendants(scope: Scope, kind: number, result?: Scope[]): Scope[];
168
308
  /**
169
309
  * Removes a scope from the page: its cleanups run, and its memo state goes,
@@ -186,7 +326,7 @@ declare function content(scope: Scope, anchor: number, value: unknown): void;
186
326
  */
187
327
  declare function writeText(scope: Scope, anchor: number, value: unknown): void;
188
328
  declare function attr(scope: Scope, anchor: number, name: string, value: unknown): void;
189
- declare function attrs(scope: Scope, anchor: number, values: Record<string, unknown>): void;
329
+ declare function attrs(scope: Scope, anchor: number, values: Record<string, unknown>, own?: string[]): void;
190
330
  type Render = (parent: Scope, item?: unknown, index?: number) => string;
191
331
  /** Shows the branch at `index` of `#if` or `#switch`, or nothing for -1. */
192
332
  declare function branch(scope: Scope, anchor: number, index: number, renders: (Render | undefined)[], kinds: number[]): void;
@@ -197,8 +337,11 @@ declare function rekey(scope: Scope, anchor: number, value: unknown, render: Ren
197
337
  * body throws, the fallback renders again with the error.
198
338
  */
199
339
  declare function reset(scope: Scope, anchor: number, id: string, body: string, fallback: string, kinds: number[]): Promise<void>;
200
- /** Renders the body of a `#client` block once. */
201
- declare function fill(scope: Scope, anchor: number, render: Render): void;
340
+ /**
341
+ * Renders the body of a `#client` block once, in place of its fallback.
342
+ * `kinds` are the scope IDs inside the fallback, whose instances go.
343
+ */
344
+ declare function fill(scope: Scope, anchor: number, render: Render, kinds?: number[]): void;
202
345
  /**
203
346
  * Shows or hides the body of an `#offscreen` block. A body that the page
204
347
  * does not have yet renders the first time it shows. `kind` is the body's
@@ -211,6 +354,8 @@ interface HiddenBody {
211
354
  ranges: [start: Comment, end: Comment][];
212
355
  }
213
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[];
214
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;
215
360
  /** Sets a style variable on the top-level elements of a component instance. */
216
361
  declare function setVar(scope: Scope, name: string, value: unknown): void;
@@ -218,7 +363,12 @@ declare function setVar(scope: Scope, name: string, value: unknown): void;
218
363
  declare function updateContext(scope: Scope, context: Context<unknown>, value: unknown): void;
219
364
  /** Sets the title of the page. */
220
365
  declare function title(value: unknown): void;
221
- /** Writes a prop of a child component. */
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;
222
372
  declare function prop(scope: Scope, anchor: number, name: string, value: unknown): void;
223
373
  /** Runs an effect or a `$client` callback, after the cleanup of its previous run. */
224
374
  declare function effect(scope: Scope, name: string, callback: () => unknown): void;
@@ -231,8 +381,21 @@ declare function action(name: string, id: string, method?: string, result?: stri
231
381
  declare function submitAction(form: HTMLFormElement, submitter: HTMLElement | null): void;
232
382
  /** Calls a server function. */
233
383
  declare function rpc(id: string, args: unknown[]): Promise<unknown>;
234
- /** Renders a value inserted in markup. */
235
- declare function insert(value: unknown): string;
384
+ /** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */
385
+ declare function insert(value: unknown, _ctx?: unknown, scope?: Scope | ScopeId): string;
386
+ /**
387
+ * Children of a component that the client renders. They render where the
388
+ * component inserts them, so they read the contexts that it provides. `from`
389
+ * is the scope of the markup that wrote them.
390
+ */
391
+ declare class Children {
392
+ private readonly from;
393
+ private readonly html;
394
+ constructor(from: Scope | ScopeId | undefined, html: () => string);
395
+ render(at: Scope | undefined): string;
396
+ }
397
+ /** The children of a component that the client renders. See `Children`. */
398
+ declare function children(from: Scope | ScopeId | undefined, html: () => string): Children;
236
399
  /** A component's client render function, from its `?brumate-render` module. */
237
400
  type Component<P = any> = (props: P) => string;
238
401
  /**
@@ -240,22 +403,38 @@ type Component<P = any> = (props: P) => string;
240
403
  * records the child's scope so the parent can update its props.
241
404
  */
242
405
  declare function component<P>(Child: Component<P>, props: P, _ctx?: unknown, scope?: Scope | number, anchor?: number): string;
243
- declare function dynamic(tag: unknown, attributes: Record<string, unknown>, children: Raw | undefined, _ctx?: unknown, scope?: Scope | number): string;
406
+ declare function dynamic(tag: unknown, attributes: Record<string, unknown>, inner: Raw | Children | undefined, _ctx?: unknown, scope?: Scope | number): string;
244
407
  /** Work that waits until rendered markup is in the page. */
245
408
  declare const afterInsert: (() => void)[];
246
409
  /** Creates a scope for markup that the client renders, and returns its ID. */
247
- declare function createScope(kind: number, parent?: Scope | number, module?: string): number;
248
- /** The ID that `$id()` makes. Client scope IDs are negative, so they differ from the server's. */
249
- declare function makeId(scope: Scope | number, index: number): string;
410
+ declare function createScope(kind: number, parent?: Scope | ScopeId, module?: string): number;
411
+ /**
412
+ * The ID that `$id()` makes, as the server does. Client scope IDs are
413
+ * negative, so they differ from the server's.
414
+ */
415
+ declare function makeId(scope: Scope | ScopeId, index: number): string;
250
416
  /** Sets the owner of the next component's root scope. */
251
- declare function setOwner(scope: Scope | number): void;
417
+ declare function setOwner(scope: Scope | ScopeId): void;
252
418
  /** Provides a value of a context to the scopes inside `scope`. */
253
- declare function provideValue<T>(context: Context<T>, value: T, scope: Scope | number): void;
419
+ declare function provideValue<T>(context: Context<T>, value: T, scope: Scope | ScopeId): void;
254
420
  /** Reads a context, and records its slot so that changes to the provided value reach it. */
255
- declare function consumeContext<T>(context: Context<T>, scope: Scope | number, slot?: number): T;
256
- declare function setSlots(id: number, values: unknown[]): void;
257
- declare function setItem(id: number, value: unknown): void;
258
- declare function elementAt(scope: number, anchor: number): ElementReference;
421
+ declare function consumeContext<T>(context: Context<T>, scope: Scope | ScopeId, slot?: number): T;
422
+ /**
423
+ * Writes a context that the runtime provides to the whole page, and the
424
+ * slot of every scope that reads it without a provider above it.
425
+ */
426
+ declare function setGlobal(key: string, value: unknown): void;
427
+ /** Reads the route of the page again, after navigation changed it. */
428
+ declare function updateRoute(): void;
429
+ declare function setSlots(id: ScopeId, values: unknown[]): void;
430
+ declare function setItem(id: ScopeId, value: unknown): void;
431
+ declare function elementAt(scope: ScopeId, anchor: number): ElementReference;
432
+ /**
433
+ * Warns in development that the browser renders a `#defer` block of a
434
+ * component, such as inside a `#client` body of its parent. Only the server
435
+ * renders the body, so the fallback stays.
436
+ */
437
+ declare function deferInBrowser(id: string): void;
259
438
  /** Adds the markup of a `#head` block to the document's head. */
260
439
  declare function addHead(html: string): void;
261
440
  /** Adds the markup of a `#portal` block at the end of the page, after the markup around it. */
@@ -263,7 +442,7 @@ declare function addPortal(html: string): void;
263
442
  /** Adds a component's stylesheet to the page, if the server did not. */
264
443
  declare function addStyle(id: string, css: string): string;
265
444
  /** A function prop rendered on the client calls the parent's exported handler. */
266
- 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;
267
446
  /**
268
447
  * What the loader calls. It is one export, so the loader's import of the core
269
448
  * names one export, and a build keeps the rest only when components call them.
@@ -273,7 +452,9 @@ declare const loader: {
273
452
  handle: typeof handle;
274
453
  dispose: typeof dispose;
275
454
  submitAction: typeof submitAction;
455
+ setGlobal: typeof setGlobal;
456
+ updateRoute: typeof updateRoute;
276
457
  };
277
458
  //#endregion
278
- export { removeScope as $, get as A, loadModule as B, descendants as C, elementAt as D, effect as E, init as F, offscreen as G, loader as H, insert as I, prop as J, pending as K, leavePage as L, handle as M, handlerProp as N, fill as O, hooks as P, removeRoot as Q, leaveRoutes as R, createScope as S, dynamic as T, makeId as U, loadPart as V, memo as W, rekey as X, provideValue as Y, remount as Z, branch as _, DevtoolsHooks as a, set as at, consumeContext as b, Scope as c, setSlots as ct, addPortal as d, text as dt, reset as et, addStyle as f, title as ft, attrs as g, writeText as gt, attr as h, updateContext as ht, DEVTOOLS as i, scopes as it, guess as j, forget as k, action as l, setVar as lt, asyncMemo as m, update as mt, Component as n, rpcPrefix as nt, HiddenBody as o, setItem as ot, afterInsert as p, track as pt, portalTo as q, CoreOptions as r, scopeOf as rt, Part as s, setOwner as st, ClientModule as t, rpc as tt, addHead as u, submitAction as ut, cells as v, dispose as w, content as x, component as y, list as z };
279
- //# sourceMappingURL=client-DwJInP_a.d.ts.map
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
@@ -1,11 +1,21 @@
1
1
  //#region src/runtime/client-routes.ts
2
+ /** Reads an ID, as `parseId` in `shared.ts` does. This module imports no code of its own. */
3
+ function readId(text) {
4
+ return /^-?\d+$/.test(text) ? Number(text) : text;
5
+ }
6
+ /** Adds a number to an ID, as `shiftId` in `shared.ts` does. */
7
+ function shiftId(id, by) {
8
+ if (typeof id === "number") return id + by;
9
+ const dot = id.indexOf(".");
10
+ return `${Number(id.slice(0, dot)) + by}${id.slice(dot)}`;
11
+ }
2
12
  /** Adds a number to the scope IDs of a state record. */
3
13
  function shiftState(core, state, by) {
4
14
  const { ElementReference, FunctionReference } = core;
5
15
  const seen = /* @__PURE__ */ new Set();
6
16
  const shiftValue = (value) => {
7
- if (value instanceof ElementReference) return new ElementReference(value.scope + by, value.anchor);
8
- if (value instanceof FunctionReference) return new FunctionReference(value.ref, value.scope + by);
17
+ if (value instanceof ElementReference) return new ElementReference(shiftId(value.scope, by), value.anchor);
18
+ if (value instanceof FunctionReference) return new FunctionReference(value.ref, shiftId(value.scope, by));
9
19
  if (value instanceof Promise) return value.then(shiftValue);
10
20
  if (typeof value === "object" && value !== null && !seen.has(value)) {
11
21
  seen.add(value);
@@ -17,11 +27,11 @@ function shiftState(core, state, by) {
17
27
  return value;
18
28
  };
19
29
  const result = {};
20
- for (const [key, record] of Object.entries(state)) result[Number(key) + by] = {
30
+ for (const [key, record] of Object.entries(state)) result[shiftId(readId(key), by)] = {
21
31
  ...record,
22
- p: record.p === void 0 ? void 0 : record.p + by,
23
- o: record.o === void 0 ? void 0 : record.o + by,
24
- c: record.c && Object.fromEntries(Object.entries(record.c).map(([anchor, id]) => [anchor, id + by])),
32
+ p: record.p === void 0 ? void 0 : shiftId(record.p, by),
33
+ o: record.o === void 0 ? void 0 : shiftId(record.o, by),
34
+ c: record.c && Object.fromEntries(Object.entries(record.c).map(([anchor, id]) => [anchor, shiftId(id, by)])),
25
35
  s: record.s?.map(shiftValue)
26
36
  };
27
37
  return result;
@@ -46,13 +56,13 @@ function routeRecord(core, script, state) {
46
56
  const offset = Number(script.getAttribute("b-offset") ?? 0);
47
57
  const value = offset ? shiftState(core, state, offset) : state;
48
58
  const drop = script.getAttribute("b-drop");
49
- if (drop) dropScopes(core, new Set(drop.split(",").map(Number)));
59
+ if (drop) dropScopes(core, new Set(drop.split(",").map(readId)));
50
60
  const list = script.getAttribute("b-roots");
51
61
  if (list === null) return value;
52
- const roots = new Set(list.split(",").filter(Boolean).map(Number));
62
+ const roots = new Set(list.split(",").filter(Boolean).map(readId));
53
63
  const alias = /* @__PURE__ */ new Map();
54
64
  for (const pair of (script.getAttribute("b-alias") ?? "").split(",").filter(Boolean)) {
55
- const [from, to] = pair.split(":").map(Number);
65
+ const [from, to] = pair.split(":").map(readId);
56
66
  alias.set(from, to);
57
67
  }
58
68
  const kept = (id) => {
@@ -65,11 +75,14 @@ function routeRecord(core, script, state) {
65
75
  };
66
76
  const resolve = (id) => id === void 0 ? void 0 : alias.get(id) ?? id;
67
77
  const result = {};
68
- for (const [key, record] of Object.entries(value)) if (kept(Number(key))) result[Number(key)] = {
69
- ...record,
70
- p: resolve(record.p),
71
- o: resolve(record.o)
72
- };
78
+ for (const [key, record] of Object.entries(value)) {
79
+ const id = readId(key);
80
+ if (kept(id)) result[id] = {
81
+ ...record,
82
+ p: resolve(record.p),
83
+ o: resolve(record.o)
84
+ };
85
+ }
73
86
  return result;
74
87
  }
75
88
  /**
@@ -91,4 +104,4 @@ const ready = import("./runtime/client.js").then(({ ElementReference, FunctionRe
91
104
  //#endregion
92
105
  export { ready };
93
106
 
94
- //# sourceMappingURL=client-routes-DakuM32C.js.map
107
+ //# sourceMappingURL=client-routes-JTbGtukf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-routes-JTbGtukf.js","names":[],"sources":["../src/runtime/client-routes.ts"],"sourcesContent":["// What the core needs to read the pages that client navigation adds. Only\n// `navigate.ts` writes the attributes that this module reads, so the loader\n// imports it when it navigates or finds such a record, and a page that never\n// navigates does not load it. Importing it sets the core's `record` hook.\n//\n// It reads the core with `import()`, as `rpc.ts` does, and imports nothing\n// else. A static import of the core would make the package build move the\n// core into a chunk behind a module that only re-exports it, and a static\n// import of `shared.ts` would split that module out of the core of a page.\n// The core is loaded already, or loads with this module.\n\nimport type * as Client from './client.ts';\nimport type { Scope } from './client.ts';\nimport type { PageState, ScopeId, ScopeState } from './shared.ts';\n\n/** The parts of the core that this module uses. */\ntype Core = Pick<\n typeof Client,\n 'ElementReference' | 'FunctionReference' | 'hooks' | 'removeScope' | 'scopes'\n>;\n\n/** Reads an ID, as `parseId` in `shared.ts` does. This module imports no code of its own. */\nfunction readId(text: string): ScopeId {\n return /^-?\\d+$/.test(text) ? Number(text) : text;\n}\n\n/** Adds a number to an ID, as `shiftId` in `shared.ts` does. */\nfunction shiftId(id: ScopeId, by: number): ScopeId {\n if (typeof id === 'number') {\n return id + by;\n }\n const dot = id.indexOf('.');\n return `${Number(id.slice(0, dot)) + by}${id.slice(dot)}`;\n}\n\n/** Adds a number to the scope IDs of a state record. */\nfunction shiftState(core: Core, state: PageState, by: number): PageState {\n const { ElementReference, FunctionReference } = core;\n const seen = new Set<object>();\n // References to elements and client functions name the scope of their markup.\n const shiftValue = (value: unknown): unknown => {\n if (value instanceof ElementReference) {\n return new ElementReference(shiftId(value.scope, by), value.anchor);\n }\n if (value instanceof FunctionReference) {\n return new FunctionReference(value.ref, shiftId(value.scope, by));\n }\n // A later record settles it, with a value whose IDs move too.\n if (value instanceof Promise) {\n return value.then(shiftValue);\n }\n if (typeof value === 'object' && value !== null && !seen.has(value)) {\n seen.add(value);\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n value[index] = shiftValue(item);\n });\n } else if (Object.getPrototypeOf(value) === Object.prototype) {\n for (const [key, item] of Object.entries(value)) {\n (value as Record<string, unknown>)[key] = shiftValue(item);\n }\n }\n }\n return value;\n };\n const result: PageState = {};\n for (const [key, record] of Object.entries(state)) {\n result[shiftId(readId(key), by)] = {\n ...record,\n p: record.p === undefined ? undefined : shiftId(record.p, by),\n o: record.o === undefined ? undefined : shiftId(record.o, by),\n c:\n record.c &&\n Object.fromEntries(\n Object.entries(record.c).map(([anchor, id]) => [anchor, shiftId(id, by)]),\n ),\n s: record.s?.map(shiftValue),\n };\n }\n return result;\n}\n\n/** Removes scopes and the scopes inside them, and runs their cleanups. */\nfunction dropScopes(core: Core, roots: Set<ScopeId>): void {\n const inside = (scope: Scope): boolean => {\n for (let current: Scope | undefined = scope; current; current = current.p ?? current.o) {\n if (roots.has(current.id)) {\n return true;\n }\n }\n return false;\n };\n // Deleting from a map while iterating it is safe.\n for (const scope of core.scopes.values()) {\n if (inside(scope)) {\n core.removeScope(scope);\n }\n }\n}\n\n/**\n * Reads the attributes that navigation set on a state record. A page whose\n * IDs started at another number, such as a prerendered file, has them moved\n * with `b-offset`. A page that replaced only some routes of the one before\n * it drops the old routes with `b-drop`, and adds only the scopes inside\n * `b-roots`, with the scopes of the kept layouts in place of the new\n * page's copies of them, by `b-alias`.\n */\nfunction routeRecord(core: Core, script: Element, state: PageState): PageState {\n // Only records with scopes hold IDs. Later records settle promises, which `shiftState` wraps.\n const offset = Number(script.getAttribute('b-offset') ?? 0);\n const value = offset ? shiftState(core, state, offset) : state;\n const drop = script.getAttribute('b-drop');\n if (drop) {\n dropScopes(core, new Set(drop.split(',').map(readId)));\n }\n const list = script.getAttribute('b-roots');\n if (list === null) {\n return value;\n }\n const roots = new Set(list.split(',').filter(Boolean).map(readId));\n const alias = new Map<ScopeId, ScopeId>();\n for (const pair of (script.getAttribute('b-alias') ?? '').split(',').filter(Boolean)) {\n const [from, to] = pair.split(':').map(readId) as [ScopeId, ScopeId];\n alias.set(from, to);\n }\n const kept = (id: ScopeId): boolean => {\n for (let current: ScopeId | undefined = id; current !== undefined;) {\n if (roots.has(current)) {\n return true;\n }\n const record: ScopeState | undefined = value[current];\n current = record?.p ?? record?.o;\n }\n return false;\n };\n const resolve = (id: ScopeId | undefined): ScopeId | undefined =>\n id === undefined ? undefined : (alias.get(id) ?? id);\n const result: PageState = {};\n for (const [key, record] of Object.entries(value)) {\n // The new page renders the kept layouts again. Their scopes are not added.\n const id = readId(key);\n if (kept(id)) {\n result[id] = { ...record, p: resolve(record.p), o: resolve(record.o) };\n }\n }\n return result;\n}\n\n/**\n * Settles once the core reads records with this module, with the function\n * that forgets the page before navigation replaces it, or only stops reading\n * when layouts stay.\n */\nexport const ready: Promise<(partial: boolean) => void> = import('./client.ts').then(\n ({ ElementReference, FunctionReference, hooks, leavePage, leaveRoutes, removeScope, scopes }) => {\n const core = { ElementReference, FunctionReference, hooks, removeScope, scopes };\n hooks.record = (script, state) => routeRecord(core, script, state);\n return (partial) => (partial ? leaveRoutes() : leavePage());\n },\n);\n"],"mappings":";;AAsBA,SAAS,OAAO,MAAuB;CACrC,OAAO,UAAU,KAAK,IAAI,IAAI,OAAO,IAAI,IAAI;AAC/C;;AAGA,SAAS,QAAQ,IAAa,IAAqB;CACjD,IAAI,OAAO,OAAO,UAChB,OAAO,KAAK;CAEd,MAAM,MAAM,GAAG,QAAQ,GAAG;CAC1B,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,MAAM,GAAG;AACxD;;AAGA,SAAS,WAAW,MAAY,OAAkB,IAAuB;CACvE,MAAM,EAAE,kBAAkB,sBAAsB;CAChD,MAAM,uBAAO,IAAI,IAAY;CAE7B,MAAM,cAAc,UAA4B;EAC9C,IAAI,iBAAiB,kBACnB,OAAO,IAAI,iBAAiB,QAAQ,MAAM,OAAO,EAAE,GAAG,MAAM,MAAM;EAEpE,IAAI,iBAAiB,mBACnB,OAAO,IAAI,kBAAkB,MAAM,KAAK,QAAQ,MAAM,OAAO,EAAE,CAAC;EAGlE,IAAI,iBAAiB,SACnB,OAAO,MAAM,KAAK,UAAU;EAE9B,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,KAAK,IAAI,KAAK,GAAG;GACnE,KAAK,IAAI,KAAK;GACd,IAAI,MAAM,QAAQ,KAAK,GACrB,MAAM,SAAS,MAAM,UAAU;IAC7B,MAAM,SAAS,WAAW,IAAI;GAChC,CAAC;QACI,IAAI,OAAO,eAAe,KAAK,MAAM,OAAO,WACjD,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,KAAK,GAC5C,MAAmC,OAAO,WAAW,I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AO,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;CACjE,MAAM,wBAAQ,IAAI,IAAsB;CACxC,KAAK,MAAM,SAAS,OAAO,aAAa,SAAS,KAAK,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,GAAG;EACpF,MAAM,CAAC,MAAM,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;EAC7C,MAAM,IAAI,MAAM,EAAE;CACpB;CACA,MAAM,QAAQ,OAAyB;EACrC,KAAK,IAAI,UAA+B,IAAI,YAAY,KAAA,IAAY;GAClE,IAAI,MAAM,IAAI,OAAO,GACnB,OAAO;GAET,MAAM,SAAiC,MAAM;GAC7C,UAAU,QAAQ,KAAK,QAAQ;EACjC;EACA,OAAO;CACT;CACA,MAAM,WAAW,OACf,OAAO,KAAA,IAAY,KAAA,IAAa,MAAM,IAAI,EAAE,KAAK;CACnD,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,KAAK,GAAG;EAEjD,MAAM,KAAK,OAAO,GAAG;EACrB,IAAI,KAAK,EAAE,GACT,OAAO,MAAM;GAAE,GAAG;GAAQ,GAAG,QAAQ,OAAO,CAAC;GAAG,GAAG,QAAQ,OAAO,CAAC;EAAE;CAEzE;CACA,OAAO;AACT;;;;;;AAOA,MAAa,QAA6C,OAAO,sBAAc,CAAC,MAC7E,EAAE,kBAAkB,mBAAmB,OAAO,WAAW,aAAa,aAAa,aAAa;CAC/F,MAAM,OAAO;EAAE;EAAkB;EAAmB;EAAO;EAAa;CAAO;CAC/E,MAAM,UAAU,QAAQ,UAAU,YAAY,MAAM,QAAQ,KAAK;CACjE,QAAQ,YAAa,UAAU,YAAY,IAAI,UAAU;AAC3D,CACF"}
@@ -0,0 +1,27 @@
1
+ //#region src/runtime/context.ts
2
+ /**
3
+ * Creates a context. `key` names it in the page state, so it must be unique
4
+ * in the app and the same on the server and the client.
5
+ */
6
+ function createContext(key, defaultValue) {
7
+ return {
8
+ key,
9
+ defaultValue
10
+ };
11
+ }
12
+ /** The key of the context of `$route`. The server and the loader write it. */
13
+ const ROUTE_KEY = "brumate.route";
14
+ /** The key of the context of `$navigation`. The loader writes it. */
15
+ const NAVIGATION_KEY = "brumate.navigation";
16
+ /** The context that `$route` reads. Its value comes from the request on the server, and from `location` in the browser. */
17
+ const routeContext = createContext(ROUTE_KEY, {
18
+ url: new URL("http://localhost/"),
19
+ search: new URLSearchParams(),
20
+ params: {}
21
+ });
22
+ /** The context that `$navigation` reads. The loader writes it while a page loads. */
23
+ const navigationContext = createContext(NAVIGATION_KEY, { pending: false });
24
+ //#endregion
25
+ export { routeContext as a, navigationContext as i, ROUTE_KEY as n, createContext as r, NAVIGATION_KEY as t };
26
+
27
+ //# sourceMappingURL=context-CTiSzQRc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-CTiSzQRc.js","names":[],"sources":["../src/runtime/context.ts"],"sourcesContent":["/** A value that a component provides to the components inside it. */\nexport interface Context<T> {\n /** The same on the server and the client, so the page state can name the context. */\n readonly key: string;\n /** The value of a component that reads the context without a provider above it. */\n readonly defaultValue: T;\n}\n\n/**\n * Creates a context. `key` names it in the page state, so it must be unique\n * in the app and the same on the server and the client.\n */\nexport function createContext<T>(key: string, defaultValue: T): Context<T> {\n return { key, defaultValue };\n}\n\n/** The route of the page, for `$route`. */\nexport interface Route<P = Record<string, string>> {\n /** The URL of the page. */\n url: URL;\n /** The query string of the page, as `url.searchParams`. */\n search: URLSearchParams;\n /** The params of the route, such as `{ id: '3' }` for `/issues/[id]`. */\n params: P;\n}\n\n/** The navigation that loads, for `$navigation`. */\nexport interface NavigationState {\n /** True while a page loads without a full page load. */\n pending: boolean;\n /** The URL of the page that is left, while one loads. */\n from?: string;\n /** The URL of the page that loads. */\n to?: string;\n}\n\n/** The key of the context of `$route`. The server and the loader write it. */\nexport const ROUTE_KEY = 'brumate.route';\n/** The key of the context of `$navigation`. The loader writes it. */\nexport const NAVIGATION_KEY = 'brumate.navigation';\n\n/** The context that `$route` reads. Its value comes from the request on the server, and from `location` in the browser. */\nexport const routeContext: Context<Route> = createContext(ROUTE_KEY, {\n url: new URL('http://localhost/'),\n search: new URLSearchParams(),\n params: {},\n});\n\n/** The context that `$navigation` reads. The loader writes it while a page loads. */\nexport const navigationContext: Context<NavigationState> = createContext(NAVIGATION_KEY, {\n pending: false,\n});\n"],"mappings":";;;;;AAYA,SAAgB,cAAiB,KAAa,cAA6B;CACzE,OAAO;EAAE;EAAK;CAAa;AAC7B;;AAuBA,MAAa,YAAY;;AAEzB,MAAa,iBAAiB;;AAG9B,MAAa,eAA+B,cAAc,WAAW;CACnE,KAAK,IAAI,IAAI,mBAAmB;CAChC,QAAQ,IAAI,gBAAgB;CAC5B,QAAQ,CAAC;AACX,CAAC;;AAGD,MAAa,oBAA8C,cAAc,gBAAgB,EACvF,SAAS,MACX,CAAC"}
@@ -0,0 +1,42 @@
1
+ //#region src/runtime/context.d.ts
2
+ /** A value that a component provides to the components inside it. */
3
+ interface Context<T> {
4
+ /** The same on the server and the client, so the page state can name the context. */
5
+ readonly key: string;
6
+ /** The value of a component that reads the context without a provider above it. */
7
+ readonly defaultValue: T;
8
+ }
9
+ /**
10
+ * Creates a context. `key` names it in the page state, so it must be unique
11
+ * in the app and the same on the server and the client.
12
+ */
13
+ declare function createContext<T>(key: string, defaultValue: T): Context<T>;
14
+ /** The route of the page, for `$route`. */
15
+ interface Route<P = Record<string, string>> {
16
+ /** The URL of the page. */
17
+ url: URL;
18
+ /** The query string of the page, as `url.searchParams`. */
19
+ search: URLSearchParams;
20
+ /** The params of the route, such as `{ id: '3' }` for `/issues/[id]`. */
21
+ params: P;
22
+ }
23
+ /** The navigation that loads, for `$navigation`. */
24
+ interface NavigationState {
25
+ /** True while a page loads without a full page load. */
26
+ pending: boolean;
27
+ /** The URL of the page that is left, while one loads. */
28
+ from?: string;
29
+ /** The URL of the page that loads. */
30
+ to?: string;
31
+ }
32
+ /** The key of the context of `$route`. The server and the loader write it. */
33
+ declare const ROUTE_KEY = "brumate.route";
34
+ /** The key of the context of `$navigation`. The loader writes it. */
35
+ declare const NAVIGATION_KEY = "brumate.navigation";
36
+ /** The context that `$route` reads. Its value comes from the request on the server, and from `location` in the browser. */
37
+ declare const routeContext: Context<Route>;
38
+ /** The context that `$navigation` reads. The loader writes it while a page loads. */
39
+ declare const navigationContext: Context<NavigationState>;
40
+ //#endregion
41
+ export { Route as a, routeContext as c, ROUTE_KEY as i, NAVIGATION_KEY as n, createContext as o, NavigationState as r, navigationContext as s, Context as t };
42
+ //# sourceMappingURL=context-btHuB01Z.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-Av5WFmcf.js.map
176
+ //# sourceMappingURL=cookies-BzllthiF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies-BzllthiF.js","names":[],"sources":["../src/runtime/cookies.ts"],"sourcesContent":["// Cookies and sessions, for server functions, rendering, middleware and\n// endpoints. They read the request of a `RequestEvent` and write `set-cookie`\n// headers on its response.\n\nimport type { RequestEvent } from './request.ts';\n\nexport interface CookieOptions {\n /** Seconds until the cookie expires. Without it, the cookie lasts until the browser closes. */\n maxAge?: number;\n expires?: Date;\n /** Defaults to `/`. */\n path?: string;\n domain?: string;\n /** Defaults to true when the request is HTTPS. */\n secure?: boolean;\n /** Keeps the cookie from browser code. Defaults to true. */\n httpOnly?: boolean;\n /** Defaults to `lax`. */\n sameSite?: 'strict' | 'lax' | 'none';\n}\n\n/** Reads the cookies of a `cookie` header. */\nexport function parseCookies(header: string | null): Record<string, string> {\n const result: Record<string, string> = {};\n for (const part of (header ?? '').split(';')) {\n const index = part.indexOf('=');\n if (index === -1) {\n continue;\n }\n const name = part.slice(0, index).trim();\n if (name && !(name in result)) {\n const value = part.slice(index + 1).trim();\n try {\n result[name] = decodeURIComponent(value);\n } catch {\n result[name] = value;\n }\n }\n }\n return result;\n}\n\n/** Writes a `set-cookie` header value. */\nexport function serializeCookie(name: string, value: string, options: CookieOptions = {}): string {\n if (!/^[\\w!#$%&'*+.^`|~-]+$/.test(name)) {\n throw new Error(`\"${name}\" is not a valid cookie name`);\n }\n const parts = [`${name}=${encodeURIComponent(value)}`, `Path=${options.path ?? '/'}`];\n if (options.maxAge !== undefined) {\n parts.push(`Max-Age=${Math.floor(options.maxAge)}`);\n }\n if (options.expires) {\n parts.push(`Expires=${options.expires.toUTCString()}`);\n }\n if (options.domain) {\n parts.push(`Domain=${options.domain}`);\n }\n if (options.httpOnly !== false) {\n parts.push('HttpOnly');\n }\n if (options.secure) {\n parts.push('Secure');\n }\n parts.push(\n `SameSite=${(options.sameSite ?? 'lax').replace(/^./, (letter) => letter.toUpperCase())}`,\n );\n return parts.join('; ');\n}\n\n/** The parsed `cookie` header of each event, with the header it was parsed from. */\nconst parsed = new WeakMap<\n RequestEvent,\n { header: string | null; cookies: Record<string, string> }\n>();\n\n/** The cookies of the request, with the ones that this request set or deleted. */\nexport function getCookies(event: RequestEvent): Record<string, string> {\n const header = event.request.headers.get('cookie');\n let cached = parsed.get(event);\n if (cached?.header !== header) {\n cached = { header, cookies: parseCookies(header) };\n parsed.set(event, cached);\n }\n // A copy, so the caller cannot change the cache.\n const result = { ...cached.cookies };\n for (const [name, value] of event.cookies ?? []) {\n if (value === undefined) {\n delete result[name];\n } else {\n result[name] = value;\n }\n }\n return result;\n}\n\n/** Sets a cookie on the response of an event. See `RequestEvent.setCookie`. */\nexport function setCookie(\n event: RequestEvent,\n name: string,\n value: string,\n options: CookieOptions = {},\n): void {\n event.personal = true;\n const secure = options.secure ?? new URL(event.request.url).protocol === 'https:';\n event.headers.append('set-cookie', serializeCookie(name, value, { ...options, secure }));\n event.cookies ??= new Map();\n event.cookies.set(name, value);\n}\n\n/** Deletes a cookie. Pass the `path` and `domain` that it was set with, if they were not the defaults. */\nexport function deleteCookie(\n event: RequestEvent,\n name: string,\n options: Pick<CookieOptions, 'path' | 'domain'> = {},\n): void {\n // `secure` follows the request, as for a cookie set without it.\n setCookie(event, name, '', { ...options, secure: undefined, maxAge: 0, expires: new Date(0) });\n event.cookies!.set(name, undefined);\n}\n\nexport interface SessionOptions {\n /**\n * Signs the cookie, so a browser cannot change it. Use a random string of\n * at least 32 characters, kept out of the code, such as in an environment\n * variable. A list signs with the first and accepts all, for changing it.\n */\n secret: string | string[];\n /** The name of the cookie. Defaults to `session`. */\n name?: string;\n /** Seconds until the session expires. Defaults to 7 days. */\n maxAge?: number;\n /** Other options of the cookie. */\n cookie?: Omit<CookieOptions, 'maxAge' | 'expires'>;\n}\n\nexport interface Session<T> {\n /** The data of the session, or undefined when there is none, it expired, or its signature does not match. */\n get(event: RequestEvent): Promise<T | undefined>;\n /** Replaces the data of the session, and starts its time again. */\n set(event: RequestEvent, data: T): Promise<void>;\n /** Changes some fields of the data, and returns the new data. */\n update(event: RequestEvent, change: Partial<T>): Promise<T>;\n /** Ends the session. */\n clear(event: RequestEvent): void;\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\nconst keys = new Map<string, Promise<CryptoKey>>();\n\nfunction key(secret: string): Promise<CryptoKey> {\n let promise = keys.get(secret);\n if (!promise) {\n promise = crypto.subtle.importKey(\n 'raw',\n encoder.encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign', 'verify'],\n );\n keys.set(secret, promise);\n }\n return promise;\n}\n\nfunction toBase64Url(bytes: Uint8Array): string {\n let text = '';\n for (const byte of bytes) {\n text += String.fromCharCode(byte);\n }\n return btoa(text).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\nfunction fromBase64Url(text: string): Uint8Array<ArrayBuffer> {\n const base64 = text.replace(/-/g, '+').replace(/_/g, '/');\n return Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));\n}\n\n/**\n * A session in a signed cookie. The browser can read the data, but cannot\n * change it, so keep secrets out of it: store an ID, and look the rest up\n * on the server.\n *\n * ```ts\n * export const session = createSession<{ userId: string }>({ secret: process.env.SESSION_SECRET! });\n *\n * async function login(form: FormData) {\n * 'use server';\n * const event = getEvent();\n * await session.set(event, { userId: await checkPassword(form) });\n * }\n * ```\n */\nexport function createSession<T>(options: SessionOptions): Session<T> {\n const secrets = Array.isArray(options.secret) ? options.secret : [options.secret];\n if (secrets.length === 0 || secrets.some((secret) => secret.length < 32)) {\n throw new Error('A session secret needs at least 32 characters');\n }\n const name = options.name ?? 'session';\n const maxAge = options.maxAge ?? 7 * 24 * 60 * 60;\n\n const read = async (event: RequestEvent): Promise<T | undefined> => {\n const value = getCookies(event)[name];\n const dot = value?.lastIndexOf('.') ?? -1;\n if (!value || dot === -1) {\n return undefined;\n }\n const payload = value.slice(0, dot);\n let signature: Uint8Array<ArrayBuffer>;\n try {\n signature = fromBase64Url(value.slice(dot + 1));\n } catch {\n return undefined;\n }\n // Any of the secrets can have signed it, such as an older one while a secret changes.\n const checks = await Promise.all(\n secrets.map(async (secret) =>\n crypto.subtle.verify('HMAC', await key(secret), signature, encoder.encode(payload)),\n ),\n );\n if (!checks.includes(true)) {\n return undefined;\n }\n try {\n const { d: data, e: expires } = JSON.parse(decoder.decode(fromBase64Url(payload))) as {\n d: T;\n e: number;\n };\n return expires > Date.now() ? data : undefined;\n } catch {\n return undefined;\n }\n };\n\n const write = async (event: RequestEvent, data: T): Promise<void> => {\n const payload = toBase64Url(\n encoder.encode(JSON.stringify({ d: data, e: Date.now() + maxAge * 1000 })),\n );\n const signature = new Uint8Array(\n await crypto.subtle.sign('HMAC', await key(secrets[0]!), encoder.encode(payload)),\n );\n const value = `${payload}.${toBase64Url(signature)}`;\n // Browsers drop cookies over about 4 KB.\n if (value.length > 4000) {\n throw new Error(\n `The session is ${value.length} bytes, over the 4000 that a cookie can hold. Store an ID in it instead`,\n );\n }\n setCookie(event, name, value, { ...options.cookie, maxAge });\n };\n\n return {\n get: read,\n set: write,\n async update(event, change) {\n const data = { ...(await read(event)), ...change } as T;\n await write(event, data);\n return data;\n },\n clear: (event) =>\n deleteCookie(event, name, { path: options.cookie?.path, domain: options.cookie?.domain }),\n };\n}\n\n/**\n * The headers of a response for Node's `writeHead`, with each `set-cookie`\n * apart. `Object.fromEntries(headers)` joins them into one, which browsers\n * read as a single cookie.\n */\nexport function toNodeHeaders(headers: Headers): Record<string, string | string[]> {\n const result: Record<string, string | string[]> = Object.fromEntries(headers);\n const cookies = headers.getSetCookie();\n if (cookies.length > 0) {\n result['set-cookie'] = cookies;\n }\n return result;\n}\n"],"mappings":";;AAsBA,SAAgB,aAAa,QAA+C;CAC1E,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,SAAS,UAAU,GAAA,CAAI,MAAM,GAAG,GAAG;EAC5C,MAAM,QAAQ,KAAK,QAAQ,GAAG;EAC9B,IAAI,UAAU,IACZ;EAEF,MAAM,OAAO,KAAK,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK;EACvC,IAAI,QAAQ,EAAE,QAAQ,SAAS;GAC7B,MAAM,QAAQ,KAAK,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK;GACzC,IAAI;IACF,OAAO,QAAQ,mBAAmB,KAAK;GACzC,QAAQ;IACN,OAAO,QAAQ;GACjB;EACF;CACF;CACA,OAAO;AACT;;AAGA,SAAgB,gBAAgB,MAAc,OAAe,UAAyB,CAAC,GAAW;CAChG,IAAI,CAAC,wBAAwB,KAAK,IAAI,GACpC,MAAM,IAAI,MAAM,IAAI,KAAK,6BAA6B;CAExD,MAAM,QA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