@lytjs/ssr 6.4.0 → 6.6.0
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/README.md +591 -0
- package/dist/index.cjs +28 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +28 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +50 -50
- package/dist/index.d.cts +0 -612
- package/dist/index.d.ts +0 -612
package/dist/index.mjs
CHANGED
|
@@ -35,11 +35,28 @@ function renderToString(vnode) {
|
|
|
35
35
|
if (isString(node.type)) {
|
|
36
36
|
const tag = node.type;
|
|
37
37
|
const props = node.props || {};
|
|
38
|
-
const voidTags = [
|
|
38
|
+
const voidTags = [
|
|
39
|
+
"area",
|
|
40
|
+
"base",
|
|
41
|
+
"br",
|
|
42
|
+
"col",
|
|
43
|
+
"embed",
|
|
44
|
+
"hr",
|
|
45
|
+
"img",
|
|
46
|
+
"input",
|
|
47
|
+
"link",
|
|
48
|
+
"meta",
|
|
49
|
+
"param",
|
|
50
|
+
"source",
|
|
51
|
+
"track",
|
|
52
|
+
"wbr"
|
|
53
|
+
];
|
|
39
54
|
if (voidTags.includes(tag)) {
|
|
40
55
|
return `<${tag}${renderAttributes(props)}>`;
|
|
41
56
|
}
|
|
42
|
-
const children = renderToString(
|
|
57
|
+
const children = renderToString(
|
|
58
|
+
node.children
|
|
59
|
+
);
|
|
43
60
|
return `<${tag}${renderAttributes(props)}>${children}</${tag}>`;
|
|
44
61
|
}
|
|
45
62
|
return "";
|
|
@@ -109,6 +126,7 @@ var VirtualList = defineComponent({
|
|
|
109
126
|
buffer: { type: Number, default: 5 },
|
|
110
127
|
class: { type: String, default: "" }
|
|
111
128
|
},
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
130
|
setup(props, { slots }) {
|
|
113
131
|
const scrollTop = signal(0);
|
|
114
132
|
const visibleCount = computedSignal(() => {
|
|
@@ -142,6 +160,7 @@ var VirtualList = defineComponent({
|
|
|
142
160
|
return () => {
|
|
143
161
|
const items = visibleData().map((item, index) => {
|
|
144
162
|
const actualIndex = startIndex() + index;
|
|
163
|
+
const slotContent = slots?.default?.({ item, index: actualIndex });
|
|
145
164
|
return createVNode(
|
|
146
165
|
"div",
|
|
147
166
|
{
|
|
@@ -149,7 +168,7 @@ var VirtualList = defineComponent({
|
|
|
149
168
|
style: `height: ${props.itemHeight}px;`,
|
|
150
169
|
"data-index": actualIndex
|
|
151
170
|
},
|
|
152
|
-
|
|
171
|
+
slotContent
|
|
153
172
|
);
|
|
154
173
|
});
|
|
155
174
|
return createVNode(
|
|
@@ -293,7 +312,7 @@ function renderToStream(vnode, options) {
|
|
|
293
312
|
errorRecovery = true
|
|
294
313
|
} = options || {};
|
|
295
314
|
const encoder = new TextEncoder();
|
|
296
|
-
|
|
315
|
+
const flowController = maxBytesPerSecond ? new FlowController(maxBytesPerSecond) : null;
|
|
297
316
|
let timeoutId = null;
|
|
298
317
|
return new ReadableStream({
|
|
299
318
|
start(controller) {
|
|
@@ -354,7 +373,7 @@ function renderToStream(vnode, options) {
|
|
|
354
373
|
console.warn("Error occurred during stream rendering, using fallback HTML");
|
|
355
374
|
controller.enqueue(encoder.encode(fallbackHtml));
|
|
356
375
|
controller.close();
|
|
357
|
-
} catch (
|
|
376
|
+
} catch (_) {
|
|
358
377
|
controller.error(error);
|
|
359
378
|
}
|
|
360
379
|
} else {
|
|
@@ -366,7 +385,7 @@ function renderToStream(vnode, options) {
|
|
|
366
385
|
if (timeoutId) {
|
|
367
386
|
clearTimeout(timeoutId);
|
|
368
387
|
}
|
|
369
|
-
console.
|
|
388
|
+
console.warn("Stream cancelled:", reason);
|
|
370
389
|
}
|
|
371
390
|
});
|
|
372
391
|
function sendChunk(controller, encoder2, chunk) {
|
|
@@ -1050,9 +1069,7 @@ function createHydrationMarkers(vnode) {
|
|
|
1050
1069
|
}
|
|
1051
1070
|
const node = vnode;
|
|
1052
1071
|
if (isArray(vnode)) {
|
|
1053
|
-
return vnode.map(
|
|
1054
|
-
(child) => createHydrationMarkers(child)
|
|
1055
|
-
);
|
|
1072
|
+
return vnode.map((child) => createHydrationMarkers(child));
|
|
1056
1073
|
}
|
|
1057
1074
|
if (isElementVNode(node)) {
|
|
1058
1075
|
const id = generateComponentId();
|
|
@@ -1066,9 +1083,7 @@ function createHydrationMarkers(vnode) {
|
|
|
1066
1083
|
let processedChildren = children;
|
|
1067
1084
|
if (children !== null && !isString(children) && !isNumber(children)) {
|
|
1068
1085
|
if (isArray(children)) {
|
|
1069
|
-
processedChildren = children.map(
|
|
1070
|
-
(child) => createHydrationMarkers(child)
|
|
1071
|
-
);
|
|
1086
|
+
processedChildren = children.map((child) => createHydrationMarkers(child));
|
|
1072
1087
|
} else if (isObject(children)) {
|
|
1073
1088
|
processedChildren = [createHydrationMarkers(children)];
|
|
1074
1089
|
}
|
|
@@ -1081,9 +1096,7 @@ function createHydrationMarkers(vnode) {
|
|
|
1081
1096
|
if (isArray(children)) {
|
|
1082
1097
|
return {
|
|
1083
1098
|
...node,
|
|
1084
|
-
children: children.map(
|
|
1085
|
-
(child) => createHydrationMarkers(child)
|
|
1086
|
-
)
|
|
1099
|
+
children: children.map((child) => createHydrationMarkers(child))
|
|
1087
1100
|
};
|
|
1088
1101
|
} else if (isObject(children)) {
|
|
1089
1102
|
return {
|