@barefootjs/vite 0.33.6 → 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/index.js +71 -49
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -10,6 +10,38 @@ import ts10 from "typescript";
|
|
|
10
10
|
|
|
11
11
|
// ../jsx/src/expression-parser.ts
|
|
12
12
|
import ts from "typescript";
|
|
13
|
+
|
|
14
|
+
// ../jsx/src/lowering-registry.ts
|
|
15
|
+
var plugins = [];
|
|
16
|
+
function registerLoweringPlugin(plugin) {
|
|
17
|
+
const existing = plugins.findIndex((p) => p.name === plugin.name);
|
|
18
|
+
if (existing >= 0)
|
|
19
|
+
plugins[existing] = plugin;
|
|
20
|
+
else
|
|
21
|
+
plugins.push(plugin);
|
|
22
|
+
}
|
|
23
|
+
function prepareLoweringMatchers(metadata) {
|
|
24
|
+
const matchers = [];
|
|
25
|
+
for (const plugin of plugins) {
|
|
26
|
+
const matcher = plugin.prepare(metadata);
|
|
27
|
+
if (matcher)
|
|
28
|
+
matchers.push(matcher);
|
|
29
|
+
}
|
|
30
|
+
return matchers;
|
|
31
|
+
}
|
|
32
|
+
function loweringNodeChildren(node) {
|
|
33
|
+
if (node.kind === "helper-call")
|
|
34
|
+
return [...node.args];
|
|
35
|
+
const children = [node.base];
|
|
36
|
+
for (const t of node.triples) {
|
|
37
|
+
if (t.guard)
|
|
38
|
+
children.push(t.guard);
|
|
39
|
+
children.push(t.value);
|
|
40
|
+
}
|
|
41
|
+
return children;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ../jsx/src/expression-parser.ts
|
|
13
45
|
var UNSUPPORTED_METHODS = new Set([
|
|
14
46
|
"filter",
|
|
15
47
|
"map",
|
|
@@ -183,7 +215,7 @@ function convertNode(node, raw) {
|
|
|
183
215
|
}
|
|
184
216
|
if (n === undefined || Number.isNaN(n)) {
|
|
185
217
|
const parsedDepth = convertNode(depthNode, raw);
|
|
186
|
-
if (checkSupport(parsedDepth, "rendered").supported) {
|
|
218
|
+
if (checkSupport(parsedDepth, "rendered", []).supported) {
|
|
187
219
|
depthExpr = parsedDepth;
|
|
188
220
|
flatDepth = 1;
|
|
189
221
|
} else {
|
|
@@ -961,13 +993,13 @@ function getUnaryOperatorString(op) {
|
|
|
961
993
|
return "unknown";
|
|
962
994
|
}
|
|
963
995
|
}
|
|
964
|
-
function isSupported(expr) {
|
|
965
|
-
return checkSupport(expr, "rendered");
|
|
996
|
+
function isSupported(expr, opts) {
|
|
997
|
+
return checkSupport(expr, "rendered", opts?.loweringMatchers ?? []);
|
|
966
998
|
}
|
|
967
|
-
function isSupportedValue(expr) {
|
|
968
|
-
return checkSupport(expr, "value");
|
|
999
|
+
function isSupportedValue(expr, opts) {
|
|
1000
|
+
return checkSupport(expr, "value", opts?.loweringMatchers ?? []);
|
|
969
1001
|
}
|
|
970
|
-
function checkSupport(expr, pos) {
|
|
1002
|
+
function checkSupport(expr, pos, matchers) {
|
|
971
1003
|
switch (expr.kind) {
|
|
972
1004
|
case "unsupported":
|
|
973
1005
|
return { supported: false, reason: expr.reason };
|
|
@@ -976,7 +1008,7 @@ function checkSupport(expr, pos) {
|
|
|
976
1008
|
return { supported: false, reason: "Unsupported syntax: ObjectLiteralExpression" };
|
|
977
1009
|
}
|
|
978
1010
|
for (const prop of expr.properties) {
|
|
979
|
-
const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos);
|
|
1011
|
+
const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos, matchers);
|
|
980
1012
|
if (!propSupport.supported)
|
|
981
1013
|
return propSupport;
|
|
982
1014
|
}
|
|
@@ -991,7 +1023,7 @@ function checkSupport(expr, pos) {
|
|
|
991
1023
|
return { supported: false, reason: "Standalone arrow functions / regex literals are not supported" };
|
|
992
1024
|
case "array-literal": {
|
|
993
1025
|
for (const el of expr.elements) {
|
|
994
|
-
const elSupport = checkSupport(el, pos);
|
|
1026
|
+
const elSupport = checkSupport(el, pos, matchers);
|
|
995
1027
|
if (!elSupport.supported)
|
|
996
1028
|
return elSupport;
|
|
997
1029
|
}
|
|
@@ -1004,28 +1036,39 @@ function checkSupport(expr, pos) {
|
|
|
1004
1036
|
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 */`
|
|
1005
1037
|
};
|
|
1006
1038
|
}
|
|
1007
|
-
const objSupport = checkSupport(expr.object, pos);
|
|
1039
|
+
const objSupport = checkSupport(expr.object, pos, matchers);
|
|
1008
1040
|
if (!objSupport.supported)
|
|
1009
1041
|
return objSupport;
|
|
1010
1042
|
for (const arg of expr.args) {
|
|
1011
|
-
const argSupport = checkSupport(arg, pos);
|
|
1043
|
+
const argSupport = checkSupport(arg, pos, matchers);
|
|
1012
1044
|
if (!argSupport.supported)
|
|
1013
1045
|
return argSupport;
|
|
1014
1046
|
}
|
|
1015
1047
|
if (expr.method === "flat" && expr.depthExpr) {
|
|
1016
|
-
const depthSupport = checkSupport(expr.depthExpr, pos);
|
|
1048
|
+
const depthSupport = checkSupport(expr.depthExpr, pos, matchers);
|
|
1017
1049
|
if (!depthSupport.supported)
|
|
1018
1050
|
return depthSupport;
|
|
1019
1051
|
}
|
|
1020
1052
|
return { supported: true, level: "L2" };
|
|
1021
1053
|
}
|
|
1022
1054
|
case "call": {
|
|
1055
|
+
for (const matcher of matchers) {
|
|
1056
|
+
const node = matcher(expr.callee, expr.args);
|
|
1057
|
+
if (!node)
|
|
1058
|
+
continue;
|
|
1059
|
+
for (const child of loweringNodeChildren(node)) {
|
|
1060
|
+
const childSupport = checkSupport(child, pos, matchers);
|
|
1061
|
+
if (!childSupport.supported)
|
|
1062
|
+
return childSupport;
|
|
1063
|
+
}
|
|
1064
|
+
return { supported: true, level: "L2" };
|
|
1065
|
+
}
|
|
1023
1066
|
const cb = asCallbackMethodCall(expr);
|
|
1024
1067
|
if (cb) {
|
|
1025
|
-
const objSupport = checkSupport(cb.object, pos);
|
|
1068
|
+
const objSupport = checkSupport(cb.object, pos, matchers);
|
|
1026
1069
|
if (!objSupport.supported)
|
|
1027
1070
|
return objSupport;
|
|
1028
|
-
const bodySupport = checkSupport(cb.arrow.body, pos);
|
|
1071
|
+
const bodySupport = checkSupport(cb.arrow.body, pos, matchers);
|
|
1029
1072
|
if (!bodySupport.supported) {
|
|
1030
1073
|
return {
|
|
1031
1074
|
supported: false,
|
|
@@ -1034,13 +1077,13 @@ function checkSupport(expr, pos) {
|
|
|
1034
1077
|
};
|
|
1035
1078
|
}
|
|
1036
1079
|
for (const rest of cb.args) {
|
|
1037
|
-
const restSupport = checkSupport(rest, pos);
|
|
1080
|
+
const restSupport = checkSupport(rest, pos, matchers);
|
|
1038
1081
|
if (!restSupport.supported)
|
|
1039
1082
|
return restSupport;
|
|
1040
1083
|
}
|
|
1041
1084
|
return { supported: true, level: "L5" };
|
|
1042
1085
|
}
|
|
1043
|
-
const calleeSupport = checkSupport(expr.callee, pos);
|
|
1086
|
+
const calleeSupport = checkSupport(expr.callee, pos, matchers);
|
|
1044
1087
|
if (!calleeSupport.supported) {
|
|
1045
1088
|
return calleeSupport;
|
|
1046
1089
|
}
|
|
@@ -1059,7 +1102,7 @@ function checkSupport(expr, pos) {
|
|
|
1059
1102
|
return { supported: true, level: "L1" };
|
|
1060
1103
|
}
|
|
1061
1104
|
for (const arg of expr.args) {
|
|
1062
|
-
const argSupport = checkSupport(arg, pos);
|
|
1105
|
+
const argSupport = checkSupport(arg, pos, matchers);
|
|
1063
1106
|
if (!argSupport.supported) {
|
|
1064
1107
|
return argSupport;
|
|
1065
1108
|
}
|
|
@@ -1067,7 +1110,7 @@ function checkSupport(expr, pos) {
|
|
|
1067
1110
|
return { supported: true, level: "L2" };
|
|
1068
1111
|
}
|
|
1069
1112
|
case "member": {
|
|
1070
|
-
const objSupport = checkSupport(expr.object, pos);
|
|
1113
|
+
const objSupport = checkSupport(expr.object, pos, matchers);
|
|
1071
1114
|
if (!objSupport.supported) {
|
|
1072
1115
|
return objSupport;
|
|
1073
1116
|
}
|
|
@@ -1077,19 +1120,19 @@ function checkSupport(expr, pos) {
|
|
|
1077
1120
|
return { supported: true, level: "L2" };
|
|
1078
1121
|
}
|
|
1079
1122
|
case "index-access": {
|
|
1080
|
-
const objSupport = checkSupport(expr.object, pos);
|
|
1123
|
+
const objSupport = checkSupport(expr.object, pos, matchers);
|
|
1081
1124
|
if (!objSupport.supported)
|
|
1082
1125
|
return objSupport;
|
|
1083
|
-
const indexSupport = checkSupport(expr.index, pos);
|
|
1126
|
+
const indexSupport = checkSupport(expr.index, pos, matchers);
|
|
1084
1127
|
if (!indexSupport.supported)
|
|
1085
1128
|
return indexSupport;
|
|
1086
1129
|
return { supported: true, level: "L2" };
|
|
1087
1130
|
}
|
|
1088
1131
|
case "binary": {
|
|
1089
|
-
const leftSupport = checkSupport(expr.left, pos);
|
|
1132
|
+
const leftSupport = checkSupport(expr.left, pos, matchers);
|
|
1090
1133
|
if (!leftSupport.supported)
|
|
1091
1134
|
return leftSupport;
|
|
1092
|
-
const rightSupport = checkSupport(expr.right, pos);
|
|
1135
|
+
const rightSupport = checkSupport(expr.right, pos, matchers);
|
|
1093
1136
|
if (!rightSupport.supported)
|
|
1094
1137
|
return rightSupport;
|
|
1095
1138
|
if (["===", "==", "!==", "!=", ">", "<", ">=", "<="].includes(expr.op)) {
|
|
@@ -1101,7 +1144,7 @@ function checkSupport(expr, pos) {
|
|
|
1101
1144
|
return { supported: false, reason: `Unknown operator: ${expr.op}` };
|
|
1102
1145
|
}
|
|
1103
1146
|
case "unary": {
|
|
1104
|
-
const argSupport = checkSupport(expr.argument, pos);
|
|
1147
|
+
const argSupport = checkSupport(expr.argument, pos, matchers);
|
|
1105
1148
|
if (!argSupport.supported)
|
|
1106
1149
|
return argSupport;
|
|
1107
1150
|
if (expr.op === "!") {
|
|
@@ -1113,25 +1156,25 @@ function checkSupport(expr, pos) {
|
|
|
1113
1156
|
return { supported: false, reason: `Unsupported unary operator: ${expr.op}` };
|
|
1114
1157
|
}
|
|
1115
1158
|
case "logical": {
|
|
1116
|
-
const leftSupport = checkSupport(expr.left, pos);
|
|
1159
|
+
const leftSupport = checkSupport(expr.left, pos, matchers);
|
|
1117
1160
|
if (!leftSupport.supported)
|
|
1118
1161
|
return leftSupport;
|
|
1119
1162
|
if (expr.op === "??" && expr.right.kind === "object-literal" && expr.right.properties.length === 0) {
|
|
1120
1163
|
return { supported: true, level: "L4" };
|
|
1121
1164
|
}
|
|
1122
|
-
const rightSupport = checkSupport(expr.right, pos);
|
|
1165
|
+
const rightSupport = checkSupport(expr.right, pos, matchers);
|
|
1123
1166
|
if (!rightSupport.supported)
|
|
1124
1167
|
return rightSupport;
|
|
1125
1168
|
return { supported: true, level: "L4" };
|
|
1126
1169
|
}
|
|
1127
1170
|
case "conditional": {
|
|
1128
|
-
const testSupport = checkSupport(expr.test, pos);
|
|
1171
|
+
const testSupport = checkSupport(expr.test, pos, matchers);
|
|
1129
1172
|
if (!testSupport.supported)
|
|
1130
1173
|
return testSupport;
|
|
1131
|
-
const consSupport = checkSupport(expr.consequent, pos);
|
|
1174
|
+
const consSupport = checkSupport(expr.consequent, pos, matchers);
|
|
1132
1175
|
if (!consSupport.supported)
|
|
1133
1176
|
return consSupport;
|
|
1134
|
-
const altSupport = checkSupport(expr.alternate, pos);
|
|
1177
|
+
const altSupport = checkSupport(expr.alternate, pos, matchers);
|
|
1135
1178
|
if (!altSupport.supported)
|
|
1136
1179
|
return altSupport;
|
|
1137
1180
|
return { supported: true, level: "L4" };
|
|
@@ -1139,7 +1182,7 @@ function checkSupport(expr, pos) {
|
|
|
1139
1182
|
case "template-literal": {
|
|
1140
1183
|
for (const part of expr.parts) {
|
|
1141
1184
|
if (part.type === "expression") {
|
|
1142
|
-
const partSupport = checkSupport(part.expr, pos);
|
|
1185
|
+
const partSupport = checkSupport(part.expr, pos, matchers);
|
|
1143
1186
|
if (!partSupport.supported)
|
|
1144
1187
|
return partSupport;
|
|
1145
1188
|
}
|
|
@@ -16436,27 +16479,6 @@ function collectComponentNames(node) {
|
|
|
16436
16479
|
|
|
16437
16480
|
// ../jsx/src/relocate.ts
|
|
16438
16481
|
import ts18 from "typescript";
|
|
16439
|
-
|
|
16440
|
-
// ../jsx/src/lowering-registry.ts
|
|
16441
|
-
var plugins = [];
|
|
16442
|
-
function registerLoweringPlugin(plugin) {
|
|
16443
|
-
const existing = plugins.findIndex((p) => p.name === plugin.name);
|
|
16444
|
-
if (existing >= 0)
|
|
16445
|
-
plugins[existing] = plugin;
|
|
16446
|
-
else
|
|
16447
|
-
plugins.push(plugin);
|
|
16448
|
-
}
|
|
16449
|
-
function prepareLoweringMatchers(metadata) {
|
|
16450
|
-
const matchers = [];
|
|
16451
|
-
for (const plugin of plugins) {
|
|
16452
|
-
const matcher = plugin.prepare(metadata);
|
|
16453
|
-
if (matcher)
|
|
16454
|
-
matchers.push(matcher);
|
|
16455
|
-
}
|
|
16456
|
-
return matchers;
|
|
16457
|
-
}
|
|
16458
|
-
|
|
16459
|
-
// ../jsx/src/relocate.ts
|
|
16460
16482
|
function classify(name, env) {
|
|
16461
16483
|
return env.bindings.get(name) ?? "global";
|
|
16462
16484
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.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.34.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.34.0",
|
|
49
|
+
"@barefootjs/go-template": "0.34.0",
|
|
50
|
+
"@barefootjs/hono": "0.34.0",
|
|
51
|
+
"@barefootjs/jsx": "0.34.0",
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vite": "^6.0.0"
|
|
54
54
|
}
|