brumate 0.4.1 → 0.4.3

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 (61) hide show
  1. package/dist/{boot-SCWYwuUd.d.ts → boot-D3NjfyUX.d.ts} +2 -2
  2. package/dist/cli.js +2 -2
  3. package/dist/{client-BBtVTOIt.js → client-AXNULmRZ.js} +67 -12
  4. package/dist/client-AXNULmRZ.js.map +1 -0
  5. package/dist/{client-Cs3o4key.d.ts → client-DNva05jp.d.ts} +20 -7
  6. package/dist/{defer-BLJjxqVc.js → defer-D3YMPgkX.js} +2 -2
  7. package/dist/{defer-BLJjxqVc.js.map → defer-D3YMPgkX.js.map} +1 -1
  8. package/dist/{devtools-DTpsVFbn.js → devtools-BiP5fDiB.js} +4 -4
  9. package/dist/{devtools-DTpsVFbn.js.map → devtools-BiP5fDiB.js.map} +1 -1
  10. package/dist/{devtools-panel-C1Dfv6nq.js → devtools-panel-EQhLm39H.js} +2 -2
  11. package/dist/{devtools-panel-C1Dfv6nq.js.map → devtools-panel-EQhLm39H.js.map} +1 -1
  12. package/dist/{files-DZIiMDnS.js → files-BUjvEO_o.js} +2 -2
  13. package/dist/{files-DZIiMDnS.js.map → files-BUjvEO_o.js.map} +1 -1
  14. package/dist/{html-DS9B1H-M.js → html-t1JpkODI.js} +6 -4
  15. package/dist/html-t1JpkODI.js.map +1 -0
  16. package/dist/index.d.ts +5 -1
  17. package/dist/index.js +1 -1
  18. package/dist/{inspect-DomFHy5O.js → inspect-BvPTZs6k.js} +235 -67
  19. package/dist/inspect-BvPTZs6k.js.map +1 -0
  20. package/dist/{loader-D62komKu.js → loader-DgMk6p9M.js} +2 -2
  21. package/dist/{loader-D62komKu.js.map → loader-DgMk6p9M.js.map} +1 -1
  22. package/dist/produce-CLABZ8k2.d.ts +11 -0
  23. package/dist/{produce-BNIpmZq2.js → produce-DS-dQaUX.js} +3 -2
  24. package/dist/produce-DS-dQaUX.js.map +1 -0
  25. package/dist/{rpc-BTMb8jap.js → rpc-Bxv7DYGe.js} +3 -3
  26. package/dist/{rpc-BTMb8jap.js.map → rpc-Bxv7DYGe.js.map} +1 -1
  27. package/dist/runtime/client.d.ts +4 -4
  28. package/dist/runtime/client.js +4 -4
  29. package/dist/runtime/devtools.d.ts +2 -2
  30. package/dist/runtime/devtools.js +1 -1
  31. package/dist/runtime/hot.d.ts +1 -1
  32. package/dist/runtime/html.d.ts +1 -1
  33. package/dist/runtime/html.js +1 -1
  34. package/dist/runtime/loader.d.ts +2 -2
  35. package/dist/runtime/loader.js +2 -2
  36. package/dist/runtime/server.d.ts +3 -3
  37. package/dist/runtime/server.js +3 -3
  38. package/dist/runtime/static-loader.d.ts +2 -2
  39. package/dist/runtime/static-loader.js +1 -1
  40. package/dist/runtime/testing.d.ts +2 -2
  41. package/dist/runtime/testing.js +2 -2
  42. package/dist/{server-CYw15Dsg.d.ts → server-BXMH3Z9T.d.ts} +4 -3
  43. package/dist/{server-BTtsQFFw.js → server-O_rC-RRL.js} +11 -9
  44. package/dist/server-O_rC-RRL.js.map +1 -0
  45. package/dist/shared-CzbnWkVA.d.ts +255 -0
  46. package/dist/{static-loader-DVuLmXeu.d.ts → static-loader-BiUaZaag.d.ts} +2 -2
  47. package/dist/{static-loader-C_GYIFtt.js → static-loader-U_x-ctJI.js} +2 -2
  48. package/dist/{static-loader-C_GYIFtt.js.map → static-loader-U_x-ctJI.js.map} +1 -1
  49. package/dist/{stream-r4V5zBKm.js → stream-JGRPr7u5.js} +29 -5
  50. package/dist/stream-JGRPr7u5.js.map +1 -0
  51. package/dist/vite.d.ts +1 -1
  52. package/dist/vite.js +2 -2
  53. package/package.json +1 -1
  54. package/dist/client-BBtVTOIt.js.map +0 -1
  55. package/dist/html-DS9B1H-M.js.map +0 -1
  56. package/dist/html-Gggepsf-.d.ts +0 -109
  57. package/dist/inspect-DomFHy5O.js.map +0 -1
  58. package/dist/produce-BNIpmZq2.js.map +0 -1
  59. package/dist/produce-CRfouraC.d.ts +0 -153
  60. package/dist/server-BTtsQFFw.js.map +0 -1
  61. package/dist/stream-r4V5zBKm.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { r as SerialEntry } from "./values-B8C7CLvG.js";
