@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @torpor/view
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- de51225: Fix: passing `:class` and `:style` to components
|
|
8
|
+
|
|
9
|
+
## 0.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0e69292: Fix: null check
|
|
14
|
+
- b69fde1: Fix: replace for var names in control statements
|
|
15
|
+
|
|
3
16
|
## 0.1.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/compile.cjs
CHANGED
|
@@ -930,6 +930,17 @@ function buildComponentNode(node, status, b, root = false) {
|
|
|
930
930
|
value = value.substring(1, value.length - 1);
|
|
931
931
|
buildRun("setProp", `${propsName}["${name}"] = ${value};`, status, b);
|
|
932
932
|
buildRun("setBinding", `${value} = ${propsName}["${name}"];`, status, b);
|
|
933
|
+
} else if (name === ":class" && value != null && isFullyReactive(value)) {
|
|
934
|
+
status.imports.add("t_class");
|
|
935
|
+
value = value.substring(1, value.length - 1);
|
|
936
|
+
if (node.scopeStyles) {
|
|
937
|
+
value += `, "torp-${status.styleHash}"`;
|
|
938
|
+
}
|
|
939
|
+
buildRun("setClasses", `${propsName}["class"] = t_class(${value});`, status, b);
|
|
940
|
+
} else if (name === ":style" && value != null && isFullyReactive(value)) {
|
|
941
|
+
status.imports.add("t_style");
|
|
942
|
+
value = value.substring(1, value.length - 1);
|
|
943
|
+
buildRun("setStyles", `${propsName}["style"] = t_style(${value});`, status, b);
|
|
933
944
|
} else if (value != null) {
|
|
934
945
|
let fullyReactive = isFullyReactive(value);
|
|
935
946
|
let partlyReactive = isReactive(value);
|
|
@@ -1250,7 +1261,7 @@ function buildIfNode(node, status, b) {
|
|
|
1250
1261
|
}
|
|
1251
1262
|
function buildIfBranch(node, status, b, parentName, rangeName, index) {
|
|
1252
1263
|
status.imports.add("t_run_branch");
|
|
1253
|
-
b.append(`${node.statement} {`);
|
|
1264
|
+
b.append(`${replaceForVarNames(node.statement, status)} {`);
|
|
1254
1265
|
b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
|
|
1255
1266
|
buildFragment(node, status, b, parentName, "t_before");
|
|
1256
1267
|
status.fragmentStack.push({
|
|
@@ -1285,7 +1296,7 @@ function buildReplaceNode(node, status, b) {
|
|
|
1285
1296
|
}
|
|
1286
1297
|
function buildReplaceBranch(node, status, b, parentName, rangeName) {
|
|
1287
1298
|
status.imports.add("t_run_branch");
|
|
1288
|
-
b.append(`${node.statement};`);
|
|
1299
|
+
b.append(`${replaceForVarNames(node.statement, status)};`);
|
|
1289
1300
|
b.append(`t_run_branch(${rangeName}, -1, () => {`);
|
|
1290
1301
|
buildFragment(node, status, b, parentName, "t_before");
|
|
1291
1302
|
status.fragmentStack.push({
|
|
@@ -1344,7 +1355,7 @@ function buildSwitchNode(node, status, b) {
|
|
|
1344
1355
|
}
|
|
1345
1356
|
function buildSwitchBranch(node, status, b, parentName, rangeName, index) {
|
|
1346
1357
|
status.imports.add("t_run_branch");
|
|
1347
|
-
b.append(`${node.statement} {`);
|
|
1358
|
+
b.append(`${replaceForVarNames(node.statement, status)} {`);
|
|
1348
1359
|
b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
|
|
1349
1360
|
buildFragment(node, status, b, parentName, "t_before");
|
|
1350
1361
|
status.fragmentStack.push({
|
|
@@ -2109,6 +2120,17 @@ function buildServerComponentNode(node, status, b) {
|
|
|
2109
2120
|
name = name.substring(1, name.length - 1);
|
|
2110
2121
|
const propName = name.split(".").at(-1);
|
|
2111
2122
|
b.append(`${propsName}["${propName}"] = ${name};`);
|
|
2123
|
+
} else if (name === ":class" && value != null && isFullyReactive(value)) {
|
|
2124
|
+
status.imports.add("t_class");
|
|
2125
|
+
value = value.substring(1, value.length - 1);
|
|
2126
|
+
if (node.scopeStyles) {
|
|
2127
|
+
value += `, "torp-${status.styleHash}"`;
|
|
2128
|
+
}
|
|
2129
|
+
b.append(`${propsName}["class"] = t_class(${value});`);
|
|
2130
|
+
} else if (name === ":style" && value != null && isFullyReactive(value)) {
|
|
2131
|
+
status.imports.add("t_style");
|
|
2132
|
+
value = value.substring(1, value.length - 1);
|
|
2133
|
+
b.append(`${propsName}["style"] = t_style(${value});`);
|
|
2112
2134
|
} else if (value != null) {
|
|
2113
2135
|
let fullyReactive = isFullyReactive(value);
|
|
2114
2136
|
let partlyReactive = isReactive(value);
|