@torpor/view 1.2.5 → 1.2.6
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/dist/{AsyncOptions-ClS1_ERX.d.mts → AsyncOptions-BDtArmeL.d.mts} +2 -8
- package/dist/AsyncOptions-BDtArmeL.d.mts.map +1 -0
- package/dist/{AsyncOptions-BtMe2PAd.d.cts → AsyncOptions-C_7mWR6F.d.cts} +2 -8
- package/dist/AsyncOptions-C_7mWR6F.d.cts.map +1 -0
- package/dist/compile.cjs +13 -21
- package/dist/compile.mjs +13 -21
- package/dist/compile.mjs.map +1 -1
- package/dist/index.cjs +102 -83
- package/dist/index.d.cts +12 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +102 -83
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.cjs +28 -2
- package/dist/ssr.d.cts +22 -2
- package/dist/ssr.d.cts.map +1 -1
- package/dist/ssr.d.mts +22 -2
- package/dist/ssr.d.mts.map +1 -1
- package/dist/ssr.mjs +27 -1
- package/dist/ssr.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/AsyncOptions-BtMe2PAd.d.cts.map +0 -1
- package/dist/AsyncOptions-ClS1_ERX.d.mts.map +0 -1
|
@@ -2,15 +2,9 @@ import { t as Cleanup } from "./Cleanup-D0wvGW5d.mjs";
|
|
|
2
2
|
//#region src/types/ClassValue.d.ts
|
|
3
3
|
type ClassValue = string | Record<string, boolean | null | undefined> | Array<ClassValue> | null | undefined;
|
|
4
4
|
//#endregion
|
|
5
|
-
//#region src/render/buildClasses.d.ts
|
|
6
|
-
declare function buildClasses(value: ClassValue, styleHash?: string): string;
|
|
7
|
-
//#endregion
|
|
8
5
|
//#region src/types/StyleValue.d.ts
|
|
9
6
|
type StyleValue = string | Record<string, string | null | undefined> | Array<StyleValue> | null | undefined;
|
|
10
7
|
//#endregion
|
|
11
|
-
//#region src/render/buildStyles.d.ts
|
|
12
|
-
declare function buildStyles(value: StyleValue): string;
|
|
13
|
-
//#endregion
|
|
14
8
|
//#region src/types/StreamSource.d.ts
|
|
15
9
|
/**
|
|
16
10
|
* A subscription to an external source of events — server-sent events,
|
|
@@ -106,5 +100,5 @@ interface AsyncOptions {
|
|
|
106
100
|
timeout?: number;
|
|
107
101
|
}
|
|
108
102
|
//#endregion
|
|
109
|
-
export { StreamSource as a,
|
|
110
|
-
//# sourceMappingURL=AsyncOptions-
|
|
103
|
+
export { StreamSource as a, fromElement as i, fromWebSocket as n, StyleValue as o, fromServer as r, ClassValue as s, AsyncOptions as t };
|
|
104
|
+
//# sourceMappingURL=AsyncOptions-BDtArmeL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncOptions-BDtArmeL.d.mts","names":[],"sources":["../src/types/ClassValue.ts","../src/types/StyleValue.ts","../src/types/StreamSource.ts","../src/stream/fromElement.ts","../src/stream/fromServer.ts","../src/stream/fromWebSocket.ts","../src/types/AsyncOptions.ts"],"mappings":";;KAAK,sBAEF,6CACA,MAAM;;;KCHJ,sBAEF,4CACA,MAAM;;;;;;;;;;;;;;;;;KCaJ,aAAa,MAAM,OAAO,OAAO,eAAe;;;;;;;;;;;;;;KCHhD,mBAAmB,qBAAqB;;;;;;;;;;;iBAYrB,YAAY,UAAU,QAAQ,OACrD,QAAQ,kBACR,eACE,aAAa;;;;;;;;;;;;;;;;;iBCZQ,WAAW,+BAA+B,aAAa;;;;;;;;;;;;;;;;;iBCAvD,cAAc,+BAA+B,aAAa;;;;;;UCbzD;;;;;;EAMxB;;;;;;EAOA"}
|
|
@@ -2,15 +2,9 @@ import { t as Cleanup } from "./Cleanup-D0wvGW5d.cjs";
|
|
|
2
2
|
//#region src/types/ClassValue.d.ts
|
|
3
3
|
type ClassValue = string | Record<string, boolean | null | undefined> | Array<ClassValue> | null | undefined;
|
|
4
4
|
//#endregion
|
|
5
|
-
//#region src/render/buildClasses.d.ts
|
|
6
|
-
declare function buildClasses(value: ClassValue, styleHash?: string): string;
|
|
7
|
-
//#endregion
|
|
8
5
|
//#region src/types/StyleValue.d.ts
|
|
9
6
|
type StyleValue = string | Record<string, string | null | undefined> | Array<StyleValue> | null | undefined;
|
|
10
7
|
//#endregion
|
|
11
|
-
//#region src/render/buildStyles.d.ts
|
|
12
|
-
declare function buildStyles(value: StyleValue): string;
|
|
13
|
-
//#endregion
|
|
14
8
|
//#region src/types/StreamSource.d.ts
|
|
15
9
|
/**
|
|
16
10
|
* A subscription to an external source of events — server-sent events,
|
|
@@ -106,5 +100,5 @@ interface AsyncOptions {
|
|
|
106
100
|
timeout?: number;
|
|
107
101
|
}
|
|
108
102
|
//#endregion
|
|
109
|
-
export { StreamSource as a,
|
|
110
|
-
//# sourceMappingURL=AsyncOptions-
|
|
103
|
+
export { StreamSource as a, fromElement as i, fromWebSocket as n, StyleValue as o, fromServer as r, ClassValue as s, AsyncOptions as t };
|
|
104
|
+
//# sourceMappingURL=AsyncOptions-C_7mWR6F.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncOptions-C_7mWR6F.d.cts","names":[],"sources":["../src/types/ClassValue.ts","../src/types/StyleValue.ts","../src/types/StreamSource.ts","../src/stream/fromElement.ts","../src/stream/fromServer.ts","../src/stream/fromWebSocket.ts","../src/types/AsyncOptions.ts"],"mappings":";;KAAK,sBAEF,6CACA,MAAM;;;KCHJ,sBAEF,4CACA,MAAM;;;;;;;;;;;;;;;;;KCaJ,aAAa,MAAM,OAAO,OAAO,eAAe;;;;;;;;;;;;;;KCHhD,mBAAmB,qBAAqB;;;;;;;;;;;iBAYrB,YAAY,UAAU,QAAQ,OACrD,QAAQ,kBACR,eACE,aAAa;;;;;;;;;;;;;;;;;iBCZQ,WAAW,+BAA+B,aAAa;;;;;;;;;;;;;;;;;iBCAvD,cAAc,+BAA+B,aAAa;;;;;;UCbzD;;;;;;EAMxB;;;;;;EAOA"}
|
package/dist/compile.cjs
CHANGED
|
@@ -935,10 +935,6 @@ function buildAddFragment(node, status, b, parentName, anchorName) {
|
|
|
935
935
|
if (fragment.singleRootElement) {
|
|
936
936
|
status.imports.add("t_add_element");
|
|
937
937
|
b.append(`t_add_element(${fragment.endVarName ?? fragmentName}, ${parentName}, ${anchorName});`);
|
|
938
|
-
if (fragment.endVarName) {
|
|
939
|
-
status.imports.add("t_next");
|
|
940
|
-
b.append(`t_next(${fragment.endVarName});`);
|
|
941
|
-
}
|
|
942
938
|
} else {
|
|
943
939
|
status.imports.add("t_add_fragment");
|
|
944
940
|
let params = [
|
|
@@ -949,10 +945,6 @@ function buildAddFragment(node, status, b, parentName, anchorName) {
|
|
|
949
945
|
if (fragment.endVarName) params.push(fragment.endVarName);
|
|
950
946
|
if (fragment.endVarName && fragment.rootVarName) params.push(fragment.rootVarName);
|
|
951
947
|
b.append(`t_add_fragment(${params.join(", ")});`);
|
|
952
|
-
if (fragment.endVarName) {
|
|
953
|
-
status.imports.add("t_next");
|
|
954
|
-
b.append(`t_next(${fragment.endVarName});`);
|
|
955
|
-
}
|
|
956
948
|
}
|
|
957
949
|
}
|
|
958
950
|
}
|
|
@@ -1322,8 +1314,10 @@ function getFragmentVarPathPart(path, varPath, status, root = false, rootFn = "t
|
|
|
1322
1314
|
}
|
|
1323
1315
|
for (let [i, child] of path.children.entries()) {
|
|
1324
1316
|
if (i > 0) {
|
|
1325
|
-
if (child.type === "text" || child.type === "space")
|
|
1326
|
-
|
|
1317
|
+
if (child.type === "text" || child.type === "space") {
|
|
1318
|
+
status.imports.add("t_next");
|
|
1319
|
+
varPath = `t_next_text(${varPath}, true)`;
|
|
1320
|
+
} else {
|
|
1327
1321
|
status.imports.add("t_next");
|
|
1328
1322
|
varPath = `t_next(${varPath})`;
|
|
1329
1323
|
}
|
|
@@ -1551,7 +1545,7 @@ function buildComponentNode(node, status, b, root = false) {
|
|
|
1551
1545
|
"$sparent: ParentNode",
|
|
1552
1546
|
"$sanchor: Node | null",
|
|
1553
1547
|
slot.hasSlotProps ? "$slot: Record<PropertyKey, any>" : "_$slot?: Record<PropertyKey, any>",
|
|
1554
|
-
"
|
|
1548
|
+
"$context?: Record<PropertyKey, any>"
|
|
1555
1549
|
];
|
|
1556
1550
|
b.append(`${slot.hasSlotProps ? "// @ts-ignore\n" : ""}${slotsName}["${slotName}"] = (\n${slotParams.join(",\n")}\n) => {`);
|
|
1557
1551
|
buildFragment(slot, status, b, "$sparent", "$sanchor");
|
|
@@ -1951,10 +1945,9 @@ function buildForNode(node, status, b) {
|
|
|
1951
1945
|
let ${listItemsName}: ListItemSpec[] = [];`);
|
|
1952
1946
|
appendForVarBindings(b, status, `${node.statement}\n${keyStatement}`);
|
|
1953
1947
|
addMappedText("", `${node.statement}`, " {", node.span, status, b);
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
else b.append(`undefined });`);
|
|
1948
|
+
const dataExpr = singleVar ? forVarNames[0] : `{ ${forVarNames.join(", ")} }`;
|
|
1949
|
+
if (key !== void 0) addMappedText(`${listItemsName}.push({ data: ${dataExpr}, key: `, `${keyStatement || "undefined"}`, " });", key.span, status, b);
|
|
1950
|
+
else b.append(`${listItemsName}.push({ data: ${dataExpr} });`);
|
|
1958
1951
|
b.append(`}`);
|
|
1959
1952
|
b.append(`return ${listItemsName};`);
|
|
1960
1953
|
b.append(`},
|
|
@@ -3150,7 +3143,7 @@ function buildServerComponentNode(node, status, b) {
|
|
|
3150
3143
|
for (let slot of node.children) if (isSpecialNode(slot) && (slot.tagName === "fill" || slot.tagName === "filldef")) {
|
|
3151
3144
|
const nameAttribute = slot.attributes.find((a) => a.name === "name");
|
|
3152
3145
|
const slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : "_";
|
|
3153
|
-
const slotParams = [slot.hasSlotProps ? "$slot: Record<PropertyKey, any>" : "_$slot?: Record<PropertyKey, any>", "
|
|
3146
|
+
const slotParams = [slot.hasSlotProps ? "$slot: Record<PropertyKey, any>" : "_$slot?: Record<PropertyKey, any>", "$context?: Record<PropertyKey, any>"];
|
|
3154
3147
|
b.append(`${slot.hasSlotProps ? "// @ts-ignore\n" : ""}${slotsName}["${slotName}"] = async (\n${slotParams.join(",\n")}\n) => {`);
|
|
3155
3148
|
b.append(`let t_body = "";`);
|
|
3156
3149
|
for (let child of slot.children) buildServerNode(child, status, b);
|
|
@@ -3418,16 +3411,15 @@ function buildElementAttributes(node, status) {
|
|
|
3418
3411
|
attributes.push(`${propName}="\${${valueOrDefault}}"`);
|
|
3419
3412
|
} else if (name === "class") {
|
|
3420
3413
|
status.imports.add("t_class");
|
|
3421
|
-
let params =
|
|
3414
|
+
let params = value;
|
|
3422
3415
|
if (node.scopeStyles && !status.inHead) {
|
|
3423
|
-
params
|
|
3416
|
+
params = `${value}, "torp-${status.styleHash}"`;
|
|
3424
3417
|
needsClass = false;
|
|
3425
3418
|
}
|
|
3426
|
-
|
|
3427
|
-
attributes.push(`\${t_class(${value}) !== "" ? \`class="\${t_class(${value})}"\` : ""}`);
|
|
3419
|
+
attributes.push(`\${t_class(${params})}`);
|
|
3428
3420
|
} else if (name === "style") {
|
|
3429
3421
|
status.imports.add("t_style");
|
|
3430
|
-
attributes.push(`\${t_style(${value})
|
|
3422
|
+
attributes.push(`\${t_style(${value})}`);
|
|
3431
3423
|
} else {
|
|
3432
3424
|
status.imports.add("t_attr");
|
|
3433
3425
|
attributes.push(`\${(${value}) ? \`${name}="\${t_attr(${value})}"\` : ""}`);
|
package/dist/compile.mjs
CHANGED
|
@@ -934,10 +934,6 @@ function buildAddFragment(node, status, b, parentName, anchorName) {
|
|
|
934
934
|
if (fragment.singleRootElement) {
|
|
935
935
|
status.imports.add("t_add_element");
|
|
936
936
|
b.append(`t_add_element(${fragment.endVarName ?? fragmentName}, ${parentName}, ${anchorName});`);
|
|
937
|
-
if (fragment.endVarName) {
|
|
938
|
-
status.imports.add("t_next");
|
|
939
|
-
b.append(`t_next(${fragment.endVarName});`);
|
|
940
|
-
}
|
|
941
937
|
} else {
|
|
942
938
|
status.imports.add("t_add_fragment");
|
|
943
939
|
let params = [
|
|
@@ -948,10 +944,6 @@ function buildAddFragment(node, status, b, parentName, anchorName) {
|
|
|
948
944
|
if (fragment.endVarName) params.push(fragment.endVarName);
|
|
949
945
|
if (fragment.endVarName && fragment.rootVarName) params.push(fragment.rootVarName);
|
|
950
946
|
b.append(`t_add_fragment(${params.join(", ")});`);
|
|
951
|
-
if (fragment.endVarName) {
|
|
952
|
-
status.imports.add("t_next");
|
|
953
|
-
b.append(`t_next(${fragment.endVarName});`);
|
|
954
|
-
}
|
|
955
947
|
}
|
|
956
948
|
}
|
|
957
949
|
}
|
|
@@ -1321,8 +1313,10 @@ function getFragmentVarPathPart(path, varPath, status, root = false, rootFn = "t
|
|
|
1321
1313
|
}
|
|
1322
1314
|
for (let [i, child] of path.children.entries()) {
|
|
1323
1315
|
if (i > 0) {
|
|
1324
|
-
if (child.type === "text" || child.type === "space")
|
|
1325
|
-
|
|
1316
|
+
if (child.type === "text" || child.type === "space") {
|
|
1317
|
+
status.imports.add("t_next");
|
|
1318
|
+
varPath = `t_next_text(${varPath}, true)`;
|
|
1319
|
+
} else {
|
|
1326
1320
|
status.imports.add("t_next");
|
|
1327
1321
|
varPath = `t_next(${varPath})`;
|
|
1328
1322
|
}
|
|
@@ -1550,7 +1544,7 @@ function buildComponentNode(node, status, b, root = false) {
|
|
|
1550
1544
|
"$sparent: ParentNode",
|
|
1551
1545
|
"$sanchor: Node | null",
|
|
1552
1546
|
slot.hasSlotProps ? "$slot: Record<PropertyKey, any>" : "_$slot?: Record<PropertyKey, any>",
|
|
1553
|
-
"
|
|
1547
|
+
"$context?: Record<PropertyKey, any>"
|
|
1554
1548
|
];
|
|
1555
1549
|
b.append(`${slot.hasSlotProps ? "// @ts-ignore\n" : ""}${slotsName}["${slotName}"] = (\n${slotParams.join(",\n")}\n) => {`);
|
|
1556
1550
|
buildFragment(slot, status, b, "$sparent", "$sanchor");
|
|
@@ -1950,10 +1944,9 @@ function buildForNode(node, status, b) {
|
|
|
1950
1944
|
let ${listItemsName}: ListItemSpec[] = [];`);
|
|
1951
1945
|
appendForVarBindings(b, status, `${node.statement}\n${keyStatement}`);
|
|
1952
1946
|
addMappedText("", `${node.statement}`, " {", node.span, status, b);
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
else b.append(`undefined });`);
|
|
1947
|
+
const dataExpr = singleVar ? forVarNames[0] : `{ ${forVarNames.join(", ")} }`;
|
|
1948
|
+
if (key !== void 0) addMappedText(`${listItemsName}.push({ data: ${dataExpr}, key: `, `${keyStatement || "undefined"}`, " });", key.span, status, b);
|
|
1949
|
+
else b.append(`${listItemsName}.push({ data: ${dataExpr} });`);
|
|
1957
1950
|
b.append(`}`);
|
|
1958
1951
|
b.append(`return ${listItemsName};`);
|
|
1959
1952
|
b.append(`},
|
|
@@ -3149,7 +3142,7 @@ function buildServerComponentNode(node, status, b) {
|
|
|
3149
3142
|
for (let slot of node.children) if (isSpecialNode(slot) && (slot.tagName === "fill" || slot.tagName === "filldef")) {
|
|
3150
3143
|
const nameAttribute = slot.attributes.find((a) => a.name === "name");
|
|
3151
3144
|
const slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : "_";
|
|
3152
|
-
const slotParams = [slot.hasSlotProps ? "$slot: Record<PropertyKey, any>" : "_$slot?: Record<PropertyKey, any>", "
|
|
3145
|
+
const slotParams = [slot.hasSlotProps ? "$slot: Record<PropertyKey, any>" : "_$slot?: Record<PropertyKey, any>", "$context?: Record<PropertyKey, any>"];
|
|
3153
3146
|
b.append(`${slot.hasSlotProps ? "// @ts-ignore\n" : ""}${slotsName}["${slotName}"] = async (\n${slotParams.join(",\n")}\n) => {`);
|
|
3154
3147
|
b.append(`let t_body = "";`);
|
|
3155
3148
|
for (let child of slot.children) buildServerNode(child, status, b);
|
|
@@ -3417,16 +3410,15 @@ function buildElementAttributes(node, status) {
|
|
|
3417
3410
|
attributes.push(`${propName}="\${${valueOrDefault}}"`);
|
|
3418
3411
|
} else if (name === "class") {
|
|
3419
3412
|
status.imports.add("t_class");
|
|
3420
|
-
let params =
|
|
3413
|
+
let params = value;
|
|
3421
3414
|
if (node.scopeStyles && !status.inHead) {
|
|
3422
|
-
params
|
|
3415
|
+
params = `${value}, "torp-${status.styleHash}"`;
|
|
3423
3416
|
needsClass = false;
|
|
3424
3417
|
}
|
|
3425
|
-
|
|
3426
|
-
attributes.push(`\${t_class(${value}) !== "" ? \`class="\${t_class(${value})}"\` : ""}`);
|
|
3418
|
+
attributes.push(`\${t_class(${params})}`);
|
|
3427
3419
|
} else if (name === "style") {
|
|
3428
3420
|
status.imports.add("t_style");
|
|
3429
|
-
attributes.push(`\${t_style(${value})
|
|
3421
|
+
attributes.push(`\${t_style(${value})}`);
|
|
3430
3422
|
} else {
|
|
3431
3423
|
status.imports.add("t_attr");
|
|
3432
3424
|
attributes.push(`\${(${value}) ? \`${name}="\${t_attr(${value})}"\` : ""}`);
|