@torpor/view 0.0.8 → 0.0.10
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 +12 -0
- package/dist/compile.cjs +28 -11
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.d.cts +1 -0
- package/dist/compile.d.ts +1 -0
- package/dist/compile.js +28 -11
- package/dist/compile.js.map +1 -1
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/src/compile/build/client/BuildStatus.ts +1 -0
- package/src/compile/build/client/buildCode.ts +1 -0
- package/src/compile/build/client/buildFragment.ts +1 -1
- package/src/compile/build/client/buildFragmentText.ts +26 -4
- package/src/compile/types/nodes/Fragment.ts +1 -0
- package/src/render/getFragment.ts +13 -3
- package/test/console/components/temp/{Console-client-2f206752ce59e59fba9bb91263b4102fd515951e.ts → Console-client-254d7d4799471401334d698b1631ab1cb5b70558.ts} +1 -1
- package/test/svg/components/Shape.d.ts +18 -0
- package/test/svg/components/Shape.torp +12 -0
- package/test/svg/components/output/Shape-client.ts +61 -0
- package/test/svg/components/output/Shape-server.ts +23 -0
- package/test/svg/components/temp/Shape-client-ea698ed1b7d0c3615adff35fa4956f22840f5fda.ts +61 -0
- package/test/svg/components/temp/Shape-server-eb32049cfb7c058b2c4079c5f86ef00651ff6d69.ts +23 -0
- package/test/svg/svg.test.ts +50 -0
package/CHANGELOG.md
CHANGED
package/dist/compile.cjs
CHANGED
|
@@ -119,7 +119,10 @@ function buildNodeFragmentText(node, status, fragments, currentFragment) {
|
|
|
119
119
|
break;
|
|
120
120
|
}
|
|
121
121
|
case "element": {
|
|
122
|
+
let ns = node.tagName === "svg";
|
|
123
|
+
if (ns) status.ns = true;
|
|
122
124
|
buildElementFragmentText(node, status, fragments, currentFragment);
|
|
125
|
+
if (ns) status.ns = false;
|
|
123
126
|
break;
|
|
124
127
|
}
|
|
125
128
|
case "text": {
|
|
@@ -136,7 +139,7 @@ function buildNodeFragmentText(node, status, fragments, currentFragment) {
|
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
function buildRootFragmentText(node, status, fragments) {
|
|
139
|
-
node.fragment = { number: fragments.length, text: "", events: [], animations: [] };
|
|
142
|
+
node.fragment = { number: fragments.length, text: "", ns: status.ns, events: [], animations: [] };
|
|
140
143
|
fragments.push(node.fragment);
|
|
141
144
|
for (let child of node.children) {
|
|
142
145
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -157,7 +160,13 @@ function buildControlFragmentText(node, status, fragments, currentFragment) {
|
|
|
157
160
|
break;
|
|
158
161
|
}
|
|
159
162
|
default: {
|
|
160
|
-
node.fragment = {
|
|
163
|
+
node.fragment = {
|
|
164
|
+
number: fragments.length,
|
|
165
|
+
text: "",
|
|
166
|
+
ns: status.ns,
|
|
167
|
+
events: [],
|
|
168
|
+
animations: []
|
|
169
|
+
};
|
|
161
170
|
fragments.push(node.fragment);
|
|
162
171
|
for (let child of node.children) {
|
|
163
172
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -169,7 +178,13 @@ function buildControlFragmentText(node, status, fragments, currentFragment) {
|
|
|
169
178
|
function buildComponentFragmentText(node, status, fragments, currentFragment) {
|
|
170
179
|
currentFragment.text += ANCHOR_COMMENT;
|
|
171
180
|
if (node.children.length) {
|
|
172
|
-
node.fragment = {
|
|
181
|
+
node.fragment = {
|
|
182
|
+
number: fragments.length,
|
|
183
|
+
text: "",
|
|
184
|
+
ns: status.ns,
|
|
185
|
+
events: [],
|
|
186
|
+
animations: []
|
|
187
|
+
};
|
|
173
188
|
fragments.push(node.fragment);
|
|
174
189
|
for (let child of node.children) {
|
|
175
190
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -206,7 +221,13 @@ function buildSpecialFragmentText(node, status, fragments, currentFragment) {
|
|
|
206
221
|
break;
|
|
207
222
|
}
|
|
208
223
|
case ":fill": {
|
|
209
|
-
node.fragment = {
|
|
224
|
+
node.fragment = {
|
|
225
|
+
number: fragments.length,
|
|
226
|
+
text: "",
|
|
227
|
+
ns: status.ns,
|
|
228
|
+
events: [],
|
|
229
|
+
animations: []
|
|
230
|
+
};
|
|
210
231
|
fragments.push(node.fragment);
|
|
211
232
|
for (let child of node.children) {
|
|
212
233
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -363,7 +384,7 @@ function buildFragment(node, status, b, parentName, anchorName) {
|
|
|
363
384
|
status.imports.add("t_fragment");
|
|
364
385
|
const fragmentText = fragment.text.replaceAll("`", "\\`").replaceAll(/\s+/g, " ");
|
|
365
386
|
b.append(
|
|
366
|
-
`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \`${fragmentText}
|
|
387
|
+
`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \`${fragmentText}\`${fragment.ns ? ", true" : ""});`
|
|
367
388
|
);
|
|
368
389
|
let fragmentPath = { parent: null, type: "fragment", children: [] };
|
|
369
390
|
let varPaths = /* @__PURE__ */ new Map();
|
|
@@ -1710,12 +1731,7 @@ function buildSlotNode(node, status, b) {
|
|
|
1710
1731
|
const slotParentName = node.parentName;
|
|
1711
1732
|
const slotAnchorName = node.varName;
|
|
1712
1733
|
b.append(`if ($slots && $slots["${slotName}"]) {`);
|
|
1713
|
-
let params = [
|
|
1714
|
-
slotParentName,
|
|
1715
|
-
slotAnchorName,
|
|
1716
|
-
slotHasProps ? propsName : "undefined",
|
|
1717
|
-
status.contextProps.length ? "$context" : "undefined"
|
|
1718
|
-
];
|
|
1734
|
+
let params = [slotParentName, slotAnchorName, slotHasProps ? propsName : "undefined", "$context"];
|
|
1719
1735
|
b.append(`$slots["${slotName}"](${params.join(", ")})`);
|
|
1720
1736
|
const fill = node.children.find((c) => isSpecialNode(c) && c.tagName === ":fill");
|
|
1721
1737
|
if (fill && isSpecialNode(fill) && fill.children.length) {
|
|
@@ -1971,6 +1987,7 @@ function buildTemplate(template, imports, b) {
|
|
|
1971
1987
|
varNames: {},
|
|
1972
1988
|
fragmentStack: [],
|
|
1973
1989
|
forVarNames: [],
|
|
1990
|
+
ns: false,
|
|
1974
1991
|
preserveWhitespace: false
|
|
1975
1992
|
};
|
|
1976
1993
|
b.append("");
|