@lytjs/ssr 6.4.0 → 6.5.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 +589 -0
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -30,9 +30,6 @@ declare const _default: {
|
|
|
30
30
|
*
|
|
31
31
|
* 高性能大数据列表渲染
|
|
32
32
|
*/
|
|
33
|
-
/**
|
|
34
|
-
* 虚拟列表组件
|
|
35
|
-
*/
|
|
36
33
|
declare const VirtualList: _lytjs_component.ComponentOptions<Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>>;
|
|
37
34
|
|
|
38
35
|
/**
|
|
@@ -72,7 +69,7 @@ interface DataPrefetchContext {
|
|
|
72
69
|
/** 异步数据预取结果 */
|
|
73
70
|
interface PrefetchResult {
|
|
74
71
|
/** 预取的数据 */
|
|
75
|
-
data: Record<string,
|
|
72
|
+
data: Record<string, unknown>;
|
|
76
73
|
/** 数据过期时间(毫秒) */
|
|
77
74
|
ttl?: number;
|
|
78
75
|
}
|
|
@@ -86,7 +83,7 @@ interface EnhancedStreamRenderOptions extends StreamRenderOptions {
|
|
|
86
83
|
/** 数据预取上下文 */
|
|
87
84
|
prefetchContext?: DataPrefetchContext;
|
|
88
85
|
/** 数据预取完成回调 */
|
|
89
|
-
onDataPrefetched?: (data: Record<string,
|
|
86
|
+
onDataPrefetched?: (data: Record<string, unknown>) => void;
|
|
90
87
|
/** 是否启用渐进式水合 */
|
|
91
88
|
progressiveHydration?: boolean;
|
|
92
89
|
}
|
|
@@ -146,7 +143,7 @@ declare function renderToStreamAsync(vnode: VNode, options?: EnhancedStreamRende
|
|
|
146
143
|
*/
|
|
147
144
|
declare function renderToStreamEnhanced(vnode: VNode, options?: EnhancedStreamRenderOptions): Promise<{
|
|
148
145
|
stream: ReadableStream<Uint8Array>;
|
|
149
|
-
dehydratedState: Record<string,
|
|
146
|
+
dehydratedState: Record<string, unknown>;
|
|
150
147
|
}>;
|
|
151
148
|
|
|
152
149
|
/**
|
|
@@ -502,7 +499,10 @@ declare function ServerComponent(options: {
|
|
|
502
499
|
prefetch?: (context: DataPrefetchContext) => Promise<PrefetchResult>;
|
|
503
500
|
onInit?: ServerLifecycleHook;
|
|
504
501
|
onCleanup?: ServerLifecycleHook;
|
|
505
|
-
}): (target:
|
|
502
|
+
}): (target: {
|
|
503
|
+
name?: string;
|
|
504
|
+
render?: () => VNode;
|
|
505
|
+
}) => void;
|
|
506
506
|
|
|
507
507
|
/**
|
|
508
508
|
* @lytjs/ssr - 组件级水合提示
|
package/dist/index.mjs
CHANGED
|
@@ -109,6 +109,7 @@ var VirtualList = defineComponent({
|
|
|
109
109
|
buffer: { type: Number, default: 5 },
|
|
110
110
|
class: { type: String, default: "" }
|
|
111
111
|
},
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
113
|
setup(props, { slots }) {
|
|
113
114
|
const scrollTop = signal(0);
|
|
114
115
|
const visibleCount = computedSignal(() => {
|
|
@@ -142,6 +143,7 @@ var VirtualList = defineComponent({
|
|
|
142
143
|
return () => {
|
|
143
144
|
const items = visibleData().map((item, index) => {
|
|
144
145
|
const actualIndex = startIndex() + index;
|
|
146
|
+
const slotContent = slots?.default?.({ item, index: actualIndex });
|
|
145
147
|
return createVNode(
|
|
146
148
|
"div",
|
|
147
149
|
{
|
|
@@ -149,7 +151,7 @@ var VirtualList = defineComponent({
|
|
|
149
151
|
style: `height: ${props.itemHeight}px;`,
|
|
150
152
|
"data-index": actualIndex
|
|
151
153
|
},
|
|
152
|
-
|
|
154
|
+
slotContent
|
|
153
155
|
);
|
|
154
156
|
});
|
|
155
157
|
return createVNode(
|
|
@@ -293,7 +295,7 @@ function renderToStream(vnode, options) {
|
|
|
293
295
|
errorRecovery = true
|
|
294
296
|
} = options || {};
|
|
295
297
|
const encoder = new TextEncoder();
|
|
296
|
-
|
|
298
|
+
const flowController = maxBytesPerSecond ? new FlowController(maxBytesPerSecond) : null;
|
|
297
299
|
let timeoutId = null;
|
|
298
300
|
return new ReadableStream({
|
|
299
301
|
start(controller) {
|
|
@@ -354,7 +356,7 @@ function renderToStream(vnode, options) {
|
|
|
354
356
|
console.warn("Error occurred during stream rendering, using fallback HTML");
|
|
355
357
|
controller.enqueue(encoder.encode(fallbackHtml));
|
|
356
358
|
controller.close();
|
|
357
|
-
} catch (
|
|
359
|
+
} catch (_) {
|
|
358
360
|
controller.error(error);
|
|
359
361
|
}
|
|
360
362
|
} else {
|
|
@@ -366,7 +368,7 @@ function renderToStream(vnode, options) {
|
|
|
366
368
|
if (timeoutId) {
|
|
367
369
|
clearTimeout(timeoutId);
|
|
368
370
|
}
|
|
369
|
-
console.
|
|
371
|
+
console.warn("Stream cancelled:", reason);
|
|
370
372
|
}
|
|
371
373
|
});
|
|
372
374
|
function sendChunk(controller, encoder2, chunk) {
|