brumate 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/{boot-DLlRmD9z.d.ts → boot-SCWYwuUd.d.ts} +2 -2
  2. package/dist/cli.js +2 -2
  3. package/dist/{client-BvDsC6Qr.js → client-BBtVTOIt.js} +71 -28
  4. package/dist/client-BBtVTOIt.js.map +1 -0
  5. package/dist/{client-DBwL2wKQ.d.ts → client-Cs3o4key.d.ts} +3 -3
  6. package/dist/{defer-CKWZLv2K.js → defer-BLJjxqVc.js} +2 -2
  7. package/dist/{defer-CKWZLv2K.js.map → defer-BLJjxqVc.js.map} +1 -1
  8. package/dist/{devtools-4uTPwR_v.js → devtools-DTpsVFbn.js} +4 -4
  9. package/dist/{devtools-4uTPwR_v.js.map → devtools-DTpsVFbn.js.map} +1 -1
  10. package/dist/{devtools-panel-Be9pxYgv.js → devtools-panel-C1Dfv6nq.js} +2 -2
  11. package/dist/{devtools-panel-Be9pxYgv.js.map → devtools-panel-C1Dfv6nq.js.map} +1 -1
  12. package/dist/{files-WW4RlajL.js → files-DZIiMDnS.js} +2 -2
  13. package/dist/{files-WW4RlajL.js.map → files-DZIiMDnS.js.map} +1 -1
  14. package/dist/{html-BtKRyi7g.js → html-DS9B1H-M.js} +10 -4
  15. package/dist/html-DS9B1H-M.js.map +1 -0
  16. package/dist/{html-Bw9Qwu6F.d.ts → html-Gggepsf-.d.ts} +4 -2
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +1 -1
  19. package/dist/{inspect-Y6y4uNZp.js → inspect-DomFHy5O.js} +67 -5
  20. package/dist/inspect-DomFHy5O.js.map +1 -0
  21. package/dist/{loader-BjKGJzLN.js → loader-D62komKu.js} +2 -2
  22. package/dist/{loader-BjKGJzLN.js.map → loader-D62komKu.js.map} +1 -1
  23. package/dist/{produce-B7X9ori9.js → produce-BNIpmZq2.js} +4 -3
  24. package/dist/produce-BNIpmZq2.js.map +1 -0
  25. package/dist/{produce-DIgHBVwL.d.ts → produce-CRfouraC.d.ts} +6 -1
  26. package/dist/{rpc-Q-XkLwFh.js → rpc-BTMb8jap.js} +3 -3
  27. package/dist/{rpc-Q-XkLwFh.js.map → rpc-BTMb8jap.js.map} +1 -1
  28. package/dist/runtime/client.d.ts +3 -3
  29. package/dist/runtime/client.js +3 -3
  30. package/dist/runtime/devtools.d.ts +2 -2
  31. package/dist/runtime/devtools.js +1 -1
  32. package/dist/runtime/hot.d.ts +1 -1
  33. package/dist/runtime/html.d.ts +2 -2
  34. package/dist/runtime/html.js +1 -1
  35. package/dist/runtime/loader.d.ts +2 -2
  36. package/dist/runtime/loader.js +2 -2
  37. package/dist/runtime/server.d.ts +3 -3
  38. package/dist/runtime/server.js +3 -3
  39. package/dist/runtime/static-loader.d.ts +2 -2
  40. package/dist/runtime/static-loader.js +1 -1
  41. package/dist/runtime/testing.d.ts +2 -2
  42. package/dist/runtime/testing.js +2 -2
  43. package/dist/{server-DjyOVJtJ.js → server-BTtsQFFw.js} +47 -11
  44. package/dist/server-BTtsQFFw.js.map +1 -0
  45. package/dist/{server-BvPIg9pT.d.ts → server-CYw15Dsg.d.ts} +22 -3
  46. package/dist/{static-loader-BZR17hSw.js → static-loader-C_GYIFtt.js} +4 -3
  47. package/dist/{static-loader-BZR17hSw.js.map → static-loader-C_GYIFtt.js.map} +1 -1
  48. package/dist/{static-loader-BGgdp_Y5.d.ts → static-loader-DVuLmXeu.d.ts} +2 -2
  49. package/dist/{stream-BP5AVmg5.js → stream-r4V5zBKm.js} +4 -4
  50. package/dist/stream-r4V5zBKm.js.map +1 -0
  51. package/dist/vite.d.ts +1 -1
  52. package/dist/vite.js +72 -12
  53. package/dist/vite.js.map +1 -1
  54. package/package.json +1 -1
  55. package/dist/client-BvDsC6Qr.js.map +0 -1
  56. package/dist/html-BtKRyi7g.js.map +0 -1
  57. package/dist/inspect-Y6y4uNZp.js.map +0 -1
  58. package/dist/produce-B7X9ori9.js.map +0 -1
  59. package/dist/server-DjyOVJtJ.js.map +0 -1
  60. package/dist/stream-BP5AVmg5.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-DBwL2wKQ.js";
