@barefootjs/vite 0.32.0 → 0.33.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/index.js +84 -37
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -183,7 +183,7 @@ function convertNode(node, raw) {
|
|
|
183
183
|
}
|
|
184
184
|
if (n === undefined || Number.isNaN(n)) {
|
|
185
185
|
const parsedDepth = convertNode(depthNode, raw);
|
|
186
|
-
if (checkSupport(parsedDepth).supported) {
|
|
186
|
+
if (checkSupport(parsedDepth, "rendered").supported) {
|
|
187
187
|
depthExpr = parsedDepth;
|
|
188
188
|
flatDepth = 1;
|
|
189
189
|
} else {
|
|
@@ -277,10 +277,12 @@ function convertNode(node, raw) {
|
|
|
277
277
|
const k = objectLiteralKeyName(prop.name);
|
|
278
278
|
if (k === null)
|
|
279
279
|
return { kind: "unsupported", raw, reason: `Unsupported syntax: ${ts.SyntaxKind[node.kind]}` };
|
|
280
|
-
properties.push({ key: k.key, keyKind: k.keyKind, shorthand: false, value: convertNode(prop.initializer, raw) });
|
|
280
|
+
properties.push({ kind: "prop", key: k.key, keyKind: k.keyKind, shorthand: false, value: convertNode(prop.initializer, raw) });
|
|
281
281
|
} else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
282
282
|
const key = prop.name.text;
|
|
283
|
-
properties.push({ key, keyKind: "identifier", shorthand: true, value: { kind: "identifier", name: key } });
|
|
283
|
+
properties.push({ kind: "prop", key, keyKind: "identifier", shorthand: true, value: { kind: "identifier", name: key } });
|
|
284
|
+
} else if (ts.isSpreadAssignment(prop)) {
|
|
285
|
+
properties.push({ kind: "spread", expr: convertNode(prop.expression, raw) });
|
|
284
286
|
} else {
|
|
285
287
|
return { kind: "unsupported", raw, reason: `Unsupported syntax: ${ts.SyntaxKind[node.kind]}` };
|
|
286
288
|
}
|
|
@@ -960,14 +962,26 @@ function getUnaryOperatorString(op) {
|
|
|
960
962
|
}
|
|
961
963
|
}
|
|
962
964
|
function isSupported(expr) {
|
|
963
|
-
return checkSupport(expr);
|
|
965
|
+
return checkSupport(expr, "rendered");
|
|
964
966
|
}
|
|
965
|
-
function
|
|
967
|
+
function isSupportedValue(expr) {
|
|
968
|
+
return checkSupport(expr, "value");
|
|
969
|
+
}
|
|
970
|
+
function checkSupport(expr, pos) {
|
|
966
971
|
switch (expr.kind) {
|
|
967
972
|
case "unsupported":
|
|
968
973
|
return { supported: false, reason: expr.reason };
|
|
969
|
-
case "object-literal":
|
|
970
|
-
|
|
974
|
+
case "object-literal": {
|
|
975
|
+
if (pos !== "value") {
|
|
976
|
+
return { supported: false, reason: "Unsupported syntax: ObjectLiteralExpression" };
|
|
977
|
+
}
|
|
978
|
+
for (const prop of expr.properties) {
|
|
979
|
+
const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos);
|
|
980
|
+
if (!propSupport.supported)
|
|
981
|
+
return propSupport;
|
|
982
|
+
}
|
|
983
|
+
return { supported: true, level: "L2" };
|
|
984
|
+
}
|
|
971
985
|
case "identifier":
|
|
972
986
|
return { supported: true, level: "L1" };
|
|
973
987
|
case "literal":
|
|
@@ -977,7 +991,7 @@ function checkSupport(expr) {
|
|
|
977
991
|
return { supported: false, reason: "Standalone arrow functions / regex literals are not supported" };
|
|
978
992
|
case "array-literal": {
|
|
979
993
|
for (const el of expr.elements) {
|
|
980
|
-
const elSupport = checkSupport(el);
|
|
994
|
+
const elSupport = checkSupport(el, pos);
|
|
981
995
|
if (!elSupport.supported)
|
|
982
996
|
return elSupport;
|
|
983
997
|
}
|
|
@@ -990,16 +1004,16 @@ function checkSupport(expr) {
|
|
|
990
1004
|
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 */`
|
|
991
1005
|
};
|
|
992
1006
|
}
|
|
993
|
-
const objSupport = checkSupport(expr.object);
|
|
1007
|
+
const objSupport = checkSupport(expr.object, pos);
|
|
994
1008
|
if (!objSupport.supported)
|
|
995
1009
|
return objSupport;
|
|
996
1010
|
for (const arg of expr.args) {
|
|
997
|
-
const argSupport = checkSupport(arg);
|
|
1011
|
+
const argSupport = checkSupport(arg, pos);
|
|
998
1012
|
if (!argSupport.supported)
|
|
999
1013
|
return argSupport;
|
|
1000
1014
|
}
|
|
1001
1015
|
if (expr.method === "flat" && expr.depthExpr) {
|
|
1002
|
-
const depthSupport = checkSupport(expr.depthExpr);
|
|
1016
|
+
const depthSupport = checkSupport(expr.depthExpr, pos);
|
|
1003
1017
|
if (!depthSupport.supported)
|
|
1004
1018
|
return depthSupport;
|
|
1005
1019
|
}
|
|
@@ -1008,10 +1022,10 @@ function checkSupport(expr) {
|
|
|
1008
1022
|
case "call": {
|
|
1009
1023
|
const cb = asCallbackMethodCall(expr);
|
|
1010
1024
|
if (cb) {
|
|
1011
|
-
const objSupport = checkSupport(cb.object);
|
|
1025
|
+
const objSupport = checkSupport(cb.object, pos);
|
|
1012
1026
|
if (!objSupport.supported)
|
|
1013
1027
|
return objSupport;
|
|
1014
|
-
const bodySupport = checkSupport(cb.arrow.body);
|
|
1028
|
+
const bodySupport = checkSupport(cb.arrow.body, pos);
|
|
1015
1029
|
if (!bodySupport.supported) {
|
|
1016
1030
|
return {
|
|
1017
1031
|
supported: false,
|
|
@@ -1020,13 +1034,13 @@ function checkSupport(expr) {
|
|
|
1020
1034
|
};
|
|
1021
1035
|
}
|
|
1022
1036
|
for (const rest of cb.args) {
|
|
1023
|
-
const restSupport = checkSupport(rest);
|
|
1037
|
+
const restSupport = checkSupport(rest, pos);
|
|
1024
1038
|
if (!restSupport.supported)
|
|
1025
1039
|
return restSupport;
|
|
1026
1040
|
}
|
|
1027
1041
|
return { supported: true, level: "L5" };
|
|
1028
1042
|
}
|
|
1029
|
-
const calleeSupport = checkSupport(expr.callee);
|
|
1043
|
+
const calleeSupport = checkSupport(expr.callee, pos);
|
|
1030
1044
|
if (!calleeSupport.supported) {
|
|
1031
1045
|
return calleeSupport;
|
|
1032
1046
|
}
|
|
@@ -1045,7 +1059,7 @@ function checkSupport(expr) {
|
|
|
1045
1059
|
return { supported: true, level: "L1" };
|
|
1046
1060
|
}
|
|
1047
1061
|
for (const arg of expr.args) {
|
|
1048
|
-
const argSupport = checkSupport(arg);
|
|
1062
|
+
const argSupport = checkSupport(arg, pos);
|
|
1049
1063
|
if (!argSupport.supported) {
|
|
1050
1064
|
return argSupport;
|
|
1051
1065
|
}
|
|
@@ -1053,7 +1067,7 @@ function checkSupport(expr) {
|
|
|
1053
1067
|
return { supported: true, level: "L2" };
|
|
1054
1068
|
}
|
|
1055
1069
|
case "member": {
|
|
1056
|
-
const objSupport = checkSupport(expr.object);
|
|
1070
|
+
const objSupport = checkSupport(expr.object, pos);
|
|
1057
1071
|
if (!objSupport.supported) {
|
|
1058
1072
|
return objSupport;
|
|
1059
1073
|
}
|
|
@@ -1063,19 +1077,19 @@ function checkSupport(expr) {
|
|
|
1063
1077
|
return { supported: true, level: "L2" };
|
|
1064
1078
|
}
|
|
1065
1079
|
case "index-access": {
|
|
1066
|
-
const objSupport = checkSupport(expr.object);
|
|
1080
|
+
const objSupport = checkSupport(expr.object, pos);
|
|
1067
1081
|
if (!objSupport.supported)
|
|
1068
1082
|
return objSupport;
|
|
1069
|
-
const indexSupport = checkSupport(expr.index);
|
|
1083
|
+
const indexSupport = checkSupport(expr.index, pos);
|
|
1070
1084
|
if (!indexSupport.supported)
|
|
1071
1085
|
return indexSupport;
|
|
1072
1086
|
return { supported: true, level: "L2" };
|
|
1073
1087
|
}
|
|
1074
1088
|
case "binary": {
|
|
1075
|
-
const leftSupport = checkSupport(expr.left);
|
|
1089
|
+
const leftSupport = checkSupport(expr.left, pos);
|
|
1076
1090
|
if (!leftSupport.supported)
|
|
1077
1091
|
return leftSupport;
|
|
1078
|
-
const rightSupport = checkSupport(expr.right);
|
|
1092
|
+
const rightSupport = checkSupport(expr.right, pos);
|
|
1079
1093
|
if (!rightSupport.supported)
|
|
1080
1094
|
return rightSupport;
|
|
1081
1095
|
if (["===", "==", "!==", "!=", ">", "<", ">=", "<="].includes(expr.op)) {
|
|
@@ -1087,7 +1101,7 @@ function checkSupport(expr) {
|
|
|
1087
1101
|
return { supported: false, reason: `Unknown operator: ${expr.op}` };
|
|
1088
1102
|
}
|
|
1089
1103
|
case "unary": {
|
|
1090
|
-
const argSupport = checkSupport(expr.argument);
|
|
1104
|
+
const argSupport = checkSupport(expr.argument, pos);
|
|
1091
1105
|
if (!argSupport.supported)
|
|
1092
1106
|
return argSupport;
|
|
1093
1107
|
if (expr.op === "!") {
|
|
@@ -1099,25 +1113,25 @@ function checkSupport(expr) {
|
|
|
1099
1113
|
return { supported: false, reason: `Unsupported unary operator: ${expr.op}` };
|
|
1100
1114
|
}
|
|
1101
1115
|
case "logical": {
|
|
1102
|
-
const leftSupport = checkSupport(expr.left);
|
|
1116
|
+
const leftSupport = checkSupport(expr.left, pos);
|
|
1103
1117
|
if (!leftSupport.supported)
|
|
1104
1118
|
return leftSupport;
|
|
1105
1119
|
if (expr.op === "??" && expr.right.kind === "object-literal" && expr.right.properties.length === 0) {
|
|
1106
1120
|
return { supported: true, level: "L4" };
|
|
1107
1121
|
}
|
|
1108
|
-
const rightSupport = checkSupport(expr.right);
|
|
1122
|
+
const rightSupport = checkSupport(expr.right, pos);
|
|
1109
1123
|
if (!rightSupport.supported)
|
|
1110
1124
|
return rightSupport;
|
|
1111
1125
|
return { supported: true, level: "L4" };
|
|
1112
1126
|
}
|
|
1113
1127
|
case "conditional": {
|
|
1114
|
-
const testSupport = checkSupport(expr.test);
|
|
1128
|
+
const testSupport = checkSupport(expr.test, pos);
|
|
1115
1129
|
if (!testSupport.supported)
|
|
1116
1130
|
return testSupport;
|
|
1117
|
-
const consSupport = checkSupport(expr.consequent);
|
|
1131
|
+
const consSupport = checkSupport(expr.consequent, pos);
|
|
1118
1132
|
if (!consSupport.supported)
|
|
1119
1133
|
return consSupport;
|
|
1120
|
-
const altSupport = checkSupport(expr.alternate);
|
|
1134
|
+
const altSupport = checkSupport(expr.alternate, pos);
|
|
1121
1135
|
if (!altSupport.supported)
|
|
1122
1136
|
return altSupport;
|
|
1123
1137
|
return { supported: true, level: "L4" };
|
|
@@ -1125,7 +1139,7 @@ function checkSupport(expr) {
|
|
|
1125
1139
|
case "template-literal": {
|
|
1126
1140
|
for (const part of expr.parts) {
|
|
1127
1141
|
if (part.type === "expression") {
|
|
1128
|
-
const partSupport = checkSupport(part.expr);
|
|
1142
|
+
const partSupport = checkSupport(part.expr, pos);
|
|
1129
1143
|
if (!partSupport.supported)
|
|
1130
1144
|
return partSupport;
|
|
1131
1145
|
}
|
|
@@ -1250,7 +1264,7 @@ function isPureInit(e, pureCallNames) {
|
|
|
1250
1264
|
case "array-literal":
|
|
1251
1265
|
return e.elements.every(pure);
|
|
1252
1266
|
case "object-literal":
|
|
1253
|
-
return e.properties.every((p) => pure(p.value));
|
|
1267
|
+
return e.properties.every((p) => pure(p.kind === "spread" ? p.expr : p.value));
|
|
1254
1268
|
case "call":
|
|
1255
1269
|
return e.callee.kind === "identifier" && e.args.length === 0 && pureCallNames !== undefined && pureCallNames.has(e.callee.name);
|
|
1256
1270
|
case "array-method":
|
|
@@ -1304,7 +1318,7 @@ function usesPerPath(name, expr) {
|
|
|
1304
1318
|
}
|
|
1305
1319
|
return add(walk(e.object), sum(e.args));
|
|
1306
1320
|
case "object-literal":
|
|
1307
|
-
return sum(e.properties.map((p) => p.value));
|
|
1321
|
+
return sum(e.properties.map((p) => p.kind === "spread" ? p.expr : p.value));
|
|
1308
1322
|
case "arrow":
|
|
1309
1323
|
return walk(e.body).max > 0 ? { min: 0, max: Number.POSITIVE_INFINITY } : { min: 0, max: 0 };
|
|
1310
1324
|
}
|
|
@@ -1370,7 +1384,7 @@ function inlineBinding(expr, name, value) {
|
|
|
1370
1384
|
case "object-literal":
|
|
1371
1385
|
return {
|
|
1372
1386
|
kind: "object-literal",
|
|
1373
|
-
properties: e.properties.map((p) => ({ ...p, value: walk(p.value, enclosing) })
|
|
1387
|
+
properties: e.properties.map((p) => p.kind === "spread" ? { ...p, expr: walk(p.expr, enclosing) } : { ...p, value: walk(p.value, enclosing) }),
|
|
1374
1388
|
raw: e.raw
|
|
1375
1389
|
};
|
|
1376
1390
|
case "literal":
|
|
@@ -1566,7 +1580,7 @@ function freeIdentifiers(expr) {
|
|
|
1566
1580
|
return true;
|
|
1567
1581
|
case "object-literal":
|
|
1568
1582
|
for (const p of e.properties)
|
|
1569
|
-
if (!visit(p.value, bound))
|
|
1583
|
+
if (!visit(p.kind === "spread" ? p.expr : p.value, bound))
|
|
1570
1584
|
return false;
|
|
1571
1585
|
return true;
|
|
1572
1586
|
case "arrow": {
|
|
@@ -9518,6 +9532,8 @@ function matchToLocaleDateStringCall(callee, args, metadata) {
|
|
|
9518
9532
|
let tz = null;
|
|
9519
9533
|
const probeOptions = {};
|
|
9520
9534
|
for (const prop of options.properties) {
|
|
9535
|
+
if (prop.kind === "spread")
|
|
9536
|
+
return null;
|
|
9521
9537
|
if (prop.value.kind !== "literal" || prop.value.literalType !== "string")
|
|
9522
9538
|
return null;
|
|
9523
9539
|
const value = String(prop.value.value);
|
|
@@ -11282,7 +11298,10 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
|
|
|
11282
11298
|
...e.method === "flat" && e.depthExpr ? { depthExpr: visit2(e.depthExpr, bound2) } : {}
|
|
11283
11299
|
};
|
|
11284
11300
|
case "object-literal":
|
|
11285
|
-
return {
|
|
11301
|
+
return {
|
|
11302
|
+
...e,
|
|
11303
|
+
properties: e.properties.map((p) => p.kind === "spread" ? { ...p, expr: visit2(p.expr, bound2) } : { ...p, value: visit2(p.value, bound2) })
|
|
11304
|
+
};
|
|
11286
11305
|
case "arrow": {
|
|
11287
11306
|
const inner = e.params.length === 0 ? bound2 : new Set([...bound2, ...e.params]);
|
|
11288
11307
|
return { ...e, body: visit2(e.body, inner) };
|
|
@@ -22819,12 +22838,38 @@ function evalNode(node, ctx) {
|
|
|
22819
22838
|
const baseResult = evalNode(node.expression, ctx);
|
|
22820
22839
|
if (baseResult === undefined)
|
|
22821
22840
|
return;
|
|
22822
|
-
|
|
22841
|
+
if (baseResult === UNRESOLVED || baseResult === null || typeof baseResult !== "object") {
|
|
22842
|
+
return UNRESOLVED;
|
|
22843
|
+
}
|
|
22844
|
+
const proto = Object.getPrototypeOf(baseResult);
|
|
22845
|
+
if (proto !== Object.prototype && proto !== null)
|
|
22846
|
+
return UNRESOLVED;
|
|
22847
|
+
const key = node.name.text;
|
|
22848
|
+
return Object.prototype.hasOwnProperty.call(baseResult, key) ? baseResult[key] : undefined;
|
|
22823
22849
|
}
|
|
22824
22850
|
if (ts22.isCallExpression(node)) {
|
|
22825
22851
|
if (node.arguments.length === 0 && ts22.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
|
|
22826
22852
|
return ctx.bindings[node.expression.text];
|
|
22827
22853
|
}
|
|
22854
|
+
if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map" && node.arguments.length === 1) {
|
|
22855
|
+
const arrow = node.arguments[0];
|
|
22856
|
+
if (ts22.isArrowFunction(arrow) && arrow.parameters.length === 1 && ts22.isIdentifier(arrow.parameters[0].name) && !ts22.isBlock(arrow.body)) {
|
|
22857
|
+
const recv = evalNode(node.expression.expression, ctx);
|
|
22858
|
+
if (Array.isArray(recv)) {
|
|
22859
|
+
const paramName = arrow.parameters[0].name.text;
|
|
22860
|
+
const mapped = [];
|
|
22861
|
+
for (const item of recv) {
|
|
22862
|
+
const localBindings = { ...ctx.bindings, [paramName]: item };
|
|
22863
|
+
const v = evalNode(arrow.body, { ...ctx, bindings: localBindings });
|
|
22864
|
+
if (v === UNRESOLVED)
|
|
22865
|
+
return UNRESOLVED;
|
|
22866
|
+
mapped.push(v === undefined ? null : v);
|
|
22867
|
+
}
|
|
22868
|
+
return mapped;
|
|
22869
|
+
}
|
|
22870
|
+
}
|
|
22871
|
+
return UNRESOLVED;
|
|
22872
|
+
}
|
|
22828
22873
|
if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
|
|
22829
22874
|
const recv = evalNode(node.expression.expression, ctx);
|
|
22830
22875
|
if (Array.isArray(recv)) {
|
|
@@ -23011,7 +23056,7 @@ function evalStringArrayJoin(source) {
|
|
|
23011
23056
|
|
|
23012
23057
|
// ../jsx/src/ssr-seed-plan.ts
|
|
23013
23058
|
function classify2(name, origin, expr, parsed, available) {
|
|
23014
|
-
if (!
|
|
23059
|
+
if (!isSupportedValue(parsed).supported)
|
|
23015
23060
|
return { kind: "opaque", name, origin };
|
|
23016
23061
|
const frees = freeIdentifiers(parsed);
|
|
23017
23062
|
if (frees === null)
|
|
@@ -23074,7 +23119,7 @@ function computeSsrSeedPlan(metadata) {
|
|
|
23074
23119
|
}
|
|
23075
23120
|
}
|
|
23076
23121
|
const expr = signal.initialValue.trim();
|
|
23077
|
-
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify2(signal.getter, "signal", expr, resolveThroughLocalConsts(parseExpression(expr), localConsts), available));
|
|
23122
|
+
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify2(signal.getter, "signal", expr, resolveThroughLocalConsts(signal.parsed ?? parseExpression(`(${expr})`), localConsts), available));
|
|
23078
23123
|
available.add(signal.getter);
|
|
23079
23124
|
}
|
|
23080
23125
|
for (const memo of metadata.memos) {
|
|
@@ -23238,7 +23283,7 @@ function checkExpr(expr, loc, meta, bindings, matchers, errors, seen) {
|
|
|
23238
23283
|
break;
|
|
23239
23284
|
case "object-literal":
|
|
23240
23285
|
for (const prop of expr.properties)
|
|
23241
|
-
recurse(prop.value);
|
|
23286
|
+
recurse(prop.kind === "spread" ? prop.expr : prop.value);
|
|
23242
23287
|
break;
|
|
23243
23288
|
case "array-method":
|
|
23244
23289
|
recurse(expr.object);
|
|
@@ -24569,6 +24614,8 @@ function matchQueryHrefCall(callee, args, localNames) {
|
|
|
24569
24614
|
return null;
|
|
24570
24615
|
const triples = [];
|
|
24571
24616
|
for (const p of obj.properties) {
|
|
24617
|
+
if (p.kind === "spread")
|
|
24618
|
+
return null;
|
|
24572
24619
|
const v = p.value;
|
|
24573
24620
|
if (v.kind === "conditional" && isOmitBranch(v.alternate)) {
|
|
24574
24621
|
triples.push({ guard: v.test, key: p.key, value: v.consequent });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Vite plugin for BarefootJS: Vite/Rollup owns bundling, hashing, chunking, tree-shaking and minification of client assets, BarefootJS keeps only the JSX to (template, client JS) compile",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"directory": "packages/vite"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@barefootjs/shared": "0.
|
|
41
|
+
"@barefootjs/shared": "0.33.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@barefootjs/jsx": ">=0.2.0",
|
|
45
45
|
"vite": "^6.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@barefootjs/client": "0.
|
|
49
|
-
"@barefootjs/go-template": "0.
|
|
50
|
-
"@barefootjs/hono": "0.
|
|
51
|
-
"@barefootjs/jsx": "0.
|
|
48
|
+
"@barefootjs/client": "0.33.0",
|
|
49
|
+
"@barefootjs/go-template": "0.33.0",
|
|
50
|
+
"@barefootjs/hono": "0.33.0",
|
|
51
|
+
"@barefootjs/jsx": "0.33.0",
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vite": "^6.0.0"
|
|
54
54
|
}
|