@torpor/view 0.0.10 → 0.0.12
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/{ServerSlotRender-AWF3bD5B.d.cts → ServerSlotRender-t1sOutne.d.cts} +1 -1
- package/dist/{ServerSlotRender-AWF3bD5B.d.ts → ServerSlotRender-t1sOutne.d.ts} +1 -1
- package/dist/{chunk-GO2L324Q.js → chunk-T6JGCJ5T.js} +5 -2
- package/dist/chunk-T6JGCJ5T.js.map +1 -0
- package/dist/compile.cjs +39 -32
- 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 +39 -32
- package/dist/compile.js.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- 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/dist/ssr.cjs +4 -1
- package/dist/ssr.cjs.map +1 -1
- package/dist/ssr.d.cts +2 -2
- package/dist/ssr.d.ts +2 -2
- package/dist/ssr.js +1 -1
- package/dist/ssr.js.map +1 -1
- package/package.json +7 -7
- package/scripts/buildTestOutput.ts +2 -121
- package/src/compile/build/client/buildAddFragment.ts +1 -1
- package/src/compile/build/client/buildAwaitNode.ts +1 -1
- package/src/compile/build/client/buildComponentNode.ts +1 -1
- package/src/compile/build/client/buildControlNode.ts +1 -1
- package/src/compile/build/client/buildElementNode.ts +7 -1
- package/src/compile/build/client/buildForNode.ts +1 -1
- package/src/compile/build/client/buildFragment.ts +1 -1
- package/src/compile/build/client/buildFragmentText.ts +7 -1
- package/src/compile/build/client/buildHeadNode.ts +1 -1
- package/src/compile/build/client/buildHtmlNode.ts +2 -6
- package/src/compile/build/client/buildIfNode.ts +1 -1
- package/src/compile/build/client/buildMount.ts +1 -1
- package/src/compile/build/client/buildNode.ts +1 -1
- package/src/compile/build/client/buildReplaceNode.ts +1 -1
- package/src/compile/build/client/buildRootNode.ts +1 -1
- package/src/compile/build/client/buildRun.ts +1 -1
- package/src/compile/build/client/buildScriptNode.ts +1 -1
- package/src/compile/build/client/buildSlotNode.ts +1 -1
- package/src/compile/build/client/buildSwitchNode.ts +1 -1
- package/src/compile/build/client/buildTextNode.ts +1 -1
- package/src/compile/build/client/replaceForVarNames.ts +1 -1
- package/src/compile/build/server/buildServerAwaitNode.ts +1 -1
- package/src/compile/build/server/buildServerComponentNode.ts +1 -1
- package/src/compile/build/server/buildServerControlNode.ts +1 -1
- package/src/compile/build/server/buildServerElementNode.ts +9 -1
- package/src/compile/build/server/buildServerForNode.ts +1 -1
- package/src/compile/build/server/buildServerHtmlNode.ts +1 -1
- package/src/compile/build/server/buildServerIfNode.ts +1 -1
- package/src/compile/build/server/buildServerNode.ts +5 -1
- package/src/compile/build/server/buildServerReplaceNode.ts +1 -1
- package/src/compile/build/server/buildServerRootNode.ts +5 -1
- package/src/compile/build/server/buildServerScriptNode.ts +1 -1
- package/src/compile/build/server/buildServerSlotNode.ts +1 -1
- package/src/compile/build/server/buildServerSpecialNode.ts +1 -1
- package/src/compile/build/server/buildServerSwitchNode.ts +1 -1
- package/src/compile/build/server/buildServerTextNode.ts +1 -1
- package/src/compile/build/utils/isFullyReactive.ts +1 -1
- package/src/compile/build/utils/isReactive.ts +1 -1
- package/src/compile/build/utils/isReactiveAttribute.ts +1 -1
- package/src/compile/parse/addSpaceElement.ts +4 -1
- package/src/compile/parse/parseControl.ts +4 -1
- package/src/compile/parse/parseImports.ts +1 -1
- package/src/compile/parse/parseMarkup.ts +1 -1
- package/src/compile/parse/parseStyles.ts +1 -1
- package/src/compile/parse/scopeStyles.ts +13 -21
- package/src/compile/parse/slottifyChildNodes.ts +1 -1
- package/src/compile/parse/utils/addError.ts +5 -1
- package/src/compile/parse/utils/consumeUntil.ts +1 -1
- package/src/compile/parse/utils/isAlphaNumeric.ts +1 -1
- package/src/compile/parse/utils/isAlphaNumericChar.ts +1 -1
- package/src/compile/parse/utils/isSpace.ts +1 -1
- package/src/compile/parse/utils/isSpaceChar.ts +1 -1
- package/src/compile/types/nodes/TemplateNode.ts +3 -0
- package/src/compile/utils/Builder.ts +3 -3
- package/src/compile/utils/trimEnd.ts +1 -1
- package/src/compile/utils/trimMatched.ts +1 -1
- package/src/compile/utils/trimQuotes.ts +1 -1
- package/src/compile/utils/trimStart.ts +1 -1
- package/src/compile/utils/trimStartAndEnd.ts +1 -1
- package/src/compile/utils/voidTags.ts +1 -1
- package/src/debug/printHtml.ts +1 -1
- package/src/motion/animate.ts +1 -1
- package/src/render/$mount.ts +1 -1
- package/src/render/$run.ts +1 -1
- package/src/render/$serverMount.ts +1 -1
- package/src/render/$serverRun.ts +1 -1
- package/src/render/$stream.ts +1 -1
- package/src/render/addAnimation.ts +1 -1
- package/src/render/addEvent.ts +1 -1
- package/src/render/addFragment.ts +1 -1
- package/src/render/applyProps.ts +1 -1
- package/src/render/clearRange.ts +1 -1
- package/src/render/createComment.ts +1 -1
- package/src/render/createElement.ts +1 -1
- package/src/render/createFragment.ts +1 -1
- package/src/render/createText.ts +1 -1
- package/src/render/flushMountEffects.ts +1 -1
- package/src/render/getClasses.ts +4 -1
- package/src/render/hydrate.ts +1 -1
- package/src/render/hydrateRoot.ts +1 -1
- package/src/render/mount.ts +1 -1
- package/src/render/moveRange.ts +1 -1
- package/src/render/popRange.ts +1 -1
- package/src/render/runControl.ts +1 -1
- package/src/render/runControlBranch.ts +1 -1
- package/src/render/runList.ts +1 -1
- package/src/render/runListItems.ts +1 -1
- package/src/render/setAttribute.ts +1 -1
- package/src/render/setDynamicElement.ts +1 -1
- package/src/watch/proxyGet.ts +1 -1
- package/src/watch/removeEffect.ts +1 -1
- package/src/watch/runEffect.ts +1 -1
- package/src/watch/symbols.ts +1 -1
- package/src/watch/trackEffect.ts +1 -1
- package/src/watch/transferEffects.ts +1 -1
- package/src/watch/triggerEffects.ts +1 -1
- package/test/bench/components/output/Bench-client.ts +0 -204
- package/test/bench/components/output/Bench-server.ts +0 -130
- package/test/bench/components/temp/Bench-client-5fee290225ae4771aa847360006123671e8f17f1.ts +208 -0
- package/test/bench/components/temp/Bench-server-00cefa588803c01ca4f2741c595e4f045cdd101e.ts +130 -0
- package/test/build-server/components/{output/IfNested-client.ts → temp/IfNested-client-979db97eea5b4595550b9b46f297f3fbc31796d2.ts} +11 -0
- package/test/buildHtml.ts +1 -1
- package/test/buildOutputFiles.ts +47 -12
- package/test/class/class.test.ts +29 -6
- package/test/class/components/Class.torp +15 -1
- package/test/class/components/output/Class-client.ts +10 -6
- package/test/class/components/output/Class-server.ts +1 -1
- package/test/class/components/temp/{Class-client-600bf865c14f1052d24e1c79242f837aaf5ae5e8.ts → Class-client-8c3f9e0257cc2b687e9bb7106cccbab94a4b5adf.ts} +10 -6
- package/test/class/components/temp/Class-server-2218c3284845fdab80d1a41ebace9a9e2ddd6fc1.ts +17 -0
- package/test/component/components/temp/Header-client-ac151eea86e3f6b058fab101661e13ae73864968.ts +34 -0
- package/test/component/components/temp/Header-server-4f10f2332f3ca7a097517cfb938ab1e6f31d68ac.ts +17 -0
- package/test/console/components/temp/{Console-client-254d7d4799471401334d698b1631ab1cb5b70558.ts → Console-client-2f206752ce59e59fba9bb91263b4102fd515951e.ts} +1 -1
- package/test/console/components/temp/Console-server-b4b15f7a0d1d2b50d87bad4870e1b8d368707c04.ts +17 -0
- package/test/globalSetup.ts +1 -1
- package/test/helpers.ts +6 -2
- package/test/hydrateComponent.ts +1 -1
- package/test/importComponent.ts +12 -40
- package/test/mountComponent.ts +5 -1
- package/test/party/components/temp/AnswerButton-client-243454cd7bf84c648f244b3587e60d01a0401039.ts +33 -0
- package/test/party/components/temp/AnswerButton-server-938e46c1d2510ea37454854ef527e4aa64eb8e52.ts +16 -0
- package/test/party/components/temp/FunnyButton-client-2e6bec8259065b5bc9ae16d1ca93dd1bd0c56b7c.ts +40 -0
- package/test/party/components/temp/FunnyButton-server-e8ab55e47c735f7e42c55d2b7504dfa4190a1b40.ts +32 -0
- package/test/party/components/temp/Time-client-7ba4ca9322af2cb88a873c812fc776760c337c64.ts +47 -0
- package/test/party/components/temp/Time-server-08f66c7f3f32b13de06d75fe679cf58b5727c473.ts +31 -0
- package/test/party/components/temp/UserProfile-client-938bcef20a2555de22aca939022a32742ac5e729.ts +51 -0
- package/test/party/components/temp/UserProfile-server-9df5c59b8797fa67c479bc76450104d45e6076f9.ts +22 -0
- package/test/party/components/temp/UserProfileContext-client-93211cdba795b8baf926f60f5b17da90701743b3.ts +44 -0
- package/test/party/components/temp/UserProfileContext-server-cf58767df1e2d1dde919f59de73cdd9764bbc006.ts +20 -0
- package/test/slots/components/temp/Article-client-741f94eab2e96655f4c9d69ccd7d9c7cc998f4ce.ts +41 -0
- package/test/slots/components/temp/Article-server-a6bd47a621cc213db4313eb775a52246541dd203.ts +28 -0
- package/test/slots/components/temp/Header-client-e2e1e7d60b48b0841cd0c20224f520330ca96458.ts +38 -0
- package/test/slots/components/temp/Header-server-1c195508a91c32822da22a08576c8a30c9070636.ts +22 -0
- package/test/slots/components/temp/List-client-0659d999cfb48b865fe5b8aaaf2a4ddac3a8a8b6.ts +76 -0
- package/test/slots/components/temp/List-server-4b76485a259d054187edad8aa691d80ac918ad86.ts +25 -0
- package/test/special-component/components/temp/BigTitle-client-881a9f84876fb3f6d994736edb253b96e71de926.ts +32 -0
- package/test/special-component/components/temp/BigTitle-server-9efc738f5eb131a4b859c4a99a8e255d93834e9a.ts +20 -0
- package/test/special-component/components/temp/SmallTitle-client-25b3097b7ae47848dd82967403faf7745fc43388.ts +32 -0
- package/test/special-component/components/temp/SmallTitle-server-fc105db9a91b83644d67e049ce583a3d1a61f50c.ts +20 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +7 -2
- package/vitest.config.ts +2 -2
- package/dist/chunk-GO2L324Q.js.map +0 -1
- package/test/bench/components/temp/Bench-client-3efcd3b6c03c7a51368df3b8b1bdf2e7fa722432.ts +0 -126
- package/test/build-server/components/IfNested.d.ts +0 -18
- package/test/class/components/temp/Class-server-082505b03612c762384ffff329472db3f55b8097.ts +0 -17
- /package/test/build-server/components/{output/IfNested-server.ts → temp/IfNested-server-3c4e4b6f2162c0906cef685830219b9ea9ee985c.ts} +0 -0
package/dist/compile.d.cts
CHANGED
package/dist/compile.d.ts
CHANGED
package/dist/compile.js
CHANGED
|
@@ -65,6 +65,17 @@ var HYDRATION_START_COMMENT = "<![>";
|
|
|
65
65
|
var HYDRATION_END_COMMENT = "<!]>";
|
|
66
66
|
var HYDRATION_BRANCH_COMMENT = "<!^>";
|
|
67
67
|
|
|
68
|
+
// src/compile/utils/trimQuotes.ts
|
|
69
|
+
function trimQuotes(text) {
|
|
70
|
+
let start = 0;
|
|
71
|
+
let end = text.length;
|
|
72
|
+
while (text[start] === "'" && text[end - 1] === "'" || text[start] === '"' && text[end - 1] === '"' || text[start] === "`" && text[end - 1] === "`") {
|
|
73
|
+
start += 1;
|
|
74
|
+
end -= 1;
|
|
75
|
+
}
|
|
76
|
+
return text.substring(start, end);
|
|
77
|
+
}
|
|
78
|
+
|
|
68
79
|
// src/compile/build/utils/isReactive.ts
|
|
69
80
|
function isReactive(text) {
|
|
70
81
|
return text.includes("{") && text.includes("}");
|
|
@@ -172,6 +183,9 @@ function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
|
172
183
|
if (a.name.startsWith("data-")) {
|
|
173
184
|
return `${a.name}=""`;
|
|
174
185
|
}
|
|
186
|
+
} else if (a.name === "class" && node.scopeStyles) {
|
|
187
|
+
let value = a.value ? `"${trimQuotes(a.value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
188
|
+
return `${a.name}=${value}`;
|
|
175
189
|
} else {
|
|
176
190
|
return `${a.name}${a.value != null ? `=${a.value}` : ""}`;
|
|
177
191
|
}
|
|
@@ -241,17 +255,6 @@ function trimMatched(text, startChar, endChar) {
|
|
|
241
255
|
return text.substring(start, end);
|
|
242
256
|
}
|
|
243
257
|
|
|
244
|
-
// src/compile/utils/trimQuotes.ts
|
|
245
|
-
function trimQuotes(text) {
|
|
246
|
-
let start = 0;
|
|
247
|
-
let end = text.length;
|
|
248
|
-
while (text[start] === "'" && text[end - 1] === "'" || text[start] === '"' && text[end - 1] === '"' || text[start] === "`" && text[end - 1] === "`") {
|
|
249
|
-
start += 1;
|
|
250
|
-
end -= 1;
|
|
251
|
-
}
|
|
252
|
-
return text.substring(start, end);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
258
|
// src/compile/build/utils/isFullyReactive.ts
|
|
256
259
|
function isFullyReactive(text) {
|
|
257
260
|
return text.trim().startsWith("{") && text.trim().endsWith("}");
|
|
@@ -1147,7 +1150,7 @@ function buildHtmlBranch(node, status, b, parentName, rangeName) {
|
|
|
1147
1150
|
status.imports.add("t_run_branch");
|
|
1148
1151
|
b.append(`t_run_branch(${rangeName}, -1, () => {`);
|
|
1149
1152
|
const templateName = nextVarName("template", status);
|
|
1150
|
-
const fragmentName =
|
|
1153
|
+
const fragmentName = `t_fragment_${node.fragment.number}`;
|
|
1151
1154
|
b.append(`const ${templateName} = document.createElement("template");`);
|
|
1152
1155
|
b.append(`${templateName}.innerHTML = ${node.statement};`);
|
|
1153
1156
|
b.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);
|
|
@@ -1508,9 +1511,15 @@ function buildElementAttributes(node, varName, status, b) {
|
|
|
1508
1511
|
} else if (name.startsWith(":transition")) {
|
|
1509
1512
|
buildTransitionAttribute(node, varName, name, value, status, b);
|
|
1510
1513
|
} else if (name === "class") {
|
|
1514
|
+
if (node.scopeStyles) {
|
|
1515
|
+
value += `+ "torp-${status.styleHash}"`;
|
|
1516
|
+
}
|
|
1511
1517
|
buildRun("setClassName", `${varName}.className = ${value};`, status, b);
|
|
1512
1518
|
} else if (name === ":class") {
|
|
1513
1519
|
status.imports.add("t_class");
|
|
1520
|
+
if (node.scopeStyles) {
|
|
1521
|
+
value += `, "torp-${status.styleHash}"`;
|
|
1522
|
+
}
|
|
1514
1523
|
buildRun("setClasses", `${varName}.className = t_class(${value});`, status, b);
|
|
1515
1524
|
} else if (name === ":style") {
|
|
1516
1525
|
status.imports.add("t_style");
|
|
@@ -2423,6 +2432,9 @@ function buildElementAttributes2(node, status) {
|
|
|
2423
2432
|
attributes.push(`${propName}="\${${valueOrDefault}}"`);
|
|
2424
2433
|
} else if (name === ":class") {
|
|
2425
2434
|
status.imports.add("t_class");
|
|
2435
|
+
if (node.scopeStyles) {
|
|
2436
|
+
value += `, "torp-${status.styleHash}"`;
|
|
2437
|
+
}
|
|
2426
2438
|
attributes.push(`class="\${t_class(${value})}"`);
|
|
2427
2439
|
} else if (name === ":style") {
|
|
2428
2440
|
status.imports.add("t_style");
|
|
@@ -2436,6 +2448,9 @@ function buildElementAttributes2(node, status) {
|
|
|
2436
2448
|
attributes.push(
|
|
2437
2449
|
`${name}="${trimQuotes(value).replaceAll("{", "${t_attr(").replaceAll("}", ")}")}"`
|
|
2438
2450
|
);
|
|
2451
|
+
} else if (name === "class" && node.scopeStyles) {
|
|
2452
|
+
value = value ? `"${trimQuotes(value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
2453
|
+
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2439
2454
|
} else if (value != null) {
|
|
2440
2455
|
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2441
2456
|
} else {
|
|
@@ -3563,40 +3578,32 @@ function scopeStyles(status) {
|
|
|
3563
3578
|
for (let block of component.style.blocks) {
|
|
3564
3579
|
collectStyleSelectors(block, selectors);
|
|
3565
3580
|
}
|
|
3566
|
-
scopeStylesOnNode(component.markup, selectors
|
|
3581
|
+
scopeStylesOnNode(component.markup, selectors);
|
|
3567
3582
|
}
|
|
3568
3583
|
}
|
|
3569
3584
|
}
|
|
3570
|
-
function scopeStylesOnNode(node, selectors
|
|
3585
|
+
function scopeStylesOnNode(node, selectors) {
|
|
3571
3586
|
if (isElementNode(node)) {
|
|
3572
|
-
let
|
|
3573
|
-
if (!
|
|
3587
|
+
let scopeStyles2 = selectors.includes(node.tagName);
|
|
3588
|
+
if (!scopeStyles2) {
|
|
3574
3589
|
for (let a of node.attributes) {
|
|
3575
3590
|
if (a.name === "class" || a.name === ":class") {
|
|
3576
|
-
|
|
3591
|
+
scopeStyles2 = true;
|
|
3577
3592
|
} else if (a.name === "id" && a.value) {
|
|
3578
|
-
|
|
3593
|
+
scopeStyles2 = selectors.includes(`#${trimQuotes(a.value)}`);
|
|
3579
3594
|
} else if (a.name === "class" && a.value) {
|
|
3580
|
-
|
|
3595
|
+
scopeStyles2 = selectors.includes(`.${trimQuotes(a.value)}`);
|
|
3596
|
+
}
|
|
3597
|
+
if (scopeStyles2) {
|
|
3598
|
+
break;
|
|
3581
3599
|
}
|
|
3582
|
-
if (addClass) break;
|
|
3583
|
-
}
|
|
3584
|
-
}
|
|
3585
|
-
if (addClass) {
|
|
3586
|
-
let classAttribute = node.attributes.find((a) => a.name === "class");
|
|
3587
|
-
if (classAttribute && classAttribute.value) {
|
|
3588
|
-
classAttribute.value = `"${trimQuotes(classAttribute.value)} torp-${styleHash}"`;
|
|
3589
|
-
} else {
|
|
3590
|
-
node.attributes.push({
|
|
3591
|
-
name: "class",
|
|
3592
|
-
value: `"torp-${styleHash}"`
|
|
3593
|
-
});
|
|
3594
3600
|
}
|
|
3595
3601
|
}
|
|
3602
|
+
node.scopeStyles = scopeStyles2;
|
|
3596
3603
|
}
|
|
3597
3604
|
if (isParentNode(node)) {
|
|
3598
3605
|
for (let child of node.children) {
|
|
3599
|
-
scopeStylesOnNode(child, selectors
|
|
3606
|
+
scopeStylesOnNode(child, selectors);
|
|
3600
3607
|
}
|
|
3601
3608
|
}
|
|
3602
3609
|
}
|