brumate 0.6.0 → 0.6.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.
- package/dist/{boot-CMvhoWRu.d.ts → boot-DkbcqdUz.d.ts} +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-eVI8Wc95.js → client-C3vRNuLi.js} +186 -78
- package/dist/client-C3vRNuLi.js.map +1 -0
- package/dist/{client-C4kNKGwH.d.ts → client-CqGDbWd_.d.ts} +29 -5
- package/dist/{defer-pKO0S6UT.js → defer-M18UKyfG.js} +2 -2
- package/dist/{defer-pKO0S6UT.js.map → defer-M18UKyfG.js.map} +1 -1
- package/dist/{devtools-DqqqdI4b.js → devtools-YnvrZ6D8.js} +4 -4
- package/dist/{devtools-DqqqdI4b.js.map → devtools-YnvrZ6D8.js.map} +1 -1
- package/dist/{devtools-panel--GYjFZ35.js → devtools-panel-DRcKclEG.js} +2 -2
- package/dist/{devtools-panel--GYjFZ35.js.map → devtools-panel-DRcKclEG.js.map} +1 -1
- package/dist/{files-CR-V05xd.js → files-HzPDUyTY.js} +2 -2
- package/dist/{files-CR-V05xd.js.map → files-HzPDUyTY.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/{inspect-ddfGeww0.js → inspect-Q5W0A66e.js} +241 -66
- package/dist/inspect-Q5W0A66e.js.map +1 -0
- package/dist/{loader-CQkAXO0g.js → loader-C-S3yzep.js} +4 -4
- package/dist/{loader-CQkAXO0g.js.map → loader-C-S3yzep.js.map} +1 -1
- package/dist/{navigate-BcV1qkkx.js → navigate-r23FFR6e.js} +5 -2
- package/dist/{navigate-BcV1qkkx.js.map → navigate-r23FFR6e.js.map} +1 -1
- package/dist/{rpc-BgYnfg_a.js → rpc-C_znDZ_w.js} +2 -2
- package/dist/{rpc-BgYnfg_a.js.map → rpc-C_znDZ_w.js.map} +1 -1
- package/dist/runtime/bundles.d.ts +1 -1
- package/dist/runtime/client.d.ts +2 -2
- package/dist/runtime/client.js +2 -2
- package/dist/runtime/devtools.d.ts +1 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +1 -1
- package/dist/runtime/testing.js +1 -1
- package/dist/{static-loader-DCxASuzA.js → static-loader-Bt2WDkY1.js} +2 -2
- package/dist/{static-loader-DCxASuzA.js.map → static-loader-Bt2WDkY1.js.map} +1 -1
- package/dist/{static-loader-CGthkX0s.d.ts → static-loader-DysAET-w.d.ts} +2 -2
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +3 -3
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +8 -2
- package/package.json +1 -1
- package/skills/brumate/references/errors.md +14 -0
- package/dist/client-eVI8Wc95.js.map +0 -1
- package/dist/inspect-ddfGeww0.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as SerialEntry } from "./values-B8C7CLvG.js";
|
|
2
|
-
import { Wt as ClientModule } from "./client-
|
|
2
|
+
import { Wt as ClientModule } from "./client-CqGDbWd_.js";
|
|
3
3
|
//#region src/runtime/boot.d.ts
|
|
4
4
|
interface LoaderOptions {
|
|
5
5
|
/**
|
|
@@ -51,4 +51,4 @@ interface NavigateOptions {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
export { NavigateOptions as n, LoaderOptions as t };
|
|
54
|
-
//# sourceMappingURL=boot-
|
|
54
|
+
//# sourceMappingURL=boot-DkbcqdUz.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-
|
|
3
|
-
import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-
|
|
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-Q5W0A66e.js";
|
|
3
|
+
import { h as findPackages, o as findPackageServerFile, s as findServerImport, t as collectSources, v as resolveComponentPackage } from "./files-HzPDUyTY.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import { cp } from "node:fs/promises";
|
|
@@ -49,6 +49,12 @@ const loads = /* @__PURE__ */ new Map();
|
|
|
49
49
|
const loadingSlots = /* @__PURE__ */ new Set();
|
|
50
50
|
/** The timers of debounced and throttled memos, by `scope:slot`, with when each last computed. */
|
|
51
51
|
const timers = /* @__PURE__ */ new Map();
|
|
52
|
+
/**
|
|
53
|
+
* The slots that the browser wrote since the page loaded, as `module:kind:slot`. The key has no
|
|
54
|
+
* instance: a write in one instance of a component marks the slot in all of them, so `refresh`
|
|
55
|
+
* runs more updates than it needs, never fewer.
|
|
56
|
+
*/
|
|
57
|
+
const written = /* @__PURE__ */ new Set();
|
|
52
58
|
/** Aborts the server function calls of a memo's compute, by memo key. */
|
|
53
59
|
const memoControllers = /* @__PURE__ */ new Map();
|
|
54
60
|
/**
|
|
@@ -76,13 +82,6 @@ function setHiding(value) {
|
|
|
76
82
|
/** Children that render where they are inserted, and the scopes that they find contexts from. */
|
|
77
83
|
const insertedChildren = [];
|
|
78
84
|
/**
|
|
79
|
-
* Slots that the render of a component in the browser filled with a promise,
|
|
80
|
-
* by `scope:slot`. The first compute of their memo takes that promise
|
|
81
|
-
* instead of calling again, so a server function is called once per row.
|
|
82
|
-
* A slot that `wait` filled with the settled value keeps it.
|
|
83
|
-
*/
|
|
84
|
-
const renderedLoads = /* @__PURE__ */ new Set();
|
|
85
|
-
/**
|
|
86
85
|
* The promises that the page knows are values still loading: a memo that the server streams, and
|
|
87
86
|
* a memo that the browser rendered. Any other promise in a slot is a plain value.
|
|
88
87
|
*/
|
|
@@ -415,7 +414,11 @@ function removeBlock(scope, kinds, start, end) {
|
|
|
415
414
|
* closes, but not the scope of the block or those around it.
|
|
416
415
|
*/
|
|
417
416
|
function destroyRange(scope, start, end) {
|
|
418
|
-
|
|
417
|
+
destroyNodes(scope, start.nextSibling, end);
|
|
418
|
+
}
|
|
419
|
+
/** Destroys the scopes whose markup is from `first` up to `end`, or to the last sibling. */
|
|
420
|
+
function destroyNodes(scope, first, end) {
|
|
421
|
+
if (scopes.size > 0 && first !== end) {
|
|
419
422
|
const above = /* @__PURE__ */ new Set();
|
|
420
423
|
for (let current = scope; current; current = current.p ?? current.o) above.add(current);
|
|
421
424
|
const inside = /* @__PURE__ */ new Set();
|
|
@@ -423,7 +426,7 @@ function destroyRange(scope, start, end) {
|
|
|
423
426
|
const found = scopes.get(parseId(id));
|
|
424
427
|
if (found && !above.has(found)) inside.add(found);
|
|
425
428
|
}
|
|
426
|
-
for (let node =
|
|
429
|
+
for (let node = first; node && node !== end; node = node.nextSibling) {
|
|
427
430
|
const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT);
|
|
428
431
|
for (let current = walker.currentNode; current; current = walker.nextNode()) if (current.nodeType === 1) {
|
|
429
432
|
const key = current.getAttribute("b-b");
|
|
@@ -578,10 +581,13 @@ let refreshing = false;
|
|
|
578
581
|
* Updates scopes that the server rendered before values changed on the
|
|
579
582
|
* client, such as the body of a `#loading` block that streams in after an
|
|
580
583
|
* event. Effects do not run: they run only when a value changes. With
|
|
581
|
-
* `
|
|
582
|
-
*
|
|
584
|
+
* `memos` off, as for a body that was held, the memos stay: they compute without the page, so the
|
|
585
|
+
* writes during the hold reached them. With `onlyWritten`, as for the body of a
|
|
586
|
+
* `#defer` block, which the server rendered for this request, only the updates that read a slot
|
|
587
|
+
* that the browser wrote run, because the other slots of the page can hold the values of a render
|
|
588
|
+
* for no request, such as a context in a prerendered page.
|
|
583
589
|
*/
|
|
584
|
-
function refresh(added,
|
|
590
|
+
function refresh(added, onlyWritten = false, memos = true) {
|
|
585
591
|
const byModule = /* @__PURE__ */ new Map();
|
|
586
592
|
for (const scope of added) {
|
|
587
593
|
const id = findRoot(scope).m;
|
|
@@ -592,7 +598,7 @@ function refresh(added, memosOnly = false) {
|
|
|
592
598
|
}
|
|
593
599
|
for (const [id, list] of byModule) loadModule(id).then(async (module) => {
|
|
594
600
|
const byKind = /* @__PURE__ */ new Map();
|
|
595
|
-
for (const scope of list) if (!byKind.has(scope.k)) byKind.set(scope.k, refreshNames(module, scope.k,
|
|
601
|
+
for (const scope of list) if (!byKind.has(scope.k)) byKind.set(scope.k, refreshNames(module, id, scope.k, onlyWritten, memos));
|
|
596
602
|
let any = false;
|
|
597
603
|
for (const names of byKind.values()) any ||= names.length > 0;
|
|
598
604
|
if (!any) return;
|
|
@@ -609,13 +615,17 @@ function refresh(added, memosOnly = false) {
|
|
|
609
615
|
});
|
|
610
616
|
}
|
|
611
617
|
/** The names of the updates of a kind of scope that `refresh` runs, memos first. */
|
|
612
|
-
function refreshNames(module, kind,
|
|
618
|
+
function refreshNames(module, id, kind, onlyWritten, withMemos) {
|
|
613
619
|
const memos = /* @__PURE__ */ new Set();
|
|
614
620
|
const others = /* @__PURE__ */ new Set();
|
|
615
|
-
for (const slots of Object.
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
|
|
621
|
+
for (const [source, slots] of Object.entries(module.g)) for (const [slot, entries] of Object.entries(slots)) {
|
|
622
|
+
if (onlyWritten && !written.has(`${id}:${source}:${slot}`)) continue;
|
|
623
|
+
for (const [entryKind, name] of entries) {
|
|
624
|
+
if (entryKind !== kind || name[0] === "e") continue;
|
|
625
|
+
if (name[0] === "m") {
|
|
626
|
+
if (withMemos) memos.add(name);
|
|
627
|
+
} else others.add(name);
|
|
628
|
+
}
|
|
619
629
|
}
|
|
620
630
|
return [...memos, ...others];
|
|
621
631
|
}
|
|
@@ -629,7 +639,7 @@ function insertHTML(before, html) {
|
|
|
629
639
|
if (typeof html === "string") fragments = [parseHTML(html, "parent" in before ? before.parent : before)];
|
|
630
640
|
else fragments = Array.isArray(html) ? html : [html];
|
|
631
641
|
if (HAS_LATE_MARKUP && markerObserver) indexAdded(markerObserver.takeRecords());
|
|
632
|
-
|
|
642
|
+
rendered.length = 0;
|
|
633
643
|
const fromServer = !cloned && SERVER_SCOPES.test(html);
|
|
634
644
|
const ids = fromServer ? /* @__PURE__ */ new Set() : void 0;
|
|
635
645
|
const markup = clonedMarkup;
|
|
@@ -671,9 +681,6 @@ function insertHTML(before, html) {
|
|
|
671
681
|
afterInsert.length = 0;
|
|
672
682
|
}
|
|
673
683
|
if (server.length > 0) refresh(server);
|
|
674
|
-
const live = [];
|
|
675
|
-
for (const scope of client) if (scopes.has(scope.id)) live.push(scope);
|
|
676
|
-
if (live.length > 0) refresh(live, true);
|
|
677
684
|
}
|
|
678
685
|
/**
|
|
679
686
|
* True when a clone holds markup that it rendered as HTML, or markers and `<template>` elements
|
|
@@ -737,6 +744,12 @@ function holdPlace(out) {
|
|
|
737
744
|
}
|
|
738
745
|
//#endregion
|
|
739
746
|
//#region src/runtime/client/references.ts
|
|
747
|
+
/**
|
|
748
|
+
* The handlers that the core makes from references, with their references,
|
|
749
|
+
* so a spread in markup that the browser renders passes them on in `b-on`,
|
|
750
|
+
* as a spread on the server does.
|
|
751
|
+
*/
|
|
752
|
+
const handlerReferences = /* @__PURE__ */ new WeakMap();
|
|
740
753
|
/** Waits forever once the page loads again, so no error shows before it goes. */
|
|
741
754
|
let reloading;
|
|
742
755
|
async function resolve$1(ref) {
|
|
@@ -784,9 +797,36 @@ let waiting$2 = 0;
|
|
|
784
797
|
function callNow(ref, scope, args) {
|
|
785
798
|
const fn = waiting$2 === 0 && !codeReady() ? loadedFunction(ref) : void 0;
|
|
786
799
|
if (!fn) return false;
|
|
787
|
-
inPass(() => fn(scope, ...args));
|
|
800
|
+
track$1(inPass(() => fn(scope, ...args)));
|
|
788
801
|
return true;
|
|
789
802
|
}
|
|
803
|
+
const unsettled = /* @__PURE__ */ new Set();
|
|
804
|
+
/** Holds the result of a setter, when it is a promise, until it settles. */
|
|
805
|
+
function track$1(result) {
|
|
806
|
+
if (HAS_BINDINGS && result && typeof result.then === "function") {
|
|
807
|
+
let open;
|
|
808
|
+
const gate = new Promise((done) => {
|
|
809
|
+
open = done;
|
|
810
|
+
});
|
|
811
|
+
unsettled.add(gate);
|
|
812
|
+
result.then(() => {
|
|
813
|
+
unsettled.delete(gate);
|
|
814
|
+
open();
|
|
815
|
+
}, (error) => {
|
|
816
|
+
unsettled.delete(gate);
|
|
817
|
+
open();
|
|
818
|
+
throw error;
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Resolves once the setter calls made so far have settled, whether they kept the write or not.
|
|
824
|
+
* Returns undefined when none waits or runs, so the caller can act at once.
|
|
825
|
+
*/
|
|
826
|
+
function whenSettled() {
|
|
827
|
+
if (unsettled.size === 0) return;
|
|
828
|
+
return Promise.all(unsettled).then(() => {});
|
|
829
|
+
}
|
|
790
830
|
let lastCall = Promise.resolve();
|
|
791
831
|
/**
|
|
792
832
|
* Calls a function of another component, such as a function prop or a provided function. The
|
|
@@ -816,9 +856,23 @@ function templateReference(ref, scope) {
|
|
|
816
856
|
return render ? insert(render(scope, ...args), void 0, at) : "";
|
|
817
857
|
});
|
|
818
858
|
}
|
|
859
|
+
/**
|
|
860
|
+
* A call of a `#template` of the file, which an insert can update in place. `render` is the
|
|
861
|
+
* template's code, and `owner` the scope that holds the template. The call finds its contexts
|
|
862
|
+
* where the template is written, as the output of a template does, so it does not render as
|
|
863
|
+
* children of the owner.
|
|
864
|
+
*/
|
|
865
|
+
function templateCall(ref, owner, render, args) {
|
|
866
|
+
return new TemplateCall(ref, owner, args, (at) => insert(render(...args), void 0, at), true);
|
|
867
|
+
}
|
|
819
868
|
/** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */
|
|
820
869
|
function insert(value, _ctx, scope) {
|
|
821
870
|
linkCalls(value, scope);
|
|
871
|
+
if (HAS_TEMPLATES && Array.isArray(value)) {
|
|
872
|
+
let out = "";
|
|
873
|
+
for (const item of value) out += insert(item, void 0, scope);
|
|
874
|
+
return out;
|
|
875
|
+
}
|
|
822
876
|
if (!((HAS_CHILDREN || HAS_TEMPLATES) && value instanceof Children)) return insertValue(value);
|
|
823
877
|
const out = value.render(resolveScope(scope));
|
|
824
878
|
return HAS_CLIENT_HTML ? holdPlace(out) : out;
|
|
@@ -879,8 +933,8 @@ var TemplateCall = class extends Children {
|
|
|
879
933
|
/** The scope of the component that wrote the template. */
|
|
880
934
|
owner;
|
|
881
935
|
args;
|
|
882
|
-
constructor(ref, owner, args, html) {
|
|
883
|
-
super(owner, html);
|
|
936
|
+
constructor(ref, owner, args, html, lexical = false) {
|
|
937
|
+
super(lexical ? void 0 : owner, html);
|
|
884
938
|
this.ref = ref;
|
|
885
939
|
this.owner = owner;
|
|
886
940
|
this.args = args;
|
|
@@ -966,10 +1020,11 @@ function children(from, html) {
|
|
|
966
1020
|
* `#try` around the scope of the code, through the parents and the owners of
|
|
967
1021
|
* scopes. A template's scope goes on from the scope where it was called.
|
|
968
1022
|
* Without a `#try`, the page gets a `brumate:error` event on `window`, with
|
|
969
|
-
* the error and the scope, and the error is logged.
|
|
1023
|
+
* the error and the scope, and the error is logged. `onError` hears it first. With `uncaught`,
|
|
1024
|
+
* it hears only an error that no `#try` catches, as on the server.
|
|
970
1025
|
*/
|
|
971
|
-
function fail(scope, error) {
|
|
972
|
-
options.onError?.(error, { scope: scope?.id });
|
|
1026
|
+
function fail(scope, error, uncaught) {
|
|
1027
|
+
if (!uncaught || !HAS_TRIES) options.onError?.(error, { scope: scope?.id });
|
|
973
1028
|
if (!HAS_TRIES) {
|
|
974
1029
|
unhandled(error, scope);
|
|
975
1030
|
return;
|
|
@@ -992,6 +1047,7 @@ function fail(scope, error) {
|
|
|
992
1047
|
return;
|
|
993
1048
|
}
|
|
994
1049
|
}
|
|
1050
|
+
if (uncaught) options.onError?.(error, { scope: scope?.id });
|
|
995
1051
|
unhandled(error, scope);
|
|
996
1052
|
})();
|
|
997
1053
|
}
|
|
@@ -1025,13 +1081,13 @@ function replaceTry(key) {
|
|
|
1025
1081
|
* one scope can hold the same promise.
|
|
1026
1082
|
*/
|
|
1027
1083
|
const reported = /* @__PURE__ */ new WeakMap();
|
|
1028
|
-
/** `fail`, once per error and scope. */
|
|
1084
|
+
/** `fail`, once per error and scope, for the rejection of a memo that a wait or an `await` reads. */
|
|
1029
1085
|
function reportOnce(scope, error) {
|
|
1030
1086
|
if (typeof error === "object" && error !== null) {
|
|
1031
1087
|
if (reported.has(error) && reported.get(error) === scope) return;
|
|
1032
1088
|
reported.set(error, scope);
|
|
1033
1089
|
}
|
|
1034
|
-
fail(scope, error);
|
|
1090
|
+
fail(scope, error, true);
|
|
1035
1091
|
}
|
|
1036
1092
|
/** Reports the error of a `#loading` body that failed on the server, with no `#try` around it. */
|
|
1037
1093
|
function failBoundary(error) {
|
|
@@ -1086,6 +1142,7 @@ let writes = 0;
|
|
|
1086
1142
|
/** Starts the count of writes again. */
|
|
1087
1143
|
function resetWrites() {
|
|
1088
1144
|
writes = 0;
|
|
1145
|
+
written.clear();
|
|
1089
1146
|
}
|
|
1090
1147
|
/**
|
|
1091
1148
|
* Writes a slot from code of a component. A prop that a parent bound with
|
|
@@ -1119,10 +1176,13 @@ function send(bound, value) {
|
|
|
1119
1176
|
const element = findElement(value.scope, value.anchor);
|
|
1120
1177
|
if (element) send(bound, element);
|
|
1121
1178
|
});
|
|
1122
|
-
else if (bound instanceof FunctionReference) {
|
|
1123
|
-
const
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1179
|
+
else if (bound instanceof FunctionReference || typeof bound === "function") {
|
|
1180
|
+
const reference = bound instanceof FunctionReference ? bound : handlerReferences.get(bound);
|
|
1181
|
+
if (reference) {
|
|
1182
|
+
const args = [...reference.args ?? [], value];
|
|
1183
|
+
if (!callNow(reference.ref, scopes.get(reference.scope), args)) track$1(call(reference.ref, scopes.get(reference.scope), args));
|
|
1184
|
+
} else if (typeof bound === "function") track$1(bound(value));
|
|
1185
|
+
}
|
|
1126
1186
|
}
|
|
1127
1187
|
/** The setters that were given each element, so an update of a spread does not call them again. */
|
|
1128
1188
|
const given = /* @__PURE__ */ new WeakMap();
|
|
@@ -1139,6 +1199,7 @@ function give$1(bound, element) {
|
|
|
1139
1199
|
function writeSlot(scope, slot, value) {
|
|
1140
1200
|
if (!Object.is(scope.s[slot], value)) {
|
|
1141
1201
|
writes++;
|
|
1202
|
+
written.add(`${findRoot(scope).m}:${scope.k}:${slot}`);
|
|
1142
1203
|
scope.s[slot] = value;
|
|
1143
1204
|
if (DEV) devtools()?.write?.(scope, slot, value);
|
|
1144
1205
|
trigger(scope, slot);
|
|
@@ -1276,6 +1337,7 @@ function asyncMemo(scope, slot, promise) {
|
|
|
1276
1337
|
}
|
|
1277
1338
|
})();
|
|
1278
1339
|
}, failed);
|
|
1340
|
+
return load;
|
|
1279
1341
|
}
|
|
1280
1342
|
/** Thrown when a memo reads a value that is still loading. */
|
|
1281
1343
|
var NotReady = class extends Error {
|
|
@@ -1367,11 +1429,6 @@ function memoSignal() {
|
|
|
1367
1429
|
function memo(scope, slot, compute) {
|
|
1368
1430
|
const key = `${scope.id}:${slot}`;
|
|
1369
1431
|
if (guesses?.same(key)) return;
|
|
1370
|
-
const rendered = scope.s[slot];
|
|
1371
|
-
if (renderedLoads.delete(key)) {
|
|
1372
|
-
if (isThenable(rendered)) asyncMemo(scope, slot, Promise.resolve(rendered));
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
1432
|
let value;
|
|
1376
1433
|
let threw = false;
|
|
1377
1434
|
memoControllers.get(key)?.abort();
|
|
@@ -1542,6 +1599,7 @@ function flush() {
|
|
|
1542
1599
|
if (running > 0 && !draining) drain();
|
|
1543
1600
|
}
|
|
1544
1601
|
globalThis[Symbol.for("brumate.flush")] = flush;
|
|
1602
|
+
if (HAS_BINDINGS) globalThis[Symbol.for("brumate.settled")] = whenSettled;
|
|
1545
1603
|
/**
|
|
1546
1604
|
* Queues the updates that read a slot, on the scope and on its descendants of
|
|
1547
1605
|
* each kind, once the code of the component has loaded.
|
|
@@ -1845,12 +1903,6 @@ function resetGuesses() {
|
|
|
1845
1903
|
}
|
|
1846
1904
|
//#endregion
|
|
1847
1905
|
//#region src/runtime/client/handlers.ts
|
|
1848
|
-
/**
|
|
1849
|
-
* The handlers that the core makes from references, with their references,
|
|
1850
|
-
* so a spread in markup that the browser renders passes them on in `b-on`,
|
|
1851
|
-
* as a spread on the server does.
|
|
1852
|
-
*/
|
|
1853
|
-
const handlerReferences = /* @__PURE__ */ new WeakMap();
|
|
1854
1906
|
/** The modifiers that the wrappers of `brumate/events` put on a handler. */
|
|
1855
1907
|
const MODIFIERS = Symbol.for("brumate.modifiers");
|
|
1856
1908
|
/**
|
|
@@ -1998,12 +2050,12 @@ function action(name, id, method, result) {
|
|
|
1998
2050
|
* call loads, so the core holds only this.
|
|
1999
2051
|
*/
|
|
2000
2052
|
function submitAction(form, submitter) {
|
|
2001
|
-
import("./rpc-
|
|
2053
|
+
import("./rpc-C_znDZ_w.js").then((module) => module.sendAction(form, submitter));
|
|
2002
2054
|
}
|
|
2003
2055
|
/** Calls a server function. */
|
|
2004
2056
|
async function rpc(id, args) {
|
|
2005
2057
|
const signal = memoSignal();
|
|
2006
|
-
return track(import("./rpc-
|
|
2058
|
+
return track(import("./rpc-C_znDZ_w.js").then((module) => module.call(rpcPrefix, id, args, signal)));
|
|
2007
2059
|
}
|
|
2008
2060
|
/** A function prop rendered on the client calls the parent's exported handler. */
|
|
2009
2061
|
function handlerProp(value, ref, scope, bound = [], modifiers) {
|
|
@@ -2034,6 +2086,10 @@ function pushRecords(...added) {
|
|
|
2034
2086
|
for (const record of added) readRecord(record);
|
|
2035
2087
|
return 0;
|
|
2036
2088
|
}
|
|
2089
|
+
/** True for the root of a `#defer` body, which the server names `d` and a number. */
|
|
2090
|
+
function isDeferRoot(root) {
|
|
2091
|
+
return root[0] === "d";
|
|
2092
|
+
}
|
|
2037
2093
|
/**
|
|
2038
2094
|
* Reads a state record. The first record holds the page state, and later
|
|
2039
2095
|
* records settle the promises in it.
|
|
@@ -2055,7 +2111,7 @@ function readRecord([script, code]) {
|
|
|
2055
2111
|
if (script.hasAttribute("b-scopes")) {
|
|
2056
2112
|
const unpacked = unpackState(decoded);
|
|
2057
2113
|
const added = addScopes(hooks.record ? hooks.record(script, unpacked) : unpacked, root);
|
|
2058
|
-
if (writes > 0) refresh(added);
|
|
2114
|
+
if (writes > 0) refresh(added, isDeferRoot(root));
|
|
2059
2115
|
}
|
|
2060
2116
|
}
|
|
2061
2117
|
/** Reads the groups of scope records back into one record per scope. See `PackedState`. */
|
|
@@ -2273,7 +2329,6 @@ function leavePage() {
|
|
|
2273
2329
|
loadingSlots.clear();
|
|
2274
2330
|
for (const memoController of memoControllers.values()) memoController.abort();
|
|
2275
2331
|
memoControllers.clear();
|
|
2276
|
-
renderedLoads.clear();
|
|
2277
2332
|
for (const { timer } of timers.values()) clearTimeout(timer);
|
|
2278
2333
|
timers.clear();
|
|
2279
2334
|
guesses?.map.clear();
|
|
@@ -2696,24 +2751,58 @@ function dynamic(tag, attributes, inner, _ctx, scope, ref) {
|
|
|
2696
2751
|
const open = `<${name}${startAttributes(attributes)}>`;
|
|
2697
2752
|
return VOID_ELEMENTS.has(name) ? open : `${open}${inner ? insert(inner, void 0, scope) : ""}</${name}>`;
|
|
2698
2753
|
}
|
|
2754
|
+
/** The promises and streams that `renderMemo` made, which `setSlots` loads as memos. */
|
|
2755
|
+
const memoLoads = /* @__PURE__ */ new WeakMap();
|
|
2756
|
+
/**
|
|
2757
|
+
* Computes a memo of a render. A promise or a stream is marked, so `setSlots` starts its load
|
|
2758
|
+
* once the scope is in the page. A throw is held in a `MemoError`, as the server holds the error
|
|
2759
|
+
* of a memo until a read.
|
|
2760
|
+
*/
|
|
2761
|
+
function renderMemo(compute) {
|
|
2762
|
+
let value;
|
|
2763
|
+
try {
|
|
2764
|
+
value = compute();
|
|
2765
|
+
} catch (error) {
|
|
2766
|
+
return new MemoError(error);
|
|
2767
|
+
}
|
|
2768
|
+
if (isThenable(value) || isAsyncIterable(value)) memoLoads.set(value, (memoLoads.get(value) ?? 0) + 1);
|
|
2769
|
+
return value;
|
|
2770
|
+
}
|
|
2771
|
+
/** Reads a memo of a render: the error that a throw held is thrown at the read. */
|
|
2772
|
+
function readMemo(value) {
|
|
2773
|
+
if (value instanceof MemoError) throw value.error;
|
|
2774
|
+
return value;
|
|
2775
|
+
}
|
|
2699
2776
|
function setSlots(id, values) {
|
|
2700
|
-
scopes.get(id)
|
|
2777
|
+
const own = scopes.get(id);
|
|
2778
|
+
own.s = values;
|
|
2779
|
+
const counted = /* @__PURE__ */ new Map();
|
|
2701
2780
|
for (let slot = 0; slot < values.length; slot++) {
|
|
2702
2781
|
const value = values[slot];
|
|
2703
|
-
|
|
2704
|
-
|
|
2782
|
+
const made = memoLoads.get(value);
|
|
2783
|
+
let loading = false;
|
|
2784
|
+
if (value instanceof Promise && own.props?.includes(value) && values.indexOf(value) === slot) {
|
|
2785
|
+
(own.plain ??= /* @__PURE__ */ new Set()).add(slot);
|
|
2705
2786
|
value.catch(noop$1);
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2787
|
+
loading = made !== void 0 && values.lastIndexOf(value) === slot;
|
|
2788
|
+
} else if (made !== void 0) {
|
|
2789
|
+
loading = (counted.get(value) ?? 0) < made;
|
|
2790
|
+
counted.set(value, (counted.get(value) ?? 0) + 1);
|
|
2791
|
+
}
|
|
2792
|
+
const key = `${id}:${slot}`;
|
|
2793
|
+
let started;
|
|
2794
|
+
if (loading) afterInsert.push(() => {
|
|
2795
|
+
if (scopes.get(id) === own) started = asyncMemo(own, slot, Promise.resolve(value));
|
|
2796
|
+
});
|
|
2797
|
+
if (isThenable(value) && !own.plain?.has(slot)) {
|
|
2709
2798
|
loadingValues.add(value);
|
|
2710
2799
|
Promise.resolve(value).then((result) => {
|
|
2711
2800
|
const scope = scopes.get(id);
|
|
2712
|
-
if (scope?.s[slot] === value && !loads.has(key)) set(scope, slot, result);
|
|
2801
|
+
if (scope?.s[slot] === value && (!loads.has(key) || loads.get(key) === started)) set(scope, slot, result);
|
|
2713
2802
|
}, noop$1);
|
|
2714
2803
|
}
|
|
2715
2804
|
}
|
|
2716
|
-
|
|
2805
|
+
own.props = void 0;
|
|
2717
2806
|
}
|
|
2718
2807
|
function setItem(id, value) {
|
|
2719
2808
|
scopes.get(id).i = value;
|
|
@@ -2836,8 +2925,9 @@ function write(parent, first, end, value, at, key, anchor) {
|
|
|
2836
2925
|
const firstWrite = key !== void 0 && !writtenInserts.has(key);
|
|
2837
2926
|
if (HAS_CHILDREN && refreshing && firstWrite && value instanceof RenderedChildren && value.at !== void 0 && value.at === at?.id && value.anchor === anchor) return;
|
|
2838
2927
|
if (key) writtenInserts.add(key);
|
|
2928
|
+
const replaced = HAS_TEMPLATES && key ? templateInserts.get(key)?.scope : void 0;
|
|
2839
2929
|
if (HAS_TEMPLATES && key && value instanceof TemplateCall) {
|
|
2840
|
-
const known = templateInserts.get(key) ?? (firstWrite ? renderedTemplate(value, at, loadedFunction(`${value.ref}k`)) : void 0);
|
|
2930
|
+
const known = templateInserts.get(key) ?? (firstWrite ? renderedTemplate(value, at, loadedFunction(`${value.ref}k`), first, end) : void 0);
|
|
2841
2931
|
const getSlots = loadedFunction(`${value.ref}a`);
|
|
2842
2932
|
if (known && getSlots && known.ref === value.ref && scopes.has(known.scope.id)) {
|
|
2843
2933
|
templateInserts.set(key, known);
|
|
@@ -2852,6 +2942,10 @@ function write(parent, first, end, value, at, key, anchor) {
|
|
|
2852
2942
|
else if (first.data !== data) first.data = data;
|
|
2853
2943
|
return;
|
|
2854
2944
|
}
|
|
2945
|
+
if (HAS_CHILDREN || HAS_TEMPLATES) {
|
|
2946
|
+
if (replaced) destroy(replaced);
|
|
2947
|
+
destroyNodes(at, first, end);
|
|
2948
|
+
}
|
|
2855
2949
|
while (first && first !== end) {
|
|
2856
2950
|
const next = first.nextSibling;
|
|
2857
2951
|
first.remove();
|
|
@@ -2859,7 +2953,7 @@ function write(parent, first, end, value, at, key, anchor) {
|
|
|
2859
2953
|
}
|
|
2860
2954
|
const made = nextId;
|
|
2861
2955
|
linkCalls(value, at);
|
|
2862
|
-
insertHTML(end ?? { parent }, (HAS_CHILDREN || HAS_TEMPLATES) && value instanceof Children ? value.render(at) :
|
|
2956
|
+
insertHTML(end ?? { parent }, (HAS_CHILDREN || HAS_TEMPLATES) && value instanceof Children ? value.render(at) : insert(value, void 0, at));
|
|
2863
2957
|
if (HAS_TEMPLATES && key) {
|
|
2864
2958
|
const scope = value instanceof TemplateCall ? scopes.get(made) : void 0;
|
|
2865
2959
|
if (scope) templateInserts.set(key, {
|
|
@@ -2877,10 +2971,10 @@ const writtenInserts = /* @__PURE__ */ new WeakSet();
|
|
|
2877
2971
|
* The scope of a template that the server rendered at an insert: the scope that the template's
|
|
2878
2972
|
* component made, and that finds its contexts from the insert.
|
|
2879
2973
|
*/
|
|
2880
|
-
function renderedTemplate(call, at, k) {
|
|
2974
|
+
function renderedTemplate(call, at, k, first, end) {
|
|
2881
2975
|
if (k === void 0) return;
|
|
2882
2976
|
let found;
|
|
2883
|
-
for (const scope of scopes.values()) if (call.owner && scope.p === call.owner && scope.t === at
|
|
2977
|
+
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))) {
|
|
2884
2978
|
if (found) return;
|
|
2885
2979
|
found = scope;
|
|
2886
2980
|
}
|
|
@@ -2889,6 +2983,17 @@ function renderedTemplate(call, at, k) {
|
|
|
2889
2983
|
scope: found
|
|
2890
2984
|
};
|
|
2891
2985
|
}
|
|
2986
|
+
/** True if an anchor of the scope, a comment, an element or a kept node, is in the range. */
|
|
2987
|
+
function inRange(scope, first, end) {
|
|
2988
|
+
const comment = `t${scope.id}:`;
|
|
2989
|
+
const element = `${scope.id}:`;
|
|
2990
|
+
for (let node = first; node && node !== end; node = node.nextSibling) {
|
|
2991
|
+
const walker = document.createTreeWalker(node, 129);
|
|
2992
|
+
for (let item = node; item; item = walker.nextNode()) if (item.nodeType === 8 ? item.data.startsWith(comment) : item.nodeType === 1 && item.getAttribute("b-b")?.startsWith(element)) return true;
|
|
2993
|
+
for (const kept of scope.n ?? []) if (kept && (kept === node || node.contains(kept))) return true;
|
|
2994
|
+
}
|
|
2995
|
+
return false;
|
|
2996
|
+
}
|
|
2892
2997
|
/** The `value` and `checked` that updates last wrote to each field. */
|
|
2893
2998
|
const fieldValues = /* @__PURE__ */ new WeakMap();
|
|
2894
2999
|
function setAttribute(element, name, value, spread = false) {
|
|
@@ -2991,8 +3096,6 @@ function updateSpreadEntries(element, values) {
|
|
|
2991
3096
|
}
|
|
2992
3097
|
//#endregion
|
|
2993
3098
|
//#region src/runtime/client/waits.ts
|
|
2994
|
-
/** The slots of a scope whose awaits settled, until the insert that shows the scope. */
|
|
2995
|
-
const settledSlots = /* @__PURE__ */ new WeakMap();
|
|
2996
3099
|
/** The boundary of the render that runs, if any. */
|
|
2997
3100
|
let boundary;
|
|
2998
3101
|
/** The scope whose rest of a render runs after a wait, if any. */
|
|
@@ -3041,7 +3144,7 @@ function give(own) {
|
|
|
3041
3144
|
return;
|
|
3042
3145
|
}
|
|
3043
3146
|
if (own.c === writes) rendered.push(...made);
|
|
3044
|
-
else queued.push(() => refresh(made));
|
|
3147
|
+
else queued.push(() => refresh(made, false, false));
|
|
3045
3148
|
afterInsert.push(...queued);
|
|
3046
3149
|
}
|
|
3047
3150
|
/**
|
|
@@ -3244,7 +3347,9 @@ function wait(id, slots, slot, rest) {
|
|
|
3244
3347
|
const promise = Promise.resolve(first);
|
|
3245
3348
|
slots[slot] = void 0;
|
|
3246
3349
|
const props = scope.props;
|
|
3350
|
+
const queued = afterInsert.length;
|
|
3247
3351
|
setSlots(id, slots);
|
|
3352
|
+
afterInsert.length = queued;
|
|
3248
3353
|
scope.props = props;
|
|
3249
3354
|
scope.s[slot] = promise;
|
|
3250
3355
|
loadingValues.add(promise);
|
|
@@ -3263,20 +3368,17 @@ function wait(id, slots, slot, rest) {
|
|
|
3263
3368
|
}
|
|
3264
3369
|
const value = scope.s[slot];
|
|
3265
3370
|
if (value instanceof MemoError) {
|
|
3266
|
-
fail(scope, value.error);
|
|
3371
|
+
fail(scope, value.error, true);
|
|
3267
3372
|
fault(own, value.error);
|
|
3268
3373
|
return;
|
|
3269
3374
|
}
|
|
3270
|
-
let shown = false;
|
|
3271
3375
|
try {
|
|
3272
3376
|
fillRange(own, end, () => {
|
|
3273
3377
|
rendered.push(scope);
|
|
3274
3378
|
const outer = resting;
|
|
3275
3379
|
resting = scope;
|
|
3276
3380
|
try {
|
|
3277
|
-
|
|
3278
|
-
shown = rendered.includes(scope);
|
|
3279
|
-
return out;
|
|
3381
|
+
return updating(() => rest(scope.s));
|
|
3280
3382
|
} finally {
|
|
3281
3383
|
resting = outer;
|
|
3282
3384
|
}
|
|
@@ -3286,13 +3388,6 @@ function wait(id, slots, slot, rest) {
|
|
|
3286
3388
|
fault(own, error);
|
|
3287
3389
|
return;
|
|
3288
3390
|
}
|
|
3289
|
-
const done = settledSlots.get(scope) ?? [];
|
|
3290
|
-
done.push(slot);
|
|
3291
|
-
settledSlots.set(scope, done);
|
|
3292
|
-
if (shown) {
|
|
3293
|
-
settledSlots.delete(scope);
|
|
3294
|
-
for (const settled of done) if (settled < scope.s.length) renderedLoads.add(`${scope.id}:${settled}`);
|
|
3295
|
-
}
|
|
3296
3391
|
leave(own);
|
|
3297
3392
|
}
|
|
3298
3393
|
const check = until(own, scope, end, () => !pending(scope, slot), settle);
|
|
@@ -4216,6 +4311,8 @@ function addStyle(id, css) {
|
|
|
4216
4311
|
//#region src/runtime/client/search.ts
|
|
4217
4312
|
/** The signals of the page that follow a parameter, by scope and slot. */
|
|
4218
4313
|
const bound = /* @__PURE__ */ new Map();
|
|
4314
|
+
/** The slots whose effect ran once. The first run is the load of the page. */
|
|
4315
|
+
const loaded = /* @__PURE__ */ new WeakMap();
|
|
4219
4316
|
/** The changes of the URL that wait for the end of the writes of one pass. */
|
|
4220
4317
|
const waiting = /* @__PURE__ */ new Map();
|
|
4221
4318
|
/** `$searchParam` in the browser: the parameter of the URL of the page. */
|
|
@@ -4238,9 +4335,20 @@ function paramEffect(scope, slot, name, options) {
|
|
|
4238
4335
|
});
|
|
4239
4336
|
globalThis[HOOK] = follow;
|
|
4240
4337
|
}
|
|
4338
|
+
let started = loaded.get(scope);
|
|
4339
|
+
if (!started) {
|
|
4340
|
+
started = /* @__PURE__ */ new Set();
|
|
4341
|
+
loaded.set(scope, started);
|
|
4342
|
+
}
|
|
4343
|
+
const first = !started.has(slot);
|
|
4344
|
+
started.add(slot);
|
|
4241
4345
|
const text = writeParam(get(scope, slot), options);
|
|
4242
4346
|
const current = readParam(new URLSearchParams(location.search), name, options);
|
|
4243
4347
|
if (writeParam(current, options) !== text) {
|
|
4348
|
+
if (first && !options?.server) {
|
|
4349
|
+
set(scope, slot, current);
|
|
4350
|
+
return () => void bound.delete(key);
|
|
4351
|
+
}
|
|
4244
4352
|
if (waiting.size === 0) queueMicrotask(commit);
|
|
4245
4353
|
waiting.set(name, {
|
|
4246
4354
|
text,
|
|
@@ -4352,6 +4460,6 @@ const loader = {
|
|
|
4352
4460
|
};
|
|
4353
4461
|
function noop() {}
|
|
4354
4462
|
//#endregion
|
|
4355
|
-
export {
|
|
4463
|
+
export { branchNodes as $, templateCall as $t, started as A, consumeContext as At, spreadProps as B, get as Bt, fillAttrs as C, handle as Ct, keepValue as D, submitAction as Dt, fillValue as E, spread as Et, portalTo as F, asyncMemo as Ft, elementAt as G, set as Gt, componentNodes as H, memo as Ht, restRef as I, binding as It, readMemo as J, update as Jt, foreignNodes as K, timed as Kt, text as L, bindings as Lt, attr as M, setGlobal as Mt, attrs as N, updateContext as Nt, loading as O, guess as Ot, content as P, updateRoute as Pt, appendText as Q, insert as Qt, writeText as R, cells as Rt, countLoads as S, action as St, fillSpread as T, rpc as Tt, dynamic as U, pending as Ut, component as V, isBound as Vt, dynamicNodes as W, resolve as Wt, setItem as X, fail as Xt, renderMemo as Y, updated as Yt, setSlots as Z, children as Zt, rekey as _, init as _t, addPortal as a, makeId as an, listNodes as at, after as b, remount as bt, setVar as c, sink as cn, putText as ct, windowList as d, DEVTOOLS as dn, setContent as dt, title as en, clone as et, windowStart as f, build as fn, setOn as ft, offscreen as g, skew as gn, forget as gt, held as h, scopes as hn, dispose as ht, addHead as i, getScope as in, keepText as it, wait as j, provideValue as jt, reveal as k, track as kt, list as l, loadModule as ln, setAttr as lt, fill as m, rpcPrefix as mn, template as mt, paramEffect as n, createScope as nn, fillList as nt, addStyle as o, removeScope as on, markBlock as ot, branch as p, hooks as pn, setSpread as pt, place as q, unreadMemo as qt, searchParam as r, descendants as rn, keep as rt, deferInBrowser as s, setOwner as sn, nodes as st, loader as t, afterInsert as tn, fillBranch as tt, toList as u, nameComment as un, setAttrText as ut, reset as v, leavePage as vt, fillSettled as w, handlerProp as wt, attempt as x, removeRoot as xt, retag as y, leaveRoutes as yt, prop as z, effect as zt };
|
|
4356
4464
|
|
|
4357
|
-
//# sourceMappingURL=client-
|
|
4465
|
+
//# sourceMappingURL=client-C3vRNuLi.js.map
|