brumate 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/{boot-D3NjfyUX.d.ts → boot-Difa0qdg.d.ts} +2 -8
  2. package/dist/cli.js +2 -2
  3. package/dist/{client-DNva05jp.d.ts → client-DvsU9qxG.d.ts} +107 -23
  4. package/dist/{client-AXNULmRZ.js → client-glvRglTB.js} +1000 -370
  5. package/dist/client-glvRglTB.js.map +1 -0
  6. package/dist/{defer-D3YMPgkX.js → defer-CNYYG-A5.js} +2 -2
  7. package/dist/{defer-D3YMPgkX.js.map → defer-CNYYG-A5.js.map} +1 -1
  8. package/dist/{devtools-BiP5fDiB.js → devtools-D8EioKXs.js} +4 -4
  9. package/dist/{devtools-BiP5fDiB.js.map → devtools-D8EioKXs.js.map} +1 -1
  10. package/dist/{devtools-panel-EQhLm39H.js → devtools-panel-BKmBqkau.js} +2 -2
  11. package/dist/{devtools-panel-EQhLm39H.js.map → devtools-panel-BKmBqkau.js.map} +1 -1
  12. package/dist/{features-CHY5Ekku.js → features-D5kLyihb.js} +19 -2
  13. package/dist/features-D5kLyihb.js.map +1 -0
  14. package/dist/{files-BUjvEO_o.js → files-ClQJlDcB.js} +2 -2
  15. package/dist/{files-BUjvEO_o.js.map → files-ClQJlDcB.js.map} +1 -1
  16. package/dist/index.d.ts +1 -8
  17. package/dist/index.js +1 -1
  18. package/dist/{inspect-BvPTZs6k.js → inspect-B8i6R3mZ.js} +877 -132
  19. package/dist/inspect-B8i6R3mZ.js.map +1 -0
  20. package/dist/{loader-DgMk6p9M.js → loader-DB0i9MwD.js} +4 -4
  21. package/dist/{loader-DgMk6p9M.js.map → loader-DB0i9MwD.js.map} +1 -1
  22. package/dist/{navigate-CfOr-TRF.js → navigate-BcV1qkkx.js} +2 -2
  23. package/dist/navigate-BcV1qkkx.js.map +1 -0
  24. package/dist/{produce-DS-dQaUX.js → produce-Cq6KKi7b.js} +2 -2
  25. package/dist/{produce-DS-dQaUX.js.map → produce-Cq6KKi7b.js.map} +1 -1
  26. package/dist/{rpc-Bxv7DYGe.js → rpc-BHlxmeWe.js} +5 -5
  27. package/dist/rpc-BHlxmeWe.js.map +1 -0
  28. package/dist/runtime/bundles.d.ts +9 -0
  29. package/dist/runtime/bundles.js +60 -0
  30. package/dist/runtime/bundles.js.map +1 -0
  31. package/dist/runtime/client.d.ts +2 -2
  32. package/dist/runtime/client.js +3 -3
  33. package/dist/runtime/devtools.d.ts +1 -1
  34. package/dist/runtime/devtools.js +1 -1
  35. package/dist/runtime/hot.d.ts +1 -1
  36. package/dist/runtime/loader.d.ts +2 -2
  37. package/dist/runtime/loader.js +2 -2
  38. package/dist/runtime/server.d.ts +3 -3
  39. package/dist/runtime/server.js +4 -4
  40. package/dist/runtime/static-loader.d.ts +2 -2
  41. package/dist/runtime/static-loader.js +1 -1
  42. package/dist/runtime/testing.d.ts +2 -2
  43. package/dist/runtime/testing.js +2 -2
  44. package/dist/{server-BXMH3Z9T.d.ts → server-CAwIqrXl.d.ts} +44 -5
  45. package/dist/{server-O_rC-RRL.js → server-Doy5HR7r.js} +106 -17
  46. package/dist/server-Doy5HR7r.js.map +1 -0
  47. package/dist/{static-loader-BiUaZaag.d.ts → static-loader-9Nc1GvF0.d.ts} +2 -2
  48. package/dist/{static-loader-U_x-ctJI.js → static-loader-D0ARlMxM.js} +3 -26
  49. package/dist/static-loader-D0ARlMxM.js.map +1 -0
  50. package/dist/{stream-JGRPr7u5.js → stream-BdhzvPQO.js} +2 -2
  51. package/dist/{stream-JGRPr7u5.js.map → stream-BdhzvPQO.js.map} +1 -1
  52. package/dist/vite.d.ts +1 -1
  53. package/dist/vite.js +129 -51
  54. package/dist/vite.js.map +1 -1
  55. package/package.json +5 -1
  56. package/skills/brumate/references/errors.md +39 -5
  57. package/dist/client-AXNULmRZ.js.map +0 -1
  58. package/dist/features-CHY5Ekku.js.map +0 -1
  59. package/dist/inspect-BvPTZs6k.js.map +0 -1
  60. package/dist/navigate-CfOr-TRF.js.map +0 -1
  61. package/dist/rpc-Bxv7DYGe.js.map +0 -1
  62. package/dist/server-O_rC-RRL.js.map +0 -1
  63. package/dist/static-loader-U_x-ctJI.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { r as SerialEntry } from "./values-B8C7CLvG.js";
