@barefootjs/rust 0.33.4 → 0.34.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/adapter/emit-context.d.ts +11 -1
- package/dist/adapter/emit-context.d.ts.map +1 -1
- package/dist/adapter/expr/emitters.d.ts +11 -1
- package/dist/adapter/expr/emitters.d.ts.map +1 -1
- package/dist/adapter/index.js +33 -23
- package/dist/adapter/minijinja-adapter.d.ts +14 -0
- package/dist/adapter/minijinja-adapter.d.ts.map +1 -1
- package/dist/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +38 -25
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +197 -135
- package/package.json +5 -5
- package/src/adapter/emit-context.ts +12 -1
- package/src/adapter/expr/emitters.ts +33 -0
- package/src/adapter/minijinja-adapter.ts +37 -43
- package/src/conformance-pins.ts +11 -0
- package/src/render-divergences.ts +4 -1
package/dist/vite.js
CHANGED
|
@@ -8,10 +8,45 @@ import { devModuleUrl, loadManifest, resolveDevOrigin, resolveScriptAssets, toPo
|
|
|
8
8
|
import ts25 from "typescript";
|
|
9
9
|
|
|
10
10
|
// ../jsx/src/analyzer.ts
|
|
11
|
-
import
|
|
11
|
+
import ts10 from "typescript";
|
|
12
12
|
|
|
13
13
|
// ../jsx/src/expression-parser.ts
|
|
14
14
|
import ts from "typescript";
|
|
15
|
+
|
|
16
|
+
// ../jsx/src/lowering-registry.ts
|
|
17
|
+
var plugins = [];
|
|
18
|
+
function registerLoweringPlugin(plugin) {
|
|
19
|
+
const existing = plugins.findIndex((p) => p.name === plugin.name);
|
|
20
|
+
if (existing >= 0)
|
|
21
|
+
plugins[existing] = plugin;
|
|
22
|
+
else
|
|
23
|
+
plugins.push(plugin);
|
|
24
|
+
}
|
|
25
|
+
function prepareLoweringMatchers(metadata) {
|
|
26
|
+
const matchers = [];
|
|
27
|
+
for (const plugin of plugins) {
|
|
28
|
+
const matcher = plugin.prepare(metadata);
|
|
29
|
+
if (matcher)
|
|
30
|
+
matchers.push(matcher);
|
|
31
|
+
}
|
|
32
|
+
return matchers;
|
|
33
|
+
}
|
|
34
|
+
function loweringNodeChildren(node) {
|
|
35
|
+
if (node.kind === "helper-call")
|
|
36
|
+
return [...node.args];
|
|
37
|
+
const children = [node.base];
|
|
38
|
+
for (const t of node.triples) {
|
|
39
|
+
if (t.guard)
|
|
40
|
+
children.push(t.guard);
|
|
41
|
+
children.push(t.value);
|
|
42
|
+
}
|
|
43
|
+
return children;
|
|
44
|
+
}
|
|
45
|
+
function isValidHelperId(helper) {
|
|
46
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(helper);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ../jsx/src/expression-parser.ts
|
|
15
50
|
var UNSUPPORTED_METHODS = new Set([
|
|
16
51
|
"filter",
|
|
17
52
|
"map",
|
|
@@ -263,7 +298,7 @@ function convertNode(node, raw) {
|
|
|
263
298
|
}
|
|
264
299
|
if (n === undefined || Number.isNaN(n)) {
|
|
265
300
|
const parsedDepth = convertNode(depthNode, raw);
|
|
266
|
-
if (checkSupport(parsedDepth, "rendered").supported) {
|
|
301
|
+
if (checkSupport(parsedDepth, "rendered", []).supported) {
|
|
267
302
|
depthExpr = parsedDepth;
|
|
268
303
|
flatDepth = 1;
|
|
269
304
|
} else {
|
|
@@ -1041,13 +1076,13 @@ function getUnaryOperatorString(op) {
|
|
|
1041
1076
|
return "unknown";
|
|
1042
1077
|
}
|
|
1043
1078
|
}
|
|
1044
|
-
function isSupported(expr) {
|
|
1045
|
-
return checkSupport(expr, "rendered");
|
|
1079
|
+
function isSupported(expr, opts) {
|
|
1080
|
+
return checkSupport(expr, "rendered", opts?.loweringMatchers ?? []);
|
|
1046
1081
|
}
|
|
1047
|
-
function isSupportedValue(expr) {
|
|
1048
|
-
return checkSupport(expr, "value");
|
|
1082
|
+
function isSupportedValue(expr, opts) {
|
|
1083
|
+
return checkSupport(expr, "value", opts?.loweringMatchers ?? []);
|
|
1049
1084
|
}
|
|
1050
|
-
function checkSupport(expr, pos) {
|
|
1085
|
+
function checkSupport(expr, pos, matchers) {
|
|
1051
1086
|
switch (expr.kind) {
|
|
1052
1087
|
case "unsupported":
|
|
1053
1088
|
return { supported: false, reason: expr.reason };
|
|
@@ -1056,7 +1091,7 @@ function checkSupport(expr, pos) {
|
|
|
1056
1091
|
return { supported: false, reason: "Unsupported syntax: ObjectLiteralExpression" };
|
|
1057
1092
|
}
|
|
1058
1093
|
for (const prop of expr.properties) {
|
|
1059
|
-
const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos);
|
|
1094
|
+
const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos, matchers);
|
|
1060
1095
|
if (!propSupport.supported)
|
|
1061
1096
|
return propSupport;
|
|
1062
1097
|
}
|
|
@@ -1071,7 +1106,7 @@ function checkSupport(expr, pos) {
|
|
|
1071
1106
|
return { supported: false, reason: "Standalone arrow functions / regex literals are not supported" };
|
|
1072
1107
|
case "array-literal": {
|
|
1073
1108
|
for (const el of expr.elements) {
|
|
1074
|
-
const elSupport = checkSupport(el, pos);
|
|
1109
|
+
const elSupport = checkSupport(el, pos, matchers);
|
|
1075
1110
|
if (!elSupport.supported)
|
|
1076
1111
|
return elSupport;
|
|
1077
1112
|
}
|
|
@@ -1084,28 +1119,39 @@ function checkSupport(expr, pos) {
|
|
|
1084
1119
|
reason: `String.prototype.${expr.method} supports only a string pattern + string replacement (the regex form is deferred); use a string pattern or wrap the expression in /* @client */`
|
|
1085
1120
|
};
|
|
1086
1121
|
}
|
|
1087
|
-
const objSupport = checkSupport(expr.object, pos);
|
|
1122
|
+
const objSupport = checkSupport(expr.object, pos, matchers);
|
|
1088
1123
|
if (!objSupport.supported)
|
|
1089
1124
|
return objSupport;
|
|
1090
1125
|
for (const arg of expr.args) {
|
|
1091
|
-
const argSupport = checkSupport(arg, pos);
|
|
1126
|
+
const argSupport = checkSupport(arg, pos, matchers);
|
|
1092
1127
|
if (!argSupport.supported)
|
|
1093
1128
|
return argSupport;
|
|
1094
1129
|
}
|
|
1095
1130
|
if (expr.method === "flat" && expr.depthExpr) {
|
|
1096
|
-
const depthSupport = checkSupport(expr.depthExpr, pos);
|
|
1131
|
+
const depthSupport = checkSupport(expr.depthExpr, pos, matchers);
|
|
1097
1132
|
if (!depthSupport.supported)
|
|
1098
1133
|
return depthSupport;
|
|
1099
1134
|
}
|
|
1100
1135
|
return { supported: true, level: "L2" };
|
|
1101
1136
|
}
|
|
1102
1137
|
case "call": {
|
|
1138
|
+
for (const matcher of matchers) {
|
|
1139
|
+
const node = matcher(expr.callee, expr.args);
|
|
1140
|
+
if (!node)
|
|
1141
|
+
continue;
|
|
1142
|
+
for (const child of loweringNodeChildren(node)) {
|
|
1143
|
+
const childSupport = checkSupport(child, pos, matchers);
|
|
1144
|
+
if (!childSupport.supported)
|
|
1145
|
+
return childSupport;
|
|
1146
|
+
}
|
|
1147
|
+
return { supported: true, level: "L2" };
|
|
1148
|
+
}
|
|
1103
1149
|
const cb = asCallbackMethodCall(expr);
|
|
1104
1150
|
if (cb) {
|
|
1105
|
-
const objSupport = checkSupport(cb.object, pos);
|
|
1151
|
+
const objSupport = checkSupport(cb.object, pos, matchers);
|
|
1106
1152
|
if (!objSupport.supported)
|
|
1107
1153
|
return objSupport;
|
|
1108
|
-
const bodySupport = checkSupport(cb.arrow.body, pos);
|
|
1154
|
+
const bodySupport = checkSupport(cb.arrow.body, pos, matchers);
|
|
1109
1155
|
if (!bodySupport.supported) {
|
|
1110
1156
|
return {
|
|
1111
1157
|
supported: false,
|
|
@@ -1114,13 +1160,13 @@ function checkSupport(expr, pos) {
|
|
|
1114
1160
|
};
|
|
1115
1161
|
}
|
|
1116
1162
|
for (const rest of cb.args) {
|
|
1117
|
-
const restSupport = checkSupport(rest, pos);
|
|
1163
|
+
const restSupport = checkSupport(rest, pos, matchers);
|
|
1118
1164
|
if (!restSupport.supported)
|
|
1119
1165
|
return restSupport;
|
|
1120
1166
|
}
|
|
1121
1167
|
return { supported: true, level: "L5" };
|
|
1122
1168
|
}
|
|
1123
|
-
const calleeSupport = checkSupport(expr.callee, pos);
|
|
1169
|
+
const calleeSupport = checkSupport(expr.callee, pos, matchers);
|
|
1124
1170
|
if (!calleeSupport.supported) {
|
|
1125
1171
|
return calleeSupport;
|
|
1126
1172
|
}
|
|
@@ -1139,7 +1185,7 @@ function checkSupport(expr, pos) {
|
|
|
1139
1185
|
return { supported: true, level: "L1" };
|
|
1140
1186
|
}
|
|
1141
1187
|
for (const arg of expr.args) {
|
|
1142
|
-
const argSupport = checkSupport(arg, pos);
|
|
1188
|
+
const argSupport = checkSupport(arg, pos, matchers);
|
|
1143
1189
|
if (!argSupport.supported) {
|
|
1144
1190
|
return argSupport;
|
|
1145
1191
|
}
|
|
@@ -1147,7 +1193,7 @@ function checkSupport(expr, pos) {
|
|
|
1147
1193
|
return { supported: true, level: "L2" };
|
|
1148
1194
|
}
|
|
1149
1195
|
case "member": {
|
|
1150
|
-
const objSupport = checkSupport(expr.object, pos);
|
|
1196
|
+
const objSupport = checkSupport(expr.object, pos, matchers);
|
|
1151
1197
|
if (!objSupport.supported) {
|
|
1152
1198
|
return objSupport;
|
|
1153
1199
|
}
|
|
@@ -1157,19 +1203,19 @@ function checkSupport(expr, pos) {
|
|
|
1157
1203
|
return { supported: true, level: "L2" };
|
|
1158
1204
|
}
|
|
1159
1205
|
case "index-access": {
|
|
1160
|
-
const objSupport = checkSupport(expr.object, pos);
|
|
1206
|
+
const objSupport = checkSupport(expr.object, pos, matchers);
|
|
1161
1207
|
if (!objSupport.supported)
|
|
1162
1208
|
return objSupport;
|
|
1163
|
-
const indexSupport = checkSupport(expr.index, pos);
|
|
1209
|
+
const indexSupport = checkSupport(expr.index, pos, matchers);
|
|
1164
1210
|
if (!indexSupport.supported)
|
|
1165
1211
|
return indexSupport;
|
|
1166
1212
|
return { supported: true, level: "L2" };
|
|
1167
1213
|
}
|
|
1168
1214
|
case "binary": {
|
|
1169
|
-
const leftSupport = checkSupport(expr.left, pos);
|
|
1215
|
+
const leftSupport = checkSupport(expr.left, pos, matchers);
|
|
1170
1216
|
if (!leftSupport.supported)
|
|
1171
1217
|
return leftSupport;
|
|
1172
|
-
const rightSupport = checkSupport(expr.right, pos);
|
|
1218
|
+
const rightSupport = checkSupport(expr.right, pos, matchers);
|
|
1173
1219
|
if (!rightSupport.supported)
|
|
1174
1220
|
return rightSupport;
|
|
1175
1221
|
if (["===", "==", "!==", "!=", ">", "<", ">=", "<="].includes(expr.op)) {
|
|
@@ -1181,7 +1227,7 @@ function checkSupport(expr, pos) {
|
|
|
1181
1227
|
return { supported: false, reason: `Unknown operator: ${expr.op}` };
|
|
1182
1228
|
}
|
|
1183
1229
|
case "unary": {
|
|
1184
|
-
const argSupport = checkSupport(expr.argument, pos);
|
|
1230
|
+
const argSupport = checkSupport(expr.argument, pos, matchers);
|
|
1185
1231
|
if (!argSupport.supported)
|
|
1186
1232
|
return argSupport;
|
|
1187
1233
|
if (expr.op === "!") {
|
|
@@ -1193,25 +1239,25 @@ function checkSupport(expr, pos) {
|
|
|
1193
1239
|
return { supported: false, reason: `Unsupported unary operator: ${expr.op}` };
|
|
1194
1240
|
}
|
|
1195
1241
|
case "logical": {
|
|
1196
|
-
const leftSupport = checkSupport(expr.left, pos);
|
|
1242
|
+
const leftSupport = checkSupport(expr.left, pos, matchers);
|
|
1197
1243
|
if (!leftSupport.supported)
|
|
1198
1244
|
return leftSupport;
|
|
1199
1245
|
if (expr.op === "??" && expr.right.kind === "object-literal" && expr.right.properties.length === 0) {
|
|
1200
1246
|
return { supported: true, level: "L4" };
|
|
1201
1247
|
}
|
|
1202
|
-
const rightSupport = checkSupport(expr.right, pos);
|
|
1248
|
+
const rightSupport = checkSupport(expr.right, pos, matchers);
|
|
1203
1249
|
if (!rightSupport.supported)
|
|
1204
1250
|
return rightSupport;
|
|
1205
1251
|
return { supported: true, level: "L4" };
|
|
1206
1252
|
}
|
|
1207
1253
|
case "conditional": {
|
|
1208
|
-
const testSupport = checkSupport(expr.test, pos);
|
|
1254
|
+
const testSupport = checkSupport(expr.test, pos, matchers);
|
|
1209
1255
|
if (!testSupport.supported)
|
|
1210
1256
|
return testSupport;
|
|
1211
|
-
const consSupport = checkSupport(expr.consequent, pos);
|
|
1257
|
+
const consSupport = checkSupport(expr.consequent, pos, matchers);
|
|
1212
1258
|
if (!consSupport.supported)
|
|
1213
1259
|
return consSupport;
|
|
1214
|
-
const altSupport = checkSupport(expr.alternate, pos);
|
|
1260
|
+
const altSupport = checkSupport(expr.alternate, pos, matchers);
|
|
1215
1261
|
if (!altSupport.supported)
|
|
1216
1262
|
return altSupport;
|
|
1217
1263
|
return { supported: true, level: "L4" };
|
|
@@ -1219,7 +1265,7 @@ function checkSupport(expr, pos) {
|
|
|
1219
1265
|
case "template-literal": {
|
|
1220
1266
|
for (const part of expr.parts) {
|
|
1221
1267
|
if (part.type === "expression") {
|
|
1222
|
-
const partSupport = checkSupport(part.expr, pos);
|
|
1268
|
+
const partSupport = checkSupport(part.expr, pos, matchers);
|
|
1223
1269
|
if (!partSupport.supported)
|
|
1224
1270
|
return partSupport;
|
|
1225
1271
|
}
|
|
@@ -1993,7 +2039,7 @@ function identifierPath(callee) {
|
|
|
1993
2039
|
}
|
|
1994
2040
|
|
|
1995
2041
|
// ../jsx/src/prop-rewrite.ts
|
|
1996
|
-
import
|
|
2042
|
+
import ts7 from "typescript";
|
|
1997
2043
|
|
|
1998
2044
|
// ../jsx/src/ir-to-client-js/utils.ts
|
|
1999
2045
|
import ts3 from "typescript";
|
|
@@ -2143,19 +2189,61 @@ function resolveJsxChildrenProp(props) {
|
|
|
2143
2189
|
return [];
|
|
2144
2190
|
return prop.value.children ?? [];
|
|
2145
2191
|
}
|
|
2192
|
+
// ../jsx/src/ir-to-client-js/component-scope.ts
|
|
2193
|
+
function buildImportAliasMap(imports) {
|
|
2194
|
+
const aliases = new Map;
|
|
2195
|
+
for (const imp of imports) {
|
|
2196
|
+
if (imp.isTypeOnly)
|
|
2197
|
+
continue;
|
|
2198
|
+
for (const spec of imp.specifiers) {
|
|
2199
|
+
if (spec.isTypeOnly || spec.isDefault || spec.isNamespace || spec.alias === null)
|
|
2200
|
+
continue;
|
|
2201
|
+
aliases.set(spec.alias, spec.name);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
return aliases;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2146
2207
|
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
2208
|
+
import ts5 from "typescript";
|
|
2209
|
+
|
|
2210
|
+
// ../jsx/src/props-binding.ts
|
|
2147
2211
|
import ts4 from "typescript";
|
|
2212
|
+
function isIdentifierName(key) {
|
|
2213
|
+
if (key.length === 0)
|
|
2214
|
+
return false;
|
|
2215
|
+
for (let i = 0;i < key.length; ) {
|
|
2216
|
+
const cp = key.codePointAt(i);
|
|
2217
|
+
const ok = i === 0 ? ts4.isIdentifierStart(cp, ts4.ScriptTarget.Latest) : ts4.isIdentifierPart(cp, ts4.ScriptTarget.Latest);
|
|
2218
|
+
if (!ok)
|
|
2219
|
+
return false;
|
|
2220
|
+
i += cp > 65535 ? 2 : 1;
|
|
2221
|
+
}
|
|
2222
|
+
return true;
|
|
2223
|
+
}
|
|
2224
|
+
function propsDestructureBinding(p) {
|
|
2225
|
+
const callerKey = p.sourceName ?? p.name;
|
|
2226
|
+
const localName = p.name;
|
|
2227
|
+
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
2228
|
+
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
2229
|
+
}
|
|
2230
|
+
var EMPTY_SET = new Set;
|
|
2231
|
+
|
|
2232
|
+
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
2148
2233
|
function extractFreeIdentifiersFromText(text) {
|
|
2149
2234
|
if (!text || text.trim().length === 0)
|
|
2150
2235
|
return new Set;
|
|
2151
|
-
const sf =
|
|
2236
|
+
const sf = ts5.createSourceFile("__free_ids__.ts", `(${text});`, ts5.ScriptTarget.Latest, true, ts5.ScriptKind.TS);
|
|
2152
2237
|
const stmt = sf.statements[0];
|
|
2153
|
-
if (!stmt || !
|
|
2238
|
+
if (!stmt || !ts5.isExpressionStatement(stmt))
|
|
2154
2239
|
return new Set;
|
|
2155
|
-
const expr =
|
|
2240
|
+
const expr = ts5.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
|
|
2156
2241
|
return extractFreeIdentifiersFromNode(expr);
|
|
2157
2242
|
}
|
|
2158
2243
|
|
|
2244
|
+
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
2245
|
+
import ts6 from "typescript";
|
|
2246
|
+
|
|
2159
2247
|
// ../jsx/src/adapters/child-scope.ts
|
|
2160
2248
|
function derivesScopeFromSlot(comp) {
|
|
2161
2249
|
return comp.slotId != null && comp.loopItemRoot !== true;
|
|
@@ -2282,27 +2370,6 @@ var SKELETON_PATH_FORCE_CLOSE_GROUPS = [
|
|
|
2282
2370
|
new Set(["li"])
|
|
2283
2371
|
];
|
|
2284
2372
|
|
|
2285
|
-
// ../jsx/src/props-binding.ts
|
|
2286
|
-
import ts6 from "typescript";
|
|
2287
|
-
function isIdentifierName(key) {
|
|
2288
|
-
if (key.length === 0)
|
|
2289
|
-
return false;
|
|
2290
|
-
for (let i = 0;i < key.length; ) {
|
|
2291
|
-
const cp = key.codePointAt(i);
|
|
2292
|
-
const ok = i === 0 ? ts6.isIdentifierStart(cp, ts6.ScriptTarget.Latest) : ts6.isIdentifierPart(cp, ts6.ScriptTarget.Latest);
|
|
2293
|
-
if (!ok)
|
|
2294
|
-
return false;
|
|
2295
|
-
i += cp > 65535 ? 2 : 1;
|
|
2296
|
-
}
|
|
2297
|
-
return true;
|
|
2298
|
-
}
|
|
2299
|
-
function propsDestructureBinding(p) {
|
|
2300
|
-
const callerKey = p.sourceName ?? p.name;
|
|
2301
|
-
const localName = p.name;
|
|
2302
|
-
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
2303
|
-
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
2373
|
// ../jsx/src/instrumentation.ts
|
|
2307
2374
|
var _counters = freshCounters();
|
|
2308
2375
|
function freshCounters() {
|
|
@@ -2316,20 +2383,21 @@ function freshCounters() {
|
|
|
2316
2383
|
}
|
|
2317
2384
|
|
|
2318
2385
|
// ../jsx/src/analyzer-context.ts
|
|
2319
|
-
import
|
|
2386
|
+
import ts9 from "typescript";
|
|
2320
2387
|
|
|
2321
2388
|
// ../jsx/src/strip-types.ts
|
|
2322
|
-
import
|
|
2389
|
+
import ts8 from "typescript";
|
|
2323
2390
|
|
|
2324
2391
|
// ../jsx/src/analyzer-context.ts
|
|
2325
|
-
var _typePrinter =
|
|
2326
|
-
var _blankTypeSourceFile =
|
|
2392
|
+
var _typePrinter = ts9.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
2393
|
+
var _blankTypeSourceFile = ts9.createSourceFile("__bf_types__.ts", "", ts9.ScriptTarget.Latest);
|
|
2327
2394
|
|
|
2328
2395
|
// ../jsx/src/errors.ts
|
|
2329
2396
|
var ErrorCodes = {
|
|
2330
2397
|
MISSING_USE_CLIENT: "BF001",
|
|
2331
2398
|
CLIENT_IMPORTING_SERVER: "BF003",
|
|
2332
2399
|
SIGNAL_OUTSIDE_COMPONENT: "BF011",
|
|
2400
|
+
PRIMITIVE_VIA_NAMESPACE_IMPORT: "BF013",
|
|
2333
2401
|
UNSUPPORTED_JSX_PATTERN: "BF021",
|
|
2334
2402
|
MISSING_KEY_IN_LIST: "BF023",
|
|
2335
2403
|
MISSING_KEY_IN_NESTED_LIST: "BF024",
|
|
@@ -2362,6 +2430,7 @@ var errorMessages = {
|
|
|
2362
2430
|
[ErrorCodes.MISSING_USE_CLIENT]: "'use client' directive required for components with createSignal or event handlers",
|
|
2363
2431
|
[ErrorCodes.CLIENT_IMPORTING_SERVER]: "Client component cannot import server component",
|
|
2364
2432
|
[ErrorCodes.SIGNAL_OUTSIDE_COMPONENT]: "Module-level reactive declaration (createSignal / createMemo) is not allowed. " + "The downstream codegen drops the declaration silently and every reference becomes a ReferenceError at SSR and at hydrate. " + "Move the declaration inside a component function so each mount gets its own state.",
|
|
2433
|
+
[ErrorCodes.PRIMITIVE_VIA_NAMESPACE_IMPORT]: "Reactive primitive called through a namespace import of '@barefootjs/client' (import * as ns) is not recognized; " + "the declaration is dropped and its references throw ReferenceError at hydrate. Import the primitive by name instead.",
|
|
2365
2434
|
[ErrorCodes.UNSUPPORTED_JSX_PATTERN]: "Unsupported JSX pattern",
|
|
2366
2435
|
[ErrorCodes.MISSING_KEY_IN_LIST]: "Missing key attribute in list rendering. Add a key prop for efficient updates",
|
|
2367
2436
|
[ErrorCodes.MISSING_KEY_IN_NESTED_LIST]: "Nested .map() loop requires key attribute for event delegation. Add a key prop to elements in the inner loop",
|
|
@@ -2553,46 +2622,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
2553
2622
|
const ids = new Set;
|
|
2554
2623
|
const boundNames = new Set;
|
|
2555
2624
|
function addBindingNames(name, out) {
|
|
2556
|
-
if (
|
|
2625
|
+
if (ts10.isIdentifier(name))
|
|
2557
2626
|
out.push(name.text);
|
|
2558
|
-
else if (
|
|
2627
|
+
else if (ts10.isObjectBindingPattern(name))
|
|
2559
2628
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
2560
|
-
else if (
|
|
2629
|
+
else if (ts10.isArrayBindingPattern(name))
|
|
2561
2630
|
name.elements.forEach((e) => {
|
|
2562
|
-
if (!
|
|
2631
|
+
if (!ts10.isOmittedExpression(e))
|
|
2563
2632
|
addBindingNames(e.name, out);
|
|
2564
2633
|
});
|
|
2565
2634
|
}
|
|
2566
2635
|
function visit(n) {
|
|
2567
|
-
if (
|
|
2636
|
+
if (ts10.isTypeNode(n))
|
|
2568
2637
|
return;
|
|
2569
|
-
if (
|
|
2638
|
+
if (ts10.isIdentifier(n)) {
|
|
2570
2639
|
const parent = n.parent;
|
|
2571
|
-
if (parent &&
|
|
2640
|
+
if (parent && ts10.isPropertyAccessExpression(parent) && parent.name === n)
|
|
2572
2641
|
return;
|
|
2573
|
-
if (parent &&
|
|
2642
|
+
if (parent && ts10.isPropertyAssignment(parent) && parent.name === n)
|
|
2574
2643
|
return;
|
|
2575
|
-
if (parent &&
|
|
2644
|
+
if (parent && ts10.isParameter(parent) && parent.name === n)
|
|
2576
2645
|
return;
|
|
2577
|
-
if (parent &&
|
|
2646
|
+
if (parent && ts10.isVariableDeclaration(parent) && parent.name === n)
|
|
2578
2647
|
return;
|
|
2579
2648
|
if (boundNames.has(n.text))
|
|
2580
2649
|
return;
|
|
2581
2650
|
ids.add(n.text);
|
|
2582
2651
|
return;
|
|
2583
2652
|
}
|
|
2584
|
-
if (
|
|
2653
|
+
if (ts10.isArrowFunction(n)) {
|
|
2585
2654
|
const params = [];
|
|
2586
2655
|
for (const p of n.parameters)
|
|
2587
2656
|
addBindingNames(p.name, params);
|
|
2588
2657
|
for (const name of params)
|
|
2589
2658
|
boundNames.add(name);
|
|
2590
|
-
|
|
2659
|
+
ts10.forEachChild(n, visit);
|
|
2591
2660
|
for (const name of params)
|
|
2592
2661
|
boundNames.delete(name);
|
|
2593
2662
|
return;
|
|
2594
2663
|
}
|
|
2595
|
-
|
|
2664
|
+
ts10.forEachChild(n, visit);
|
|
2596
2665
|
}
|
|
2597
2666
|
visit(node);
|
|
2598
2667
|
return ids;
|
|
@@ -2615,7 +2684,7 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
2615
2684
|
]);
|
|
2616
2685
|
|
|
2617
2686
|
// ../jsx/src/jsx-to-ir.ts
|
|
2618
|
-
import
|
|
2687
|
+
import ts14 from "typescript";
|
|
2619
2688
|
|
|
2620
2689
|
// ../jsx/src/types.ts
|
|
2621
2690
|
var SCOPE_FORBIDDEN = {
|
|
@@ -2665,7 +2734,7 @@ function preambleAnalysisTemplateText(p) {
|
|
|
2665
2734
|
}
|
|
2666
2735
|
|
|
2667
2736
|
// ../jsx/src/module-exports.ts
|
|
2668
|
-
import
|
|
2737
|
+
import ts11 from "typescript";
|
|
2669
2738
|
function formatParamWithType(p) {
|
|
2670
2739
|
const rest = p.isRest ? "..." : "";
|
|
2671
2740
|
const optional = p.optional ? "?" : "";
|
|
@@ -2700,21 +2769,21 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
2700
2769
|
const assigned = new Set;
|
|
2701
2770
|
if (candidates.size === 0)
|
|
2702
2771
|
return assigned;
|
|
2703
|
-
const sf =
|
|
2772
|
+
const sf = ts11.createSourceFile("bf-assignment-scan.tsx", bodyText, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
|
|
2704
2773
|
const record = (target) => {
|
|
2705
|
-
if (
|
|
2774
|
+
if (ts11.isIdentifier(target) && candidates.has(target.text)) {
|
|
2706
2775
|
assigned.add(target.text);
|
|
2707
2776
|
}
|
|
2708
2777
|
};
|
|
2709
2778
|
const visit = (node) => {
|
|
2710
|
-
if (
|
|
2779
|
+
if (ts11.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
2711
2780
|
record(node.left);
|
|
2712
|
-
} else if ((
|
|
2781
|
+
} else if ((ts11.isPrefixUnaryExpression(node) || ts11.isPostfixUnaryExpression(node)) && (node.operator === ts11.SyntaxKind.PlusPlusToken || node.operator === ts11.SyntaxKind.MinusMinusToken)) {
|
|
2713
2782
|
record(node.operand);
|
|
2714
2783
|
}
|
|
2715
|
-
|
|
2784
|
+
ts11.forEachChild(node, visit);
|
|
2716
2785
|
};
|
|
2717
|
-
|
|
2786
|
+
ts11.forEachChild(sf, visit);
|
|
2718
2787
|
return assigned;
|
|
2719
2788
|
}
|
|
2720
2789
|
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
@@ -2737,14 +2806,14 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
2737
2806
|
return reachable;
|
|
2738
2807
|
}
|
|
2739
2808
|
function isAssignmentOperator(kind) {
|
|
2740
|
-
return kind >=
|
|
2809
|
+
return kind >= ts11.SyntaxKind.FirstAssignment && kind <= ts11.SyntaxKind.LastAssignment;
|
|
2741
2810
|
}
|
|
2742
2811
|
|
|
2743
2812
|
// ../jsx/src/reactivity-checker.ts
|
|
2744
|
-
import
|
|
2813
|
+
import ts12 from "typescript";
|
|
2745
2814
|
|
|
2746
2815
|
// ../jsx/src/free-refs.ts
|
|
2747
|
-
import
|
|
2816
|
+
import ts13 from "typescript";
|
|
2748
2817
|
var _bindingMapCache = new WeakMap;
|
|
2749
2818
|
|
|
2750
2819
|
// ../jsx/src/to-locale-date-lowering.ts
|
|
@@ -3192,40 +3261,16 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
3192
3261
|
]);
|
|
3193
3262
|
|
|
3194
3263
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
3195
|
-
import ts14 from "typescript";
|
|
3196
|
-
|
|
3197
|
-
// ../jsx/src/ir-to-client-js/imports.ts
|
|
3198
|
-
import ts16 from "typescript";
|
|
3199
|
-
|
|
3200
|
-
// ../jsx/src/value-references.ts
|
|
3201
3264
|
import ts15 from "typescript";
|
|
3202
3265
|
|
|
3203
|
-
// ../jsx/src/
|
|
3266
|
+
// ../jsx/src/ir-to-client-js/imports.ts
|
|
3204
3267
|
import ts17 from "typescript";
|
|
3205
3268
|
|
|
3206
|
-
// ../jsx/src/
|
|
3207
|
-
|
|
3208
|
-
function registerLoweringPlugin(plugin) {
|
|
3209
|
-
const existing = plugins.findIndex((p) => p.name === plugin.name);
|
|
3210
|
-
if (existing >= 0)
|
|
3211
|
-
plugins[existing] = plugin;
|
|
3212
|
-
else
|
|
3213
|
-
plugins.push(plugin);
|
|
3214
|
-
}
|
|
3215
|
-
function prepareLoweringMatchers(metadata) {
|
|
3216
|
-
const matchers = [];
|
|
3217
|
-
for (const plugin of plugins) {
|
|
3218
|
-
const matcher = plugin.prepare(metadata);
|
|
3219
|
-
if (matcher)
|
|
3220
|
-
matchers.push(matcher);
|
|
3221
|
-
}
|
|
3222
|
-
return matchers;
|
|
3223
|
-
}
|
|
3224
|
-
function isValidHelperId(helper) {
|
|
3225
|
-
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(helper);
|
|
3226
|
-
}
|
|
3269
|
+
// ../jsx/src/value-references.ts
|
|
3270
|
+
import ts16 from "typescript";
|
|
3227
3271
|
|
|
3228
3272
|
// ../jsx/src/relocate.ts
|
|
3273
|
+
import ts18 from "typescript";
|
|
3229
3274
|
var REGISTRY_SAFE_BINDING_KINDS = new Set([
|
|
3230
3275
|
"global",
|
|
3231
3276
|
"module-import",
|
|
@@ -3418,10 +3463,10 @@ function matchSearchParamsMethodCall(callee, args, localNames) {
|
|
|
3418
3463
|
}
|
|
3419
3464
|
|
|
3420
3465
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
3421
|
-
import
|
|
3466
|
+
import ts19 from "typescript";
|
|
3422
3467
|
|
|
3423
3468
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
3424
|
-
import
|
|
3469
|
+
import ts20 from "typescript";
|
|
3425
3470
|
var NO_PREAMBLE = {
|
|
3426
3471
|
lazySafe: true,
|
|
3427
3472
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -3471,7 +3516,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
3471
3516
|
]);
|
|
3472
3517
|
|
|
3473
3518
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
3474
|
-
import
|
|
3519
|
+
import ts21 from "typescript";
|
|
3475
3520
|
|
|
3476
3521
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
3477
3522
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -3485,9 +3530,6 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
3485
3530
|
"pointerleave"
|
|
3486
3531
|
]);
|
|
3487
3532
|
|
|
3488
|
-
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
3489
|
-
import ts21 from "typescript";
|
|
3490
|
-
|
|
3491
3533
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
3492
3534
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3493
3535
|
function encodeVLQ(value) {
|
|
@@ -4675,6 +4717,17 @@ function emitParsedExpr(expr, emitter) {
|
|
|
4675
4717
|
case "literal":
|
|
4676
4718
|
return emitter.literal(expr.value, expr.literalType);
|
|
4677
4719
|
case "call": {
|
|
4720
|
+
if (emitter.lowering) {
|
|
4721
|
+
for (const matcher of emitter.lowering.matchers) {
|
|
4722
|
+
const node = matcher(expr.callee, expr.args);
|
|
4723
|
+
if (!node)
|
|
4724
|
+
continue;
|
|
4725
|
+
const rendered = emitter.lowering.render(node, emit);
|
|
4726
|
+
if (rendered !== null)
|
|
4727
|
+
return rendered;
|
|
4728
|
+
break;
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4678
4731
|
const cb = asCallbackMethodCall(expr);
|
|
4679
4732
|
if (cb)
|
|
4680
4733
|
return emitter.callbackMethod(cb.method, cb.object, cb.arrow, cb.args, emit);
|
|
@@ -5670,6 +5723,21 @@ class JinjaTopLevelEmitter {
|
|
|
5670
5723
|
constructor(ctx) {
|
|
5671
5724
|
this.ctx = ctx;
|
|
5672
5725
|
}
|
|
5726
|
+
get lowering() {
|
|
5727
|
+
return {
|
|
5728
|
+
matchers: this.ctx._loweringMatchers,
|
|
5729
|
+
render: (node, emit) => {
|
|
5730
|
+
if (node.kind === "guard-list" && node.helper === "query") {
|
|
5731
|
+
const qArgs = queryHrefArgs(node, emit);
|
|
5732
|
+
return `bf.query(${qArgs.join(", ")})`;
|
|
5733
|
+
}
|
|
5734
|
+
if (node.kind === "helper-call" && isValidHelperId(node.helper)) {
|
|
5735
|
+
return `bf.${node.helper}(${node.args.map(emit).join(", ")})`;
|
|
5736
|
+
}
|
|
5737
|
+
return null;
|
|
5738
|
+
}
|
|
5739
|
+
};
|
|
5740
|
+
}
|
|
5673
5741
|
identifier(name) {
|
|
5674
5742
|
if (name === "undefined" || name === "null")
|
|
5675
5743
|
return "none";
|
|
@@ -6159,6 +6227,7 @@ class MinijinjaAdapter extends BaseAdapter {
|
|
|
6159
6227
|
localConstants = [];
|
|
6160
6228
|
scope = BindingScope.EMPTY;
|
|
6161
6229
|
nullableOptionalProps = new Set;
|
|
6230
|
+
importAliases = new Map;
|
|
6162
6231
|
constructor(options = {}) {
|
|
6163
6232
|
super();
|
|
6164
6233
|
this.options = {
|
|
@@ -6179,6 +6248,7 @@ class MinijinjaAdapter extends BaseAdapter {
|
|
|
6179
6248
|
this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
|
|
6180
6249
|
this._searchParamsLocals = searchParamsLocalNames(ir.metadata);
|
|
6181
6250
|
this._loweringMatchers = prepareLoweringMatchers(ir.metadata);
|
|
6251
|
+
this.importAliases = buildImportAliasMap(ir.metadata.imports ?? []);
|
|
6182
6252
|
this.errors = [];
|
|
6183
6253
|
this.childrenCaptureCounter = 0;
|
|
6184
6254
|
if (!options?.siblingTemplatesRegistered) {
|
|
@@ -6655,7 +6725,8 @@ ${childrenUnderLoop}` : childrenUnderLoop;
|
|
|
6655
6725
|
childrenCaptureCounter = 0;
|
|
6656
6726
|
presenceVarCounter = 0;
|
|
6657
6727
|
toTemplateName(componentName) {
|
|
6658
|
-
|
|
6728
|
+
const declaredName = this.importAliases.get(componentName) ?? componentName;
|
|
6729
|
+
return declaredName.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
|
6659
6730
|
}
|
|
6660
6731
|
renderIfStatement(ifStmt) {
|
|
6661
6732
|
const condition = this.convertConditionToJinja(ifStmt.condition);
|
|
@@ -6734,8 +6805,8 @@ ${body}
|
|
|
6734
6805
|
{
|
|
6735
6806
|
const m = this.parseUndefinedAlternateTernary(value.expr);
|
|
6736
6807
|
if (m) {
|
|
6737
|
-
const cond = this.convertConditionToJinja(m.
|
|
6738
|
-
const val = this.convertExpressionToJinja(m.
|
|
6808
|
+
const cond = this.convertConditionToJinja("", m.testParsed);
|
|
6809
|
+
const val = this.convertExpressionToJinja("", m.consequentParsed);
|
|
6739
6810
|
return `
|
|
6740
6811
|
{% if ${cond} %}
|
|
6741
6812
|
${name}="{{ bf.string(${val}) }}"
|
|
@@ -6868,7 +6939,7 @@ ${name}="{{ bf.string(${val}) }}"
|
|
|
6868
6939
|
if (!startsAsObjectLiteral && !hasTaggedTemplate)
|
|
6869
6940
|
return false;
|
|
6870
6941
|
const parsed = parseExpression(expr.trim());
|
|
6871
|
-
const support = isSupported(parsed);
|
|
6942
|
+
const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers });
|
|
6872
6943
|
if (parsed.kind !== "unsupported" && support.supported)
|
|
6873
6944
|
return false;
|
|
6874
6945
|
const reason = support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined);
|
|
@@ -6888,6 +6959,7 @@ ${reason}` : "";
|
|
|
6888
6959
|
get emitCtx() {
|
|
6889
6960
|
return {
|
|
6890
6961
|
_searchParamsLocals: this._searchParamsLocals,
|
|
6962
|
+
_loweringMatchers: this._loweringMatchers,
|
|
6891
6963
|
_resolveModuleStringConst: (name) => this._resolveModuleStringConst(name),
|
|
6892
6964
|
_resolveLiteralConst: (name) => this._resolveLiteralConst(name),
|
|
6893
6965
|
_resolveStaticRecordLiteral: (o, k) => this._resolveStaticRecordLiteral(o, k),
|
|
@@ -6921,20 +6993,8 @@ ${reason}` : "";
|
|
|
6921
6993
|
return "''";
|
|
6922
6994
|
parsed = parseExpression(trimmed);
|
|
6923
6995
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
const node = matcher(parsed.callee, parsed.args);
|
|
6927
|
-
if (node?.kind === "guard-list" && node.helper === "query") {
|
|
6928
|
-
const qArgs = queryHrefArgs(node, (n) => this.renderParsedExprToJinja(n));
|
|
6929
|
-
return `bf.query(${qArgs.join(", ")})`;
|
|
6930
|
-
}
|
|
6931
|
-
if (node?.kind === "helper-call" && isValidHelperId(node.helper)) {
|
|
6932
|
-
const argsX = node.args.map((a) => this.renderParsedExprToJinja(a));
|
|
6933
|
-
return `bf.${node.helper}(${argsX.join(", ")})`;
|
|
6934
|
-
}
|
|
6935
|
-
}
|
|
6936
|
-
}
|
|
6937
|
-
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
6996
|
+
const supportOpts = { loweringMatchers: this._loweringMatchers };
|
|
6997
|
+
const support = pos === "value" ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts);
|
|
6938
6998
|
if (!support.supported) {
|
|
6939
6999
|
this.errors.push({
|
|
6940
7000
|
code: "BF101",
|
|
@@ -6979,7 +7039,9 @@ Options:
|
|
|
6979
7039
|
return null;
|
|
6980
7040
|
return {
|
|
6981
7041
|
condition: exprToString(parsed.test),
|
|
6982
|
-
consequent: exprToString(parsed.consequent)
|
|
7042
|
+
consequent: exprToString(parsed.consequent),
|
|
7043
|
+
testParsed: parsed.test,
|
|
7044
|
+
consequentParsed: parsed.consequent
|
|
6983
7045
|
};
|
|
6984
7046
|
}
|
|
6985
7047
|
isBooleanTypedPropRef(expr) {
|