react-virtual-renderer 1.0.3
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 +170 -0
- package/dist/App.d.ts +3 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +7 -0
- package/dist/App.js.map +1 -0
- package/dist/accessibility/a11y.d.ts +111 -0
- package/dist/accessibility/a11y.d.ts.map +1 -0
- package/dist/accessibility/a11y.js +254 -0
- package/dist/accessibility/a11y.js.map +1 -0
- package/dist/components/VirtualGrid.d.ts +8 -0
- package/dist/components/VirtualGrid.d.ts.map +1 -0
- package/dist/components/VirtualGrid.js +187 -0
- package/dist/components/VirtualGrid.js.map +1 -0
- package/dist/components/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList.d.ts.map +1 -0
- package/dist/components/VirtualList.js +102 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/core/MeasurementSystem.d.ts +52 -0
- package/dist/core/MeasurementSystem.d.ts.map +1 -0
- package/dist/core/MeasurementSystem.js +138 -0
- package/dist/core/MeasurementSystem.js.map +1 -0
- package/dist/core/VirtualizationEngine.d.ts +65 -0
- package/dist/core/VirtualizationEngine.d.ts.map +1 -0
- package/dist/core/VirtualizationEngine.js +203 -0
- package/dist/core/VirtualizationEngine.js.map +1 -0
- package/dist/examples/AdvancedExamples.d.ts +24 -0
- package/dist/examples/AdvancedExamples.d.ts.map +1 -0
- package/dist/examples/AdvancedExamples.js +216 -0
- package/dist/examples/AdvancedExamples.js.map +1 -0
- package/dist/examples/Example.d.ts +26 -0
- package/dist/examples/Example.d.ts.map +1 -0
- package/dist/examples/Example.js +186 -0
- package/dist/examples/Example.js.map +1 -0
- package/dist/hooks/useInfiniteScroll.d.ts +17 -0
- package/dist/hooks/useInfiniteScroll.d.ts.map +1 -0
- package/dist/hooks/useInfiniteScroll.js +41 -0
- package/dist/hooks/useInfiniteScroll.js.map +1 -0
- package/dist/hooks/useLazyLoad.d.ts +16 -0
- package/dist/hooks/useLazyLoad.d.ts.map +1 -0
- package/dist/hooks/useLazyLoad.js +34 -0
- package/dist/hooks/useLazyLoad.js.map +1 -0
- package/dist/hooks/useScrollRestoration.d.ts +10 -0
- package/dist/hooks/useScrollRestoration.d.ts.map +1 -0
- package/dist/hooks/useScrollRestoration.js +63 -0
- package/dist/hooks/useScrollRestoration.js.map +1 -0
- package/dist/hooks/useVirtualList.d.ts +33 -0
- package/dist/hooks/useVirtualList.d.ts.map +1 -0
- package/dist/hooks/useVirtualList.js +226 -0
- package/dist/hooks/useVirtualList.js.map +1 -0
- package/dist/hooks/useVirtualizedSearch.d.ts +40 -0
- package/dist/hooks/useVirtualizedSearch.d.ts.map +1 -0
- package/dist/hooks/useVirtualizedSearch.js +168 -0
- package/dist/hooks/useVirtualizedSearch.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +11 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -0
- package/dist/performance/metrics.d.ts +110 -0
- package/dist/performance/metrics.d.ts.map +1 -0
- package/dist/performance/metrics.js +310 -0
- package/dist/performance/metrics.js.map +1 -0
- package/dist/plugin.d.ts +182 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +409 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +84 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/helpers.d.ts +66 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +166 -0
- package/dist/utils/helpers.js.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance monitoring for Virtualize
|
|
3
|
+
* Tracks render time, scroll performance, memory usage, etc.
|
|
4
|
+
*/
|
|
5
|
+
export interface PerformanceMetrics {
|
|
6
|
+
renderTime: number;
|
|
7
|
+
itemsRendered: number;
|
|
8
|
+
itemsMeasured: number;
|
|
9
|
+
scrollFPS: number;
|
|
10
|
+
scrollDelta: number;
|
|
11
|
+
memoryUsed: number;
|
|
12
|
+
cacheSize: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PerformanceWarnings {
|
|
15
|
+
slowRender?: boolean;
|
|
16
|
+
lowFPS?: boolean;
|
|
17
|
+
highMemory?: boolean;
|
|
18
|
+
largeCache?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Performance metrics collector
|
|
22
|
+
*/
|
|
23
|
+
export declare class MetricsCollector {
|
|
24
|
+
private metrics;
|
|
25
|
+
private startTime;
|
|
26
|
+
private lastScrollTime;
|
|
27
|
+
private frameCount;
|
|
28
|
+
private lastFPSTime;
|
|
29
|
+
private isRecording;
|
|
30
|
+
start(): void;
|
|
31
|
+
stop(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Record a render cycle
|
|
34
|
+
*/
|
|
35
|
+
recordRender(itemsRendered: number, itemsMeasured: number, cacheSize: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Record scroll event
|
|
38
|
+
*/
|
|
39
|
+
recordScroll(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate frames per second
|
|
42
|
+
*/
|
|
43
|
+
private calculateFPS;
|
|
44
|
+
/**
|
|
45
|
+
* Get average metrics
|
|
46
|
+
*/
|
|
47
|
+
getAverageMetrics(): Partial<PerformanceMetrics>;
|
|
48
|
+
/**
|
|
49
|
+
* Check for performance issues
|
|
50
|
+
*/
|
|
51
|
+
checkWarnings(): PerformanceWarnings;
|
|
52
|
+
/**
|
|
53
|
+
* Get detailed report
|
|
54
|
+
*/
|
|
55
|
+
getReport(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Clear metrics
|
|
58
|
+
*/
|
|
59
|
+
clear(): void;
|
|
60
|
+
}
|
|
61
|
+
export declare function usePerformanceMonitoring(enabled?: boolean): {
|
|
62
|
+
recordRender: (rendered: number, measured: number, cacheSize: number) => void;
|
|
63
|
+
recordScroll: () => void;
|
|
64
|
+
getMetrics: () => Partial<PerformanceMetrics>;
|
|
65
|
+
getWarnings: () => PerformanceWarnings;
|
|
66
|
+
getReport: () => string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Browser DevTools integration
|
|
70
|
+
*/
|
|
71
|
+
export declare class VirtualizeDevTools {
|
|
72
|
+
static inject(): void;
|
|
73
|
+
static getMetrics(): any;
|
|
74
|
+
static generateReport(): any;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Performance profiler for detailed analysis
|
|
78
|
+
*/
|
|
79
|
+
export declare class PerformanceProfiler {
|
|
80
|
+
private marks;
|
|
81
|
+
private measures;
|
|
82
|
+
mark(label: string): void;
|
|
83
|
+
measure(label: string, startMark: string, endMark?: string): number;
|
|
84
|
+
getMeasures(): {
|
|
85
|
+
[k: string]: number;
|
|
86
|
+
};
|
|
87
|
+
generateFlameChart(width?: number): string;
|
|
88
|
+
clear(): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Memory leak detector
|
|
92
|
+
*/
|
|
93
|
+
export declare class MemoryLeakDetector {
|
|
94
|
+
private initialMemory;
|
|
95
|
+
private measurements;
|
|
96
|
+
start(): void;
|
|
97
|
+
measure(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Detect if memory is continuously growing (potential leak)
|
|
100
|
+
*/
|
|
101
|
+
detectLeak(sampleSize?: number, threshold?: number): boolean;
|
|
102
|
+
getReport(): {
|
|
103
|
+
initialMemory: string;
|
|
104
|
+
currentMemory: string;
|
|
105
|
+
trend: string;
|
|
106
|
+
potentialLeak: boolean;
|
|
107
|
+
};
|
|
108
|
+
clear(): void;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM;IAWb,MAAM,CAAC,UAAU;IAIjB,MAAM,CAAC,cAAc;CAGxB;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,QAAQ,CAAkC;IAElD,IAAI,CAAC,KAAK,EAAE,MAAM;IAIlB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAa1D,WAAW;;;IAIX,kBAAkB,CAAC,KAAK,GAAE,MAAW,GAAG,MAAM;IAe9C,KAAK;CAIR;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,YAAY,CAAgB;IAEpC,KAAK;IAML,OAAO;IAMP;;OAEG;IACH,UAAU,CAAC,UAAU,GAAE,MAAW,EAAE,SAAS,GAAE,MAAY,GAAG,OAAO;IAgBrE,SAAS;;;;;;IAiBT,KAAK;CAGR"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance monitoring for Virtualize
|
|
3
|
+
* Tracks render time, scroll performance, memory usage, etc.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Performance metrics collector
|
|
7
|
+
*/
|
|
8
|
+
export class MetricsCollector {
|
|
9
|
+
constructor() {
|
|
10
|
+
Object.defineProperty(this, "metrics", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: []
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "startTime", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "lastScrollTime", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "frameCount", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: 0
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "lastFPSTime", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: 0
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "isRecording", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: false
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
start() {
|
|
48
|
+
this.isRecording = true;
|
|
49
|
+
this.startTime = performance.now();
|
|
50
|
+
this.lastScrollTime = performance.now();
|
|
51
|
+
}
|
|
52
|
+
stop() {
|
|
53
|
+
this.isRecording = false;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Record a render cycle
|
|
57
|
+
*/
|
|
58
|
+
recordRender(itemsRendered, itemsMeasured, cacheSize) {
|
|
59
|
+
if (!this.isRecording)
|
|
60
|
+
return;
|
|
61
|
+
const renderTime = performance.now() - this.startTime;
|
|
62
|
+
const memoryUsed = performance.memory?.usedJSHeapSize || 0;
|
|
63
|
+
const metric = {
|
|
64
|
+
renderTime,
|
|
65
|
+
itemsRendered,
|
|
66
|
+
itemsMeasured,
|
|
67
|
+
scrollFPS: this.calculateFPS(),
|
|
68
|
+
scrollDelta: performance.now() - this.lastScrollTime,
|
|
69
|
+
memoryUsed,
|
|
70
|
+
cacheSize,
|
|
71
|
+
};
|
|
72
|
+
this.metrics.push(metric);
|
|
73
|
+
this.startTime = performance.now();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Record scroll event
|
|
77
|
+
*/
|
|
78
|
+
recordScroll() {
|
|
79
|
+
this.lastScrollTime = performance.now();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Calculate frames per second
|
|
83
|
+
*/
|
|
84
|
+
calculateFPS() {
|
|
85
|
+
const now = performance.now();
|
|
86
|
+
this.frameCount++;
|
|
87
|
+
if (now - this.lastFPSTime >= 1000) {
|
|
88
|
+
const fps = this.frameCount;
|
|
89
|
+
this.frameCount = 0;
|
|
90
|
+
this.lastFPSTime = now;
|
|
91
|
+
return fps;
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get average metrics
|
|
97
|
+
*/
|
|
98
|
+
getAverageMetrics() {
|
|
99
|
+
if (this.metrics.length === 0)
|
|
100
|
+
return {};
|
|
101
|
+
const avg = (key) => this.metrics.reduce((sum, m) => sum + m[key], 0) / this.metrics.length;
|
|
102
|
+
return {
|
|
103
|
+
renderTime: avg('renderTime'),
|
|
104
|
+
itemsRendered: avg('itemsRendered'),
|
|
105
|
+
itemsMeasured: avg('itemsMeasured'),
|
|
106
|
+
scrollFPS: avg('scrollFPS'),
|
|
107
|
+
scrollDelta: avg('scrollDelta'),
|
|
108
|
+
memoryUsed: avg('memoryUsed'),
|
|
109
|
+
cacheSize: avg('cacheSize'),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Check for performance issues
|
|
114
|
+
*/
|
|
115
|
+
checkWarnings() {
|
|
116
|
+
const avg = this.getAverageMetrics();
|
|
117
|
+
return {
|
|
118
|
+
slowRender: (avg.renderTime ?? 0) > 16.67,
|
|
119
|
+
lowFPS: (avg.scrollFPS ?? 60) < 50,
|
|
120
|
+
highMemory: (avg.memoryUsed ?? 0) > 50 * 1024 * 1024,
|
|
121
|
+
largeCache: (avg.cacheSize ?? 0) > 10000, // > 10k items cached
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get detailed report
|
|
126
|
+
*/
|
|
127
|
+
getReport() {
|
|
128
|
+
const avg = this.getAverageMetrics();
|
|
129
|
+
const warnings = this.checkWarnings();
|
|
130
|
+
return `
|
|
131
|
+
=== VIRTUALIZE PERFORMANCE REPORT ===
|
|
132
|
+
|
|
133
|
+
📊 METRICS:
|
|
134
|
+
• Render Time: ${(avg.renderTime ?? 0).toFixed(2)}ms
|
|
135
|
+
• Items Rendered: ${Math.round(avg.itemsRendered ?? 0)}
|
|
136
|
+
• Items Measured: ${Math.round(avg.itemsMeasured ?? 0)}
|
|
137
|
+
• Scroll FPS: ${Math.round(avg.scrollFPS ?? 0)}
|
|
138
|
+
• Memory Used: ${((avg.memoryUsed ?? 0) / 1024 / 1024).toFixed(2)}MB
|
|
139
|
+
• Cache Size: ${Math.round(avg.cacheSize ?? 0)}
|
|
140
|
+
|
|
141
|
+
⚠️ WARNINGS:
|
|
142
|
+
${warnings.slowRender ? '• ⚠️ SLOW RENDER: Render time exceeds 16.67ms (1 frame @ 60fps)' : ''}
|
|
143
|
+
${warnings.lowFPS ? '• ⚠️ LOW FPS: Scrolling performance below 50 FPS' : ''}
|
|
144
|
+
${warnings.highMemory ? '• ⚠️ HIGH MEMORY: Using more than 50MB of memory' : ''}
|
|
145
|
+
${warnings.largeCache ? '• ⚠️ LARGE CACHE: Cache size exceeds 10,000 items' : ''}
|
|
146
|
+
|
|
147
|
+
✅ STATUS: ${Object.values(warnings).some((w) => w) ? 'NEEDS OPTIMIZATION' : 'HEALTHY'}
|
|
148
|
+
`.trim();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Clear metrics
|
|
152
|
+
*/
|
|
153
|
+
clear() {
|
|
154
|
+
this.metrics = [];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* React hook for performance monitoring
|
|
159
|
+
*/
|
|
160
|
+
import React from 'react';
|
|
161
|
+
export function usePerformanceMonitoring(enabled = false) {
|
|
162
|
+
const collectorRef = React.useRef(new MetricsCollector());
|
|
163
|
+
React.useEffect(() => {
|
|
164
|
+
if (enabled) {
|
|
165
|
+
collectorRef.current.start();
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
collectorRef.current.stop();
|
|
169
|
+
}
|
|
170
|
+
}, [enabled]);
|
|
171
|
+
return {
|
|
172
|
+
recordRender: (rendered, measured, cacheSize) => collectorRef.current.recordRender(rendered, measured, cacheSize),
|
|
173
|
+
recordScroll: () => collectorRef.current.recordScroll(),
|
|
174
|
+
getMetrics: () => collectorRef.current.getAverageMetrics(),
|
|
175
|
+
getWarnings: () => collectorRef.current.checkWarnings(),
|
|
176
|
+
getReport: () => collectorRef.current.getReport(),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Browser DevTools integration
|
|
181
|
+
*/
|
|
182
|
+
export class VirtualizeDevTools {
|
|
183
|
+
static inject() {
|
|
184
|
+
if (typeof window !== 'undefined') {
|
|
185
|
+
window.__VIRTUALIZE_DEVTOOLS__ = {
|
|
186
|
+
version: '1.0.0',
|
|
187
|
+
metrics: new MetricsCollector(),
|
|
188
|
+
};
|
|
189
|
+
console.log('🎯 Virtualize DevTools injected. Access via window.__VIRTUALIZE_DEVTOOLS__');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
static getMetrics() {
|
|
193
|
+
return window.__VIRTUALIZE_DEVTOOLS__?.metrics.getAverageMetrics();
|
|
194
|
+
}
|
|
195
|
+
static generateReport() {
|
|
196
|
+
return window.__VIRTUALIZE_DEVTOOLS__?.metrics.getReport();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Performance profiler for detailed analysis
|
|
201
|
+
*/
|
|
202
|
+
export class PerformanceProfiler {
|
|
203
|
+
constructor() {
|
|
204
|
+
Object.defineProperty(this, "marks", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
configurable: true,
|
|
207
|
+
writable: true,
|
|
208
|
+
value: new Map()
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(this, "measures", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
configurable: true,
|
|
213
|
+
writable: true,
|
|
214
|
+
value: new Map()
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
mark(label) {
|
|
218
|
+
this.marks.set(label, performance.now());
|
|
219
|
+
}
|
|
220
|
+
measure(label, startMark, endMark) {
|
|
221
|
+
const start = this.marks.get(startMark);
|
|
222
|
+
const end = endMark ? this.marks.get(endMark) : performance.now();
|
|
223
|
+
if (start !== undefined && end !== undefined) {
|
|
224
|
+
const duration = end - start;
|
|
225
|
+
this.measures.set(label, duration);
|
|
226
|
+
return duration;
|
|
227
|
+
}
|
|
228
|
+
return 0;
|
|
229
|
+
}
|
|
230
|
+
getMeasures() {
|
|
231
|
+
return Object.fromEntries(this.measures);
|
|
232
|
+
}
|
|
233
|
+
generateFlameChart(width = 80) {
|
|
234
|
+
let chart = '═'.repeat(width) + '\n';
|
|
235
|
+
const maxDuration = Math.max(...this.measures.values(), 1);
|
|
236
|
+
for (const [label, duration] of this.measures) {
|
|
237
|
+
const barLength = Math.round((duration / maxDuration) * (width - 20));
|
|
238
|
+
const bar = '█'.repeat(Math.max(barLength, 1));
|
|
239
|
+
chart += `${label.padEnd(15)} ${bar} ${duration.toFixed(2)}ms\n`;
|
|
240
|
+
}
|
|
241
|
+
chart += '═'.repeat(width);
|
|
242
|
+
return chart;
|
|
243
|
+
}
|
|
244
|
+
clear() {
|
|
245
|
+
this.marks.clear();
|
|
246
|
+
this.measures.clear();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Memory leak detector
|
|
251
|
+
*/
|
|
252
|
+
export class MemoryLeakDetector {
|
|
253
|
+
constructor() {
|
|
254
|
+
Object.defineProperty(this, "initialMemory", {
|
|
255
|
+
enumerable: true,
|
|
256
|
+
configurable: true,
|
|
257
|
+
writable: true,
|
|
258
|
+
value: 0
|
|
259
|
+
});
|
|
260
|
+
Object.defineProperty(this, "measurements", {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
configurable: true,
|
|
263
|
+
writable: true,
|
|
264
|
+
value: []
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
start() {
|
|
268
|
+
if (performance.memory) {
|
|
269
|
+
this.initialMemory = performance.memory.usedJSHeapSize;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
measure() {
|
|
273
|
+
if (performance.memory) {
|
|
274
|
+
this.measurements.push(performance.memory.usedJSHeapSize);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Detect if memory is continuously growing (potential leak)
|
|
279
|
+
*/
|
|
280
|
+
detectLeak(sampleSize = 10, threshold = 0.8) {
|
|
281
|
+
if (this.measurements.length < sampleSize)
|
|
282
|
+
return false;
|
|
283
|
+
const recentMeasurements = this.measurements.slice(-sampleSize);
|
|
284
|
+
let increasingTrend = 0;
|
|
285
|
+
for (let i = 1; i < recentMeasurements.length; i++) {
|
|
286
|
+
if (recentMeasurements[i] > recentMeasurements[i - 1]) {
|
|
287
|
+
increasingTrend++;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const increasingRatio = increasingTrend / (sampleSize - 1);
|
|
291
|
+
return increasingRatio > threshold;
|
|
292
|
+
}
|
|
293
|
+
getReport() {
|
|
294
|
+
const initialMB = (this.initialMemory / 1024 / 1024).toFixed(2);
|
|
295
|
+
const currentMB = (this.measurements[this.measurements.length - 1] /
|
|
296
|
+
1024 /
|
|
297
|
+
1024).toFixed(2);
|
|
298
|
+
const hasLeak = this.detectLeak();
|
|
299
|
+
return {
|
|
300
|
+
initialMemory: `${initialMB}MB`,
|
|
301
|
+
currentMemory: `${currentMB}MB`,
|
|
302
|
+
trend: hasLeak ? '📈 INCREASING' : '📉 STABLE',
|
|
303
|
+
potentialLeak: hasLeak,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
clear() {
|
|
307
|
+
this.measurements = [];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AAC,WAAW;YAC9C,aAAa,EAAE,OAAO;SACzB,CAAC;IACN,CAAC;IAED,KAAK;QACD,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IAC3B,CAAC;CACJ"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
export interface VirtualizePlugin {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
hooks?: {
|
|
5
|
+
beforeRender?: (items: any[]) => any[];
|
|
6
|
+
afterRender?: (elements: HTMLElement[]) => void;
|
|
7
|
+
onScroll?: (offset: number) => void;
|
|
8
|
+
onMeasurement?: (index: number, size: number) => void;
|
|
9
|
+
};
|
|
10
|
+
methods?: Record<string, (...args: any[]) => any>;
|
|
11
|
+
}
|
|
12
|
+
export declare class PluginManager {
|
|
13
|
+
private plugins;
|
|
14
|
+
/**
|
|
15
|
+
* Register a plugin
|
|
16
|
+
*/
|
|
17
|
+
register(plugin: VirtualizePlugin): void;
|
|
18
|
+
/**
|
|
19
|
+
* Unregister a plugin
|
|
20
|
+
*/
|
|
21
|
+
unregister(name: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get registered plugins
|
|
24
|
+
*/
|
|
25
|
+
getPlugins(): VirtualizePlugin[];
|
|
26
|
+
/**
|
|
27
|
+
* Call plugin hook
|
|
28
|
+
*/
|
|
29
|
+
callHook(hookName: keyof NonNullable<VirtualizePlugin['hooks']>, ...args: any[]): Promise<any[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Call plugin method
|
|
32
|
+
*/
|
|
33
|
+
callMethod(pluginName: string, methodName: string, ...args: any[]): any;
|
|
34
|
+
}
|
|
35
|
+
export declare enum LayoutType {
|
|
36
|
+
LIST = "list",
|
|
37
|
+
GRID = "grid",
|
|
38
|
+
MASONRY = "masonry",
|
|
39
|
+
WATERFALL = "waterfall",
|
|
40
|
+
FEED = "feed",
|
|
41
|
+
TIMELINE = "timeline"
|
|
42
|
+
}
|
|
43
|
+
export interface LayoutConfig {
|
|
44
|
+
type: LayoutType;
|
|
45
|
+
columnCount?: number;
|
|
46
|
+
gapSize?: number;
|
|
47
|
+
itemAspectRatio?: number;
|
|
48
|
+
maxWidth?: number;
|
|
49
|
+
minItemSize?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Waterfall Layout - Multi-column layout with items filling shortest column
|
|
53
|
+
* Perfect for: Image galleries, product showcases
|
|
54
|
+
*/
|
|
55
|
+
export declare class WaterfallLayout {
|
|
56
|
+
private columns;
|
|
57
|
+
private gapSize;
|
|
58
|
+
private columnHeights;
|
|
59
|
+
constructor(columns: number, gapSize?: number);
|
|
60
|
+
/**
|
|
61
|
+
* Get position for item
|
|
62
|
+
*/
|
|
63
|
+
getItemPosition(_: number, itemHeight: number, width: number): {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
column: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Get total height needed
|
|
70
|
+
*/
|
|
71
|
+
getTotalHeight(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Reset layout
|
|
74
|
+
*/
|
|
75
|
+
reset(): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Feed Layout - Social media feed style (variable width, full-width items)
|
|
79
|
+
* Perfect for: Social feeds, blogs, news
|
|
80
|
+
*/
|
|
81
|
+
export declare class FeedLayout {
|
|
82
|
+
private itemHeights;
|
|
83
|
+
private itemOffsets;
|
|
84
|
+
private totalHeight;
|
|
85
|
+
/**
|
|
86
|
+
* Record item height
|
|
87
|
+
*/
|
|
88
|
+
recordItemHeight(index: number, height: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get item offset and height
|
|
91
|
+
*/
|
|
92
|
+
getItemDimensions(index: number): {
|
|
93
|
+
offset: number;
|
|
94
|
+
height: number;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Update all offsets
|
|
98
|
+
*/
|
|
99
|
+
private updateOffsets;
|
|
100
|
+
/**
|
|
101
|
+
* Get total height
|
|
102
|
+
*/
|
|
103
|
+
getTotalHeight(): number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Vue 3 Adapter
|
|
107
|
+
*/
|
|
108
|
+
export declare const createVueVirtualList: () => {
|
|
109
|
+
name: string;
|
|
110
|
+
template: string;
|
|
111
|
+
props: {
|
|
112
|
+
items: ArrayConstructor;
|
|
113
|
+
height: {
|
|
114
|
+
type: NumberConstructor;
|
|
115
|
+
default: number;
|
|
116
|
+
};
|
|
117
|
+
width: {
|
|
118
|
+
type: NumberConstructor;
|
|
119
|
+
default: number;
|
|
120
|
+
};
|
|
121
|
+
estimatedItemSize: {
|
|
122
|
+
type: NumberConstructor;
|
|
123
|
+
default: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Svelte Component
|
|
129
|
+
*/
|
|
130
|
+
export declare const SvelteVirtualList = "\n<script>\n import { useVirtualList } from 'virtualize';\n\n export let items = [];\n export let height = 400;\n export let width = 300;\n export let estimatedItemSize = 50;\n\n let containerRef;\n const { virtualItems, getItemStyle } = useVirtualList({\n items,\n containerHeight: height,\n estimatedItemSize,\n });\n</script>\n\n<div\n bind:this={containerRef}\n class=\"virtualize-container\"\n style=\"height: {height}px; width: {width}px; overflow: auto;\"\n>\n {#each $virtualItems as virtualItem (virtualItem.key)}\n <div style={getItemStyle(virtualItem.index, virtualItem.size)}>\n <slot item={virtualItem.data} index={virtualItem.index} />\n </div>\n {/each}\n</div>\n\n<style>\n .virtualize-container {\n position: relative;\n border: 1px solid #ccc;\n }\n</style>\n";
|
|
131
|
+
export interface AnalyticsEvent {
|
|
132
|
+
type: string;
|
|
133
|
+
timestamp: number;
|
|
134
|
+
data: any;
|
|
135
|
+
}
|
|
136
|
+
export declare class AdvancedAnalytics {
|
|
137
|
+
private events;
|
|
138
|
+
private sessionStart;
|
|
139
|
+
private maxEvents;
|
|
140
|
+
/**
|
|
141
|
+
* Track event
|
|
142
|
+
*/
|
|
143
|
+
trackEvent(type: string, data: any): void;
|
|
144
|
+
/**
|
|
145
|
+
* Get session duration
|
|
146
|
+
*/
|
|
147
|
+
getSessionDuration(): number;
|
|
148
|
+
/**
|
|
149
|
+
* Get analytics report
|
|
150
|
+
*/
|
|
151
|
+
getReport(): {
|
|
152
|
+
sessionDuration: number;
|
|
153
|
+
totalEvents: number;
|
|
154
|
+
eventBreakdown: Record<string, number>;
|
|
155
|
+
timeline: AnalyticsEvent[];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Get event breakdown
|
|
159
|
+
*/
|
|
160
|
+
private getEventBreakdown;
|
|
161
|
+
/**
|
|
162
|
+
* Send analytics to server
|
|
163
|
+
*/
|
|
164
|
+
sendAnalytics(endpoint: string): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Export analytics as CSV
|
|
167
|
+
*/
|
|
168
|
+
exportAsCSV(): string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Example: Analytics Plugin
|
|
172
|
+
*/
|
|
173
|
+
export declare const AnalyticsPlugin: VirtualizePlugin;
|
|
174
|
+
/**
|
|
175
|
+
* Example: Logger Plugin
|
|
176
|
+
*/
|
|
177
|
+
export declare const LoggerPlugin: VirtualizePlugin;
|
|
178
|
+
/**
|
|
179
|
+
* Example: Custom Plugin
|
|
180
|
+
*/
|
|
181
|
+
export declare function createCustomPlugin(options: any): VirtualizePlugin;
|
|
182
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACJ,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE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