2
+ import { At as ClientModule } from "./client-Cs3o4key.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-DLlRmD9z.d.ts.map
60
+ //# sourceMappingURL=boot-SCWYwuUd.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-Y6y4uNZp.js";
3
- import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-WW4RlajL.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-DomFHy5O.js";
3
+ import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-DZIiMDnS.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 { S as spread$1, _ as onAttribute, f as handlerEntry, n as VOID_ELEMENTS, o as attributeText, p as insertValue, r as actionAttributes, s as bindEntry, v as onValue, w as textValue, y as ownValue } from "./html-BtKRyi7g.js";
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";
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-B7X9ori9.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";
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
@@ -1074,6 +1074,17 @@ function send(bound, value) {
1074
1074
  if (!callNow(bound.ref, scopes.get(bound.scope), args)) call(bound.ref, scopes.get(bound.scope), args);
1075
1075
  } else if (typeof bound === "function") bound(value);
1076
1076
  }
1077
+ /** The setters that were given each element, so an update of a spread does not call them again. */
1078
+ const given = /* @__PURE__ */ new WeakMap();
1079
+ /** Calls the setter of a binding with an element, once for each element and setter. */
1080
+ function give(bound, element) {
1081
+ const key = bound instanceof FunctionReference ? `${bound.scope}#${bound.ref}` : bound;
1082
+ const seen = given.get(element) ?? /* @__PURE__ */ new Set();
1083
+ if (!seen.has(key)) {
1084
+ given.set(element, seen.add(key));
1085
+ send(bound, element);
1086
+ }
1087
+ }
1077
1088
  /** Writes a slot, and updates what reads it. */