2
- import { Mt as ClientModule } from "./client-DNva05jp.js";
2
+ import { Ht as ClientModule } from "./client-DvsU9qxG.js";
3
3
  //#region src/runtime/boot.d.ts
4
4
  interface LoaderOptions {
5
5
  /**
@@ -7,12 +7,6 @@ interface LoaderOptions {
7
7
  * a component that has no client code.
8
8
  */
9
9
  load: (id: string) => Promise<ClientModule> | undefined;
10
- /**
11
- * Loads the bundle of a root component of the page, such as a route: the client modules of
12
- * the components that it can render, in one chunk. Undefined for a component that is not a
13
- * root.
14
- */
15
- loadBundle?: (id: string) => Promise<unknown> | undefined;
16
10
  /** The URL prefix of server function calls. */
17
11
  rpc?: string;
18
12
  /** Imports the serial entry, which the core takes before it reads the page state. */
@@ -57,4 +51,4 @@ interface NavigateOptions {
57
51
  }
58
52
  //#endregion
59
53
  export { NavigateOptions as n, LoaderOptions as t };
60
- //# sourceMappingURL=boot-D3NjfyUX.d.ts.map
54
+ //# sourceMappingURL=boot-Difa0qdg.d.ts.map
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { B as getLocation, H as findError, j as analyzeProjectProps, o as CompileError, r as inspect, s as compile, w as resolveFromDisk, z as BrumateError } from "./inspect-BvPTZs6k.js";
3
- import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-BUjvEO_o.js";
2
+ import { B as getLocation, H as findError, j as analyzeProjectProps, o as CompileError, r as inspect, s as compile, w as resolveFromDisk, z as BrumateError } from "./inspect-B8i6R3mZ.js";
3
+ import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-ClQJlDcB.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import { cp } from "node:fs/promises";
@@ -52,6 +52,14 @@ declare function fill(scope: Scope, anchor: number, render: Render, kinds?: numb
52
52
  * scope ID in the compiled component.
53
53
  */
54
54
  declare function offscreen(scope: Scope, anchor: number, value: unknown, render: Render, kind: number, holderKind?: number, holderAnchor?: number): void;
55
+ /**
56
+ * Hides the body of a `#loading (memo)` block that has shown, and shows its fallback after it,
57
+ * while a memo of the header loads, then shows the body again. The body stays in the page and
58
+ * follows the `#offscreen` rules. A body that has not shown yet has no markers in the page, so
59
+ * its boundary shows the fallback. `kind` is the body's scope ID in the compiled component, and
60
+ * `kinds` are the scope IDs inside the fallback, whose instances go with it.
61
+ */
62
+ declare function held(scope: Scope, anchor: number, pending: boolean, kind: number, render: Render | undefined, kinds: number[], holderKind?: number, holderAnchor?: number): void;
55
63
  /** A hidden `#offscreen` body: its scope, and the ranges of its markup and of its portals. */
56
64
  interface HiddenBody {
57
65
  scope: Scope;
@@ -110,13 +118,6 @@ interface ClientModule {
110
118
  props: Record<string, number>;
111
119
  /** Scope kind, then slot, to the updates that read it. */
112
120
  g: Record<number, Record<number, Update[]>>;
113
- /** The handlers that can write a slot of another component. The others write only their own. */
114
- w?: string[];
115
- /**
116
- * Imports a part of the module. A module without it holds every part
117
- * itself, as a small component's module does.
118
- */
119
- load?: (part: string) => Promise<Part>;
120
121
  /**
121
122
  * The render functions of components that this component sends as values, such as in a
122
123
  * prop. The state holds only their IDs, so `dynamic` finds them here.
@@ -134,8 +135,6 @@ interface ClientModule {
134
135
  */
135
136
  t?: Record<number, [owner: number, anchor: number, body: string, fallback: string, kinds: number[], holderKind?: number, holderAnchor?: number]>;
136
137
  }
137
- /** A part of a client module: one client root, or the updates. */
138
- type Part = Record<string, unknown>;
139
138
  /** The instance of a scope in the page. */
140
139
  interface Scope {
141
140
  id: ScopeId;
@@ -190,6 +189,11 @@ interface Scope {
190
189
  * the start comments of text inserts.
191
190
  */
192
191
  n?: Node[];
192
+ /**
193
+ * The latest value written at each place of the markup that was ever given a promise, by
194
+ * anchor, or anchor and attribute name, so an older promise that settles later writes nothing.
195
+ */
196
+ q?: Record<string, unknown>;
193
197
  }
194
198
  interface CoreOptions {
195
199
  /** The exports of the serial entry, for the values of the app in the page state. */
@@ -199,10 +203,6 @@ interface CoreOptions {
199
203
  * has no client code, which a build leaves out.
200
204
  */
201
205
  load: (id: string) => Promise<ClientModule> | undefined;
202
- /** Loads the bundle of a root component of the page, before the modules in it. */
203
- loadBundle?: (id: string) => Promise<unknown> | undefined;
204
- /** Imports a part of a module, once for each part, as the loader preloads it. */
205
- loadPart?: (module: ClientModule, part: string) => Promise<Part>;
206
206
  /** Adds event listeners for the `b-on` attributes in new markup. */
207
207
  listen: (root: ParentNode) => void;
208
208
  /** Tells the loader that the markup that `listen` scanned is in the page now. */
@@ -382,7 +382,6 @@ declare function nameComment(place: Comment, data: string): void;
382
382
  //#endregion
383
383
  //#region src/runtime/client/code.d.ts
384
384
  declare function loadModule(id: string): Promise<ClientModule>;
385
- declare function loadPart(module: ClientModule, name: string): Promise<Part>;
386
385
  //#endregion
387
386
  //#region src/runtime/client/errors.d.ts
388
387
  /**
@@ -395,6 +394,97 @@ declare function loadPart(module: ClientModule, name: string): Promise<Part>;
395
394
  */
396
395
  declare function fail(scope: Scope | undefined, error: unknown): void;
397
396
  //#endregion
397
+ //#region src/runtime/client/waits.d.ts
398
+ /** What a render function of the browser returns. */
399
+ type Out = string | DocumentFragment;
400
+ /**
401
+ * The body of a `#try` that the browser renders, in a boundary of its own that counts as one wait
402
+ * of the boundary around it. A wait of the body that fails ends there, so a `#loading` around the
403
+ * `#try` shows its body, and `fail` renders the `#catch` body in place of the `#try`. Outside a
404
+ * boundary, the body fills in place.
405
+ */
406
+ declare function attempt(body: () => Out): DocumentFragment;
407
+ /**
408
+ * The wait of cloned markup that reads memos which never change: `write` runs once the ones
409
+ * that are promises settle, as no update writes their values. It counts in the boundary of the
410
+ * render, as `wait` does. A rejection goes to `fail`, once per error and scope, then to `fault`.
411
+ * A scope that goes during the wait ends it with `leave`.
412
+ */
413
+ declare function fillSettled(id: ScopeId | Scope, values: unknown[], write: (...values: unknown[]) => void): void;
414
+ /**
415
+ * A value of markup that the browser writes, in text or an attribute, which can be a promise.
416
+ * A value that is not one is written at once. A promise counts in the boundary of the render, as
417
+ * a memo of `fillSettled` does, and `write` gets its value once it settles. The scope keeps the
418
+ * latest value of each place, by `key`, so a promise that an update replaced before it settled
419
+ * writes nothing: the latest wins.
420
+ */
421
+ declare function fillValue(id: ScopeId | Scope, key: number | string, value: unknown, write: (value: unknown) => void): void;
422
+ /**
423
+ * A text insert of cloned markup whose value can be a promise, as `keepText` writes it, or as
424
+ * `appendText` does at the end of the element when `append` is set. A promise leaves an empty
425
+ * text node, which the scope keeps, so an update finds it, and its value takes the place of that
426
+ * node once it settles, in or out of the page.
427
+ */
428
+ declare function keepValue(id: ScopeId, anchor: number, place: Comment | Element, value: unknown, at?: ScopeId | Scope, append?: boolean): void;
429
+ /**
430
+ * The update of the spreads of an element whose values can be promises, as `attrs` writes them.
431
+ * An attribute whose value is a promise keeps what it shows until the promise settles.
432
+ */
433
+ declare function fillAttrs(scope: Scope, anchor: number, values: Record<string, unknown>, own?: string[]): void;
434
+ /**
435
+ * The spreads of an element of cloned markup whose values can be promises, as `setSpread` writes
436
+ * them. An attribute whose value is a promise is written once it settles. `place` names the
437
+ * element among the places of the scope: its anchor, which the update of the spread uses too.
438
+ */
439
+ declare function fillSpread(id: ScopeId, place: number | string, element: Element, attributes: Record<string, unknown>, on?: string[], names?: boolean): void;
440
+ /**
441
+ * The rest of a render after `const x = await $memo(...)`. `slots` are the slots that the code
442
+ * before the `await` set, with the value of the memo at `slot`, and `rest` gets them back.
443
+ *
444
+ * A value goes on at once, in the same render. A promise leaves a range of two comments, and
445
+ * the scope holds `slots` while it waits, so a parent can write its props. The rest renders when
446
+ * the slot holds a value: the first load's, or a newer load's that a prop started, whichever
447
+ * settles as the latest. Its markup fills the range. A rejection, or a throw of `rest`, goes to
448
+ * `fail`. A scope that goes during the wait ends it, and its boundary counts down.
449
+ */
450
+ declare function wait(id: ScopeId, slots: unknown[], slot: number, rest: (slots: any[]) => Out): Out;
451
+ /**
452
+ * Starts the load of an awaited memo before its `await`, where its inputs are ready. A throw
453
+ * becomes a rejected promise, and a rejection is handled here, so neither surfaces before the
454
+ * `await` waits for the load, which gets the same rejection.
455
+ */
456
+ declare function started(load: () => unknown): unknown;
457
+ /**
458
+ * Starts the load of an awaited memo that reads other awaited memos once their loads settle.
459
+ * `load` gets their values. A rejection of theirs rejects it too.
460
+ */
461
+ declare function after(loads: unknown[], load: (...values: any[]) => unknown): unknown;
462
+ /**
463
+ * Counts the memos that markup of a browser render reads and that still load, in the boundary of
464
+ * the render, as the server waits for them. The compiler passes the memos of a scope that markup
465
+ * outside every `#loading` body reads, and the memos that a `#loading` body reads from outside.
466
+ * Each counts down when its value settles. A rejection goes to `fail` and `fault`, as in
467
+ * `fillSettled`. Outside a boundary, the markup fills in when the values arrive.
468
+ */
469
+ declare function countLoads(id: ScopeId | Scope, values: unknown[]): void;
470
+ /** The order of a `#reveal` block. */
471
+ type RevealOrder = "sequential" | "backwards" | "together" | "natural";
472
+ /**
473
+ * A `#reveal` block in a browser render: the `#loading` blocks that its body renders, also in
474
+ * the components inside it, join one group, as on the server. The group ends with the render,
475
+ * before any body settles, so a block that a later update adds there is not ordered.
476
+ */
477
+ declare function reveal(order: RevealOrder, collapsed: boolean, body: () => Out): DocumentFragment;
478
+ /**
479
+ * A `#loading` block that the browser renders, as a streamed one shows: the body at once when
480
+ * nothing that it reads loads, and otherwise the fallback, until every wait of the body ends.
481
+ * The body renders now, in a boundary of its own, and enters the page in one insert with its
482
+ * work. A body whose wait fails keeps the fallback, and `fail` reported the error. The `#reveal`
483
+ * block around it can hold a body that is ready for its turn. Updates after that keep the
484
+ * content, since they render no boundary.
485
+ */
486
+ declare function loading(body: () => Out, fallback?: () => Out): DocumentFragment;
487
+ //#endregion
398
488
  //#region src/runtime/client/guesses.d.ts
399
489
  /**
400
490
  * Writes a guess into an optimistic value. It goes back to its source when
@@ -430,7 +520,7 @@ declare function attrs(scope: Scope, anchor: number, values: Record<string, unkn
430
520
  /** The items of a `#for` list: an array as it is, since `list` only reads it, or any iterable as an array. */
431
521
  declare function toList(value: Iterable<unknown> | ArrayLike<unknown>): unknown[];
432
522
  /** Updates the items of `#for` or `#repeat`, keeping the elements of items whose keys stay. */
433
- declare function list(scope: Scope, anchor: number, items: unknown[], key: (item: unknown, index: number) => unknown, given: Render, assign: (scope: Scope, item: unknown, index: number) => void, givenFallback: Render | undefined, fallbackKinds: number[], holderKind?: number, holderAnchor?: number, park?: Parking): void;
523
+ declare function list(scope: Scope, anchor: number, items: unknown[], key: (item: unknown, index: number) => unknown, given: Render, assign: (scope: Scope, item: unknown, index: number) => void, givenFallback: Render | undefined, fallbackKinds: number[], holderKind?: number, holderAnchor?: number, givenPark?: Parking): void;
434
524
  /**
435
525
  * Renders the items of a windowed list that are in view, from `#for … window(height, count)`,
436
526
  * with `list`, between the spacers that the server wrote before and after the block. Items that
@@ -577,12 +667,6 @@ declare function putText(place: Comment, value: unknown, at?: ScopeId | Scope):
577
667
  declare function setSpread(element: Element, attributes: Record<string, unknown>, on?: string[], names?: boolean): void;
578
668
  /** Writes the `b-on` of an element of cloned markup with spreads, as `onAttribute` does. */
579
669
  declare function setOn(element: Element, on: string[], own: string): void;
580
- /**
581
- * Writes cloned markup that reads memos which never change, once the ones that are promises
582
- * settle, as no update writes their values. A rejection goes to the nearest `#try` around the
583
- * scope, or `onError`.
584
- */
585
- declare function fillSettled(scope: ScopeId | Scope, values: unknown[], write: (...values: unknown[]) => void): void;
586
670
  /** Writes the content of an element of cloned markup, as `insert` writes it in HTML. */
587
671
  declare function setContent(element: Element, value: unknown, at?: ScopeId | Scope): void;
588
672
  //#endregion
@@ -678,5 +762,5 @@ declare const loader: {
678
762
  updateRoute: typeof updateRoute;
679
763
  };
680
764
  //#endregion
681
- export { windowList as $, children as $t, setAttr as A, updateContext as At, makeId as B, rpcPrefix as Bt, fillSettled as C, handlerProp as Ct, markBlock as D, consumeContext as Dt, listNodes as E, submitAction as Et, template as F, DevtoolsHooks as Ft, spreadProps as G, componentNodes as Gt, setOwner as H, skew as Ht, afterInsert as I, Part as It, addStyle as J, elementAt as Jt, addHead as K, dynamic as Kt, createScope as L, Scope as Lt, setContent as M, ClientModule as Mt, setOn as N, CoreOptions as Nt, nodes as O, provideValue as Ot, setSpread as P, DEVTOOLS as Pt, toList as Q, setSlots as Qt, descendants as R, build as Rt, fillList as S, handle as St, keepText as T, spread as Tt, sink as U, Component as Ut, removeScope as V, scopes as Vt, prop as W, component as Wt, setVar as X, place as Xt, deferInBrowser as Y, foreignNodes as Yt, list as Z, setItem as Zt, title as _, leavePage as _t, cells as a, rekey as an, restRef as at, clone as b, removeRoot as bt, isBound as c, NavigationReport as cn, guess as ct, resolve as d, loadModule as dt, insert as en, windowStart as et, set as f, loadPart as ft, updated as g, init as gt, update as h, forget as ht, bindings as i, offscreen as in, portalTo as it, setAttrText as j, updateRoute as jt, putText as k, setGlobal as kt, memo as l, track as lt, unreadMemo as m, dispose as mt, asyncMemo as n, branch as nn, attrs as nt, effect as o, reset as on, text as ot, timed as p, nameComment as pt, addPortal as q, dynamicNodes as qt, binding as r, fill as rn, content as rt, get as s, retag as sn, writeText as st, loader as t, HiddenBody as tn, attr as tt, pending as u, fail as ut, appendText as v, leaveRoutes as vt, keep as w, rpc as wt, fillBranch as x, action as xt, branchNodes as y, remount as yt, getScope as z, hooks as zt };
682
- //# sourceMappingURL=client-DNva05jp.d.ts.map
765
+ export { windowStart as $, component as $t, setAttrText as A, removeRoot as At, removeScope as B, updateContext as Bt, keep as C, nameComment as Ct, nodes as D, leavePage as Dt, markBlock as E, init as Et, afterInsert as F, spread as Ft, addHead as G, DevtoolsHooks as Gt, sink as H, ClientModule as Ht, createScope as I, submitAction as It, deferInBrowser as J, hooks as Jt, addPortal as K, Scope as Kt, descendants as L, consumeContext as Lt, setOn as M, handle as Mt, setSpread as N, handlerProp as Nt, putText as O, leaveRoutes as Ot, template as P, rpc as Pt, windowList as Q, Component as Qt, getScope as R, provideValue as Rt, fillList as S, loadModule as St, listNodes as T, forget as Tt, prop as U, CoreOptions as Ut, setOwner as V, updateRoute as Vt, spreadProps as W, DEVTOOLS as Wt, list as X, scopes as Xt, setVar as Y, rpcPrefix as Yt, toList as Z, skew as Zt, title as _, retag as _n, loading as _t, cells as a, place as an, text as at, clone as b, wait as bt, isBound as c, children as cn, track as ct, resolve as d, branch as dn, countLoads as dt, componentNodes as en, attr as et, set as f, fill as fn, fillAttrs as ft, updated as g, reset as gn, keepValue as gt, update as h, rekey as hn, fillValue as ht, bindings as i, foreignNodes as in, restRef as it, setContent as j, action as jt, setAttr as k, remount as kt, memo as l, insert as ln, after as lt, unreadMemo as m, offscreen as mn, fillSpread as mt, asyncMemo as n, dynamicNodes as nn, content as nt, effect as o, setItem as on, writeText as ot, timed as p, held as pn, fillSettled as pt, addStyle as q, build as qt, binding as r, elementAt as rn, portalTo as rt, get as s, setSlots as sn, guess as st, loader as t, dynamic as tn, attrs as tt, pending as u, HiddenBody as un, attempt as ut, appendText as v, NavigationReport as vn, reveal as vt, keepText as w, dispose as wt, fillBranch as x, fail as xt, branchNodes as y, started as yt, makeId as z, setGlobal as zt };
766
+ //# sourceMappingURL=client-DvsU9qxG.d.ts.map