2
- import { At as ClientModule } from "./client-Cs3o4key.js";
2
+ import { Mt as ClientModule } from "./client-DNva05jp.js";
3
3
  //#region src/runtime/boot.d.ts
4
4
  interface LoaderOptions {
5
5
  /**
@@ -57,4 +57,4 @@ interface NavigateOptions {
57
57
  }
58
58
  //#endregion
59
59
  export { NavigateOptions as n, LoaderOptions as t };
60
- //# sourceMappingURL=boot-SCWYwuUd.d.ts.map
60
+ //# sourceMappingURL=boot-D3NjfyUX.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-DomFHy5O.js";
3
- import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-DZIiMDnS.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-BvPTZs6k.js";
3
+ import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-BUjvEO_o.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import { cp } from "node:fs/promises";
@@ -1,6 +1,6 @@
1
- import { C as spread$1, T as textValue, b as ownValue, f as handlerEntry, n as VOID_ELEMENTS, o as attributeText, p as insertValue, r as actionAttributes, s as bindEntry, v as onAttribute, y as onValue } from "./html-DS9B1H-M.js";
1
+ import { C as spread$1, T as textValue, b as ownValue, f as handlerEntry, g as isRaw, n as VOID_ELEMENTS, o as attributeText, p as insertValue, r as actionAttributes, s as bindEntry, v as onAttribute, y as onValue } from "./html-t1JpkODI.js";
2
2
  import { a as HAS_CLIENT_HTML, c as HAS_TEMPLATES, i as HAS_CHILDREN, l as HAS_TITLES, n as HAS_BINDINGS, o as HAS_LATE_MARKUP } from "./features-CHY5Ekku.js";
3
- import { C as useSerialEntry, _ as mergeHandlers, a as ElementReference, b as parseId, c as PARTS, d as SlotReference, f as addEntryHandlers, g as isSlotReference, h as isPropWrapper, i as ChildrenReference, m as isBinding, n as Binding, o as FunctionReference, p as isAsyncIterable, s as MemoError, x as stateValues } from "./produce-BNIpmZq2.js";
3
+ import { C as useSerialEntry, _ as mergeHandlers, a as ElementReference, b as parseId, c as PARTS, d as SlotReference, f as addEntryHandlers, g as isSlotReference, h as isPropWrapper, i as ChildrenReference, m as isBinding, n as Binding, o as FunctionReference, p as isAsyncIterable, s as MemoError, x as stateValues } from "./produce-DS-dQaUX.js";
4
4
  import { n as ROUTE_KEY } from "./context-CTiSzQRc.js";
5
5
  import { n as trustedHTML, t as loadOnce } from "./skew-FRmAy9iy.js";
6
6
  //#region src/runtime/client/state.ts
@@ -800,18 +800,31 @@ function call(ref, scope, args) {
800
800
  * with the page, and updates wait for it.
801
801
  */
802
802
  function templateReference(ref, scope) {
803
- return (...args) => new TemplateCall(ref, scope, args, () => {
803
+ return (...args) => new TemplateCall(ref, scope, args, (at) => {
804
804
  const render = loadedFunction(ref);
805
- return render ? insertValue(render(scope, ...args)) : "";
805
+ return render ? insert(render(scope, ...args), void 0, at) : "";
806
806
  });
807
807
  }
808
808
  /** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */
809
809
  function insert(value, _ctx, scope) {
810
+ linkCalls(value, scope);
810
811
  if (!((HAS_CHILDREN || HAS_TEMPLATES) && value instanceof Children)) return insertValue(value);
811
812
  const out = value.render(resolveScope(scope));
812
813
  return HAS_CLIENT_HTML ? holdPlace(out) : out;
813
814
  }
814
815
  /**
816
+ * Links the scope of each template whose output a value holds to `at`, the scope where it is
817
+ * inserted, so an error in the template goes to a `#try` there.
818
+ */
819
+ function linkCalls(value, at) {
820
+ if (Array.isArray(value)) {
821
+ for (const item of value) linkCalls(item, at);
822
+ return;
823
+ }
824
+ const scope = isRaw(value) && value.s !== void 0 ? scopes.get(value.s) : void 0;
825
+ if (scope && at !== void 0) scope.l = resolveScope(at);
826
+ }
827
+ /**
815
828
  * Children of a component that the client renders. They render where the
816
829
  * component inserts them, so they read the contexts that it provides. `from`
817
830
  * is the scope of the markup that wrote them.
@@ -843,7 +856,7 @@ var Children = class {
843
856
  };
844
857
  insertedChildren.push(entry);
845
858
  try {
846
- return this.html();
859
+ return this.html(target);
847
860
  } finally {
848
861
  insertedChildren.splice(insertedChildren.indexOf(entry), 1);
849
862
  }
@@ -940,13 +953,14 @@ function children(from, html) {
940
953
  * Reports an error of client code: a handler, an effect, a `$client`
941
954
  * callback or a memo that loads. It renders the `#catch` body of the nearest
942
955
  * `#try` around the scope of the code, through the parents and the owners of
943
- * scopes. Without one, the page gets a `brumate:error` event on `window`,
944
- * with the error and the scope, and the error is logged.
956
+ * scopes. A template's scope goes on from the scope where it was called.
957
+ * Without a `#try`, the page gets a `brumate:error` event on `window`, with
958
+ * the error and the scope, and the error is logged.
945
959
  */
946
960
  function fail(scope, error) {
947
961
  options.onError?.(error, { scope: scope?.id });
948
962
  (async () => {
949
- for (let current = scope; current; current = current.p ?? current.o) {
963
+ for (let current = scope; current; current = current.l ?? current.p ?? current.o) {
950
964
  const id = findRoot(current).m;
951
965
  if (!id) continue;
952
966
  const module = await loadModule(id).catch(() => void 0);
@@ -1181,6 +1195,16 @@ function isThenable(value) {
1181
1195
  return value !== null && typeof value === "object" && typeof value.then === "function";
1182
1196
  }
1183
1197
  /**
1198
+ * Reports the rejection of a memo that the browser renders and nothing reads, so it has no slot.
1199
+ * The error reaches the nearest `#try` around the scope, or `onError`.
1200
+ */
1201
+ function unreadMemo(scope, value) {
1202
+ if (isThenable(value)) {
1203
+ const at = resolveScope(scope);
1204
+ value.then(void 0, (error) => fail(at, error));
1205
+ }
1206
+ }
1207
+ /**
1184
1208
  * Writes the result of an async memo when it arrives. Until then the slot
1185
1209
  * keeps its value, and `pending` is true. Only the latest load is written.
1186
1210
  */
@@ -1959,12 +1983,12 @@ function action(name, id, method, result) {
1959
1983
  * call loads, so the core holds only this.
1960
1984
  */
1961
1985
  function submitAction(form, submitter) {
1962
- import("./rpc-BTMb8jap.js").then((module) => module.sendAction(form, submitter));
1986
+ import("./rpc-Bxv7DYGe.js").then((module) => module.sendAction(form, submitter));
1963
1987
  }
1964
1988
  /** Calls a server function. */
1965
1989
  async function rpc(id, args) {
1966
1990
  const signal = memoSignal();
1967
- return track(import("./rpc-BTMb8jap.js").then((module) => module.call(rpcPrefix, id, args, signal)));
1991
+ return track(import("./rpc-Bxv7DYGe.js").then((module) => module.call(rpcPrefix, id, args, signal)));
1968
1992
  }
1969
1993
  /** A function prop rendered on the client calls the parent's exported handler. */
1970
1994
  function handlerProp(value, ref, scope, bound = [], modifiers) {
@@ -2101,6 +2125,7 @@ function addScopes(state, root) {
2101
2125
  }
2102
2126
  if (record.t !== void 0) scope.t = scopes.get(record.t);
2103
2127
  if (record.f !== void 0) scope.f = scopes.get(record.f);
2128
+ if (record.l !== void 0) scope.l = scopes.get(record.l);
2104
2129
  }
2105
2130
  for (const scope of added) if (scope.m) options.loadBundle?.(scope.m)?.catch(() => {});
2106
2131
  for (const scope of added) if (scope.m) loadComponent(scope.m);
@@ -2798,6 +2823,35 @@ function setOn(element, on, own) {
2798
2823
  options?.listen(element);
2799
2824
  }
2800
2825
  }
2826
+ /**
2827
+ * The scope that `fillSettled` reported each rejection to, as two renders or two writes in one
2828
+ * scope can read the same memo.
2829
+ */
2830
+ const reportedRejections = /* @__PURE__ */ new WeakMap();
2831
+ /**
2832
+ * Writes cloned markup that reads memos which never change, once the ones that are promises
2833
+ * settle, as no update writes their values. A rejection goes to the nearest `#try` around the
2834
+ * scope, or `onError`.
2835
+ */
2836
+ function fillSettled(scope, values, write) {
2837
+ let loading = false;
2838
+ for (const value of values) loading ||= isThenable(value);
2839
+ if (!loading) {
2840
+ write(...values);
2841
+ return;
2842
+ }
2843
+ const at = resolveScope(scope);
2844
+ Promise.all(values).then((settled) => {
2845
+ if (scopes.get(at.id) === at) write(...settled);
2846
+ }, (error) => {
2847
+ if (scopes.get(at.id) !== at) return;
2848
+ if (typeof error === "object" && error !== null) {
2849
+ if (reportedRejections.get(error) === at) return;
2850
+ reportedRejections.set(error, at);
2851
+ }
2852
+ fail(at, error);
2853
+ });
2854
+ }
2801
2855
  /** Writes the content of an element of cloned markup, as `insert` writes it in HTML. */
2802
2856
  function setContent(element, value, at) {
2803
2857
  if (typeof value === "string" || typeof value === "number") {
@@ -3046,6 +3100,7 @@ function write(parent, first, end, value, at, key, anchor) {
3046
3100
  first = next;
3047
3101
  }
3048
3102
  const made = nextId;
3103
+ linkCalls(value, at);
3049
3104
  insertHTML(end ?? { parent }, (HAS_CHILDREN || HAS_TEMPLATES) && value instanceof Children ? value.render(at) : insertValue(value));
3050
3105
  if (HAS_TEMPLATES && key) {
3051
3106
  const scope = value instanceof TemplateCall ? scopes.get(made) : void 0;
@@ -3501,6 +3556,6 @@ const loader = {
3501
3556
  updateRoute
3502
3557
  };
3503
3558
  //#endregion
3504
- export { forget as $, branchNodes as A, update as At, setAttr as B, makeId as Bt, dynamicNodes as C, get as Ct, setItem as D, resolve as Dt, place as E, pending as Et, keepText as F, title as Ft, template as G, loadPart as Gt, setContent as H, setOwner as Ht, listNodes as I, afterInsert as It, offscreen as J, build as Jt, branch as K, nameComment as Kt, markBlock as L, createScope as Lt, fillBranch as M, fail as Mt, fillList as N, children as Nt, setSlots as O, set as Ot, keep as P, insert as Pt, dispose as Q, skew as Qt, nodes as R, descendants as Rt, dynamic as S, effect as St, foreignNodes as T, memo as Tt, setOn as U, sink as Ut, setAttrText as V, removeScope as Vt, setSpread as W, loadModule as Wt, reset as X, rpcPrefix as Xt, rekey as Y, hooks as Yt, retag as Z, scopes as Zt, writeText as _, updateRoute as _t, deferInBrowser as a, action as at, component as b, bindings as bt, toList as c, rpc as ct, attr as d, guess as dt, init as et, attrs as f, track as ft, text as g, updateContext as gt, restRef as h, setGlobal as ht, addStyle as i, removeRoot as it, clone as j, updated as jt, appendText as k, timed as kt, windowList as l, spread as lt, portalTo as m, provideValue as mt, addHead as n, leaveRoutes as nt, setVar as o, handle as ot, content as p, consumeContext as pt, fill as q, DEVTOOLS as qt, addPortal as r, remount as rt, list as s, handlerProp as st, loader as t, leavePage as tt, windowStart as u, submitAction as ut, prop as v, asyncMemo as vt, elementAt as w, isBound as wt, componentNodes as x, cells as xt, spreadProps as y, binding as yt, putText as z, getScope as zt };
3559
+ export { dispose as $, scopes as $t, branchNodes as A, timed as At, putText as B, descendants as Bt, dynamicNodes as C, effect as Ct, setItem as D, pending as Dt, place as E, memo as Et, keep as F, children as Ft, setSpread as G, sink as Gt, setAttrText as H, makeId as Ht, keepText as I, insert as It, fill as J, nameComment as Jt, template as K, loadModule as Kt, listNodes as L, title as Lt, fillBranch as M, update as Mt, fillList as N, updated as Nt, setSlots as O, resolve as Ot, fillSettled as P, fail as Pt, retag as Q, rpcPrefix as Qt, markBlock as R, afterInsert as Rt, dynamic as S, cells as St, foreignNodes as T, isBound as Tt, setContent as U, removeScope as Ut, setAttr as V, getScope as Vt, setOn as W, setOwner as Wt, rekey as X, build as Xt, offscreen as Y, DEVTOOLS as Yt, reset as Z, hooks as Zt, writeText as _, updateContext as _t, deferInBrowser as a, removeRoot as at, component as b, binding as bt, toList as c, handlerProp as ct, attr as d, submitAction as dt, skew as en, forget as et, attrs as f, guess as ft, text as g, setGlobal as gt, restRef as h, provideValue as ht, addStyle as i, remount as it, clone as j, unreadMemo as jt, appendText as k, set as kt, windowList as l, rpc as lt, portalTo as m, consumeContext as mt, addHead as n, leavePage as nt, setVar as o, action as ot, content as p, track as pt, branch as q, loadPart as qt, addPortal as r, leaveRoutes as rt, list as s, handle as st, loader as t, init as tt, windowStart as u, spread as ut, prop as v, updateRoute as vt, elementAt as w, get as wt, componentNodes as x, bindings as xt, spreadProps as y, asyncMemo as yt, nodes as z, createScope as zt };
3505
3560
 
3506
- //# sourceMappingURL=client-BBtVTOIt.js.map
3561
+ //# sourceMappingURL=client-AXNULmRZ.js.map