@torpor/view 0.0.9 → 0.0.11
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 -6
- 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 -6
- 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 +3 -3
- 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/build/client/buildHtmlNode.ts +1 -5
- 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/dist/compile.d.cts
CHANGED
package/dist/compile.d.ts
CHANGED
package/dist/compile.js
CHANGED
|
@@ -93,7 +93,10 @@ function buildNodeFragmentText(node, status, fragments, currentFragment) {
|
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
case "element": {
|
|
96
|
+
let ns = node.tagName === "svg";
|
|
97
|
+
if (ns) status.ns = true;
|
|
96
98
|
buildElementFragmentText(node, status, fragments, currentFragment);
|
|
99
|
+
if (ns) status.ns = false;
|
|
97
100
|
break;
|
|
98
101
|
}
|
|
99
102
|
case "text": {
|
|
@@ -110,7 +113,7 @@ function buildNodeFragmentText(node, status, fragments, currentFragment) {
|
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
function buildRootFragmentText(node, status, fragments) {
|
|
113
|
-
node.fragment = { number: fragments.length, text: "", events: [], animations: [] };
|
|
116
|
+
node.fragment = { number: fragments.length, text: "", ns: status.ns, events: [], animations: [] };
|
|
114
117
|
fragments.push(node.fragment);
|
|
115
118
|
for (let child of node.children) {
|
|
116
119
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -131,7 +134,13 @@ function buildControlFragmentText(node, status, fragments, currentFragment) {
|
|
|
131
134
|
break;
|
|
132
135
|
}
|
|
133
136
|
default: {
|
|
134
|
-
node.fragment = {
|
|
137
|
+
node.fragment = {
|
|
138
|
+
number: fragments.length,
|
|
139
|
+
text: "",
|
|
140
|
+
ns: status.ns,
|
|
141
|
+
events: [],
|
|
142
|
+
animations: []
|
|
143
|
+
};
|
|
135
144
|
fragments.push(node.fragment);
|
|
136
145
|
for (let child of node.children) {
|
|
137
146
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -143,7 +152,13 @@ function buildControlFragmentText(node, status, fragments, currentFragment) {
|
|
|
143
152
|
function buildComponentFragmentText(node, status, fragments, currentFragment) {
|
|
144
153
|
currentFragment.text += ANCHOR_COMMENT;
|
|
145
154
|
if (node.children.length) {
|
|
146
|
-
node.fragment = {
|
|
155
|
+
node.fragment = {
|
|
156
|
+
number: fragments.length,
|
|
157
|
+
text: "",
|
|
158
|
+
ns: status.ns,
|
|
159
|
+
events: [],
|
|
160
|
+
animations: []
|
|
161
|
+
};
|
|
147
162
|
fragments.push(node.fragment);
|
|
148
163
|
for (let child of node.children) {
|
|
149
164
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -180,7 +195,13 @@ function buildSpecialFragmentText(node, status, fragments, currentFragment) {
|
|
|
180
195
|
break;
|
|
181
196
|
}
|
|
182
197
|
case ":fill": {
|
|
183
|
-
node.fragment = {
|
|
198
|
+
node.fragment = {
|
|
199
|
+
number: fragments.length,
|
|
200
|
+
text: "",
|
|
201
|
+
ns: status.ns,
|
|
202
|
+
events: [],
|
|
203
|
+
animations: []
|
|
204
|
+
};
|
|
184
205
|
fragments.push(node.fragment);
|
|
185
206
|
for (let child of node.children) {
|
|
186
207
|
buildNodeFragmentText(child, status, fragments, node.fragment);
|
|
@@ -337,7 +358,7 @@ function buildFragment(node, status, b, parentName, anchorName) {
|
|
|
337
358
|
status.imports.add("t_fragment");
|
|
338
359
|
const fragmentText = fragment.text.replaceAll("`", "\\`").replaceAll(/\s+/g, " ");
|
|
339
360
|
b.append(
|
|
340
|
-
`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \`${fragmentText}
|
|
361
|
+
`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \`${fragmentText}\`${fragment.ns ? ", true" : ""});`
|
|
341
362
|
);
|
|
342
363
|
let fragmentPath = { parent: null, type: "fragment", children: [] };
|
|
343
364
|
let varPaths = /* @__PURE__ */ new Map();
|
|
@@ -1126,7 +1147,7 @@ function buildHtmlBranch(node, status, b, parentName, rangeName) {
|
|
|
1126
1147
|
status.imports.add("t_run_branch");
|
|
1127
1148
|
b.append(`t_run_branch(${rangeName}, -1, () => {`);
|
|
1128
1149
|
const templateName = nextVarName("template", status);
|
|
1129
|
-
const fragmentName =
|
|
1150
|
+
const fragmentName = `t_fragment_${node.fragment.number}`;
|
|
1130
1151
|
b.append(`const ${templateName} = document.createElement("template");`);
|
|
1131
1152
|
b.append(`${templateName}.innerHTML = ${node.statement};`);
|
|
1132
1153
|
b.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);
|
|
@@ -1940,6 +1961,7 @@ function buildTemplate(template, imports, b) {
|
|
|
1940
1961
|
varNames: {},
|
|
1941
1962
|
fragmentStack: [],
|
|
1942
1963
|
forVarNames: [],
|
|
1964
|
+
ns: false,
|
|
1943
1965
|
preserveWhitespace: false
|
|
1944
1966
|
};
|
|
1945
1967
|
b.append("");
|