brumate 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-BkUdiYOF.d.ts → boot-ej-9NRT3.d.ts} +20 -2
- package/dist/cli.js +88 -82
- package/dist/cli.js.map +1 -1
- package/dist/{client-B0FXW5Kw.js → client-B-ww-PQ7.js} +402 -63
- package/dist/client-B-ww-PQ7.js.map +1 -0
- package/dist/{client-Cq6aTiDs.d.ts → client-Do6IBIhI.d.ts} +58 -14
- package/dist/{defer-BMIMP4Hq.js → defer-JD2FK9mV.js} +5 -3
- package/dist/defer-JD2FK9mV.js.map +1 -0
- package/dist/{devtools-calls-DGW6nLZ2.js → devtools-calls-DCjuSkim.js} +3 -3
- package/dist/{devtools-calls-DGW6nLZ2.js.map → devtools-calls-DCjuSkim.js.map} +1 -1
- package/dist/{devtools-panel-B1nF1KB7.js → devtools-panel-DLeWTPhU.js} +4 -4
- package/dist/{devtools-panel-B1nF1KB7.js.map → devtools-panel-DLeWTPhU.js.map} +1 -1
- package/dist/{devtools-B4prrxht.js → devtools-tuq7ATGN.js} +10 -7
- package/dist/devtools-tuq7ATGN.js.map +1 -0
- package/dist/{error-catalog-DakxjSgj.js → error-catalog-BBWB7w-E.js} +11 -4
- package/dist/error-catalog-BBWB7w-E.js.map +1 -0
- package/dist/{error-catalog-VxLbz-6p.js → error-catalog-CbmQqfat.js} +1 -1
- package/dist/{events-LgLdp1R7.js → events-BDVITj3P.js} +3 -5
- package/dist/events-BDVITj3P.js.map +1 -0
- package/dist/{features-DwMYKBIC.js → features-Cte5aj20.js} +8 -2
- package/dist/features-Cte5aj20.js.map +1 -0
- package/dist/{files-D5GtxwEQ.js → files-Bz0lAQzD.js} +2 -2
- package/dist/{files-D5GtxwEQ.js.map → files-Bz0lAQzD.js.map} +1 -1
- package/dist/{html-Cf5uKhLs.js → html-BYuHDvxy.js} +10 -3
- package/dist/html-BYuHDvxy.js.map +1 -0
- package/dist/index.d.ts +71 -19
- package/dist/index.js +3 -3
- package/dist/{inspect-CGl5Y8q6.js → inspect-fpaBJ5pm.js} +1305 -75
- package/dist/inspect-fpaBJ5pm.js.map +1 -0
- package/dist/{loader-BsaSuIoG.js → loader-DMxuZ6He.js} +14 -6
- package/dist/loader-DMxuZ6He.js.map +1 -0
- package/dist/{navigate-BlowKvhB.js → navigate-C5PjwYMh.js} +108 -20
- package/dist/navigate-C5PjwYMh.js.map +1 -0
- package/dist/{produce-CLABZ8k2.d.ts → produce-BDkCsGH7.d.ts} +3 -3
- package/dist/{rpc-C1jYVNAe.js → rpc-DOdrekhP.js} +23 -13
- package/dist/rpc-DOdrekhP.js.map +1 -0
- package/dist/runtime/bundles.d.ts +3 -2
- package/dist/runtime/bundles.js +20 -5
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -3
- package/dist/runtime/client.js +5 -5
- package/dist/runtime/devtools.d.ts +3 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/otel.d.ts +18 -0
- package/dist/runtime/otel.js +127 -0
- package/dist/runtime/otel.js.map +1 -0
- package/dist/runtime/server.d.ts +4 -3
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +4 -1
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -2
- package/dist/runtime/store.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/search-params-qGERTLi3.js +382 -0
- package/dist/search-params-qGERTLi3.js.map +1 -0
- package/dist/{serial-ribg9NAj.js → serial-B2AJ9VGx.js} +1 -1
- package/dist/{serial-ioa17MuY.js → serial-Cj6pDGOq.js} +6 -6
- package/dist/{serial-ioa17MuY.js.map → serial-Cj6pDGOq.js.map} +1 -1
- package/dist/{server-DesBZv5g.d.ts → server-2-LS_KFo.d.ts} +125 -9
- package/dist/{server-BUuf7XPZ.js → server-CRGZMWnK.js} +545 -236
- package/dist/server-CRGZMWnK.js.map +1 -0
- package/dist/{shared-CX_YacDm.js → shared-CUBWrbiM.js} +4 -4
- package/dist/{shared-CX_YacDm.js.map → shared-CUBWrbiM.js.map} +1 -1
- package/dist/sheets-B9Zr50mf.js +105 -0
- package/dist/sheets-B9Zr50mf.js.map +1 -0
- package/dist/{signals-7VVD9C_H.d.ts → signals-BgsJK-uT.d.ts} +16 -6
- package/dist/{static-loader-C_en-4v8.js → static-loader-BDBtWsdg.js} +107 -19
- package/dist/static-loader-BDBtWsdg.js.map +1 -0
- package/dist/{static-loader-UKnK11Em.d.ts → static-loader-CAFn6p0l.d.ts} +2 -2
- package/dist/{store-9_oa0HG1.d.ts → store-BwWg-Iei.d.ts} +79 -2
- package/dist/store-DNr24Z8L.js +950 -0
- package/dist/store-DNr24Z8L.js.map +1 -0
- package/dist/{stream-read-BTsYstJY.js → stream-read-CiLDH60b.js} +2 -2
- package/dist/{stream-read-BTsYstJY.js.map → stream-read-CiLDH60b.js.map} +1 -1
- package/dist/{stream-read-Dek3HnqO.js → stream-read-DVoregpA.js} +1 -1
- package/dist/trace-DT7RGRAV.d.ts +52 -0
- package/dist/trace-browser-C7MFMove.js +170 -0
- package/dist/trace-browser-C7MFMove.js.map +1 -0
- package/dist/trace-flag-Dy267snx.js +7 -0
- package/dist/trace-flag-Dy267snx.js.map +1 -0
- package/dist/{trusted-g_zUJbh2.js → trusted-Bmwg4_hf.js} +12 -5
- package/dist/trusted-Bmwg4_hf.js.map +1 -0
- package/dist/view-transitions-BpnVwtS4.js +141 -0
- package/dist/view-transitions-BpnVwtS4.js.map +1 -0
- package/dist/vite.d.ts +8 -1
- package/dist/vite.js +356 -46
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +8 -0
- package/package.json +13 -1
- package/skills/brumate/SKILL.md +9 -5
- package/skills/brumate/references/errors.md +95 -14
- package/skills/brumate/references/events.md +27 -1
- package/skills/brumate/references/signals.md +4 -4
- package/skills/brumate/references/state.md +79 -4
- package/skills/brumate/references/syntax.md +58 -9
- package/dist/client-B0FXW5Kw.js.map +0 -1
- package/dist/defer-BMIMP4Hq.js.map +0 -1
- package/dist/devtools-B4prrxht.js.map +0 -1
- package/dist/error-catalog-DakxjSgj.js.map +0 -1
- package/dist/events-LgLdp1R7.js.map +0 -1
- package/dist/features-DwMYKBIC.js.map +0 -1
- package/dist/html-Cf5uKhLs.js.map +0 -1
- package/dist/inspect-CGl5Y8q6.js.map +0 -1
- package/dist/loader-BsaSuIoG.js.map +0 -1
- package/dist/navigate-BlowKvhB.js.map +0 -1
- package/dist/rpc-C1jYVNAe.js.map +0 -1
- package/dist/search-params-Wg-0FsMj.js +0 -148
- package/dist/search-params-Wg-0FsMj.js.map +0 -1
- package/dist/server-BUuf7XPZ.js.map +0 -1
- package/dist/static-loader-C_en-4v8.js.map +0 -1
- package/dist/store-Cy4EEyZ7.js +0 -439
- package/dist/store-Cy4EEyZ7.js.map +0 -1
- package/dist/trusted-g_zUJbh2.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { S as stateValues, _ as madeStores, a as FunctionReference, d as addEntryHandlers, f as gateValue, g as isSlotReference, h as isPropWrapper, i as ElementReference, m as isBinding, o as MemoError, p as isAsyncIterable, r as ChildrenReference, s as PARTS, t as Binding, u as SlotReference, v as mergeHandlers, w as useSerialEntry, x as parseId } from "./shared-
|
|
5
|
-
import { r as writeParam, t as readParam } from "./search-params-
|
|
1
|
+
import { S as HAS_WINDOWS, _ as HAS_STORES, a as HAS_CHILDREN, b as HAS_TRIES, c as HAS_FIELDS, d as HAS_LOADING, f as HAS_MODULE_MEMOS, i as HAS_BRIDGES, l as HAS_LATE_MARKUP, m as HAS_ROUTES, n as HAS_BINDINGS, o as HAS_CLIENT_HTML, p as HAS_ROOT_WAIT, s as HAS_DYNAMIC, v as HAS_TEMPLATES, y as HAS_TITLES } from "./features-Cte5aj20.js";
|
|
2
|
+
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-BYuHDvxy.js";
|
|
3
|
+
import { S as setBridgeLoader, _ as onServer, b as sendStore, i as Store, l as findStored, m as isStore, n as HOLDS, u as isBridged, v as pendingOf, y as sameData } from "./store-DNr24Z8L.js";
|
|
4
|
+
import { S as stateValues, _ as madeStores, a as FunctionReference, d as addEntryHandlers, f as gateValue, g as isSlotReference, h as isPropWrapper, i as ElementReference, m as isBinding, o as MemoError, p as isAsyncIterable, r as ChildrenReference, s as PARTS, t as Binding, u as SlotReference, v as mergeHandlers, w as useSerialEntry, x as parseId } from "./shared-CUBWrbiM.js";
|
|
5
|
+
import { r as writeParam, t as readParam } from "./search-params-qGERTLi3.js";
|
|
6
6
|
import { i as missingContext, n as ROUTE_KEY, t as NAVIGATION_KEY } from "./context-CU4Fpn5a.js";
|
|
7
|
-
import { t as trustedHTML } from "./trusted-
|
|
7
|
+
import { t as trustedHTML } from "./trusted-Bmwg4_hf.js";
|
|
8
8
|
import { t as loadOnce } from "./skew-CwmX_GFI.js";
|
|
9
|
+
import { t as TRACE } from "./trace-flag-Dy267snx.js";
|
|
10
|
+
import { o as traceRequest, r as traceContext } from "./trace-browser-C7MFMove.js";
|
|
9
11
|
import { n as navigate } from "./routes-D21FQyGF.js";
|
|
10
12
|
//#region src/runtime/client/state.ts
|
|
11
13
|
let options;
|
|
@@ -340,10 +342,6 @@ let nextId = -1;
|
|
|
340
342
|
function resetIds() {
|
|
341
343
|
nextId = -1;
|
|
342
344
|
}
|
|
343
|
-
/** Returns the instance of a scope by its ID. */
|
|
344
|
-
function getScope(id) {
|
|
345
|
-
return scopes.get(id);
|
|
346
|
-
}
|
|
347
345
|
function findRoot(scope) {
|
|
348
346
|
let current = scope;
|
|
349
347
|
while (current.p) current = current.p;
|
|
@@ -397,6 +395,7 @@ function removeScope(scope) {
|
|
|
397
395
|
}
|
|
398
396
|
if (scope.h) hiding?.bodies.delete(scope.h);
|
|
399
397
|
scopes.delete(scope.id);
|
|
398
|
+
scope.gone = true;
|
|
400
399
|
for (const [check, owner] of waiters) if (owner === scope) check();
|
|
401
400
|
scope.p?.children?.delete(scope);
|
|
402
401
|
scope.o?.owned?.delete(scope);
|
|
@@ -862,12 +861,12 @@ function templateReference(ref, scope) {
|
|
|
862
861
|
}
|
|
863
862
|
/**
|
|
864
863
|
* A call of a `#template` of the file, which an insert can update in place. `render` is the
|
|
865
|
-
* template's code, and `owner` the scope that holds the template. The call
|
|
866
|
-
*
|
|
867
|
-
*
|
|
864
|
+
* template's code, and `owner` the scope that holds the template. The call renders as children
|
|
865
|
+
* of its owner, where the component that gets it inserts it, so it reads the contexts there, as
|
|
866
|
+
* on the server.
|
|
868
867
|
*/
|
|
869
868
|
function templateCall(ref, owner, render, args) {
|
|
870
|
-
return new TemplateCall(ref, owner, args, (at) => insert(render(...args), void 0, at)
|
|
869
|
+
return new TemplateCall(ref, owner, args, (at) => insert(render(...args), void 0, at));
|
|
871
870
|
}
|
|
872
871
|
/** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */
|
|
873
872
|
function insert(value, _ctx, scope) {
|
|
@@ -937,8 +936,8 @@ var TemplateCall = class extends Children {
|
|
|
937
936
|
/** The scope of the component that wrote the template. */
|
|
938
937
|
owner;
|
|
939
938
|
args;
|
|
940
|
-
constructor(ref, owner, args, html
|
|
941
|
-
super(
|
|
939
|
+
constructor(ref, owner, args, html) {
|
|
940
|
+
super(owner, html);
|
|
942
941
|
this.ref = ref;
|
|
943
942
|
this.owner = owner;
|
|
944
943
|
this.args = args;
|
|
@@ -1115,9 +1114,14 @@ async function catchInto(owner, body, module, [, anchor, , fallback, kinds, hold
|
|
|
1115
1114
|
function get(scope, slot) {
|
|
1116
1115
|
if (dirty.size > 0 && !draining) settle(scope);
|
|
1117
1116
|
const value = scope.s[slot];
|
|
1118
|
-
if (value === void 0 && exempt > 0 && !(slot in scope.s)) throw new NotReady(
|
|
1117
|
+
if (value === void 0 && (exempt > 0 || reading > 0) && !(slot in scope.s)) throw new NotReady(unreached);
|
|
1119
1118
|
if (value instanceof Promise && !scope.plain?.has(slot)) {
|
|
1120
1119
|
if (computing > 0) throw new NotReady(value);
|
|
1120
|
+
if (reading > 0 && loadingValues.has(value)) {
|
|
1121
|
+
const result = memoResults.get(value);
|
|
1122
|
+
if (result) return result.value;
|
|
1123
|
+
throw new NotReady(value);
|
|
1124
|
+
}
|
|
1121
1125
|
if (loadingValues.has(value)) {
|
|
1122
1126
|
if (runningEffects > 0) throw new NotReady(value);
|
|
1123
1127
|
if (exempt === 0) throw new Error("This value is still loading. Wait for it with await $resolve(memo), or check $isPending(memo) first");
|
|
@@ -1136,7 +1140,7 @@ function get(scope, slot) {
|
|
|
1136
1140
|
* reads it throws into the nearest `#try` around it, and the code that does not read it runs as
|
|
1137
1141
|
* usual. A memo that computes again without a throw holds its value again.
|
|
1138
1142
|
*/
|
|
1139
|
-
function hold$
|
|
1143
|
+
function hold$2(scope, slot, key, error) {
|
|
1140
1144
|
loadingSlots.delete(key);
|
|
1141
1145
|
loads.delete(key);
|
|
1142
1146
|
guesses?.map.delete(key);
|
|
@@ -1285,6 +1289,15 @@ function startLoading(scope, slot, key) {
|
|
|
1285
1289
|
}
|
|
1286
1290
|
}
|
|
1287
1291
|
/**
|
|
1292
|
+
* Marks the slot of a store that can be pending, such as a debounced value of a module, as loading
|
|
1293
|
+
* or not. `$isPending` and `$resolve` read it as they read a memo.
|
|
1294
|
+
*/
|
|
1295
|
+
function markPending(scope, slot, on) {
|
|
1296
|
+
const key = `${scope.id}:${slot}`;
|
|
1297
|
+
if (on) startLoading(scope, slot, key);
|
|
1298
|
+
else if (loadingSlots.delete(key)) trigger(scope, slot);
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1288
1301
|
* Computes a memo of `$debounced` after its value stops changing for `ms`,
|
|
1289
1302
|
* or one of `$throttled` at most once every `ms`, with the last value after
|
|
1290
1303
|
* the wait. The memo is pending while it waits.
|
|
@@ -1341,7 +1354,7 @@ function asyncMemo(scope, slot, promise) {
|
|
|
1341
1354
|
else trigger(scope, slot);
|
|
1342
1355
|
}
|
|
1343
1356
|
function failed(error) {
|
|
1344
|
-
if (loads.get(key) === load) hold$
|
|
1357
|
+
if (loads.get(key) === load) hold$2(scope, slot, key, error);
|
|
1345
1358
|
}
|
|
1346
1359
|
promise.then((value) => {
|
|
1347
1360
|
if (!isAsyncIterable(value)) {
|
|
@@ -1370,6 +1383,41 @@ var NotReady = class extends Error {
|
|
|
1370
1383
|
this.source = source;
|
|
1371
1384
|
}
|
|
1372
1385
|
};
|
|
1386
|
+
/** The values of the promises of memos of a render that settled, which a read of the memo gives. */
|
|
1387
|
+
const memoResults = /* @__PURE__ */ new WeakMap();
|
|
1388
|
+
let reading = 0;
|
|
1389
|
+
function isReading() {
|
|
1390
|
+
return reading > 0;
|
|
1391
|
+
}
|
|
1392
|
+
const unreached = Promise.resolve();
|
|
1393
|
+
/**
|
|
1394
|
+
* Computes a value of a render that can read a memo that is still loading, as an update does:
|
|
1395
|
+
* the value is a promise that computes again once the memo settles, so what reads it waits.
|
|
1396
|
+
* A second stop at the same wait is no wait for it, so it throws. A scope that goes, `owner`,
|
|
1397
|
+
* computes nothing more. The scopes and the work that a stopped compute started are dropped.
|
|
1398
|
+
*/
|
|
1399
|
+
function pend(compute, owner, last) {
|
|
1400
|
+
const at = owner === void 0 || typeof owner === "object" ? owner : scopes.get(owner) ?? findRendered(owner);
|
|
1401
|
+
const made = rendered.length;
|
|
1402
|
+
const queued = afterInsert.length;
|
|
1403
|
+
reading++;
|
|
1404
|
+
try {
|
|
1405
|
+
return compute();
|
|
1406
|
+
} catch (error) {
|
|
1407
|
+
if (error instanceof NotReady && error.source !== last) {
|
|
1408
|
+
rendered.length = made;
|
|
1409
|
+
afterInsert.length = queued;
|
|
1410
|
+
const source = error.source;
|
|
1411
|
+
return Promise.resolve(source).then(() => at?.gone ? void 0 : pend(compute, at, source));
|
|
1412
|
+
}
|
|
1413
|
+
throw error;
|
|
1414
|
+
} finally {
|
|
1415
|
+
reading--;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
function findRendered(id) {
|
|
1419
|
+
return rendered.find((scope) => scope.id === id);
|
|
1420
|
+
}
|
|
1373
1421
|
let computing = 0;
|
|
1374
1422
|
let origin;
|
|
1375
1423
|
let viaContext = false;
|
|
@@ -1473,7 +1521,7 @@ function memo(scope, slot, compute) {
|
|
|
1473
1521
|
memoKey = outer;
|
|
1474
1522
|
}
|
|
1475
1523
|
if (threw) {
|
|
1476
|
-
hold$
|
|
1524
|
+
hold$2(scope, slot, key, value);
|
|
1477
1525
|
return;
|
|
1478
1526
|
}
|
|
1479
1527
|
if (isThenable(value) || isAsyncIterable(value)) {
|
|
@@ -1780,18 +1828,7 @@ function effect(scope, name, callback, client) {
|
|
|
1780
1828
|
cleanup = callback();
|
|
1781
1829
|
} catch (error) {
|
|
1782
1830
|
if (error instanceof NotReady) {
|
|
1783
|
-
|
|
1784
|
-
skipped.set(key, token);
|
|
1785
|
-
scope.cleanups.set(name, noop$1);
|
|
1786
|
-
function again() {
|
|
1787
|
-
if (skipped.get(key) === token && scopes.get(scope.id) === scope) effect(scope, name, callback);
|
|
1788
|
-
}
|
|
1789
|
-
error.source.then(() => Promise.allSettled(loadingUpdates).then(again), (reason) => {
|
|
1790
|
-
if (skipped.get(key) === token) {
|
|
1791
|
-
skipped.delete(key);
|
|
1792
|
-
fail(scope, reason);
|
|
1793
|
-
}
|
|
1794
|
-
});
|
|
1831
|
+
skipEffect(scope, name, error, () => effect(scope, name, callback));
|
|
1795
1832
|
return;
|
|
1796
1833
|
}
|
|
1797
1834
|
fail(scope, error);
|
|
@@ -1799,16 +1836,70 @@ function effect(scope, name, callback, client) {
|
|
|
1799
1836
|
origin = outer;
|
|
1800
1837
|
if (!client) runningEffects--;
|
|
1801
1838
|
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1839
|
+
scope.cleanups.set(name, reportCleanup(scope, name, toCleanup(cleanup), start, true));
|
|
1840
|
+
}
|
|
1841
|
+
/**
|
|
1842
|
+
* The cleanup of a run as one function, for a value that the callback returned: a function, or
|
|
1843
|
+
* an object with `[Symbol.asyncDispose]` or `[Symbol.dispose]`. Any other value is no cleanup.
|
|
1844
|
+
*/
|
|
1845
|
+
function toCleanup(value) {
|
|
1846
|
+
if (typeof value === "function") return value;
|
|
1847
|
+
if (typeof value === "object" && value !== null) {
|
|
1848
|
+
const dispose = value[Symbol.asyncDispose] ?? value[Symbol.dispose];
|
|
1849
|
+
if (typeof dispose === "function") return () => dispose.call(value);
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* The function that a scope stores for a run. With `catches`, a promise that a cleanup returns,
|
|
1854
|
+
* which fails, goes to `#try`. An async effect awaits the cleanup and sends its failure itself.
|
|
1855
|
+
* In development, each way that a cleanup runs reports it: the next run, a removed scope, a hidden
|
|
1856
|
+
* `#offscreen` body, or a page that navigation leaves.
|
|
1857
|
+
*/
|
|
1858
|
+
function reportCleanup(scope, name, cleanup, start, catches) {
|
|
1859
|
+
if (DEV) devtools()?.effect?.(scope, name, "run", performance.now() - start);
|
|
1860
|
+
else if (!cleanup) return noop$1;
|
|
1861
|
+
return () => {
|
|
1862
|
+
if (DEV) devtools()?.effect?.(scope, name, "cleanup", 0);
|
|
1863
|
+
const result = cleanup?.();
|
|
1864
|
+
if (catches && result instanceof Promise) result.catch((error) => fail(scope, error));
|
|
1865
|
+
return result;
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* A run that reads a value that is still loading is skipped. It runs again when the value arrives,
|
|
1870
|
+
* unless a change ran it first. The cleanup of the run before has already run.
|
|
1871
|
+
*/
|
|
1872
|
+
function skipEffect(scope, name, error, rerun) {
|
|
1873
|
+
const key = `${scope.id}:${name}`;
|
|
1874
|
+
const token = {};
|
|
1875
|
+
skipped.set(key, token);
|
|
1876
|
+
scope.cleanups.set(name, noop$1);
|
|
1877
|
+
function again() {
|
|
1878
|
+
if (skipped.get(key) === token && scopes.get(scope.id) === scope) rerun();
|
|
1879
|
+
}
|
|
1880
|
+
error.source.then(() => Promise.allSettled(loadingUpdates).then(again), (reason) => {
|
|
1881
|
+
if (skipped.get(key) === token) {
|
|
1882
|
+
skipped.delete(key);
|
|
1883
|
+
fail(scope, reason);
|
|
1884
|
+
}
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Calls the callback of an async effect, as `effect` does. Only its synchronous part, up to the
|
|
1889
|
+
* first `await`, counts as running, so a write there does not run the effect again.
|
|
1890
|
+
*/
|
|
1891
|
+
function enterEffect(scope, name, callback, client) {
|
|
1892
|
+
const key = `${scope.id}:${name}`;
|
|
1893
|
+
skipped.delete(key);
|
|
1894
|
+
const outer = origin;
|
|
1895
|
+
origin = key;
|
|
1896
|
+
if (!client) runningEffects++;
|
|
1897
|
+
try {
|
|
1898
|
+
return Promise.resolve(callback());
|
|
1899
|
+
} finally {
|
|
1900
|
+
origin = outer;
|
|
1901
|
+
if (!client) runningEffects--;
|
|
1810
1902
|
}
|
|
1811
|
-
scope.cleanups.set(name, stored);
|
|
1812
1903
|
}
|
|
1813
1904
|
function noop$1() {}
|
|
1814
1905
|
//#endregion
|
|
@@ -1885,9 +1976,19 @@ function findStore(scope, read) {
|
|
|
1885
1976
|
* value that changed since the server render is written now. The scope stops reading when it goes.
|
|
1886
1977
|
*/
|
|
1887
1978
|
function subscribeSlot(scope, slot, found, repair, write) {
|
|
1979
|
+
const holds = found[HOLDS] === true;
|
|
1980
|
+
const read = () => {
|
|
1981
|
+
if (!holds) return found.get();
|
|
1982
|
+
try {
|
|
1983
|
+
return found.get();
|
|
1984
|
+
} catch (error) {
|
|
1985
|
+
return new MemoError(error);
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1888
1988
|
const listener = (value) => {
|
|
1889
|
-
sendContext(() => writeSlot(scope, slot, value));
|
|
1989
|
+
sendContext(() => writeSlot(scope, slot, holds ? read() : value));
|
|
1890
1990
|
};
|
|
1991
|
+
if (HAS_MODULE_MEMOS && repair && holds) found.s?.(scope.s[slot]);
|
|
1891
1992
|
let bridged = false;
|
|
1892
1993
|
let stop;
|
|
1893
1994
|
if (HAS_BRIDGES && repair && isBridged(found)) {
|
|
@@ -1895,8 +1996,18 @@ function subscribeSlot(scope, slot, found, repair, write) {
|
|
|
1895
1996
|
stop = found.subscribe(listener, scope.s[slot]);
|
|
1896
1997
|
} else stop = found.subscribe(listener);
|
|
1897
1998
|
(scope.stops ??= []).push(stop);
|
|
1999
|
+
const waits = pendingOf(found);
|
|
2000
|
+
if (waits) {
|
|
2001
|
+
const listener = (on) => sendContext(() => markPending(scope, slot, on));
|
|
2002
|
+
waits.q.add(listener);
|
|
2003
|
+
scope.stops.push(() => waits.q.delete(listener));
|
|
2004
|
+
if (waits.n) listener(true);
|
|
2005
|
+
}
|
|
1898
2006
|
if (write) (scope.b ??= {})[slot] = (value) => found.set(value);
|
|
1899
|
-
if (repair && !bridged
|
|
2007
|
+
if (repair && !bridged) {
|
|
2008
|
+
const current = read();
|
|
2009
|
+
if (!sameData(current, scope.s[slot])) sendContext(() => writeSlot(scope, slot, current));
|
|
2010
|
+
}
|
|
1900
2011
|
}
|
|
1901
2012
|
/** Links a read of `$store` that a scope resumed with. */
|
|
1902
2013
|
function linkRead(scope, read) {
|
|
@@ -2040,6 +2151,84 @@ function resetGuesses() {
|
|
|
2040
2151
|
if (source && scopes.has(scope.id) && !Object.is(scope.s[slot], source[0].s[source[1]])) set(scope, slot, source[0].s[source[1]]);
|
|
2041
2152
|
}
|
|
2042
2153
|
}
|
|
2154
|
+
/** The stores of `$optimistic` at the top level of a module that hold a guess. */
|
|
2155
|
+
const held$1 = /* @__PURE__ */ new Set();
|
|
2156
|
+
/** The guesses that already put the stores of modules back, with the calls of the page. */
|
|
2157
|
+
const linked = /* @__PURE__ */ new WeakSet();
|
|
2158
|
+
/**
|
|
2159
|
+
* The store of `$optimistic(source)` at the top level of a module: it follows the store `source`,
|
|
2160
|
+
* and an exported function writes a guess with `set`. The guess goes back to the source when the
|
|
2161
|
+
* source changes, or when every server call of the page finishes. On the server a write is
|
|
2162
|
+
* dropped, as the server holds no guess.
|
|
2163
|
+
*/
|
|
2164
|
+
function optimisticStore(source) {
|
|
2165
|
+
const out = new Store(void 0);
|
|
2166
|
+
let count = 0;
|
|
2167
|
+
let guessed = false;
|
|
2168
|
+
let stop;
|
|
2169
|
+
function follow() {
|
|
2170
|
+
if (!stop) {
|
|
2171
|
+
out.v = source.get();
|
|
2172
|
+
stop = source.subscribe((value) => {
|
|
2173
|
+
reset(value);
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
function unfollow() {
|
|
2178
|
+
if (count === 0 && !guessed) {
|
|
2179
|
+
stop?.();
|
|
2180
|
+
stop = void 0;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
function reset(value) {
|
|
2184
|
+
guessed = false;
|
|
2185
|
+
held$1.delete(back);
|
|
2186
|
+
sendStore(out, value);
|
|
2187
|
+
unfollow();
|
|
2188
|
+
}
|
|
2189
|
+
function back() {
|
|
2190
|
+
if (guessed) reset(source.get());
|
|
2191
|
+
}
|
|
2192
|
+
return {
|
|
2193
|
+
get() {
|
|
2194
|
+
return guessed || count > 0 ? out.v : source.get();
|
|
2195
|
+
},
|
|
2196
|
+
set(value) {
|
|
2197
|
+
if (onServer()) return;
|
|
2198
|
+
follow();
|
|
2199
|
+
guessed = true;
|
|
2200
|
+
held$1.add(back);
|
|
2201
|
+
const all = guesses ?? setGuesses({
|
|
2202
|
+
map: /* @__PURE__ */ new Map(),
|
|
2203
|
+
same: sameSource,
|
|
2204
|
+
reset: resetGuesses
|
|
2205
|
+
});
|
|
2206
|
+
if (!linked.has(all)) {
|
|
2207
|
+
linked.add(all);
|
|
2208
|
+
const before = all.reset;
|
|
2209
|
+
all.reset = () => {
|
|
2210
|
+
before();
|
|
2211
|
+
for (const undo of held$1) undo();
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
sendStore(out, value);
|
|
2215
|
+
},
|
|
2216
|
+
subscribe(listener) {
|
|
2217
|
+
const off = out.subscribe(listener);
|
|
2218
|
+
count++;
|
|
2219
|
+
follow();
|
|
2220
|
+
let done = false;
|
|
2221
|
+
return () => {
|
|
2222
|
+
if (!done) {
|
|
2223
|
+
done = true;
|
|
2224
|
+
off();
|
|
2225
|
+
count--;
|
|
2226
|
+
unfollow();
|
|
2227
|
+
}
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2043
2232
|
//#endregion
|
|
2044
2233
|
//#region src/runtime/client/handlers.ts
|
|
2045
2234
|
/** The modifiers that the wrappers of `brumate/events` put on a handler. */
|
|
@@ -2139,7 +2328,7 @@ function fieldValue(element, typed) {
|
|
|
2139
2328
|
* `b-b` anchor, or from the nearest element around it that has one, which
|
|
2140
2329
|
* the compiler checks is in the same scope.
|
|
2141
2330
|
*/
|
|
2142
|
-
function handle(element, entry, event, typed) {
|
|
2331
|
+
function handle(element, entry, event, typed, trace) {
|
|
2143
2332
|
const [ref, owner, encoded] = entry.split("@");
|
|
2144
2333
|
const bound = encoded ? JSON.parse(decodeURIComponent(encoded)) : [];
|
|
2145
2334
|
const anchor = owner ?? element.closest("[b-b]")?.getAttribute("b-b")?.split(":")[0];
|
|
@@ -2166,10 +2355,14 @@ function handle(element, entry, event, typed) {
|
|
|
2166
2355
|
children,
|
|
2167
2356
|
code
|
|
2168
2357
|
]).then(([handler]) => handler);
|
|
2358
|
+
if (TRACE && trace) {
|
|
2359
|
+
trace.waits ||= !modules.has(ref.split("#")[0]) || !!children || !!code;
|
|
2360
|
+
loaded.then(() => trace.ready(), (error) => trace.ready(true, error));
|
|
2361
|
+
}
|
|
2169
2362
|
const started = lastHandler.then(() => loaded).then((handler) => {
|
|
2170
|
-
if (!DEV) return { value: pass(() => handler(scope, ...args)) };
|
|
2363
|
+
if (!DEV) return { value: TRACE && trace ? trace.run(() => pass(() => handler(scope, ...args))) : pass(() => handler(scope, ...args)) };
|
|
2171
2364
|
const ready = performance.now();
|
|
2172
|
-
const value = pass(() => handler(scope, ...args));
|
|
2365
|
+
const value = TRACE && trace ? trace.run(() => pass(() => handler(scope, ...args))) : pass(() => handler(scope, ...args));
|
|
2173
2366
|
devtools()?.handled?.({
|
|
2174
2367
|
ref,
|
|
2175
2368
|
element,
|
|
@@ -2184,8 +2377,17 @@ function handle(element, entry, event, typed) {
|
|
|
2184
2377
|
lastHandler = started.catch(() => {});
|
|
2185
2378
|
return started.then((result) => result.value).catch((error) => {
|
|
2186
2379
|
fail(scope, error);
|
|
2380
|
+
if (TRACE) trace?.fail(error);
|
|
2187
2381
|
});
|
|
2188
2382
|
}
|
|
2383
|
+
/** The span of a call of a server function. It has no argument, result or query string. */
|
|
2384
|
+
function traceCall(id, parent) {
|
|
2385
|
+
const route = `${rpcPrefix}/${id}`;
|
|
2386
|
+
return traceRequest("brumate.fetch", id, route, {
|
|
2387
|
+
"http.method": "POST",
|
|
2388
|
+
"http.route": route
|
|
2389
|
+
}, parent);
|
|
2390
|
+
}
|
|
2189
2391
|
/** Renders the attributes of a form or button that posts to a server function. */
|
|
2190
2392
|
function action(name, id, method, result) {
|
|
2191
2393
|
return actionAttributes(rpcPrefix, name, id, method, result, build);
|
|
@@ -2195,12 +2397,14 @@ function action(name, id, method, result) {
|
|
|
2195
2397
|
* call loads, so the core holds only this.
|
|
2196
2398
|
*/
|
|
2197
2399
|
function submitAction(form, submitter) {
|
|
2198
|
-
|
|
2400
|
+
const trace = TRACE ? traceCall(form.getAttribute("b-action")) : void 0;
|
|
2401
|
+
import("./rpc-DOdrekhP.js").then((module) => module.sendAction(form, submitter, trace));
|
|
2199
2402
|
}
|
|
2200
2403
|
/** Calls a server function. */
|
|
2201
2404
|
async function rpc(id, args) {
|
|
2202
2405
|
const signal = memoSignal();
|
|
2203
|
-
|
|
2406
|
+
const trace = TRACE ? traceCall(id, traceContext()) : void 0;
|
|
2407
|
+
return track(import("./rpc-DOdrekhP.js").then((module) => module.call(rpcPrefix, id, args, signal, trace)));
|
|
2204
2408
|
}
|
|
2205
2409
|
/** A function prop rendered on the client calls the parent's exported handler. */
|
|
2206
2410
|
function handlerProp(value, ref, scope, bound = [], modifiers) {
|
|
@@ -2912,6 +3116,7 @@ const memoLoads = /* @__PURE__ */ new WeakMap();
|
|
|
2912
3116
|
*/
|
|
2913
3117
|
function memoNow(value) {
|
|
2914
3118
|
if (isThenable(value) || isAsyncIterable(value)) memoLoads.set(value, (memoLoads.get(value) ?? 0) + 1);
|
|
3119
|
+
if (isThenable(value)) value.then((result) => memoResults.set(value, { value: result }), noop$1);
|
|
2915
3120
|
return value;
|
|
2916
3121
|
}
|
|
2917
3122
|
/**
|
|
@@ -2920,14 +3125,22 @@ function memoNow(value) {
|
|
|
2920
3125
|
*/
|
|
2921
3126
|
function renderMemo(compute) {
|
|
2922
3127
|
try {
|
|
2923
|
-
return memoNow(compute());
|
|
3128
|
+
return memoNow(pend(compute, rendered.at(-1)));
|
|
2924
3129
|
} catch (error) {
|
|
2925
3130
|
return new MemoError(error);
|
|
2926
3131
|
}
|
|
2927
3132
|
}
|
|
2928
|
-
/**
|
|
3133
|
+
/**
|
|
3134
|
+
* Reads a memo of a render: the error that a throw held is thrown at the read. A memo that is
|
|
3135
|
+
* still loading stops the code that reads it, which waits for the memo.
|
|
3136
|
+
*/
|
|
2929
3137
|
function readMemo(value) {
|
|
2930
3138
|
if (value instanceof MemoError) throw value.error;
|
|
3139
|
+
if (isThenable(value) && memoLoads.has(value)) {
|
|
3140
|
+
const result = memoResults.get(value);
|
|
3141
|
+
if (result) return result.value;
|
|
3142
|
+
if (isReading()) throw new NotReady(value);
|
|
3143
|
+
}
|
|
2931
3144
|
return value;
|
|
2932
3145
|
}
|
|
2933
3146
|
function setSlots(id, values) {
|
|
@@ -3131,7 +3344,7 @@ const writtenInserts = /* @__PURE__ */ new WeakSet();
|
|
|
3131
3344
|
function renderedTemplate(call, at, k, first, end) {
|
|
3132
3345
|
if (k === void 0) return;
|
|
3133
3346
|
let found;
|
|
3134
|
-
for (const scope of scopes.values()) if (call.owner && scope.p === call.owner && scope.k === k && (scope.t === at || scope.l === at && inRange(scope, first, end))
|
|
3347
|
+
for (const scope of scopes.values()) if (call.owner && scope.p === call.owner && scope.k === k && (scope.t === at || scope.l === at) && inRange(scope, first, end)) {
|
|
3135
3348
|
if (found) return;
|
|
3136
3349
|
found = scope;
|
|
3137
3350
|
}
|
|
@@ -3140,17 +3353,39 @@ function renderedTemplate(call, at, k, first, end) {
|
|
|
3140
3353
|
scope: found
|
|
3141
3354
|
};
|
|
3142
3355
|
}
|
|
3143
|
-
/**
|
|
3356
|
+
/**
|
|
3357
|
+
* True if the range holds markup of the scope or of a scope inside it: an anchor, a comment or an
|
|
3358
|
+
* element, or a kept node. A template that only renders a component has no anchor of its own, so
|
|
3359
|
+
* the anchors of the scopes it made count too.
|
|
3360
|
+
*/
|
|
3144
3361
|
function inRange(scope, first, end) {
|
|
3145
|
-
const
|
|
3146
|
-
const element = `${scope.id}:`;
|
|
3362
|
+
const kept = keptNodes(scope, []);
|
|
3147
3363
|
for (let node = first; node && node !== end; node = node.nextSibling) {
|
|
3148
3364
|
const walker = document.createTreeWalker(node, 129);
|
|
3149
|
-
for (let item = node; item; item = walker.nextNode())
|
|
3150
|
-
|
|
3365
|
+
for (let item = node; item; item = walker.nextNode()) {
|
|
3366
|
+
let id;
|
|
3367
|
+
if (item.nodeType === 8) {
|
|
3368
|
+
const data = item.data;
|
|
3369
|
+
id = MARKER.test(data) ? data.slice(1).split(":")[0] : void 0;
|
|
3370
|
+
} else if (item.nodeType === 1) id = item.getAttribute("b-b")?.split(":")[0];
|
|
3371
|
+
if (id !== void 0 && isInside(scopes.get(parseId(id)), scope)) return true;
|
|
3372
|
+
}
|
|
3373
|
+
for (const item of kept) if (item === node || node.contains(item)) return true;
|
|
3151
3374
|
}
|
|
3152
3375
|
return false;
|
|
3153
3376
|
}
|
|
3377
|
+
/** True if `found` is `scope` or a scope that it made, by its parents and owners. */
|
|
3378
|
+
function isInside(found, scope) {
|
|
3379
|
+
for (let current = found; current; current = current.p ?? current.o) if (current === scope) return true;
|
|
3380
|
+
return false;
|
|
3381
|
+
}
|
|
3382
|
+
/** Adds the nodes that the scope and the scopes inside it keep, of markup the browser cloned. */
|
|
3383
|
+
function keptNodes(scope, nodes) {
|
|
3384
|
+
for (const node of scope.n ?? []) if (node) nodes.push(node);
|
|
3385
|
+
for (const child of scope.children ?? []) keptNodes(child, nodes);
|
|
3386
|
+
for (const child of scope.owned ?? []) keptNodes(child, nodes);
|
|
3387
|
+
return nodes;
|
|
3388
|
+
}
|
|
3154
3389
|
/** The `value` and `checked` that updates last wrote to each field. */
|
|
3155
3390
|
const fieldValues = /* @__PURE__ */ new WeakMap();
|
|
3156
3391
|
function setAttribute(element, name, value, spread = false) {
|
|
@@ -3412,6 +3647,17 @@ function fillSettled(id, values, write) {
|
|
|
3412
3647
|
}, (error) => failOnce(scope, own, error));
|
|
3413
3648
|
}
|
|
3414
3649
|
/**
|
|
3650
|
+
* A write of cloned markup whose values come from code that can read a memo that is still
|
|
3651
|
+
* loading, such as a block header or a prop that calls a function. The write waits for the memo,
|
|
3652
|
+
* and runs again with its value. It counts in the boundary of the render, as `fillSettled` does.
|
|
3653
|
+
*/
|
|
3654
|
+
function fillPend(id, write) {
|
|
3655
|
+
const waiting = pend(() => {
|
|
3656
|
+
write();
|
|
3657
|
+
}, id);
|
|
3658
|
+
if (isThenable(waiting)) fillSettled(id, [waiting], noop$1);
|
|
3659
|
+
}
|
|
3660
|
+
/**
|
|
3415
3661
|
* A value of markup that the browser writes, in text or an attribute, which can be a promise.
|
|
3416
3662
|
* A value that is not one is written at once. A promise counts in the boundary of the render, as
|
|
3417
3663
|
* a memo of `fillSettled` does, and `write` gets its value once it settles. The scope keeps the
|
|
@@ -3619,7 +3865,7 @@ function drop(at) {
|
|
|
3619
3865
|
* nothing waits, otherwise when the waits end. A block that asks again for the key that it
|
|
3620
3866
|
* holds keeps waiting, and another key drops the held body.
|
|
3621
3867
|
*/
|
|
3622
|
-
function hold(at, key, render, show) {
|
|
3868
|
+
function hold$1(at, key, render, show) {
|
|
3623
3869
|
const held = holds.get(at);
|
|
3624
3870
|
if (held && Object.is(held[0], key)) {
|
|
3625
3871
|
held[2] = false;
|
|
@@ -3651,7 +3897,7 @@ function swap(scope, kinds, start, key, render, mark) {
|
|
|
3651
3897
|
for (const child of scope.children ?? []) if (!old.has(child)) made.push(child);
|
|
3652
3898
|
return out;
|
|
3653
3899
|
}
|
|
3654
|
-
hold(start, key, renderNew, (out) => {
|
|
3900
|
+
hold$1(start, key, renderNew, (out) => {
|
|
3655
3901
|
for (const child of Array.from(scope.children ?? [])) if (kinds.includes(child.k) && !made.includes(child)) destroy(child);
|
|
3656
3902
|
const end = rangeEnd(start);
|
|
3657
3903
|
removeBlock(scope, [], start, end);
|
|
@@ -3946,7 +4192,7 @@ function fill(scope, anchor, render, kinds = [], holderKind, holderAnchor) {
|
|
|
3946
4192
|
if (!start || start.data.split(":").length > 2) return;
|
|
3947
4193
|
if (HAS_ROOT_WAIT) {
|
|
3948
4194
|
const body = inPlace(scope, render, holderKind, holderAnchor);
|
|
3949
|
-
hold(start, 1, () => body(scope), (out) => {
|
|
4195
|
+
hold$1(start, 1, () => body(scope), (out) => {
|
|
3950
4196
|
start.data += ":1";
|
|
3951
4197
|
const end = rangeEnd(start);
|
|
3952
4198
|
removeBlock(scope, kinds, start, end);
|
|
@@ -3975,7 +4221,7 @@ function offscreen(scope, anchor, value, render, kind, holderKind, holderAnchor)
|
|
|
3975
4221
|
if (state === "-1") {
|
|
3976
4222
|
if (HAS_ROOT_WAIT) {
|
|
3977
4223
|
const body = inPlace(scope, render, holderKind, holderAnchor);
|
|
3978
|
-
hold(start, 1, () => body(scope), (out) => insertHTML(end, out));
|
|
4224
|
+
hold$1(start, 1, () => body(scope), (out) => insertHTML(end, out));
|
|
3979
4225
|
return;
|
|
3980
4226
|
}
|
|
3981
4227
|
insertHTML(end, inPlace(scope, render, holderKind, holderAnchor)(scope));
|
|
@@ -4216,7 +4462,7 @@ function list(scope, anchor, items, key, given, assign, givenFallback, fallbackK
|
|
|
4216
4462
|
if (count === 0 && !(park && park.total > 0)) {
|
|
4217
4463
|
if (previous.size === 0 && others) return;
|
|
4218
4464
|
if (HAS_ROOT_WAIT) {
|
|
4219
|
-
hold(start, 0, () => fallback ? fallback(scope) : "", (out) => {
|
|
4465
|
+
hold$1(start, 0, () => fallback ? fallback(scope) : "", (out) => {
|
|
4220
4466
|
removeBlock(scope, [], start, end);
|
|
4221
4467
|
insertHTML(end, out);
|
|
4222
4468
|
});
|
|
@@ -4504,6 +4750,99 @@ function addStyle(id, css) {
|
|
|
4504
4750
|
return "";
|
|
4505
4751
|
}
|
|
4506
4752
|
//#endregion
|
|
4753
|
+
//#region src/runtime/client/async-effect.ts
|
|
4754
|
+
const runs = /* @__PURE__ */ new WeakMap();
|
|
4755
|
+
/**
|
|
4756
|
+
* Runs an async effect, or a `$client` callback when `client` is set. One run goes at a time: a
|
|
4757
|
+
* change while it is busy makes one run after it, and after its cleanup, has settled.
|
|
4758
|
+
*/
|
|
4759
|
+
function asyncEffect(scope, name, callback, client) {
|
|
4760
|
+
if (hiding?.paused(scope, name)) return;
|
|
4761
|
+
let byName = runs.get(scope);
|
|
4762
|
+
if (!byName) {
|
|
4763
|
+
byName = /* @__PURE__ */ new Map();
|
|
4764
|
+
runs.set(scope, byName);
|
|
4765
|
+
}
|
|
4766
|
+
let run = byName.get(name);
|
|
4767
|
+
if (!run) {
|
|
4768
|
+
run = { callback };
|
|
4769
|
+
byName.set(name, run);
|
|
4770
|
+
}
|
|
4771
|
+
run.callback = callback;
|
|
4772
|
+
run.client = client;
|
|
4773
|
+
if (run.busy) {
|
|
4774
|
+
run.again = true;
|
|
4775
|
+
return;
|
|
4776
|
+
}
|
|
4777
|
+
scope.cleanups ??= /* @__PURE__ */ new Map();
|
|
4778
|
+
run.busy = true;
|
|
4779
|
+
const own = run;
|
|
4780
|
+
const token = { gone: false };
|
|
4781
|
+
scope.cleanups.set(name, () => stop(scope, name, own, token));
|
|
4782
|
+
hold(scope, name, run, execute(scope, name, run, token));
|
|
4783
|
+
}
|
|
4784
|
+
/** Marks the run as busy until its work settles, and starts the run that waited. */
|
|
4785
|
+
function hold(scope, name, run, work) {
|
|
4786
|
+
run.busy = true;
|
|
4787
|
+
work.then(() => {
|
|
4788
|
+
run.busy = false;
|
|
4789
|
+
if (run.again) {
|
|
4790
|
+
run.again = false;
|
|
4791
|
+
if (scopes.get(scope.id) === scope) asyncEffect(scope, name, run.callback, run.client);
|
|
4792
|
+
}
|
|
4793
|
+
});
|
|
4794
|
+
}
|
|
4795
|
+
/**
|
|
4796
|
+
* The cleanup that the scope calls when a body hides, a scope goes or a page is left. It never
|
|
4797
|
+
* waits. A run that is pending cleans up when it settles, and an idle one cleans up at once.
|
|
4798
|
+
*/
|
|
4799
|
+
function stop(scope, name, run, token) {
|
|
4800
|
+
token.gone = true;
|
|
4801
|
+
const cleanup = run.cleanup;
|
|
4802
|
+
if (!run.busy && cleanup) {
|
|
4803
|
+
run.cleanup = void 0;
|
|
4804
|
+
hold(scope, name, run, clean(scope, cleanup));
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
/** Runs a cleanup and waits for it. A failure goes to `#try`. */
|
|
4808
|
+
async function clean(scope, cleanup) {
|
|
4809
|
+
try {
|
|
4810
|
+
await cleanup();
|
|
4811
|
+
} catch (error) {
|
|
4812
|
+
fail(scope, error);
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
async function execute(scope, name, run, token) {
|
|
4816
|
+
const before = run.cleanup;
|
|
4817
|
+
if (before) {
|
|
4818
|
+
run.cleanup = void 0;
|
|
4819
|
+
await clean(scope, before);
|
|
4820
|
+
run.again = false;
|
|
4821
|
+
}
|
|
4822
|
+
if (token.gone) return;
|
|
4823
|
+
const start = DEV ? performance.now() : 0;
|
|
4824
|
+
let value;
|
|
4825
|
+
if (DEV) devtools()?.effect?.(scope, name, "pending", 0);
|
|
4826
|
+
try {
|
|
4827
|
+
value = await enterEffect(scope, name, run.callback, run.client);
|
|
4828
|
+
} catch (error) {
|
|
4829
|
+
if (error instanceof NotReady) {
|
|
4830
|
+
if (DEV) devtools()?.effect?.(scope, name, "skip", 0);
|
|
4831
|
+
skipEffect(scope, name, error, () => asyncEffect(scope, name, run.callback, run.client));
|
|
4832
|
+
return;
|
|
4833
|
+
}
|
|
4834
|
+
if (DEV) devtools()?.effect?.(scope, name, "run", performance.now() - start);
|
|
4835
|
+
fail(scope, error);
|
|
4836
|
+
return;
|
|
4837
|
+
}
|
|
4838
|
+
const stored = reportCleanup(scope, name, toCleanup(value), start);
|
|
4839
|
+
if (token.gone) {
|
|
4840
|
+
await clean(scope, stored);
|
|
4841
|
+
return;
|
|
4842
|
+
}
|
|
4843
|
+
run.cleanup = stored;
|
|
4844
|
+
}
|
|
4845
|
+
//#endregion
|
|
4507
4846
|
//#region src/runtime/client/search.ts
|
|
4508
4847
|
/** The signals of the page that follow a parameter, by scope and slot. */
|
|
4509
4848
|
const bound = /* @__PURE__ */ new Map();
|
|
@@ -4656,6 +4995,6 @@ const loader = {
|
|
|
4656
4995
|
};
|
|
4657
4996
|
function noop() {}
|
|
4658
4997
|
//#endregion
|
|
4659
|
-
export {
|
|
4998
|
+
export { setItem as $, set as $t, loading as A, submitAction as At, writeText as B, updateRoute as Bt, countLoads as C, skew as Cn, remount as Ct, fillSpread as D, handlerProp as Dt, fillSettled as E, handle as Et, attrs as F, consumeStore as Ft, dynamic as G, effect as Gt, spreadProps as H, binding as Ht, content as I, provideValue as It, foreignNodes as J, isBound as Jt, dynamicNodes as K, gate as Kt, portalTo as L, setGlobal as Lt, started as M, optimisticStore as Mt, wait as N, track as Nt, fillValue as O, rpc as Ot, attr as P, consumeContext as Pt, renderMemo as Q, resolve as Qt, restRef as R, storeUpdate as Rt, attempt as S, scopes as Sn, leaveRoutes as St, fillPend as T, action as Tt, component as U, bindings as Ut, prop as V, asyncMemo as Vt, componentNodes as W, cells as Wt, place as X, pend as Xt, memoNow as Y, memo as Yt, readMemo as Z, pending as Zt, offscreen as _, loadModule as _n, template as _t, addHead as a, children as an, fillList as at, retag as b, hooks as bn, init as bt, deferInBrowser as c, title as cn, listNodes as ct, toList as d, descendants as dn, putText as dt, timed as en, setSlots as et, windowList as f, makeId as fn, setAttr as ft, held as g, nameComment as gn, setSpread as gt, fill as h, sink as hn, setOn as ht, asyncEffect as i, fail as in, fillBranch as it, reveal as j, guess as jt, keepValue as k, spread as kt, setVar as l, afterInsert as ln, markBlock as lt, branch as m, setOwner as mn, setContent as mt, paramEffect as n, update as nn, branchNodes as nt, addPortal as o, insert as on, keep as ot, windowStart as p, removeScope as pn, setAttrText as pt, elementAt as q, get as qt, searchParam as r, updated as rn, clone as rt, addStyle as s, templateCall as sn, keepText as st, loader as t, unreadMemo as tn, appendText as tt, list as u, createScope as un, nodes as ut, rekey as v, DEVTOOLS as vn, dispose as vt, fillAttrs as w, removeRoot as wt, after as x, rpcPrefix as xn, leavePage as xt, reset as y, build as yn, forget as yt, text as z, toStore as zt };
|
|
4660
4999
|
|
|
4661
|
-
//# sourceMappingURL=client-
|
|
5000
|
+
//# sourceMappingURL=client-B-ww-PQ7.js.map
|