@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.
Files changed (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/compile.cjs +28 -6
  3. package/dist/compile.cjs.map +1 -1
  4. package/dist/compile.d.cts +1 -0
  5. package/dist/compile.d.ts +1 -0
  6. package/dist/compile.js +28 -6
  7. package/dist/compile.js.map +1 -1
  8. package/dist/index.cjs +12 -4
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +12 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/metafile-cjs.json +1 -1
  15. package/dist/metafile-esm.json +1 -1
  16. package/package.json +3 -3
  17. package/src/compile/build/client/BuildStatus.ts +1 -0
  18. package/src/compile/build/client/buildCode.ts +1 -0
  19. package/src/compile/build/client/buildFragment.ts +1 -1
  20. package/src/compile/build/client/buildFragmentText.ts +26 -4
  21. package/src/compile/build/client/buildHtmlNode.ts +1 -5
  22. package/src/compile/types/nodes/Fragment.ts +1 -0
  23. package/src/render/getFragment.ts +13 -3
  24. package/test/console/components/temp/{Console-client-2f206752ce59e59fba9bb91263b4102fd515951e.ts → Console-client-254d7d4799471401334d698b1631ab1cb5b70558.ts} +1 -1
  25. package/test/svg/components/Shape.d.ts +18 -0
  26. package/test/svg/components/Shape.torp +12 -0
  27. package/test/svg/components/output/Shape-client.ts +61 -0
  28. package/test/svg/components/output/Shape-server.ts +23 -0
  29. package/test/svg/components/temp/Shape-client-ea698ed1b7d0c3615adff35fa4956f22840f5fda.ts +61 -0
  30. package/test/svg/components/temp/Shape-server-eb32049cfb7c058b2c4079c5f86ef00651ff6d69.ts +23 -0
  31. package/test/svg/svg.test.ts +50 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @torpor/view
2
2
 
3
+ ## 0.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 78e78b9: Fix: use the existing fragment name
8
+
9
+ ## 0.0.10
10
+
11
+ ### Patch Changes
12
+
13
+ - 3cf6de6: Fix: use namespace when creating svg fragments
14
+
3
15
  ## 0.0.9
4
16
 
5
17
  ### Patch Changes
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 = { number: fragments.length, text: "", events: [], animations: [] };
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 = { number: fragments.length, text: "", events: [], animations: [] };
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 = { number: fragments.length, text: "", events: [], animations: [] };
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();
@@ -1152,7 +1173,7 @@ function buildHtmlBranch(node, status, b, parentName, rangeName) {
1152
1173
  status.imports.add("t_run_branch");
1153
1174
  b.append(`t_run_branch(${rangeName}, -1, () => {`);
1154
1175
  const templateName = nextVarName("template", status);
1155
- const fragmentName = nextVarName("fragment", status);
1176
+ const fragmentName = `t_fragment_${node.fragment.number}`;
1156
1177
  b.append(`const ${templateName} = document.createElement("template");`);
1157
1178
  b.append(`${templateName}.innerHTML = ${node.statement};`);
1158
1179
  b.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);
@@ -1966,6 +1987,7 @@ function buildTemplate(template, imports, b) {
1966
1987
  varNames: {},
1967
1988
  fragmentStack: [],
1968
1989
  forVarNames: [],
1990
+ ns: false,
1969
1991
  preserveWhitespace: false
1970
1992
  };
1971
1993
  b.append("");