@torpor/view 0.1.1 → 0.1.3
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/CHANGELOG.md +13 -0
- package/dist/compile.cjs +25 -3
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +25 -3
- package/dist/compile.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +4 -4
- package/src/compile/build/client/buildComponentNode.ts +11 -0
- package/src/compile/build/client/buildIfNode.ts +2 -1
- package/src/compile/build/client/buildReplaceNode.ts +2 -1
- package/src/compile/build/client/buildSwitchNode.ts +2 -1
- package/src/compile/build/server/buildServerComponentNode.ts +11 -0
- package/src/watch/transferEffects.ts +1 -1
- package/test/class/class.test.ts +6 -0
- package/test/class/components/Class.torp +11 -1
- package/test/class/components/output/Class-client.ts +35 -1
- package/test/class/components/output/Class-server.ts +23 -1
- package/test/class/components/temp/{Class-client-dc885e1e391f38973bd9ea25b7475b07f7c23960.ts → Class-client-12f09850a5f8c27de6cf94c23a2b17aadbf66f01.ts} +35 -1
- package/test/class/components/temp/{Class-server-d1a2463ba432e10c6f68bd59d1d31949c5a2044f.ts → Class-server-853a463d2ad1a1e3da4da5ad59ad1c75461d2431.ts} +23 -1
package/dist/compile.js
CHANGED
|
@@ -904,6 +904,17 @@ function buildComponentNode(node, status, b, root = false) {
|
|
|
904
904
|
value = value.substring(1, value.length - 1);
|
|
905
905
|
buildRun("setProp", `${propsName}["${name}"] = ${value};`, status, b);
|
|
906
906
|
buildRun("setBinding", `${value} = ${propsName}["${name}"];`, status, b);
|
|
907
|
+
} else if (name === ":class" && value != null && isFullyReactive(value)) {
|
|
908
|
+
status.imports.add("t_class");
|
|
909
|
+
value = value.substring(1, value.length - 1);
|
|
910
|
+
if (node.scopeStyles) {
|
|
911
|
+
value += `, "torp-${status.styleHash}"`;
|
|
912
|
+
}
|
|
913
|
+
buildRun("setClasses", `${propsName}["class"] = t_class(${value});`, status, b);
|
|
914
|
+
} else if (name === ":style" && value != null && isFullyReactive(value)) {
|
|
915
|
+
status.imports.add("t_style");
|
|
916
|
+
value = value.substring(1, value.length - 1);
|
|
917
|
+
buildRun("setStyles", `${propsName}["style"] = t_style(${value});`, status, b);
|
|
907
918
|
} else if (value != null) {
|
|
908
919
|
let fullyReactive = isFullyReactive(value);
|
|
909
920
|
let partlyReactive = isReactive(value);
|
|
@@ -1224,7 +1235,7 @@ function buildIfNode(node, status, b) {
|
|
|
1224
1235
|
}
|
|
1225
1236
|
function buildIfBranch(node, status, b, parentName, rangeName, index) {
|
|
1226
1237
|
status.imports.add("t_run_branch");
|
|
1227
|
-
b.append(`${node.statement} {`);
|
|
1238
|
+
b.append(`${replaceForVarNames(node.statement, status)} {`);
|
|
1228
1239
|
b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
|
|
1229
1240
|
buildFragment(node, status, b, parentName, "t_before");
|
|
1230
1241
|
status.fragmentStack.push({
|
|
@@ -1259,7 +1270,7 @@ function buildReplaceNode(node, status, b) {
|
|
|
1259
1270
|
}
|
|
1260
1271
|
function buildReplaceBranch(node, status, b, parentName, rangeName) {
|
|
1261
1272
|
status.imports.add("t_run_branch");
|
|
1262
|
-
b.append(`${node.statement};`);
|
|
1273
|
+
b.append(`${replaceForVarNames(node.statement, status)};`);
|
|
1263
1274
|
b.append(`t_run_branch(${rangeName}, -1, () => {`);
|
|
1264
1275
|
buildFragment(node, status, b, parentName, "t_before");
|
|
1265
1276
|
status.fragmentStack.push({
|
|
@@ -1318,7 +1329,7 @@ function buildSwitchNode(node, status, b) {
|
|
|
1318
1329
|
}
|
|
1319
1330
|
function buildSwitchBranch(node, status, b, parentName, rangeName, index) {
|
|
1320
1331
|
status.imports.add("t_run_branch");
|
|
1321
|
-
b.append(`${node.statement} {`);
|
|
1332
|
+
b.append(`${replaceForVarNames(node.statement, status)} {`);
|
|
1322
1333
|
b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
|
|
1323
1334
|
buildFragment(node, status, b, parentName, "t_before");
|
|
1324
1335
|
status.fragmentStack.push({
|
|
@@ -2083,6 +2094,17 @@ function buildServerComponentNode(node, status, b) {
|
|
|
2083
2094
|
name = name.substring(1, name.length - 1);
|
|
2084
2095
|
const propName = name.split(".").at(-1);
|
|
2085
2096
|
b.append(`${propsName}["${propName}"] = ${name};`);
|
|
2097
|
+
} else if (name === ":class" && value != null && isFullyReactive(value)) {
|
|
2098
|
+
status.imports.add("t_class");
|
|
2099
|
+
value = value.substring(1, value.length - 1);
|
|
2100
|
+
if (node.scopeStyles) {
|
|
2101
|
+
value += `, "torp-${status.styleHash}"`;
|
|
2102
|
+
}
|
|
2103
|
+
b.append(`${propsName}["class"] = t_class(${value});`);
|
|
2104
|
+
} else if (name === ":style" && value != null && isFullyReactive(value)) {
|
|
2105
|
+
status.imports.add("t_style");
|
|
2106
|
+
value = value.substring(1, value.length - 1);
|
|
2107
|
+
b.append(`${propsName}["style"] = t_style(${value});`);
|
|
2086
2108
|
} else if (value != null) {
|
|
2087
2109
|
let fullyReactive = isFullyReactive(value);
|
|
2088
2110
|
let partlyReactive = isReactive(value);
|