brumate 0.4.1 → 0.4.2
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-SCWYwuUd.d.ts → boot-D3NjfyUX.d.ts} +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-BBtVTOIt.js → client-Cwr2AfP4.js} +67 -12
- package/dist/client-Cwr2AfP4.js.map +1 -0
- package/dist/{client-Cs3o4key.d.ts → client-DNva05jp.d.ts} +20 -7
- package/dist/{defer-BLJjxqVc.js → defer-CxjvJXD_.js} +2 -2
- package/dist/{defer-BLJjxqVc.js.map → defer-CxjvJXD_.js.map} +1 -1
- package/dist/{devtools-DTpsVFbn.js → devtools-BdB_9WB8.js} +4 -4
- package/dist/{devtools-DTpsVFbn.js.map → devtools-BdB_9WB8.js.map} +1 -1
- package/dist/{devtools-panel-C1Dfv6nq.js → devtools-panel-Bp6LE4nM.js} +2 -2
- package/dist/{devtools-panel-C1Dfv6nq.js.map → devtools-panel-Bp6LE4nM.js.map} +1 -1
- package/dist/{files-DZIiMDnS.js → files-BzVNgGOL.js} +2 -2
- package/dist/{files-DZIiMDnS.js.map → files-BzVNgGOL.js.map} +1 -1
- package/dist/{html-DS9B1H-M.js → html-t1JpkODI.js} +6 -4
- package/dist/html-t1JpkODI.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/{inspect-DomFHy5O.js → inspect-DaZtoKgg.js} +225 -67
- package/dist/inspect-DaZtoKgg.js.map +1 -0
- package/dist/{loader-D62komKu.js → loader-BX8uIUav.js} +2 -2
- package/dist/{loader-D62komKu.js.map → loader-BX8uIUav.js.map} +1 -1
- package/dist/produce-CLABZ8k2.d.ts +11 -0
- package/dist/{produce-BNIpmZq2.js → produce-DS-dQaUX.js} +3 -2
- package/dist/produce-DS-dQaUX.js.map +1 -0
- package/dist/{rpc-BTMb8jap.js → rpc-t5M5dqs9.js} +3 -3
- package/dist/{rpc-BTMb8jap.js.map → rpc-t5M5dqs9.js.map} +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.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/server.d.ts +3 -3
- package/dist/runtime/server.js +3 -3
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{server-CYw15Dsg.d.ts → server-BXMH3Z9T.d.ts} +4 -3
- package/dist/{server-BTtsQFFw.js → server-C6c-GXF4.js} +11 -9
- package/dist/server-C6c-GXF4.js.map +1 -0
- package/dist/shared-CzbnWkVA.d.ts +255 -0
- package/dist/{static-loader-DVuLmXeu.d.ts → static-loader-BiUaZaag.d.ts} +2 -2
- package/dist/{static-loader-C_GYIFtt.js → static-loader-CqQRu-p9.js} +2 -2
- package/dist/{static-loader-C_GYIFtt.js.map → static-loader-CqQRu-p9.js.map} +1 -1
- package/dist/{stream-r4V5zBKm.js → stream-CqhuQJwK.js} +3 -3
- package/dist/{stream-r4V5zBKm.js.map → stream-CqhuQJwK.js.map} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/package.json +1 -1
- package/dist/client-BBtVTOIt.js.map +0 -1
- package/dist/html-DS9B1H-M.js.map +0 -1
- package/dist/html-Gggepsf-.d.ts +0 -109
- package/dist/inspect-DomFHy5O.js.map +0 -1
- package/dist/produce-BNIpmZq2.js.map +0 -1
- package/dist/produce-CRfouraC.d.ts +0 -153
- package/dist/server-BTtsQFFw.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as paragraphComponents, t as checkNesting } from "./nesting-DA5vJw9X.js";
|
|
2
2
|
import { t as KEY_NAMES } from "./events-LgLdp1R7.js";
|
|
3
|
-
import { p as insertValue } from "./html-
|
|
3
|
+
import { p as insertValue } from "./html-t1JpkODI.js";
|
|
4
4
|
import { parseSync } from "oxc-parser";
|
|
5
5
|
import { parse } from "postcss";
|
|
6
6
|
import selectorParser from "postcss-selector-parser";
|
|
@@ -2055,6 +2055,47 @@ function createFail(source, filename) {
|
|
|
2055
2055
|
};
|
|
2056
2056
|
}
|
|
2057
2057
|
//#endregion
|
|
2058
|
+
//#region src/ast.ts
|
|
2059
|
+
/** The markup inside a node: the children of an element, or the bodies of a block. */
|
|
2060
|
+
function getChildren(node) {
|
|
2061
|
+
switch (node.kind) {
|
|
2062
|
+
case "element":
|
|
2063
|
+
case "component":
|
|
2064
|
+
case "dynamic":
|
|
2065
|
+
case "fragment": return node.children;
|
|
2066
|
+
case "if": {
|
|
2067
|
+
const children = [];
|
|
2068
|
+
for (const branch of node.branches) children.push(...branch.body.children);
|
|
2069
|
+
children.push(...node.fallback?.children ?? []);
|
|
2070
|
+
return children;
|
|
2071
|
+
}
|
|
2072
|
+
case "switch": {
|
|
2073
|
+
const children = [];
|
|
2074
|
+
for (const branch of node.cases) children.push(...branch.body.children);
|
|
2075
|
+
children.push(...node.fallback?.children ?? []);
|
|
2076
|
+
return children;
|
|
2077
|
+
}
|
|
2078
|
+
case "for":
|
|
2079
|
+
case "repeat":
|
|
2080
|
+
case "loading":
|
|
2081
|
+
case "client":
|
|
2082
|
+
case "defer": return [...node.body.children, ...node.fallback?.children ?? []];
|
|
2083
|
+
case "try": return [...node.body.children, ...node.fallback.children];
|
|
2084
|
+
case "key":
|
|
2085
|
+
case "portal":
|
|
2086
|
+
case "head":
|
|
2087
|
+
case "offscreen": return node.body.children;
|
|
2088
|
+
default: return [];
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
/** Visits every markup node of a file, including blocks and templates. */
|
|
2092
|
+
function forEachNode(nodes, visit) {
|
|
2093
|
+
for (const node of nodes) {
|
|
2094
|
+
visit(node);
|
|
2095
|
+
forEachNode(getChildren(node), visit);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
//#endregion
|
|
2058
2099
|
//#region src/graph.ts
|
|
2059
2100
|
/** Memos that a server function refreshes are live, so they have client code. */
|
|
2060
2101
|
function isMemoKind(kind) {
|
|
@@ -2118,18 +2159,69 @@ const CLIENT_CODE = /* @__PURE__ */ new Set([
|
|
|
2118
2159
|
"effect",
|
|
2119
2160
|
"client"
|
|
2120
2161
|
]);
|
|
2162
|
+
/** True if one of the markup nodes holds a component or a dynamic tag, whose code this file cannot see. */
|
|
2163
|
+
function holdsComponent(nodes) {
|
|
2164
|
+
let found = false;
|
|
2165
|
+
forEachNode(nodes, (node) => {
|
|
2166
|
+
found ||= node.kind === "component" || node.kind === "dynamic";
|
|
2167
|
+
});
|
|
2168
|
+
return found;
|
|
2169
|
+
}
|
|
2170
|
+
/** True if `scope` is inside one of `ancestors`. */
|
|
2171
|
+
function isWithinAny$1(scope, ancestors) {
|
|
2172
|
+
for (const ancestor of ancestors) if (isWithin(scope, ancestor)) return true;
|
|
2173
|
+
return false;
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* The scopes of the templates declared outside the body of a `#try` that are
|
|
2177
|
+
* called in it, in another such template, or in a function that one of them
|
|
2178
|
+
* calls. A template's scope links to where it is called at runtime, so the
|
|
2179
|
+
* `#try` catches the errors of these calls.
|
|
2180
|
+
*/
|
|
2181
|
+
function calledTemplates(model, block) {
|
|
2182
|
+
const body = findBodyScope(model, block);
|
|
2183
|
+
if (body === void 0) return [];
|
|
2184
|
+
const inside = [body];
|
|
2185
|
+
const found = [];
|
|
2186
|
+
const called = /* @__PURE__ */ new Set();
|
|
2187
|
+
let added = true;
|
|
2188
|
+
while (added) {
|
|
2189
|
+
added = false;
|
|
2190
|
+
for (const site of model.sites) {
|
|
2191
|
+
if (!isWithinAny$1(site.scope, inside) && (site.declaration === void 0 || !called.has(site.declaration))) continue;
|
|
2192
|
+
for (const declaration of site.calls) if ((declaration.kind === "function" || declaration.kind === "template") && !called.has(declaration)) {
|
|
2193
|
+
called.add(declaration);
|
|
2194
|
+
added = true;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
for (const scope of model.scopes) {
|
|
2198
|
+
if (scope.kind !== "template" || isWithinAny$1(scope, inside)) continue;
|
|
2199
|
+
const declaration = lookup(scope.parent, scope.template.name);
|
|
2200
|
+
if (declaration && called.has(declaration)) {
|
|
2201
|
+
inside.push(scope);
|
|
2202
|
+
found.push(scope);
|
|
2203
|
+
added = true;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
return found;
|
|
2208
|
+
}
|
|
2121
2209
|
/**
|
|
2122
2210
|
* True if the body of a `#try` holds code that runs in the browser: a
|
|
2123
2211
|
* handler, an effect, a `$client` callback, a memo that loads, or a read of a
|
|
2124
2212
|
* memo, which throws when the memo holds an error. An error in it renders
|
|
2125
|
-
* the `#catch` body in the browser, so both bodies ship.
|
|
2213
|
+
* the `#catch` body in the browser, so both bodies ship. A component in the
|
|
2214
|
+
* body counts too, since its code can be any of these.
|
|
2126
2215
|
*/
|
|
2127
2216
|
function tryCatchesClient(model, block) {
|
|
2128
2217
|
const body = findBodyScope(model, block);
|
|
2129
2218
|
if (body === void 0) return false;
|
|
2130
|
-
|
|
2219
|
+
const inside = [body, ...calledTemplates(model, block)];
|
|
2220
|
+
if (holdsComponent(block.body.children)) return true;
|
|
2221
|
+
for (const scope of model.scopes) if (scope.template && isWithinAny$1(scope, inside) && holdsComponent(scope.template.body.children)) return true;
|
|
2222
|
+
for (const site of model.sites) if ((CLIENT_CODE.has(site.kind) || site.kind === "memo" && site.declaration?.kind === "async-memo") && isWithinAny$1(site.scope, inside)) return true;
|
|
2131
2223
|
for (const declaration of model.declarations) if (isMemoKind(declaration.kind)) {
|
|
2132
|
-
for (const read of declaration.reads) if (
|
|
2224
|
+
for (const read of declaration.reads) if (isWithinAny$1(read.site.scope, inside)) return true;
|
|
2133
2225
|
}
|
|
2134
2226
|
return false;
|
|
2135
2227
|
}
|
|
@@ -3601,45 +3693,6 @@ function importedComponents(file) {
|
|
|
3601
3693
|
for (const program of [file.moduleScript?.program, file.instanceScript?.program]) for (const statement of program?.body ?? []) if (statement.type === "ImportDeclaration" && statement.source.value.endsWith(".brm")) specifiers.push(statement.source.value);
|
|
3602
3694
|
return specifiers;
|
|
3603
3695
|
}
|
|
3604
|
-
/** The markup inside a node: the children of an element, or the bodies of a block. */
|
|
3605
|
-
function getChildren(node) {
|
|
3606
|
-
switch (node.kind) {
|
|
3607
|
-
case "element":
|
|
3608
|
-
case "component":
|
|
3609
|
-
case "dynamic":
|
|
3610
|
-
case "fragment": return node.children;
|
|
3611
|
-
case "if": {
|
|
3612
|
-
const children = [];
|
|
3613
|
-
for (const branch of node.branches) children.push(...branch.body.children);
|
|
3614
|
-
children.push(...node.fallback?.children ?? []);
|
|
3615
|
-
return children;
|
|
3616
|
-
}
|
|
3617
|
-
case "switch": {
|
|
3618
|
-
const children = [];
|
|
3619
|
-
for (const branch of node.cases) children.push(...branch.body.children);
|
|
3620
|
-
children.push(...node.fallback?.children ?? []);
|
|
3621
|
-
return children;
|
|
3622
|
-
}
|
|
3623
|
-
case "for":
|
|
3624
|
-
case "repeat":
|
|
3625
|
-
case "loading":
|
|
3626
|
-
case "client":
|
|
3627
|
-
case "defer": return [...node.body.children, ...node.fallback?.children ?? []];
|
|
3628
|
-
case "try": return [...node.body.children, ...node.fallback.children];
|
|
3629
|
-
case "key":
|
|
3630
|
-
case "portal":
|
|
3631
|
-
case "head":
|
|
3632
|
-
case "offscreen": return node.body.children;
|
|
3633
|
-
default: return [];
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
/** Visits every markup node of a file, including blocks and templates. */
|
|
3637
|
-
function forEachNode(nodes, visit) {
|
|
3638
|
-
for (const node of nodes) {
|
|
3639
|
-
visit(node);
|
|
3640
|
-
forEachNode(getChildren(node), visit);
|
|
3641
|
-
}
|
|
3642
|
-
}
|
|
3643
3696
|
/**
|
|
3644
3697
|
* The live prop that a dynamic tag gives to the component it names. A spread or a computed name
|
|
3645
3698
|
* can hold any prop, but `children` come from the body of the tag, so they are left out: `~`.
|
|
@@ -6232,6 +6285,7 @@ function createPlan(file, graph, path, hideNames = false) {
|
|
|
6232
6285
|
if (!anchors.has(holder)) anchor(holderScope, holder);
|
|
6233
6286
|
}
|
|
6234
6287
|
}
|
|
6288
|
+
if (block.kind === "try" && tryCatchesClient(model, block)) scopes.get(bodyScopes.get(block.body)).needsId = true;
|
|
6235
6289
|
if (live && block.kind === "offscreen") scopes.get(bodyScopes.get(block.body)).needsId = true;
|
|
6236
6290
|
if (block.kind === "portal" || block.kind === "head") scopes.get(bodyScopes.get(block.body)).needsId = true;
|
|
6237
6291
|
const inner = block.kind === "portal" || block.kind === "head" ? void 0 : outer;
|
|
@@ -6610,7 +6664,8 @@ function clonedTemplate(parts) {
|
|
|
6610
6664
|
add({
|
|
6611
6665
|
kind: "attribute",
|
|
6612
6666
|
name: attribute[1],
|
|
6613
|
-
value: attribute[2]
|
|
6667
|
+
value: attribute[2],
|
|
6668
|
+
settled: part.settled
|
|
6614
6669
|
});
|
|
6615
6670
|
continue;
|
|
6616
6671
|
}
|
|
@@ -6629,7 +6684,8 @@ function clonedTemplate(parts) {
|
|
|
6629
6684
|
add({
|
|
6630
6685
|
kind: "content",
|
|
6631
6686
|
value: insert[1],
|
|
6632
|
-
at: insert[2]
|
|
6687
|
+
at: insert[2],
|
|
6688
|
+
settled: part.settled
|
|
6633
6689
|
});
|
|
6634
6690
|
continue;
|
|
6635
6691
|
}
|
|
@@ -6670,7 +6726,8 @@ function clonedTemplate(parts) {
|
|
|
6670
6726
|
const mark = writes.length;
|
|
6671
6727
|
writes.push([{
|
|
6672
6728
|
kind: "component",
|
|
6673
|
-
call: code.replace(COMPONENT, "$$$$b.componentNodes(")
|
|
6729
|
+
call: code.replace(COMPONENT, "$$$$b.componentNodes("),
|
|
6730
|
+
settled: part.settled
|
|
6674
6731
|
}]);
|
|
6675
6732
|
reader.append(`<!--x${mark}-->`);
|
|
6676
6733
|
continue;
|
|
@@ -6680,7 +6737,8 @@ function clonedTemplate(parts) {
|
|
|
6680
6737
|
const mark = writes.length;
|
|
6681
6738
|
writes.push([{
|
|
6682
6739
|
kind: "component",
|
|
6683
|
-
call: nodes[1]
|
|
6740
|
+
call: nodes[1],
|
|
6741
|
+
settled: part.settled
|
|
6684
6742
|
}]);
|
|
6685
6743
|
reader.append(`<!--x${mark}-->`);
|
|
6686
6744
|
continue;
|
|
@@ -6810,7 +6868,8 @@ function clonedTemplate(parts) {
|
|
|
6810
6868
|
writes.push([{
|
|
6811
6869
|
kind: "put",
|
|
6812
6870
|
value: insert[1],
|
|
6813
|
-
at: insert[2]
|
|
6871
|
+
at: insert[2],
|
|
6872
|
+
settled: part.settled
|
|
6814
6873
|
}]);
|
|
6815
6874
|
reader.append(`<!--x${mark}-->`);
|
|
6816
6875
|
continue;
|
|
@@ -6900,6 +6959,24 @@ function cloneLines(emitter, hoist, fn = 0) {
|
|
|
6900
6959
|
const foreign = found.foreign ? `, ${JSON.stringify(found.foreign)}` : "";
|
|
6901
6960
|
const lines = [`${indent}const $$e = $$b.clone(${hoist(`$$b.template(${JSON.stringify(found.html)}, ${found.writes.length}${foreign})`)}), $$f = $$e[${found.writes.length}];`];
|
|
6902
6961
|
const fills = [];
|
|
6962
|
+
const settled = /* @__PURE__ */ new Map();
|
|
6963
|
+
function addLine(line, memos) {
|
|
6964
|
+
if (!memos) {
|
|
6965
|
+
lines.push(`${indent}${line}`);
|
|
6966
|
+
return;
|
|
6967
|
+
}
|
|
6968
|
+
const key = `${memos.scope} ${memos.names.join(" ")}`;
|
|
6969
|
+
let group = settled.get(key);
|
|
6970
|
+
if (!group) {
|
|
6971
|
+
group = {
|
|
6972
|
+
scope: memos.scope,
|
|
6973
|
+
names: memos.names,
|
|
6974
|
+
writes: []
|
|
6975
|
+
};
|
|
6976
|
+
settled.set(key, group);
|
|
6977
|
+
}
|
|
6978
|
+
group.writes.push(line);
|
|
6979
|
+
}
|
|
6903
6980
|
let missing = false;
|
|
6904
6981
|
for (const [index, writes] of found.writes.entries()) {
|
|
6905
6982
|
let anchored;
|
|
@@ -6914,17 +6991,21 @@ function cloneLines(emitter, hoist, fn = 0) {
|
|
|
6914
6991
|
for (const write of ordered) if (write.kind === "anchor") lines.push(`${indent}$$b.keep(${write.scope}, ${write.anchor}, $$e[${index}]${write.named ? ", true" : ""});`);
|
|
6915
6992
|
else if (write.kind === "last") lines.push(`${indent}$$b.appendText(${write.scope}, ${write.anchor}, $$e[${index}], ${write.value}${write.at ? `, ${write.at}` : ""});`);
|
|
6916
6993
|
else if (write.kind === "text") lines.push(`${indent}$$b.keepText(${write.scope}, ${write.anchor}, $$e[${index}], ${write.value}${write.at ? `, ${write.at}` : ""});`);
|
|
6917
|
-
else if (write.kind === "attribute")
|
|
6918
|
-
else if (write.kind === "component")
|
|
6994
|
+
else if (write.kind === "attribute") addLine(`$$b.setAttr($$e[${index}], ${write.name}, ${write.value});`, write.settled);
|
|
6995
|
+
else if (write.kind === "component") addLine(`$$b.place($$e[${index}], ${write.call});`, write.settled);
|
|
6919
6996
|
else if (write.kind === "comment") lines.push(`${indent}$$b.nameComment($$e[${index}], ${write.data});`);
|
|
6920
|
-
else if (write.kind === "put")
|
|
6997
|
+
else if (write.kind === "put") addLine(`$$b.putText($$e[${index}], ${write.value}${write.at ? `, ${write.at}` : ""});`, write.settled);
|
|
6921
6998
|
else if (write.kind === "call") lines.push(`${indent}${write.call.replace("$$m", () => `$$e[${index}]`)};`);
|
|
6922
6999
|
else if (write.kind === "marker") lines.push(`${indent}$$b.markBlock($$e[${index}], ${write.scope}, ${write.anchor}, ${JSON.stringify(write.suffix)});`);
|
|
6923
7000
|
else if (write.kind === "block") {
|
|
6924
7001
|
const call = emitter.fills.get(`${write.scope}:${write.anchor}`);
|
|
6925
7002
|
if (call === void 0) missing = true;
|
|
6926
7003
|
else fills.push(`${indent}${call.replace("$$m", () => `$$e[${index}]`)};`);
|
|
6927
|
-
} else
|
|
7004
|
+
} else addLine(`$$b.setContent($$e[${index}], ${write.value}${write.at ? `, ${write.at}` : at});`, write.settled);
|
|
7005
|
+
}
|
|
7006
|
+
for (const group of settled.values()) {
|
|
7007
|
+
const names = group.names.join(", ");
|
|
7008
|
+
lines.push(`${indent}$$b.fillSettled(${group.scope}, [${names}], (${names}) => { ${group.writes.join(" ")} });`);
|
|
6928
7009
|
}
|
|
6929
7010
|
if (missing) return false;
|
|
6930
7011
|
const sizes = /* @__PURE__ */ new Map();
|
|
@@ -7282,6 +7363,12 @@ const TYPE_DECLARATIONS = /* @__PURE__ */ new Set([
|
|
|
7282
7363
|
"TSDeclareFunction",
|
|
7283
7364
|
"TSModuleDeclaration"
|
|
7284
7365
|
]);
|
|
7366
|
+
/** Expressions whose value is never a promise, as the memo of a list or a function. */
|
|
7367
|
+
const NEVER_PROMISE = /* @__PURE__ */ new Set([
|
|
7368
|
+
"ArrayExpression",
|
|
7369
|
+
"ArrowFunctionExpression",
|
|
7370
|
+
"FunctionExpression"
|
|
7371
|
+
]);
|
|
7285
7372
|
/** The static or value attribute named `style`. */
|
|
7286
7373
|
function findStyleAttribute(attributes) {
|
|
7287
7374
|
for (const attribute of attributes) if ((attribute.kind === "static" || attribute.kind === "value") && attribute.name === "style") return attribute;
|
|
@@ -7300,6 +7387,11 @@ function readsProps(site) {
|
|
|
7300
7387
|
for (const read of site?.reads ?? []) if (read.declaration.kind === "prop" || read.declaration.kind === "props-rest") return true;
|
|
7301
7388
|
return false;
|
|
7302
7389
|
}
|
|
7390
|
+
/** True if a site calls a template, or a function, which can return the output of one. */
|
|
7391
|
+
function callsTemplate(site) {
|
|
7392
|
+
for (const declaration of site?.calls ?? []) if (declaration.kind === "template" || declaration.kind === "function") return true;
|
|
7393
|
+
return false;
|
|
7394
|
+
}
|
|
7303
7395
|
/** The name of the compile-time function that a declarator calls, for `$getContext` and `$id`. */
|
|
7304
7396
|
function specialCall(declarator) {
|
|
7305
7397
|
const init = declarator.init;
|
|
@@ -7436,6 +7528,8 @@ var Emitter = class {
|
|
|
7436
7528
|
blocking;
|
|
7437
7529
|
/** Memos and signals that hold a primitive on the server, so it awaits none of them. */
|
|
7438
7530
|
inline;
|
|
7531
|
+
/** The sites of the markup that update in the browser. */
|
|
7532
|
+
liveSites = /* @__PURE__ */ new Set();
|
|
7439
7533
|
parts = [];
|
|
7440
7534
|
depth = 0;
|
|
7441
7535
|
/** How many of this component's elements contain the current node. */
|
|
@@ -7457,6 +7551,7 @@ var Emitter = class {
|
|
|
7457
7551
|
this.blocking = blockingMemos(plan);
|
|
7458
7552
|
this.inline = options.mode === "server" ? plainValues(plan, this.blocking) : /* @__PURE__ */ new Set();
|
|
7459
7553
|
for (const site of plan.graph.model.sites) this.sitesByNode.set(site.node, site);
|
|
7554
|
+
for (const node of plan.graph.nodes) if (node.kind !== "source" && plan.graph.live.has(node)) this.liveSites.add(node.site);
|
|
7460
7555
|
this.addHandlerEdits();
|
|
7461
7556
|
this.addBindEdits();
|
|
7462
7557
|
for (const declaration of plan.graph.model.declarations) for (const ref of declaration.refs) this.refTargets.set(ref.attribute, declaration);
|
|
@@ -7596,8 +7691,32 @@ var Emitter = class {
|
|
|
7596
7691
|
if (last && "static" in last) last.static += text;
|
|
7597
7692
|
else this.parts.push({ static: text });
|
|
7598
7693
|
}
|
|
7599
|
-
code(code) {
|
|
7600
|
-
this.parts.push(
|
|
7694
|
+
code(code, settled) {
|
|
7695
|
+
this.parts.push(settled ? {
|
|
7696
|
+
code,
|
|
7697
|
+
settled
|
|
7698
|
+
} : { code });
|
|
7699
|
+
}
|
|
7700
|
+
/**
|
|
7701
|
+
* In the browser, the memos that values of the markup read that never change and can be a
|
|
7702
|
+
* promise, such as an insert, the headers of a block or the props of a component. No update
|
|
7703
|
+
* writes them when the memos settle, so the clone holds back what reads them.
|
|
7704
|
+
*/
|
|
7705
|
+
settledMemos(expressions, scope) {
|
|
7706
|
+
if (this.options.mode !== "client") return;
|
|
7707
|
+
const names = [];
|
|
7708
|
+
for (const expression of expressions) {
|
|
7709
|
+
const site = this.sitesByNode.get(expression.ast);
|
|
7710
|
+
if (!site || this.liveSites.has(site)) return;
|
|
7711
|
+
for (const reference of site.reads) {
|
|
7712
|
+
const declaration = reference.declaration;
|
|
7713
|
+
if ((declaration.kind === "memo" || declaration.kind === "async-memo") && !(declaration.site && isPrimitive(declaration.site.node)) && !NEVER_PROMISE.has(declaration.site?.node.type ?? "") && !names.includes(declaration.name)) names.push(declaration.name);
|
|
7714
|
+
}
|
|
7715
|
+
}
|
|
7716
|
+
return names.length > 0 ? {
|
|
7717
|
+
names,
|
|
7718
|
+
scope: this.scopeVar(instanceScope(this.plan, scope))
|
|
7719
|
+
} : void 0;
|
|
7601
7720
|
}
|
|
7602
7721
|
flush() {
|
|
7603
7722
|
if (this.parts.length === 0) return;
|
|
@@ -7794,9 +7913,26 @@ var Emitter = class {
|
|
|
7794
7913
|
if (!this.options.functions && this.isFunctionStatement(statement)) continue;
|
|
7795
7914
|
}
|
|
7796
7915
|
this.raw(this.patch.slice(statement.start, statement.end), statement.start);
|
|
7916
|
+
if (this.options.mode === "client" && statement.type === "VariableDeclaration") this.watchUnreadMemos(statement, scope);
|
|
7797
7917
|
}
|
|
7798
7918
|
endRun();
|
|
7799
7919
|
}
|
|
7920
|
+
/**
|
|
7921
|
+
* In the browser, a memo that nothing reads has no slot, so no load takes its promise. Its
|
|
7922
|
+
* rejection goes to the nearest `#try`, which is where a memo that throws sends its error. A
|
|
7923
|
+
* memo that always gives a primitive, such as `count * 2`, is never a promise. `await memo`
|
|
7924
|
+
* compiles to a plain read of the promise, which drops it, unless the read is the whole value
|
|
7925
|
+
* of another memo, as in `$memo(await memo)`, which then holds the same promise.
|
|
7926
|
+
*/
|
|
7927
|
+
watchUnreadMemos(statement, scope) {
|
|
7928
|
+
for (const declarator of statement.declarations) {
|
|
7929
|
+
const declaration = declarator.id.type === "Identifier" ? scope.declarations.get(declarator.id.name) : void 0;
|
|
7930
|
+
if (declaration && (declaration.kind === "memo" || declaration.kind === "async-memo") && declaration.reads.every((read) => read.await && (read.site.kind !== "memo" || read.site.node.start !== read.await.start || read.site.node.end !== read.await.end)) && slotIndex(this.plan, declaration) === -1 && !(declaration.site && isPrimitive(declaration.site.node))) {
|
|
7931
|
+
const target = this.scopeVar(instanceScope(this.plan, scope));
|
|
7932
|
+
this.line(`$$b.unreadMemo(${target}, ${declaration.name});`);
|
|
7933
|
+
}
|
|
7934
|
+
}
|
|
7935
|
+
}
|
|
7800
7936
|
source(node) {
|
|
7801
7937
|
return this.patch.slice(node.start, node.end);
|
|
7802
7938
|
}
|
|
@@ -7975,7 +8111,9 @@ var Emitter = class {
|
|
|
7975
8111
|
this.line(`let $$html = '';`);
|
|
7976
8112
|
this.atTopLevel(() => this.emitBody(template.body));
|
|
7977
8113
|
this.flush();
|
|
7978
|
-
this.
|
|
8114
|
+
const scope = this.plan.bodyScopes.get(template.body);
|
|
8115
|
+
const at = this.plan.scopes.get(scope).needsId ? `, ${this.scopeVar(scope)}` : "";
|
|
8116
|
+
this.line(`return $$b.raw($$html${at});`);
|
|
7979
8117
|
this.close();
|
|
7980
8118
|
}
|
|
7981
8119
|
emitNodes(nodes, scope) {
|
|
@@ -7996,15 +8134,17 @@ var Emitter = class {
|
|
|
7996
8134
|
return;
|
|
7997
8135
|
case "insert": {
|
|
7998
8136
|
const anchor = this.anchor(scope, node);
|
|
7999
|
-
const
|
|
8137
|
+
const site = this.sitesByNode.get(node.expression.ast);
|
|
8138
|
+
const readsProp = readsProps(site);
|
|
8000
8139
|
const spacer = this.parentSpacer();
|
|
8001
8140
|
const server = this.options.mode === "server" && readsProp;
|
|
8002
8141
|
let rest = server && spacer !== void 0 ? `, ${JSON.stringify(spacer)}` : "";
|
|
8003
8142
|
if (server && anchor) rest = `${rest || ", undefined"}, ${anchor.index}`;
|
|
8004
|
-
const at = this.options.mode === "server" || readsProp ? `, ${this.ctxArgument}, ${this.scopeVar(instanceScope(this.plan, scope))}${rest}` : "";
|
|
8143
|
+
const at = this.options.mode === "server" || readsProp || callsTemplate(site) ? `, ${this.ctxArgument}, ${this.scopeVar(instanceScope(this.plan, scope))}${rest}` : "";
|
|
8005
8144
|
const value = this.isPrimitiveInsert(node.expression) ? `$$b.insert(${this.expression(node.expression)})` : this.ready(`$$b.insert(${this.expression(node.expression)}${at})`);
|
|
8006
8145
|
const text = literalText(node.expression.ast);
|
|
8007
|
-
const
|
|
8146
|
+
const settled = this.settledMemos([node.expression], scope);
|
|
8147
|
+
const emitValue = () => text === void 0 ? this.code(value, settled) : this.html(text);
|
|
8008
8148
|
if (anchor && !this.plan.contents.has(node)) {
|
|
8009
8149
|
this.html("<!--t");
|
|
8010
8150
|
this.code(anchor.scope);
|
|
@@ -8219,7 +8359,7 @@ var Emitter = class {
|
|
|
8219
8359
|
this.emitClasses(classes);
|
|
8220
8360
|
break;
|
|
8221
8361
|
}
|
|
8222
|
-
this.code(`$$b.attribute(${JSON.stringify(attribute.name)}, ${this.expression(attribute.value)})
|
|
8362
|
+
this.code(`$$b.attribute(${JSON.stringify(attribute.name)}, ${this.expression(attribute.value)})`, this.settledMemos([attribute.value], scope));
|
|
8223
8363
|
const bound = this.bindEntry(node, attribute, scope);
|
|
8224
8364
|
if (bound) events.unshift(bound);
|
|
8225
8365
|
break;
|
|
@@ -8485,7 +8625,17 @@ var Emitter = class {
|
|
|
8485
8625
|
const at = `${this.file.filename}:${before.length}:${before.at(-1).length + 1}`;
|
|
8486
8626
|
link = `${link || ", undefined"}, ${JSON.stringify(`<${node.name}> in ${at}`)}`;
|
|
8487
8627
|
}
|
|
8488
|
-
|
|
8628
|
+
const values = [];
|
|
8629
|
+
for (const attribute of node.attributes) {
|
|
8630
|
+
const type = attribute.kind === "value" ? attribute.value.ast.type : "";
|
|
8631
|
+
if (type === "ArrowFunctionExpression" || type === "FunctionExpression") continue;
|
|
8632
|
+
if (attribute.kind === "value" || attribute.kind === "spread") values.push(attribute.value);
|
|
8633
|
+
else if (attribute.kind === "computed") {
|
|
8634
|
+
values.push(attribute.name);
|
|
8635
|
+
if (attribute.value !== true) values.push(attribute.value);
|
|
8636
|
+
}
|
|
8637
|
+
}
|
|
8638
|
+
this.code(`${this.wait}$$b.component(${node.name}, ${props}, ${this.ctxArgument}, ${owner}${link})`, this.settledMemos(values, scope));
|
|
8489
8639
|
}
|
|
8490
8640
|
emitDynamic(node, scope) {
|
|
8491
8641
|
const childrenName = this.emitChildren(node, scope);
|
|
@@ -8739,7 +8889,9 @@ var Emitter = class {
|
|
|
8739
8889
|
let index = other ? String(branches.length) : "-1";
|
|
8740
8890
|
for (let at = branches.length - 1; at >= 0; at--) index = `${this.expression(branches[at].condition)} ? ${at} : ${index}`;
|
|
8741
8891
|
const names = `[${[...bodies, ...other ? [other] : []].join(", ")}]`;
|
|
8742
|
-
|
|
8892
|
+
const conditions = [];
|
|
8893
|
+
for (const branch of branches) conditions.push(branch.condition);
|
|
8894
|
+
this.code(`$$b.nodes($$b.branchNodes(${marks}, ${index}, ${names}))`, this.settledMemos(conditions, scope));
|
|
8743
8895
|
return true;
|
|
8744
8896
|
}
|
|
8745
8897
|
if (block.kind === "for" || block.kind === "repeat") {
|
|
@@ -8749,7 +8901,7 @@ var Emitter = class {
|
|
|
8749
8901
|
const fallback = block.fallback;
|
|
8750
8902
|
const other = fallback && this.bodyFunction("", () => this.emitBody(fallback));
|
|
8751
8903
|
const items = block.kind === "for" ? `$$b.toList(${this.expression(block.list)})` : `Array.from({ length: ${this.expression(block.count)} }, (_, index) => index)`;
|
|
8752
|
-
this.code(`$$b.nodes($$b.listNodes(${marks}, ${items}, ${body}, ${other ?? "undefined"}))
|
|
8904
|
+
this.code(`$$b.nodes($$b.listNodes(${marks}, ${items}, ${body}, ${other ?? "undefined"}))`, this.settledMemos([block.kind === "for" ? block.list : block.count], scope));
|
|
8753
8905
|
return true;
|
|
8754
8906
|
}
|
|
8755
8907
|
return false;
|
|
@@ -10938,15 +11090,21 @@ var ClientGenerator = class {
|
|
|
10938
11090
|
* body, and the kinds of both bodies, and the holder of a block in children.
|
|
10939
11091
|
*/
|
|
10940
11092
|
triesTable() {
|
|
10941
|
-
const
|
|
11093
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
10942
11094
|
for (const scope of this.model.scopes) {
|
|
10943
11095
|
const block = scope.block;
|
|
10944
11096
|
if (block?.kind !== "try" || scope.body !== block.body || !this.plan.anchors.has(block) || !tryCatchesClient(this.model, block)) continue;
|
|
10945
11097
|
const owner = instanceScope(this.plan, scope.parent);
|
|
10946
11098
|
const fallback = this.plan.bodyScopes.get(block.fallback);
|
|
10947
11099
|
const held = holderArguments(this.plan, block);
|
|
10948
|
-
|
|
10949
|
-
|
|
11100
|
+
bodies.set(scope, `[${owner.id}, ${this.plan.anchors.get(block)}, ${JSON.stringify(`r${scope.id}`)}, ${JSON.stringify(`r${fallback.id}`)}, [${this.kinds(blockBodies(block)).join(", ")}]${held}]`);
|
|
11101
|
+
}
|
|
11102
|
+
const entries = [];
|
|
11103
|
+
for (const inside of this.model.scopes) {
|
|
11104
|
+
let current = inside;
|
|
11105
|
+
while (current && !bodies.has(current) && current.kind !== "template") current = current.parent;
|
|
11106
|
+
const entry = current && bodies.get(current);
|
|
11107
|
+
if (entry) entries.push(`${inside.id}: ${entry}`);
|
|
10950
11108
|
}
|
|
10951
11109
|
return entries.length > 0 ? `{ ${entries.join(", ")} }` : void 0;
|
|
10952
11110
|
}
|
|
@@ -11472,6 +11630,6 @@ function inspect(source, options = {}) {
|
|
|
11472
11630
|
};
|
|
11473
11631
|
}
|
|
11474
11632
|
//#endregion
|
|
11475
|
-
export { analyzeProject as A, getLocation as B, isReactiveModule as C, unmarked as D, originalPosition as E,
|
|
11633
|
+
export { analyzeProject as A, getLocation as B, isReactiveModule as C, unmarked as D, originalPosition as E, summarize as F, isWithin as G, findError as H, parse$1 as I, walk as J, lookup as K, buildGraph as L, importSource as M, importedComponents as N, entryClasses as O, resolveRelative as P, forEachNode as R, sharedSites as S, builtin as T, analyze$1 as U, errorLink as V, getPatternNames as W, functionId as _, scopeLabel as a, SHARED_QUERY as b, DEFAULT_MERGE as c, generateServer as d, instanceScope as f, createPlan as g, clientState as h, report as i, analyzeProjectProps as j, refreshedNames as k, generateClient as l, blockBodies as m, formatReport as n, CompileError as o, slotIndex as p, resolveMacros as q, inspect as r, compile as s, anchorLabel as t, generateRender as u, getComponentName as v, resolveFromDisk as w, generateShared as x, hash as y, BrumateError as z };
|
|
11476
11634
|
|
|
11477
|
-
//# sourceMappingURL=inspect-
|
|
11635
|
+
//# sourceMappingURL=inspect-DaZtoKgg.js.map
|