@nice2dev/ui-core 1.0.10
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 +63 -0
- package/README.md +62 -0
- package/dist/core/NiceInlineHelp.d.ts +69 -0
- package/dist/core/NiceInlineHelp.d.ts.map +1 -0
- package/dist/core/NiceThemeProvider.d.ts +31 -0
- package/dist/core/NiceThemeProvider.d.ts.map +1 -0
- package/dist/core/NiceThemeVariants.d.ts +55 -0
- package/dist/core/NiceThemeVariants.d.ts.map +1 -0
- package/dist/core/NiceUserPreferences.d.ts +304 -0
- package/dist/core/NiceUserPreferences.d.ts.map +1 -0
- package/dist/core/a11y-advanced.d.ts +157 -0
- package/dist/core/a11y-advanced.d.ts.map +1 -0
- package/dist/core/a11y.d.ts +299 -0
- package/dist/core/a11y.d.ts.map +1 -0
- package/dist/core/access-control.d.ts +59 -0
- package/dist/core/access-control.d.ts.map +1 -0
- package/dist/core/adapters.d.ts +178 -0
- package/dist/core/adapters.d.ts.map +1 -0
- package/dist/core/ai.d.ts +191 -0
- package/dist/core/ai.d.ts.map +1 -0
- package/dist/core/animations.d.ts +48 -0
- package/dist/core/animations.d.ts.map +1 -0
- package/dist/core/colorBlind.d.ts +22 -0
- package/dist/core/colorBlind.d.ts.map +1 -0
- package/dist/core/datasource-advanced.d.ts +261 -0
- package/dist/core/datasource-advanced.d.ts.map +1 -0
- package/dist/core/datasource-aggregation.d.ts +221 -0
- package/dist/core/datasource-aggregation.d.ts.map +1 -0
- package/dist/core/datasource-hooks.d.ts +93 -0
- package/dist/core/datasource-hooks.d.ts.map +1 -0
- package/dist/core/datasource-offline.d.ts +201 -0
- package/dist/core/datasource-offline.d.ts.map +1 -0
- package/dist/core/datasource.d.ts +181 -0
- package/dist/core/datasource.d.ts.map +1 -0
- package/dist/core/displayMode.d.ts +46 -0
- package/dist/core/displayMode.d.ts.map +1 -0
- package/dist/core/displayStyle.d.ts +79 -0
- package/dist/core/displayStyle.d.ts.map +1 -0
- package/dist/core/helpContext.d.ts +97 -0
- package/dist/core/helpContext.d.ts.map +1 -0
- package/dist/core/hooks.d.ts +149 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +10 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/i18nDictionaries.d.ts +4 -0
- package/dist/core/i18nDictionaries.d.ts.map +1 -0
- package/dist/core/icons.d.ts +45 -0
- package/dist/core/icons.d.ts.map +1 -0
- package/dist/core/icuMessageFormat.d.ts +10 -0
- package/dist/core/icuMessageFormat.d.ts.map +1 -0
- package/dist/core/leak-detector.d.ts +263 -0
- package/dist/core/leak-detector.d.ts.map +1 -0
- package/dist/core/omniverkTypes.d.ts +164 -0
- package/dist/core/omniverkTypes.d.ts.map +1 -0
- package/dist/core/pluginSystem.d.ts +97 -0
- package/dist/core/pluginSystem.d.ts.map +1 -0
- package/dist/core/profiling.d.ts +276 -0
- package/dist/core/profiling.d.ts.map +1 -0
- package/dist/core/responsive.d.ts +107 -0
- package/dist/core/responsive.d.ts.map +1 -0
- package/dist/core/rtl.d.ts +47 -0
- package/dist/core/rtl.d.ts.map +1 -0
- package/dist/core/sanitizeHtml.d.ts +16 -0
- package/dist/core/sanitizeHtml.d.ts.map +1 -0
- package/dist/core/testing.d.ts +107 -0
- package/dist/core/testing.d.ts.map +1 -0
- package/dist/core/theme.d.ts +213 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/themeGallery.d.ts +104 -0
- package/dist/core/themeGallery.d.ts.map +1 -0
- package/dist/core/themePacks.d.ts +53 -0
- package/dist/core/themePacks.d.ts.map +1 -0
- package/dist/core/themePacksExtended.d.ts +59 -0
- package/dist/core/themePacksExtended.d.ts.map +1 -0
- package/dist/core/themePresets.d.ts +10 -0
- package/dist/core/themePresets.d.ts.map +1 -0
- package/dist/core/themeVariants.d.ts +204 -0
- package/dist/core/themeVariants.d.ts.map +1 -0
- package/dist/core/touch.d.ts +208 -0
- package/dist/core/touch.d.ts.map +1 -0
- package/dist/core/traceless.d.ts +461 -0
- package/dist/core/traceless.d.ts.map +1 -0
- package/dist/core/types.d.ts +105 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/useThemeIsDark.d.ts +15 -0
- package/dist/core/useThemeIsDark.d.ts.map +1 -0
- package/dist/index.cjs +128 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +16881 -0
- package/dist/index.mjs.map +1 -0
- package/dist/performance/concurrent.d.ts +190 -0
- package/dist/performance/concurrent.d.ts.map +1 -0
- package/dist/performance/images.d.ts +189 -0
- package/dist/performance/images.d.ts.map +1 -0
- package/dist/performance/index.d.ts +17 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/memory.d.ts +223 -0
- package/dist/performance/memory.d.ts.map +1 -0
- package/dist/performance/virtualization.d.ts +166 -0
- package/dist/performance/virtualization.d.ts.map +1 -0
- package/dist/performance/workers.d.ts +125 -0
- package/dist/performance/workers.d.ts.map +1 -0
- package/dist/viewSchema.d.ts +81 -0
- package/dist/viewSchema.d.ts.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file concurrent.ts
|
|
3
|
+
* @description Nice2Dev Performance — Concurrent Rendering Utilities
|
|
4
|
+
*
|
|
5
|
+
* React 18+ concurrent rendering optimizations.
|
|
6
|
+
* Uses useTransition, useDeferredValue for responsive UIs.
|
|
7
|
+
*/
|
|
8
|
+
export interface DeferredSearchConfig<T> {
|
|
9
|
+
/** Items to search through */
|
|
10
|
+
items: T[];
|
|
11
|
+
/** Search function */
|
|
12
|
+
searchFn: (item: T, query: string) => boolean;
|
|
13
|
+
/** Debounce time in ms */
|
|
14
|
+
debounce?: number;
|
|
15
|
+
/** Minimum query length to trigger search */
|
|
16
|
+
minLength?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TransitionState<T> {
|
|
19
|
+
/** Current stable value */
|
|
20
|
+
value: T;
|
|
21
|
+
/** Pending value (during transition) */
|
|
22
|
+
pendingValue: T;
|
|
23
|
+
/** Is transition in progress */
|
|
24
|
+
isPending: boolean;
|
|
25
|
+
/** Update value with transition */
|
|
26
|
+
setValue: (value: T | ((prev: T) => T)) => void;
|
|
27
|
+
/** Update value immediately */
|
|
28
|
+
setValueImmediate: (value: T | ((prev: T) => T)) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface ChunkedProcessorConfig<T, R> {
|
|
31
|
+
/** Items to process */
|
|
32
|
+
data: T[];
|
|
33
|
+
/** Processing function */
|
|
34
|
+
processFn: (item: T, index: number) => R;
|
|
35
|
+
/** Chunk size (items per frame) */
|
|
36
|
+
chunkSize?: number;
|
|
37
|
+
/** Priority (user-blocking, user-visible, background) */
|
|
38
|
+
priority?: 'user-blocking' | 'user-visible' | 'background';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Search with deferred value for responsive UI
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* function SearchableList({ items }) {
|
|
46
|
+
* const { query, setQuery, results, isStale } = useDeferredSearch({
|
|
47
|
+
* items,
|
|
48
|
+
* searchFn: (item, q) => item.name.toLowerCase().includes(q.toLowerCase()),
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* return (
|
|
52
|
+
* <>
|
|
53
|
+
* <input value={query} onChange={e => setQuery(e.target.value)} />
|
|
54
|
+
* <div style={{ opacity: isStale ? 0.7 : 1 }}>
|
|
55
|
+
* {results.map(item => <div key={item.id}>{item.name}</div>)}
|
|
56
|
+
* </div>
|
|
57
|
+
* </>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function useDeferredSearch<T>(config: DeferredSearchConfig<T>): {
|
|
63
|
+
query: string;
|
|
64
|
+
setQuery: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
65
|
+
results: T[];
|
|
66
|
+
isStale: boolean;
|
|
67
|
+
deferredQuery: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* State with useTransition for non-blocking updates
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* function Tab({ content }) {
|
|
75
|
+
* const { value, setValue, isPending } = useTransitionState(0);
|
|
76
|
+
*
|
|
77
|
+
* return (
|
|
78
|
+
* <>
|
|
79
|
+
* <nav>
|
|
80
|
+
* {tabs.map((tab, i) => (
|
|
81
|
+
* <button key={i} onClick={() => setValue(i)}>
|
|
82
|
+
* {tab.title}
|
|
83
|
+
* </button>
|
|
84
|
+
* ))}
|
|
85
|
+
* </nav>
|
|
86
|
+
* {isPending && <Spinner />}
|
|
87
|
+
* <TabPanel index={value} />
|
|
88
|
+
* </>
|
|
89
|
+
* );
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function useTransitionState<T>(initialValue: T): TransitionState<T>;
|
|
94
|
+
/**
|
|
95
|
+
* Process large arrays in chunks to keep UI responsive
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* function DataProcessor({ data }) {
|
|
100
|
+
* const { result, progress, isProcessing } = useChunkedProcessor({
|
|
101
|
+
* data,
|
|
102
|
+
* processFn: (item) => complexTransform(item),
|
|
103
|
+
* chunkSize: 1000,
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* return (
|
|
107
|
+
* <div>
|
|
108
|
+
* {isProcessing && <ProgressBar value={progress} />}
|
|
109
|
+
* {result && <DataView data={result} />}
|
|
110
|
+
* </div>
|
|
111
|
+
* );
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function useChunkedProcessor<T, R>(config: ChunkedProcessorConfig<T, R>): {
|
|
116
|
+
result: R[] | null;
|
|
117
|
+
progress: number;
|
|
118
|
+
isProcessing: boolean;
|
|
119
|
+
process: () => Promise<void>;
|
|
120
|
+
cancel: () => void;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* List that renders items progressively for fast initial display
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* function LargeList({ items }) {
|
|
128
|
+
* const { visibleItems, isComplete } = useDeferredList(items, {
|
|
129
|
+
* initialCount: 20,
|
|
130
|
+
* batchSize: 50,
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* return (
|
|
134
|
+
* <ul>
|
|
135
|
+
* {visibleItems.map(item => <li key={item.id}>{item.name}</li>)}
|
|
136
|
+
* {!isComplete && <li>Loading more...</li>}
|
|
137
|
+
* </ul>
|
|
138
|
+
* );
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export declare function useDeferredList<T>(items: T[], options?: {
|
|
143
|
+
/** Initial items to render */
|
|
144
|
+
initialCount?: number;
|
|
145
|
+
/** Items to add per batch */
|
|
146
|
+
batchSize?: number;
|
|
147
|
+
/** Delay between batches */
|
|
148
|
+
batchDelay?: number;
|
|
149
|
+
}): {
|
|
150
|
+
visibleItems: T[];
|
|
151
|
+
visibleCount: number;
|
|
152
|
+
totalCount: number;
|
|
153
|
+
isComplete: boolean;
|
|
154
|
+
progress: number;
|
|
155
|
+
};
|
|
156
|
+
export interface OptimisticConfig<T> {
|
|
157
|
+
/** Initial value */
|
|
158
|
+
initial: T;
|
|
159
|
+
/** Async mutation function */
|
|
160
|
+
mutate: (value: T) => Promise<T>;
|
|
161
|
+
/** Rollback on error */
|
|
162
|
+
rollbackOnError?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Optimistic UI updates with automatic rollback
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```tsx
|
|
169
|
+
* function LikeButton({ postId, initialLikes }) {
|
|
170
|
+
* const { value, update, isPending, error } = useOptimistic({
|
|
171
|
+
* initial: initialLikes,
|
|
172
|
+
* mutate: (likes) => api.updateLikes(postId, likes),
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* return (
|
|
176
|
+
* <button onClick={() => update(value + 1)}>
|
|
177
|
+
* ❤️ {value} {isPending && '...'}
|
|
178
|
+
* </button>
|
|
179
|
+
* );
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function useOptimistic<T>(config: OptimisticConfig<T>): {
|
|
184
|
+
value: T;
|
|
185
|
+
update: (newValue: T) => Promise<void>;
|
|
186
|
+
isPending: boolean;
|
|
187
|
+
error: Error | null;
|
|
188
|
+
reset: () => void;
|
|
189
|
+
};
|
|
190
|
+
//# sourceMappingURL=concurrent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrent.d.ts","sourceRoot":"","sources":["../../src/performance/concurrent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,8BAA8B;IAC9B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,sBAAsB;IACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,2BAA2B;IAC3B,KAAK,EAAE,CAAC,CAAC;IACT,wCAAwC;IACxC,YAAY,EAAE,CAAC,CAAC;IAChB,gCAAgC;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,mCAAmC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;IAChD,+BAA+B;IA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,CAAC,CAAC;IACX,8BAA8B;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACjC,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;;uBASvC,CAAC;;;;EAoCrB"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file images.ts
|
|
3
|
+
* @description Nice2Dev Performance — Image Optimization Utilities
|
|
4
|
+
*
|
|
5
|
+
* Lazy loading, progressive rendering, responsive images, and format detection.
|
|
6
|
+
*/
|
|
7
|
+
export interface ImageFormat {
|
|
8
|
+
format: 'avif' | 'webp' | 'jpg' | 'png' | 'gif';
|
|
9
|
+
mimeType: string;
|
|
10
|
+
supported: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ResponsiveImageSource {
|
|
13
|
+
src: string;
|
|
14
|
+
width: number;
|
|
15
|
+
format?: ImageFormat['format'];
|
|
16
|
+
}
|
|
17
|
+
export interface ProgressiveImageState {
|
|
18
|
+
/** Current displayed source */
|
|
19
|
+
currentSrc: string | null;
|
|
20
|
+
/** Thumbnail/LQIP source */
|
|
21
|
+
thumbnailSrc: string | null;
|
|
22
|
+
/** Full-res source */
|
|
23
|
+
fullSrc: string;
|
|
24
|
+
/** Loading stage: 'idle' | 'thumbnail' | 'loading' | 'loaded' | 'error' */
|
|
25
|
+
stage: 'idle' | 'thumbnail' | 'loading' | 'loaded' | 'error';
|
|
26
|
+
/** Is fully loaded */
|
|
27
|
+
isLoaded: boolean;
|
|
28
|
+
/** Is in viewport */
|
|
29
|
+
isInView: boolean;
|
|
30
|
+
/** Error if any */
|
|
31
|
+
error: Error | null;
|
|
32
|
+
}
|
|
33
|
+
export interface LazyImageConfig {
|
|
34
|
+
/** Intersection Observer root margin */
|
|
35
|
+
rootMargin?: string;
|
|
36
|
+
/** Intersection Observer threshold */
|
|
37
|
+
threshold?: number;
|
|
38
|
+
/** Enable progressive loading */
|
|
39
|
+
progressive?: boolean;
|
|
40
|
+
/** Low-quality image placeholder src */
|
|
41
|
+
lqip?: string;
|
|
42
|
+
/** Blur amount for LQIP (in px) */
|
|
43
|
+
blurRadius?: number;
|
|
44
|
+
/** Delay before loading (for prioritization) */
|
|
45
|
+
delay?: number;
|
|
46
|
+
/** Priority: 'high' | 'low' | 'auto' */
|
|
47
|
+
priority?: 'high' | 'low' | 'auto';
|
|
48
|
+
/** Callback when loaded */
|
|
49
|
+
onLoad?: () => void;
|
|
50
|
+
/** Callback on error */
|
|
51
|
+
onError?: (error: Error) => void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if browser supports a specific image format
|
|
55
|
+
*/
|
|
56
|
+
export declare function checkFormatSupport(format: 'avif' | 'webp'): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Hook to get supported image formats
|
|
59
|
+
*/
|
|
60
|
+
export declare function useImageFormats(): {
|
|
61
|
+
formats: Record<string, boolean>;
|
|
62
|
+
isChecking: boolean;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Generate srcset string from sources
|
|
66
|
+
*/
|
|
67
|
+
export declare function generateSrcset(sources: ResponsiveImageSource[]): string;
|
|
68
|
+
/**
|
|
69
|
+
* Generate sizes attribute for responsive images
|
|
70
|
+
*/
|
|
71
|
+
export declare function generateSizes(breakpoints: {
|
|
72
|
+
maxWidth: number;
|
|
73
|
+
size: string;
|
|
74
|
+
}[], defaultSize: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Select optimal image source based on viewport and DPR
|
|
77
|
+
*/
|
|
78
|
+
export declare function selectOptimalSource(sources: ResponsiveImageSource[], containerWidth: number, dpr?: number): ResponsiveImageSource;
|
|
79
|
+
/**
|
|
80
|
+
* Hook for progressive image loading (blur-up technique)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* function ProgressiveImage({ src, lqip, alt }) {
|
|
85
|
+
* const { currentSrc, stage, style, ref } = useProgressiveImage({
|
|
86
|
+
* src,
|
|
87
|
+
* lqip,
|
|
88
|
+
* blurRadius: 20,
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* return (
|
|
92
|
+
* <img
|
|
93
|
+
* ref={ref}
|
|
94
|
+
* src={currentSrc}
|
|
95
|
+
* alt={alt}
|
|
96
|
+
* style={style}
|
|
97
|
+
* />
|
|
98
|
+
* );
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function useProgressiveImage(config: LazyImageConfig & {
|
|
103
|
+
src: string;
|
|
104
|
+
}): {
|
|
105
|
+
style: import("react").CSSProperties;
|
|
106
|
+
/** Current displayed source */
|
|
107
|
+
currentSrc: string | null;
|
|
108
|
+
/** Thumbnail/LQIP source */
|
|
109
|
+
thumbnailSrc: string | null;
|
|
110
|
+
/** Full-res source */
|
|
111
|
+
fullSrc: string;
|
|
112
|
+
/** Loading stage: 'idle' | 'thumbnail' | 'loading' | 'loaded' | 'error' */
|
|
113
|
+
stage: "idle" | "thumbnail" | "loading" | "loaded" | "error";
|
|
114
|
+
/** Is fully loaded */
|
|
115
|
+
isLoaded: boolean;
|
|
116
|
+
/** Is in viewport */
|
|
117
|
+
isInView: boolean;
|
|
118
|
+
/** Error if any */
|
|
119
|
+
error: Error | null;
|
|
120
|
+
ref: import("react").RefObject<HTMLImageElement>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Preload images in the background
|
|
124
|
+
*/
|
|
125
|
+
export declare function preloadImages(urls: string[]): Promise<void[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Hook for preloading images on mount
|
|
128
|
+
*/
|
|
129
|
+
export declare function useImagePreload(urls: string[]): {
|
|
130
|
+
loaded: number;
|
|
131
|
+
total: number;
|
|
132
|
+
isComplete: boolean;
|
|
133
|
+
errors: string[];
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Load and decode image off main thread
|
|
137
|
+
*/
|
|
138
|
+
export declare function loadAndDecodeImage(src: string): Promise<HTMLImageElement>;
|
|
139
|
+
/**
|
|
140
|
+
* Hook that loads and decodes image before rendering
|
|
141
|
+
*/
|
|
142
|
+
export declare function useDecodedImage(src: string | null): {
|
|
143
|
+
image: HTMLImageElement | null;
|
|
144
|
+
isLoading: boolean;
|
|
145
|
+
error: Error | null;
|
|
146
|
+
};
|
|
147
|
+
type LazyLoadCallback = (entry: IntersectionObserverEntry) => void;
|
|
148
|
+
/**
|
|
149
|
+
* Shared IntersectionObserver for multiple images
|
|
150
|
+
* Reduces overhead compared to one observer per image
|
|
151
|
+
*/
|
|
152
|
+
export declare function createImageObserver(options?: IntersectionObserverInit): {
|
|
153
|
+
observe: (element: Element, callback: LazyLoadCallback) => void;
|
|
154
|
+
unobserve: (element: Element) => void;
|
|
155
|
+
disconnect: () => void;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Hook for using shared image observer
|
|
159
|
+
*/
|
|
160
|
+
export declare function useSharedImageObserver(observer: ReturnType<typeof createImageObserver>, onIntersect: () => void): {
|
|
161
|
+
ref: import("react").RefObject<HTMLImageElement>;
|
|
162
|
+
isInView: boolean;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Generate a solid color placeholder as data URI
|
|
166
|
+
*/
|
|
167
|
+
export declare function generateColorPlaceholder(color: string, width?: number, height?: number): string;
|
|
168
|
+
/**
|
|
169
|
+
* Generate a gradient placeholder as data URI
|
|
170
|
+
*/
|
|
171
|
+
export declare function generateGradientPlaceholder(colors: [string, string], direction?: 'horizontal' | 'vertical', width?: number, height?: number): string;
|
|
172
|
+
export declare const ImageOptimization: {
|
|
173
|
+
checkFormatSupport: typeof checkFormatSupport;
|
|
174
|
+
useImageFormats: typeof useImageFormats;
|
|
175
|
+
generateSrcset: typeof generateSrcset;
|
|
176
|
+
generateSizes: typeof generateSizes;
|
|
177
|
+
selectOptimalSource: typeof selectOptimalSource;
|
|
178
|
+
useProgressiveImage: typeof useProgressiveImage;
|
|
179
|
+
preloadImages: typeof preloadImages;
|
|
180
|
+
useImagePreload: typeof useImagePreload;
|
|
181
|
+
loadAndDecodeImage: typeof loadAndDecodeImage;
|
|
182
|
+
useDecodedImage: typeof useDecodedImage;
|
|
183
|
+
createImageObserver: typeof createImageObserver;
|
|
184
|
+
useSharedImageObserver: typeof useSharedImageObserver;
|
|
185
|
+
generateColorPlaceholder: typeof generateColorPlaceholder;
|
|
186
|
+
generateGradientPlaceholder: typeof generateGradientPlaceholder;
|
|
187
|
+
};
|
|
188
|
+
export {};
|
|
189
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/performance/images.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4BAA4B;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC7D,sBAAsB;IACt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D,WAAW,EAAE,MAAM,IAAI;;;EAuBxB;AAMD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,EAAE,MAAM,SAAK,GAAG,MAAM,CAGvF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,SAAS,GAAE,YAAY,GAAG,UAAuB,EACjD,KAAK,SAAK,EACV,MAAM,SAAK,GACV,MAAM,CAgBR;AAMD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;CAsB7B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @description Nice2Dev Performance — Core Utilities
|
|
4
|
+
*
|
|
5
|
+
* High-performance utilities for React applications:
|
|
6
|
+
* - Virtualization for 500k+ rows
|
|
7
|
+
* - Concurrent rendering with React 18+
|
|
8
|
+
* - Web Worker offloading
|
|
9
|
+
* - Memory optimization (WeakMap caches, cleanup)
|
|
10
|
+
* - Image lazy loading & progressive rendering
|
|
11
|
+
*/
|
|
12
|
+
export * from './virtualization';
|
|
13
|
+
export * from './concurrent';
|
|
14
|
+
export * from './workers';
|
|
15
|
+
export * from './memory';
|
|
16
|
+
export * from './images';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/performance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file memory.ts
|
|
3
|
+
* @description Nice2Dev Performance — Memory Optimization Utilities
|
|
4
|
+
*
|
|
5
|
+
* Memory-efficient caching, automatic cleanup, and monitoring.
|
|
6
|
+
*/
|
|
7
|
+
export interface WeakCacheOptions<K extends object> {
|
|
8
|
+
/** Maximum cache size (for LRU eviction on fallback) */
|
|
9
|
+
maxSize?: number;
|
|
10
|
+
/** TTL in milliseconds (optional) */
|
|
11
|
+
ttl?: number;
|
|
12
|
+
/** Key extractor function */
|
|
13
|
+
getKey?: (key: K) => string;
|
|
14
|
+
}
|
|
15
|
+
export interface MemoryStats {
|
|
16
|
+
/** JS heap size limit */
|
|
17
|
+
jsHeapSizeLimit: number;
|
|
18
|
+
/** Total JS heap size */
|
|
19
|
+
totalJSHeapSize: number;
|
|
20
|
+
/** Used JS heap size */
|
|
21
|
+
usedJSHeapSize: number;
|
|
22
|
+
/** Used heap percentage */
|
|
23
|
+
usedPercent: number;
|
|
24
|
+
/** Is available */
|
|
25
|
+
isSupported: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface EventCleanup {
|
|
28
|
+
/** Add event listener with automatic cleanup */
|
|
29
|
+
add: <K extends keyof WindowEventMap>(target: EventTarget, event: K | string, handler: EventListener, options?: AddEventListenerOptions) => void;
|
|
30
|
+
/** Remove all registered listeners */
|
|
31
|
+
removeAll: () => void;
|
|
32
|
+
/** Get count of active listeners */
|
|
33
|
+
count: () => number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* WeakMap-based cache that automatically releases memory
|
|
37
|
+
* when keys are garbage collected.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const userCache = createWeakCache<User, UserProfile>();
|
|
42
|
+
*
|
|
43
|
+
* function UserCard({ user }) {
|
|
44
|
+
* let profile = userCache.get(user);
|
|
45
|
+
*
|
|
46
|
+
* if (!profile) {
|
|
47
|
+
* profile = computeExpensiveProfile(user);
|
|
48
|
+
* userCache.set(user, profile);
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* return <div>{profile.name}</div>;
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function createWeakCache<K extends object, V>(): {
|
|
56
|
+
get: (key: K) => V | undefined;
|
|
57
|
+
set: (key: K, value: V) => void;
|
|
58
|
+
has: (key: K) => boolean;
|
|
59
|
+
delete: (key: K) => boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* LRU cache with optional TTL and WeakRef for values
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const imageCache = createLRUCache<string, ImageBitmap>({
|
|
67
|
+
* maxSize: 100,
|
|
68
|
+
* ttl: 60000, // 1 minute
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function createLRUCache<K, V>(options?: {
|
|
73
|
+
maxSize?: number;
|
|
74
|
+
ttl?: number;
|
|
75
|
+
}): {
|
|
76
|
+
get: (key: K) => V | undefined;
|
|
77
|
+
set: (key: K, value: V) => void;
|
|
78
|
+
has: (key: K) => boolean;
|
|
79
|
+
delete: (key: K) => boolean;
|
|
80
|
+
clear: () => void;
|
|
81
|
+
size: () => number;
|
|
82
|
+
keys: () => K[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Cache using WeakRef for values - allows GC to collect unused values
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* const componentCache = createWeakRefCache<string, React.ComponentType>();
|
|
90
|
+
*
|
|
91
|
+
* // Values can be garbage collected when no other references exist
|
|
92
|
+
* componentCache.set('MyComponent', MyComponent);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function createWeakRefCache<K, V extends object>(): {
|
|
96
|
+
get: (key: K) => V | undefined;
|
|
97
|
+
set: (key: K, value: V) => void;
|
|
98
|
+
has: (key: K) => boolean;
|
|
99
|
+
delete: (key: K) => boolean;
|
|
100
|
+
clear: () => void;
|
|
101
|
+
size: () => number;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Hook for automatic event listener cleanup
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* function ScrollTracker() {
|
|
109
|
+
* const events = useEventCleanup();
|
|
110
|
+
*
|
|
111
|
+
* useEffect(() => {
|
|
112
|
+
* events.add(window, 'scroll', handleScroll);
|
|
113
|
+
* events.add(document, 'keydown', handleKeyDown);
|
|
114
|
+
* // All listeners automatically removed on unmount
|
|
115
|
+
* }, []);
|
|
116
|
+
*
|
|
117
|
+
* return <div>...</div>;
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function useEventCleanup(): EventCleanup;
|
|
122
|
+
/**
|
|
123
|
+
* Create standalone event cleanup manager
|
|
124
|
+
*/
|
|
125
|
+
export declare function createEventCleanup(): EventCleanup & {
|
|
126
|
+
dispose: () => void;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Get current memory stats (Chrome only)
|
|
130
|
+
*/
|
|
131
|
+
export declare function getMemoryStats(): MemoryStats;
|
|
132
|
+
/**
|
|
133
|
+
* Hook for monitoring memory usage
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```tsx
|
|
137
|
+
* function MemoryMonitor() {
|
|
138
|
+
* const { stats, isHighUsage } = useMemoryMonitor({
|
|
139
|
+
* warningThreshold: 80, // Warn at 80% usage
|
|
140
|
+
* pollInterval: 5000,
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* if (isHighUsage) {
|
|
144
|
+
* console.warn('High memory usage!');
|
|
145
|
+
* }
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare function useMemoryMonitorPerf(options?: {
|
|
150
|
+
warningThreshold?: number;
|
|
151
|
+
pollInterval?: number;
|
|
152
|
+
onHighUsage?: (stats: MemoryStats) => void;
|
|
153
|
+
}): {
|
|
154
|
+
stats: MemoryStats;
|
|
155
|
+
isHighUsage: boolean;
|
|
156
|
+
};
|
|
157
|
+
export interface LazyImageOptions {
|
|
158
|
+
/** Intersection Observer root margin */
|
|
159
|
+
rootMargin?: string;
|
|
160
|
+
/** Intersection Observer threshold */
|
|
161
|
+
threshold?: number;
|
|
162
|
+
/** Placeholder while loading */
|
|
163
|
+
placeholder?: string;
|
|
164
|
+
/** Enable progressive loading (blur-up) */
|
|
165
|
+
progressive?: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Hook for lazy loading images with intersection observer
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```tsx
|
|
172
|
+
* function LazyImage({ src, alt }) {
|
|
173
|
+
* const { ref, isLoaded, isInView } = useLazyImage({ src });
|
|
174
|
+
*
|
|
175
|
+
* return (
|
|
176
|
+
* <img
|
|
177
|
+
* ref={ref}
|
|
178
|
+
* src={isInView ? src : placeholder}
|
|
179
|
+
* alt={alt}
|
|
180
|
+
* className={isLoaded ? 'loaded' : 'loading'}
|
|
181
|
+
* />
|
|
182
|
+
* );
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function useLazyImage(options: LazyImageOptions & {
|
|
187
|
+
src: string;
|
|
188
|
+
}): {
|
|
189
|
+
ref: import("react").RefObject<HTMLImageElement>;
|
|
190
|
+
isInView: boolean;
|
|
191
|
+
isLoaded: boolean;
|
|
192
|
+
currentSrc: string;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Object pool for reducing GC pressure
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* const vectorPool = createObjectPool({
|
|
200
|
+
* create: () => ({ x: 0, y: 0 }),
|
|
201
|
+
* reset: (v) => { v.x = 0; v.y = 0; },
|
|
202
|
+
* maxSize: 100,
|
|
203
|
+
* });
|
|
204
|
+
*
|
|
205
|
+
* function useVector() {
|
|
206
|
+
* const v = vectorPool.acquire();
|
|
207
|
+
* // Use vector...
|
|
208
|
+
* vectorPool.release(v);
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export declare function createObjectPool<T>(options: {
|
|
213
|
+
create: () => T;
|
|
214
|
+
reset?: (obj: T) => void;
|
|
215
|
+
maxSize?: number;
|
|
216
|
+
}): {
|
|
217
|
+
acquire: () => T;
|
|
218
|
+
release: (obj: T) => void;
|
|
219
|
+
preallocate: (count: number) => void;
|
|
220
|
+
clear: () => void;
|
|
221
|
+
size: () => number;
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/performance/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM;IAChD,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,GAAG,EAAE,CAAC,CAAC,SAAS,MAAM,cAAc,EAClC,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,CAAC,GAAG,MAAM,EACjB,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,uBAAuB,KAC9B,IAAI,CAAC;IACV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