1078
1089
  function writeSlot(scope, slot, value) {
1079
1090
  if (!Object.is(scope.s[slot], value)) {
@@ -1214,6 +1225,17 @@ var NotReady = class extends Error {
1214
1225
  }
1215
1226
  };
1216
1227
  let computing = 0;
1228
+ let origin;
1229
+ let viaContext = false;
1230
+ function sendContext(send) {
1231
+ const before = viaContext;
1232
+ viaContext = true;
1233
+ try {
1234
+ send();
1235
+ } finally {
1236
+ viaContext = before;
1237
+ }
1238
+ }
1217
1239
  let runningEffects = 0;
1218
1240
  /**
1219
1241
  * `$resolve(memo, { timeout, signal })`: resolves with the value of the memo once it is no longer
@@ -1353,6 +1375,8 @@ function trigger(scope, slot) {
1353
1375
  ]);
1354
1376
  return;
1355
1377
  }
1378
+ const from = origin;
1379
+ const via = viaContext;
1356
1380
  const list = [[scope, slot]];
1357
1381
  if (running > 0) waiting = list;
1358
1382
  const loading = loadModule(id).then(async (loaded) => {
@@ -1360,9 +1384,18 @@ function trigger(scope, slot) {
1360
1384
  const waits = [...loadingCode, children];
1361
1385
  for (const [, , load] of list) waits.push(load);
1362
1386
  await Promise.allSettled(waits);
1363
- pass(() => {
1364
- for (const [target, at] of list) queueWrite(target, at);
1365
- });
1387
+ const before = origin;
1388
+ const viaBefore = viaContext;
1389
+ origin = from;
1390
+ viaContext = via;
1391
+ try {
1392
+ pass(() => {
1393
+ for (const [target, at] of list) queueWrite(target, at);
1394
+ });
1395
+ } finally {
1396
+ origin = before;
1397
+ viaContext = viaBefore;
1398
+ }
1366
1399
  }).catch((error) => {
1367
1400
  fail(scope, error);
1368
1401
  flushEffects();
@@ -1485,13 +1518,21 @@ function queueWrite(scope, slot) {
1485
1518
  function queue(fn, name, target) {
1486
1519
  if (DEV) updateCount++;
1487
1520
  const key = `${target.id}:${name}`;
1521
+ const from = origin;
1522
+ if (name[0] === "e" && viaContext && from === key) return;
1488
1523
  function later() {
1489
1524
  if (!failed && scopes.get(target.id) === target) try {
1490
1525
  if (stuck) {
1491
1526
  failed = true;
1492
1527
  throw new Error(DEV ? "The updates of a write did not settle after 10000 rounds. An update writes a value that it reads, such as through ref=$bind." : "Update loop");
1493
1528
  }
1494
- updating(() => fn(target));
1529
+ const before = origin;
1530
+ origin = from;
1531
+ try {
1532
+ updating(() => fn(target));
1533
+ } finally {
1534
+ origin = before;
1535
+ }
1495
1536
  } catch (error) {
1496
1537
  fail(target, error);
1497
1538
  }
@@ -1598,6 +1639,8 @@ function effect(scope, name, callback, client) {
1598
1639
  scope.cleanups.get(name)?.();
1599
1640
  let cleanup;
1600
1641
  const start = DEV ? performance.now() : 0;
1642
+ const outer = origin;
1643
+ origin = key;
1601
1644
  if (!client) runningEffects++;
1602
1645
  try {
1603
1646
  cleanup = callback();
@@ -1619,6 +1662,7 @@ function effect(scope, name, callback, client) {
1619
1662
  }
1620
1663
  fail(scope, error);
1621
1664
  } finally {
1665
+ origin = outer;
1622
1666
  if (!client) runningEffects--;
1623
1667
  }
1624
1668
  let stored = typeof cleanup === "function" ? cleanup : noop;
@@ -1646,10 +1690,12 @@ function findProvider(scope, key) {
1646
1690
  function updateContext(scope, context, value) {
1647
1691
  scope.v ??= {};
1648
1692
  scope.v[context.key] = value;
1649
- for (const target of scopes.values()) {
1650
- const slot = target.x?.[context.key];
1651
- if (slot !== void 0 && findProvider(target, context.key) === scope) set(target, slot, value);
1652
- }
1693
+ sendContext(() => {
1694
+ for (const target of scopes.values()) {
1695
+ const slot = target.x?.[context.key];
1696
+ if (slot !== void 0 && findProvider(target, context.key) === scope) set(target, slot, value);
1697
+ }
1698
+ });
1653
1699
  }
1654
1700
  /** Provides a value of a context to the scopes inside `scope`. */
1655
1701
  function provideValue(context, value, scope) {
@@ -1913,12 +1959,12 @@ function action(name, id, method, result) {
1913
1959
  * call loads, so the core holds only this.
1914
1960
  */
1915
1961
  function submitAction(form, submitter) {
1916
- import("./rpc-Q-XkLwFh.js").then((module) => module.sendAction(form, submitter));
1962
+ import("./rpc-BTMb8jap.js").then((module) => module.sendAction(form, submitter));
1917
1963
  }
1918
1964
  /** Calls a server function. */
1919
1965
  async function rpc(id, args) {
1920
1966
  const signal = memoSignal();
1921
- return track(import("./rpc-Q-XkLwFh.js").then((module) => module.call(rpcPrefix, id, args, signal)));
1967
+ return track(import("./rpc-BTMb8jap.js").then((module) => module.call(rpcPrefix, id, args, signal)));
1922
1968
  }
1923
1969
  /** A function prop rendered on the client calls the parent's exported handler. */
1924
1970
  function handlerProp(value, ref, scope, bound = [], modifiers) {
@@ -2079,10 +2125,16 @@ function addScopes(state, root) {
2079
2125
  }
2080
2126
  }
2081
2127
  }
2082
- if (HAS_BINDINGS) for (const scope of added) for (const [slot, bound] of Object.entries(scope.b ?? {})) {
2083
- const value = scope.s[+slot];
2084
- const element = value instanceof ElementReference ? findElement(value.scope, value.anchor) : null;
2085
- if (element && !isSlotReference(bound)) send(bound, element);
2128
+ if (HAS_BINDINGS) {
2129
+ for (const scope of added) for (const [slot, bound] of Object.entries(scope.b ?? {})) {
2130
+ const value = scope.s[+slot];
2131
+ const element = value instanceof ElementReference ? findElement(value.scope, value.anchor) : null;
2132
+ if (element && !isSlotReference(bound)) send(bound, element);
2133
+ }
2134
+ for (const scope of added) for (const [anchor, bound] of Object.entries(state[scope.id].r ?? {})) {
2135
+ const element = findElement(scope.id, +anchor);
2136
+ if (element) give(bound, element);
2137
+ }
2086
2138
  }
2087
2139
  hooks.added?.(added);
2088
2140
  return added;
@@ -2913,7 +2965,7 @@ function prop(scope, anchor, name, value) {
2913
2965
  };
2914
2966
  const module = modules.get(child.m);
2915
2967
  if (module) apply(module);
2916
- else loadModule(child.m).then(apply);
2968
+ else loadModule(child.m).then(apply, (error) => fail(child, error));
2917
2969
  }
2918
2970
  //#endregion
2919
2971
  //#region src/runtime/client/inserts.ts
@@ -3066,8 +3118,6 @@ function attr(scope, anchor, name, value) {
3066
3118
  }
3067
3119
  /** The attributes that the last update of a spread wrote, so the next one removes those it drops. */
3068
3120
  const spreadNames = /* @__PURE__ */ new WeakMap();
3069
- /** The setters that were given each element, so an update of a spread does not call them again. */
3070
- const given = /* @__PURE__ */ new WeakMap();
3071
3121
  /**
3072
3122
  * Gives the element of a spread to the signal that a `ref` in its attributes is bound to, or to
3073
3123
  * the setter of the binding.
@@ -3079,14 +3129,7 @@ function forwardRef(element, values) {
3079
3129
  if (isSlotReference(target)) {
3080
3130
  const owner = scopes.get(target.scope);
3081
3131
  if (owner) set(owner, target.slot, element);
3082
- } else {
3083
- const key = target instanceof FunctionReference ? `${target.scope}#${target.ref}` : target;
3084
- const seen = given.get(element) ?? /* @__PURE__ */ new Set();
3085
- if (!seen.has(key)) {
3086
- given.set(element, seen.add(key));
3087
- send(target, element);
3088
- }
3089
- }
3132
+ } else give(target, element);
3090
3133
  }
3091
3134
  }
3092
3135
  /** The element of a spread in markup that the browser renders goes to the `ref` of its attributes. */
@@ -3460,4 +3503,4 @@ const loader = {
3460
3503
  //#endregion
3461
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 };
3462
3505
 
3463
- //# sourceMappingURL=client-BvDsC6Qr.js.map
3506
+ //# sourceMappingURL=client-BBtVTOIt.js.map