tailwind-styled-v4 5.0.11 → 5.0.13
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 +100 -4
- package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
- package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
- package/dist/analyzer.d.mts +4 -4
- package/dist/analyzer.d.ts +4 -4
- package/dist/analyzer.js +34 -69
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +33 -68
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -0
- package/dist/animate.d.ts +4 -0
- package/dist/animate.js +33 -11
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +33 -11
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +57 -6
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +57 -6
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +404 -190
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +401 -187
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +2700 -212
- package/dist/compiler.d.ts +2700 -212
- package/dist/compiler.js +1996 -503
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +1847 -448
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +17 -4
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +17 -4
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +11 -470
- package/dist/engine.d.ts +11 -470
- package/dist/engine.js +2777 -455
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2776 -454
- package/dist/engine.mjs.map +1 -1
- package/dist/index-BDQw13kn.d.ts +464 -0
- package/dist/index-DJv28Uzq.d.mts +464 -0
- package/dist/index.browser.mjs +143 -255
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +23 -39
- package/dist/index.d.ts +23 -39
- package/dist/index.js +7234 -1400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7234 -1400
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +44 -1
- package/dist/next.d.ts +44 -1
- package/dist/next.js +3224 -1065
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +3223 -1066
- package/dist/next.mjs.map +1 -1
- package/dist/rspack.d.mts +9 -0
- package/dist/rspack.d.ts +9 -0
- package/dist/rspack.js +99 -61
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +99 -61
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime-css.d.mts +8 -0
- package/dist/runtime-css.d.ts +8 -0
- package/dist/runtime-css.js +23 -7
- package/dist/runtime-css.js.map +1 -1
- package/dist/runtime-css.mjs +23 -7
- package/dist/runtime-css.mjs.map +1 -1
- package/dist/scanner.js +16 -37
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +15 -36
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +107 -1
- package/dist/shared.d.ts +107 -1
- package/dist/shared.js +3014 -466
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +3008 -445
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +39 -35
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -34
- package/dist/svelte.mjs.map +1 -1
- package/dist/theme.js +85 -76
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +83 -74
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +2351 -187
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +2351 -187
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +404 -190
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +401 -187
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +2657 -320
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +2657 -320
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +39 -35
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -34
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +190 -33
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +190 -33
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/index.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
- package/package.json +9 -4
- package/CHANGELOG.md +0 -285
package/dist/compiler.d.ts
CHANGED
|
@@ -18,11 +18,122 @@ interface NativeRscResult {
|
|
|
18
18
|
needsClientDirective: boolean;
|
|
19
19
|
clientReasons: string[];
|
|
20
20
|
}
|
|
21
|
+
interface ScanWorkspaceResult {
|
|
22
|
+
files: string[];
|
|
23
|
+
total_files: number;
|
|
24
|
+
classes: string[];
|
|
25
|
+
unique_classes: number;
|
|
26
|
+
duration_ms: number;
|
|
27
|
+
errors: string[];
|
|
28
|
+
}
|
|
29
|
+
interface ScanFileResult {
|
|
30
|
+
file: string;
|
|
31
|
+
classes: string[];
|
|
32
|
+
class_count: number;
|
|
33
|
+
has_tw_usage: boolean;
|
|
34
|
+
size_bytes: number;
|
|
35
|
+
duration_ms: number;
|
|
36
|
+
}
|
|
37
|
+
interface BatchExtractResult {
|
|
38
|
+
file: string;
|
|
39
|
+
classes: string[];
|
|
40
|
+
contentHash: string;
|
|
41
|
+
ok: boolean;
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
interface SafelistCheckResult {
|
|
45
|
+
matched: string[];
|
|
46
|
+
unmatched: string[];
|
|
47
|
+
safelistSize: number;
|
|
48
|
+
}
|
|
49
|
+
interface PrefilterFileResult {
|
|
50
|
+
file: string;
|
|
51
|
+
has_tw_usage: boolean;
|
|
52
|
+
duration_ms: number;
|
|
53
|
+
size_bytes: number;
|
|
54
|
+
status: "processed" | "skipped" | "error";
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
interface DeadCodeResult {
|
|
58
|
+
deadInCss: string[];
|
|
59
|
+
deadInSource: string[];
|
|
60
|
+
liveClasses: string[];
|
|
61
|
+
totalCssClasses: number;
|
|
62
|
+
totalSourceClasses: number;
|
|
63
|
+
}
|
|
64
|
+
interface ProcessedCssResult {
|
|
65
|
+
css: string;
|
|
66
|
+
size_bytes: number;
|
|
67
|
+
resolved_classes: string[];
|
|
68
|
+
unknown_classes: string[];
|
|
69
|
+
}
|
|
70
|
+
interface ContainerConfig {
|
|
71
|
+
tag: string;
|
|
72
|
+
containerJson: string;
|
|
73
|
+
containerName?: string;
|
|
74
|
+
breakpoints: Array<{
|
|
75
|
+
key: string;
|
|
76
|
+
classes: string;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
interface HoistResult {
|
|
80
|
+
code: string;
|
|
81
|
+
hoisted: string[];
|
|
82
|
+
warnings: string[];
|
|
83
|
+
}
|
|
84
|
+
interface VariantTableResult {
|
|
85
|
+
id: string;
|
|
86
|
+
tableJson: string;
|
|
87
|
+
keys: string[];
|
|
88
|
+
defaultKey: string;
|
|
89
|
+
combinations: number;
|
|
90
|
+
}
|
|
91
|
+
interface ClassifyResult {
|
|
92
|
+
className: string;
|
|
93
|
+
bucket: string;
|
|
94
|
+
sortOrder: number;
|
|
95
|
+
}
|
|
96
|
+
interface MergeResult {
|
|
97
|
+
declarationsJson: string;
|
|
98
|
+
declarationString: string;
|
|
99
|
+
count: number;
|
|
100
|
+
}
|
|
101
|
+
interface ClassUsageItem {
|
|
102
|
+
className: string;
|
|
103
|
+
usageCount: number;
|
|
104
|
+
filesJson: string;
|
|
105
|
+
bundleSizeBytes: number;
|
|
106
|
+
isDeadCode: boolean;
|
|
107
|
+
}
|
|
108
|
+
interface StateCssConfig {
|
|
109
|
+
tag: string;
|
|
110
|
+
componentName: string;
|
|
111
|
+
statesJson: string;
|
|
112
|
+
sourceFile: string;
|
|
113
|
+
}
|
|
114
|
+
interface GeneratedStateCss {
|
|
115
|
+
selector: string;
|
|
116
|
+
declarations: string;
|
|
117
|
+
cssRule: string;
|
|
118
|
+
componentName: string;
|
|
119
|
+
stateName: string;
|
|
120
|
+
}
|
|
21
121
|
interface NativeBridge {
|
|
122
|
+
generateCssNative?: (classes: string[], theme_json: string) => string;
|
|
123
|
+
getCacheStats?: () => [number, number];
|
|
124
|
+
clearThemeCache?: () => void;
|
|
22
125
|
transformSource?: (source: string, opts?: Record<string, string>) => NativeTransformResult | null;
|
|
23
126
|
extractClassesFromSource?: (source: string) => string[];
|
|
24
127
|
hasTwUsage?: (source: string) => boolean;
|
|
25
128
|
isAlreadyTransformed?: (source: string) => boolean;
|
|
129
|
+
scan_workspace?: (root: string, extensions?: string[]) => ScanWorkspaceResult;
|
|
130
|
+
extract_classes_from_source?: (source: string) => string[];
|
|
131
|
+
batch_extract_classes?: (filePaths: string[]) => BatchExtractResult[];
|
|
132
|
+
check_against_safelist?: (classes: string[], safelist: string[]) => SafelistCheckResult;
|
|
133
|
+
scan_file?: (filePath: string) => ScanFileResult;
|
|
134
|
+
collect_files?: (root: string, extensions?: string[]) => string[];
|
|
135
|
+
walk_and_prefilter_source_files?: (root: string, extensions?: string[]) => PrefilterFileResult[];
|
|
136
|
+
generate_sub_component_types?: (root: string, outputPath?: string) => string;
|
|
26
137
|
extractAllClasses?: (source: string) => string[];
|
|
27
138
|
parseClasses?: (raw: string) => Array<{
|
|
28
139
|
raw: string;
|
|
@@ -55,35 +166,11 @@ interface NativeBridge {
|
|
|
55
166
|
unmatched: string[];
|
|
56
167
|
safelistSize: number;
|
|
57
168
|
};
|
|
58
|
-
hoistComponents?: (source: string) =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
compileVariantTable?: (configJson: string) => {
|
|
64
|
-
id: string;
|
|
65
|
-
tableJson: string;
|
|
66
|
-
keys: string[];
|
|
67
|
-
defaultKey: string;
|
|
68
|
-
combinations: number;
|
|
69
|
-
};
|
|
70
|
-
classifyAndSortClasses?: (classes: string[]) => Array<{
|
|
71
|
-
className: string;
|
|
72
|
-
bucket: string;
|
|
73
|
-
sortOrder: number;
|
|
74
|
-
}>;
|
|
75
|
-
mergeCssDeclarations?: (cssChunks: string[]) => {
|
|
76
|
-
declarationsJson: string;
|
|
77
|
-
declarationString: string;
|
|
78
|
-
count: number;
|
|
79
|
-
};
|
|
80
|
-
analyzeClassUsage?: (classes: string[], scanResultJson: string, css: string) => Array<{
|
|
81
|
-
className: string;
|
|
82
|
-
usageCount: number;
|
|
83
|
-
filesJson: string;
|
|
84
|
-
bundleSizeBytes: number;
|
|
85
|
-
isDeadCode: boolean;
|
|
86
|
-
}>;
|
|
169
|
+
hoistComponents?: (source: string) => HoistResult;
|
|
170
|
+
compileVariantTable?: (configJson: string) => VariantTableResult;
|
|
171
|
+
classifyAndSortClasses?: (classes: string[]) => ClassifyResult[];
|
|
172
|
+
mergeCssDeclarations?: (cssChunks: string[]) => MergeResult;
|
|
173
|
+
analyzeClassUsage?: (classes: string[], scanResultJson: string, css: string) => ClassUsageItem[];
|
|
87
174
|
analyzeRsc?: (source: string, filename: string) => {
|
|
88
175
|
isServer: boolean;
|
|
89
176
|
needsClientDirective: boolean;
|
|
@@ -104,19 +191,8 @@ interface NativeBridge {
|
|
|
104
191
|
};
|
|
105
192
|
compileCssLightning?: (classes: string[]) => string;
|
|
106
193
|
/** Post-process raw Tailwind-generated CSS dengan LightningCSS di Rust */
|
|
107
|
-
detectDeadCode?: (scanResultJson: string, css: string) =>
|
|
108
|
-
|
|
109
|
-
deadInSource: string[];
|
|
110
|
-
liveClasses: string[];
|
|
111
|
-
totalCssClasses: number;
|
|
112
|
-
totalSourceClasses: number;
|
|
113
|
-
};
|
|
114
|
-
processTailwindCssLightning?: (css: string) => {
|
|
115
|
-
css: string;
|
|
116
|
-
size_bytes: number;
|
|
117
|
-
resolved_classes: string[];
|
|
118
|
-
unknown_classes: string[];
|
|
119
|
-
};
|
|
194
|
+
detectDeadCode?: (scanResultJson: string, css: string) => DeadCodeResult;
|
|
195
|
+
processTailwindCssLightning?: (css: string) => ProcessedCssResult;
|
|
120
196
|
processTailwindCssWithTargets?: (css: string, targets: string | null) => {
|
|
121
197
|
css: string;
|
|
122
198
|
size_bytes: number;
|
|
@@ -129,6 +205,207 @@ interface NativeBridge {
|
|
|
129
205
|
calculateImpact?: (impactJson: string) => string;
|
|
130
206
|
calculateRisk?: (className: string, totalComponents: number) => string;
|
|
131
207
|
calculateSavings?: (bundleSizeBytes: number, componentCount: number) => number;
|
|
208
|
+
extractTwStateConfigs?: (source: string, filename: string) => StateCssConfig[];
|
|
209
|
+
generateStaticStateCss?: (inputs: Array<{
|
|
210
|
+
tag: string;
|
|
211
|
+
componentName: string;
|
|
212
|
+
statesJson: string;
|
|
213
|
+
}>, resolvedCss: string | null) => GeneratedStateCss[];
|
|
214
|
+
extractAndGenerateStateCss?: (source: string, filename: string) => GeneratedStateCss[];
|
|
215
|
+
/**
|
|
216
|
+
* Convert layout/utility class string ke CSS declarations.
|
|
217
|
+
* Dipakai oleh extractContainerCssFromSource sebagai Rust-accelerated fallback.
|
|
218
|
+
*/
|
|
219
|
+
layoutClassesToCss?: (classes: string) => string;
|
|
220
|
+
/**
|
|
221
|
+
* Hash string dengan algoritma tertentu, return n karakter pertama.
|
|
222
|
+
* Dipakai untuk generate deterministic container CSS IDs.
|
|
223
|
+
*/
|
|
224
|
+
hashContent?: (input: string, algo: string, length: number) => string;
|
|
225
|
+
/** Hapus dead CSS selectors + minify via Lightning CSS. */
|
|
226
|
+
eliminateDeadCss?: (css: string, deadClasses: string[]) => string;
|
|
227
|
+
/** Dead code detection + strip + Lightning CSS minify dalam satu call. */
|
|
228
|
+
optimizeCss?: (css: string) => string;
|
|
229
|
+
/** Extract tw container configs dari source untuk static @container CSS generation. */
|
|
230
|
+
extractTwContainerConfigs?: (source: string) => Array<{
|
|
231
|
+
tag: string;
|
|
232
|
+
containerJson: string;
|
|
233
|
+
containerName?: string;
|
|
234
|
+
breakpoints: Array<{
|
|
235
|
+
key: string;
|
|
236
|
+
classes: string;
|
|
237
|
+
}>;
|
|
238
|
+
}>;
|
|
239
|
+
get_cache_statistics?: () => string;
|
|
240
|
+
clear_all_caches?: () => void;
|
|
241
|
+
clear_parse_cache?: () => void;
|
|
242
|
+
clear_resolve_cache?: () => void;
|
|
243
|
+
clear_compile_cache?: () => void;
|
|
244
|
+
clear_css_gen_cache?: () => void;
|
|
245
|
+
get_cache_optimization_hints?: (hit_rate_percent: number, memory_used_mb: number) => string;
|
|
246
|
+
estimate_optimal_cache_config_native?: (total_budget_mb: number, workload_type: string) => string;
|
|
247
|
+
cache_read?: (cache_path: string) => {
|
|
248
|
+
entries_json: string;
|
|
249
|
+
};
|
|
250
|
+
cache_write?: (cache_path: string, entries: Array<{
|
|
251
|
+
file: string;
|
|
252
|
+
content_hash: string;
|
|
253
|
+
classes: string[];
|
|
254
|
+
mtime_ms: number;
|
|
255
|
+
size_bytes: number;
|
|
256
|
+
}>) => boolean;
|
|
257
|
+
cache_priority?: (mtime_ms: number, size_bytes: number, hit_count: number) => number;
|
|
258
|
+
resolve_variants?: (configJson: string) => string;
|
|
259
|
+
validate_variant_config?: (configJson: string) => string;
|
|
260
|
+
resolve_cascade?: (baseThemeJson: string, overridesJson: string) => string;
|
|
261
|
+
resolve_class_names?: (classNames: string[], themeJson: string) => string;
|
|
262
|
+
resolve_conflict_group?: (groupName: string, themeJson: string) => string;
|
|
263
|
+
resolve_theme_value?: (keyPath: string, themeJson: string) => string | null;
|
|
264
|
+
resolve_simple_variants?: (configJson: string) => string;
|
|
265
|
+
process_file_change?: (fileChangeJson: string) => string;
|
|
266
|
+
compute_incremental_diff?: (oldScanJson: string, newScanJson: string) => string;
|
|
267
|
+
create_fingerprint?: (filePath: string, fileContent: string) => string;
|
|
268
|
+
inject_state_hash?: (css: string, stateHash: string) => string;
|
|
269
|
+
prune_stale_entries?: (maxAgeSeconds: number, maxEntries: number) => string;
|
|
270
|
+
rebuild_workspace_result?: (rootDir: string, extensions?: string[]) => string;
|
|
271
|
+
scan_file_native?: (filePath: string, fileContent: string) => string;
|
|
272
|
+
scan_files_batch_native?: (filesJson: string) => string;
|
|
273
|
+
compile_class?: (input: string) => string;
|
|
274
|
+
compile_classes?: (inputs: string[]) => string;
|
|
275
|
+
compile_to_css?: (input: string, minify: boolean) => string;
|
|
276
|
+
compile_to_css_batch?: (inputs: string[], minify: boolean) => string;
|
|
277
|
+
minify_css?: (css: string) => string;
|
|
278
|
+
compile_animation?: (animationName: string, from: string, to: string) => string;
|
|
279
|
+
compile_keyframes?: (name: string, stopsJson: string) => string;
|
|
280
|
+
compile_theme?: (tokensJson: string, themeName: string, prefix: string) => string;
|
|
281
|
+
tw_merge?: (classString: string) => string;
|
|
282
|
+
tw_merge_many?: (classStrings: string[]) => string;
|
|
283
|
+
tw_merge_with_separator?: (classString: string, options: Record<string, unknown>) => string;
|
|
284
|
+
tw_merge_many_with_separator?: (classStrings: string[], options: Record<string, unknown>) => string;
|
|
285
|
+
tw_merge_raw?: (classLists: string[]) => string;
|
|
286
|
+
id_registry_create?: () => number;
|
|
287
|
+
id_registry_generate?: (handle: number, name: string) => number;
|
|
288
|
+
id_registry_lookup?: (handle: number, name: string) => number;
|
|
289
|
+
id_registry_next?: (handle: number) => number;
|
|
290
|
+
id_registry_destroy?: (handle: number) => void;
|
|
291
|
+
id_registry_reset?: (handle: number) => void;
|
|
292
|
+
id_registry_snapshot?: (handle: number) => string;
|
|
293
|
+
id_registry_active_count?: () => number;
|
|
294
|
+
register_property_name?: (propertyName: string) => number;
|
|
295
|
+
register_value_name?: (valueName: string) => number;
|
|
296
|
+
property_id_to_string?: (propertyId: number) => string;
|
|
297
|
+
value_id_to_string?: (valueId: number) => string;
|
|
298
|
+
reverse_lookup_property?: (propertyId: number) => string;
|
|
299
|
+
reverse_lookup_value?: (valueId: number) => string;
|
|
300
|
+
id_registry_export?: (handle: number) => string;
|
|
301
|
+
id_registry_import?: (importedData: string) => number;
|
|
302
|
+
redis_ping?: () => string;
|
|
303
|
+
redis_get?: (key: string) => string;
|
|
304
|
+
redis_set?: (key: string, value: string, ttl_seconds?: number) => string;
|
|
305
|
+
redis_delete?: (key: string) => number;
|
|
306
|
+
redis_exists?: (key: string) => number;
|
|
307
|
+
redis_mget?: (keys: string[]) => string;
|
|
308
|
+
redis_mset?: (pairs: Array<[string, string]>) => string;
|
|
309
|
+
redis_flush_db?: () => number;
|
|
310
|
+
redis_flush_all?: () => number;
|
|
311
|
+
redis_pool_connect?: (host: string, port: number, pool_size?: number) => string;
|
|
312
|
+
redis_pool_stats?: () => string;
|
|
313
|
+
redis_pool_reconnect?: () => string;
|
|
314
|
+
redis_enable_cluster?: (initial_nodes: string[]) => string;
|
|
315
|
+
redis_disable_cluster?: () => string;
|
|
316
|
+
redis_cluster_status?: () => string;
|
|
317
|
+
redis_subscribe?: (channel: string) => string;
|
|
318
|
+
redis_publish?: (channel: string, message: string) => number;
|
|
319
|
+
redis_expiration_set?: (key: string, ttl_seconds: number) => number;
|
|
320
|
+
redis_expiration_get?: (key: string) => string;
|
|
321
|
+
redis_info?: () => string;
|
|
322
|
+
redis_monitor?: () => string;
|
|
323
|
+
redis_cache_size?: () => number;
|
|
324
|
+
redis_cache_key_count?: () => number;
|
|
325
|
+
redis_cache_clear?: () => number;
|
|
326
|
+
redis_cache_hit_rate?: () => number;
|
|
327
|
+
redis_enable_persistence?: (mode: string) => string;
|
|
328
|
+
redis_disable_persistence?: () => string;
|
|
329
|
+
redis_snapshot?: () => string;
|
|
330
|
+
redis_memory_stats?: () => string;
|
|
331
|
+
redis_optimize_memory?: () => number;
|
|
332
|
+
redis_set_eviction_policy?: (policy: string) => string;
|
|
333
|
+
redis_get_eviction_policy?: () => string;
|
|
334
|
+
redis_replicate?: (target_host: string, target_port: number) => number;
|
|
335
|
+
redis_replication_status?: () => string;
|
|
336
|
+
redis_cache_sync?: (peers: string[]) => number;
|
|
337
|
+
redis_enable_cache_warming?: (key_pattern: string) => string;
|
|
338
|
+
redis_disable_cache_warming?: () => string;
|
|
339
|
+
redis_diagnose?: () => string;
|
|
340
|
+
start_watch?: (root_path: string, patterns?: string[]) => number;
|
|
341
|
+
poll_watch_events?: (handle: number, timeout_ms?: number) => string;
|
|
342
|
+
stop_watch?: (handle: number) => number;
|
|
343
|
+
watch_add_pattern?: (handle: number, pattern: string) => string;
|
|
344
|
+
watch_remove_pattern?: (handle: number, pattern: string) => string;
|
|
345
|
+
watch_get_active_handles?: () => string;
|
|
346
|
+
watch_clear_all?: () => number;
|
|
347
|
+
watch_event_type_to_string?: (event_type_code: number) => string;
|
|
348
|
+
is_watch_running?: (handle: number) => boolean;
|
|
349
|
+
get_watch_stats?: () => string;
|
|
350
|
+
watch_pause?: (handle: number) => string;
|
|
351
|
+
watch_resume?: (handle: number) => string;
|
|
352
|
+
scan_cache_optimizations?: () => string;
|
|
353
|
+
get_plugin_hooks?: () => string;
|
|
354
|
+
register_plugin_hook?: (hook_name: string, handler_id: string) => string;
|
|
355
|
+
unregister_plugin_hook?: (hook_name: string, handler_id: string) => string;
|
|
356
|
+
emit_plugin_hook?: (hook_name: string, data_json: string) => string;
|
|
357
|
+
get_compilation_metrics?: () => string;
|
|
358
|
+
reset_compilation_metrics?: () => string;
|
|
359
|
+
validate_css_output?: (css: string) => string;
|
|
360
|
+
get_compiler_diagnostics?: () => string;
|
|
361
|
+
configureCacheBackend?: (configJson: string) => string;
|
|
362
|
+
getRecommendedCacheConfig?: (workloadType: string) => string;
|
|
363
|
+
clearAllCachesNapi?: () => void;
|
|
364
|
+
clearResolveCacheNapi?: () => void;
|
|
365
|
+
clearCompileCacheNapi?: () => void;
|
|
366
|
+
clearCssGenCacheNapi?: () => void;
|
|
367
|
+
getResolverPoolStats?: () => string;
|
|
368
|
+
clearResolverPool?: () => string;
|
|
369
|
+
getCacheOptimizationHints?: () => string;
|
|
370
|
+
estimateStreamingBatchSize?: (targetMemoryMb: number) => string;
|
|
371
|
+
parseClass?: (input: string) => string;
|
|
372
|
+
compileClassNapi?: (input: string) => string;
|
|
373
|
+
getParseStats?: () => string;
|
|
374
|
+
clearParseCacheNapi?: () => void;
|
|
375
|
+
parseColorsNapi?: (colorsJson: string) => string | Record<string, string>;
|
|
376
|
+
parseSpacingNapi?: (spacingJson: string) => string | Record<string, string>;
|
|
377
|
+
parseTransformNapi?: (transformJson: string) => string | Record<string, string>;
|
|
378
|
+
normalizeColorNapi?: (color: string, opacity: string) => string;
|
|
379
|
+
sanitizeColorNapi?: (color: string) => string;
|
|
380
|
+
splitRgbaNapi?: (color: string) => string | {
|
|
381
|
+
r: number;
|
|
382
|
+
g: number;
|
|
383
|
+
b: number;
|
|
384
|
+
a: number;
|
|
385
|
+
};
|
|
386
|
+
validateColorsNapi?: (colorsJson: string) => boolean;
|
|
387
|
+
validateBreakpointsNapi?: (breakpointsJson: string) => boolean;
|
|
388
|
+
runHealthCheck?: () => void;
|
|
389
|
+
watchFiles?: (rootDir: string, optionsJson?: string | null) => string;
|
|
390
|
+
stopWatching?: (handleId: number) => string;
|
|
391
|
+
getWatchEvents?: (handleId: number, maxEvents?: number | null) => string;
|
|
392
|
+
getWatchPerformance?: () => string;
|
|
393
|
+
clearWatchStats?: () => string;
|
|
394
|
+
getActiveWatches?: () => number;
|
|
395
|
+
setWatchMetrics?: (metricName: string, value: string) => string;
|
|
396
|
+
setWatchAggregation?: (aggregationType: string) => string;
|
|
397
|
+
getOptimizationRecommendations?: (hitRate: number, memoryMb: number, classCount: number) => string;
|
|
398
|
+
estimateOptimalBatchSize?: (totalClasses: number, memoryAvailableMb: number) => number;
|
|
399
|
+
predictMemoryUsage?: (uniqueClasses: number, avgClassSizeBytes: number) => number;
|
|
400
|
+
recommendCachingStrategy?: (isSsr: boolean, memoryConstraintMb: number) => string;
|
|
401
|
+
benchmarkStreamingVsBuffered?: (classCount: number) => string;
|
|
402
|
+
getWeek6OptimizationStatus?: () => string;
|
|
403
|
+
scanCacheGet?: (filePath: string, contentHash: string) => string[] | null;
|
|
404
|
+
scanCachePut?: (filePath: string, contentHash: string, classes: string[], mtimeMs: number, size: number) => void;
|
|
405
|
+
scanCacheInvalidate?: (filePath: string) => void;
|
|
406
|
+
scanCacheStats?: () => {
|
|
407
|
+
size: number;
|
|
408
|
+
};
|
|
132
409
|
}
|
|
133
410
|
interface NativeTransformResult {
|
|
134
411
|
code: string;
|
|
@@ -155,180 +432,2391 @@ declare const adaptNativeResult: (raw: NativeTransformResult) => {
|
|
|
155
432
|
};
|
|
156
433
|
|
|
157
434
|
/**
|
|
158
|
-
*
|
|
435
|
+
* cssGeneratorNative.ts
|
|
436
|
+
*
|
|
437
|
+
* High-performance CSS generator using Rust compiler via NAPI binding.
|
|
438
|
+
* Rust-only implementation - no JavaScript fallback.
|
|
439
|
+
*/
|
|
440
|
+
interface GenerateCssNativeOptions {
|
|
441
|
+
theme: Record<string, unknown>;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Generate CSS from Tailwind classes using the Rust compiler.
|
|
445
|
+
*
|
|
446
|
+
* @param classes - Array of Tailwind class names (e.g., ["px-4", "hover:bg-blue-600"])
|
|
447
|
+
* @param options - Configuration including theme object
|
|
448
|
+
* @returns Promise resolving to CSS string
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```ts
|
|
452
|
+
* const css = await generateCssNative(
|
|
453
|
+
* ["px-4", "hover:bg-blue-600", "md:text-lg"],
|
|
454
|
+
* {
|
|
455
|
+
* theme: defaultTheme,
|
|
456
|
+
* fallbackToJs: true,
|
|
457
|
+
* logFallback: process.env.DEBUG === "true"
|
|
458
|
+
* }
|
|
459
|
+
* )
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* **Performance**: Rust compiler typically 40-60% faster than Tailwind JS
|
|
463
|
+
* - Rust: 60-90ms for 100 classes
|
|
464
|
+
* - JavaScript: 150ms baseline
|
|
465
|
+
*
|
|
466
|
+
* **Error Handling**:
|
|
467
|
+
* - If Rust binding fails and fallbackToJs=true, falls back to Tailwind JS
|
|
468
|
+
* - If Rust binding fails and fallbackToJs=false, throws error
|
|
469
|
+
* - Invalid classes log warnings but don't stop compilation
|
|
470
|
+
*/
|
|
471
|
+
declare function generateCssNative(classes: string[], options: GenerateCssNativeOptions): Promise<string>;
|
|
472
|
+
/**
|
|
473
|
+
* Get cache statistics from the Rust compiler.
|
|
474
|
+
*
|
|
475
|
+
* @returns Object with cache hit/miss counts, or null if binding unavailable
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```ts
|
|
479
|
+
* const stats = getCacheStats()
|
|
480
|
+
* if (stats) {
|
|
481
|
+
* console.log(`Cache hits: ${stats.hits}, misses: ${stats.misses}`)
|
|
482
|
+
* console.log(`Hit rate: ${(stats.hits / (stats.hits + stats.misses) * 100).toFixed(1)}%`)
|
|
483
|
+
* }
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
declare function getCacheStats(): {
|
|
487
|
+
hits: number;
|
|
488
|
+
misses: number;
|
|
489
|
+
} | null;
|
|
490
|
+
/**
|
|
491
|
+
* Clear the theme resolver cache.
|
|
159
492
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
493
|
+
* Useful for:
|
|
494
|
+
* - Testing with different themes
|
|
495
|
+
* - Freeing memory in long-running processes
|
|
496
|
+
* - Resetting state between build cycles
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* // Clear cache before each build
|
|
501
|
+
* clearThemeCache()
|
|
502
|
+
* const css = await generateCssNative(classes, { theme })
|
|
503
|
+
* ```
|
|
162
504
|
*/
|
|
505
|
+
declare function clearThemeCache(): void;
|
|
163
506
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
isServer?: boolean;
|
|
170
|
-
needsClientDirective?: boolean;
|
|
171
|
-
clientReasons?: string[];
|
|
172
|
-
};
|
|
173
|
-
engine?: string;
|
|
174
|
-
};
|
|
175
|
-
declare const transformSource: (source: string, opts?: Record<string, unknown>) => NativeTransformResult;
|
|
176
|
-
declare const hasTwUsage: (source: string) => boolean;
|
|
177
|
-
declare const isAlreadyTransformed: (source: string) => boolean;
|
|
178
|
-
declare const shouldProcess: (source: string) => boolean;
|
|
179
|
-
declare const compileCssFromClasses: (classes: string[], prefix?: string | null) => NativeTransformResult;
|
|
180
|
-
declare const buildStyleTag: (classes: string[]) => string;
|
|
181
|
-
declare const compileCssNative: (classes: string[], prefix?: string | null) => NativeTransformResult;
|
|
182
|
-
declare const generateCssForClasses: (classes: string[], _tailwindConfig?: Record<string, unknown>, root?: string, cssEntryContent?: string, minify?: boolean) => Promise<string>;
|
|
183
|
-
declare const extractAllClasses: (source: string) => string[];
|
|
184
|
-
declare const extractClassesFromSource: (source: string) => string;
|
|
185
|
-
declare const astExtractClasses: (source: string, filename: string) => string[];
|
|
186
|
-
declare const parseClasses: (raw: string) => Array<{
|
|
187
|
-
raw: string;
|
|
188
|
-
type: string;
|
|
189
|
-
}>;
|
|
190
|
-
declare const normalizeClasses: (raw: string) => string;
|
|
191
|
-
declare const mergeClassesStatic: (classes: string) => string;
|
|
192
|
-
declare const normalizeAndDedupClasses: (raw: string) => {
|
|
193
|
-
normalized: string;
|
|
194
|
-
duplicatesRemoved: number;
|
|
195
|
-
uniqueCount: number;
|
|
196
|
-
};
|
|
197
|
-
declare const eliminateDeadCss: (css: string, deadClasses: Set<string>) => string;
|
|
198
|
-
declare const findDeadVariants: (variantConfig: Record<string, unknown> | Array<{
|
|
199
|
-
name: string;
|
|
200
|
-
variants: Record<string, Record<string, string>>;
|
|
201
|
-
defaultVariants?: Record<string, string>;
|
|
202
|
-
}>, usage: Record<string, Set<string>>) => {
|
|
203
|
-
unusedCount: number;
|
|
204
|
-
unused: string[];
|
|
205
|
-
};
|
|
206
|
-
declare const runElimination: (css: string, scanResult: unknown) => string;
|
|
207
|
-
declare const optimizeCss: (css: string) => string;
|
|
208
|
-
declare const scanProjectUsage: (dirs: string[], cwd: string) => Record<string, Record<string, Set<string>>>;
|
|
209
|
-
declare const extractComponentUsage: (source: string) => Array<{
|
|
210
|
-
component: string;
|
|
211
|
-
propsJson: string;
|
|
212
|
-
}>;
|
|
213
|
-
declare const diffClassLists: (previous: string[], current: string[]) => {
|
|
214
|
-
added: string[];
|
|
215
|
-
removed: string[];
|
|
216
|
-
unchanged: string[];
|
|
217
|
-
hasChanges: boolean;
|
|
218
|
-
};
|
|
219
|
-
declare const batchExtractClasses: (filePaths: string[]) => {
|
|
220
|
-
file: string;
|
|
507
|
+
/**
|
|
508
|
+
* Compile Tailwind classes directly to CSS.
|
|
509
|
+
*/
|
|
510
|
+
declare function compileCssNative2(classes: string[], prefix?: string | null): {
|
|
511
|
+
css: string;
|
|
221
512
|
classes: string[];
|
|
222
|
-
contentHash: string;
|
|
223
|
-
ok: boolean;
|
|
224
|
-
error?: string;
|
|
225
|
-
}[];
|
|
226
|
-
declare const checkAgainstSafelist: (classes: string[], safelist: string[]) => {
|
|
227
|
-
matched: string[];
|
|
228
|
-
unmatched: string[];
|
|
229
|
-
safelistSize: number;
|
|
230
|
-
};
|
|
231
|
-
declare const hoistComponents: (source: string) => {
|
|
232
|
-
code: string;
|
|
233
|
-
hoisted: string[];
|
|
234
|
-
warnings: string[];
|
|
235
|
-
};
|
|
236
|
-
declare const compileVariantTable: (configJson: string) => {
|
|
237
|
-
id: string;
|
|
238
|
-
tableJson: string;
|
|
239
|
-
keys: string[];
|
|
240
|
-
defaultKey: string;
|
|
241
|
-
combinations: number;
|
|
242
|
-
};
|
|
243
|
-
declare const compileVariants: (componentId: string, config: Record<string, unknown>) => {
|
|
244
|
-
id: string;
|
|
245
|
-
tableJson: string;
|
|
246
|
-
keys: string[];
|
|
247
|
-
defaultKey: string;
|
|
248
|
-
combinations: number;
|
|
249
|
-
};
|
|
250
|
-
declare const classifyAndSortClasses: (classes: string[]) => {
|
|
251
|
-
className: string;
|
|
252
|
-
bucket: string;
|
|
253
|
-
sortOrder: number;
|
|
254
|
-
}[];
|
|
255
|
-
declare const mergeCssDeclarations: (cssChunks: string[]) => {
|
|
256
|
-
declarationsJson: string;
|
|
257
|
-
declarationString: string;
|
|
258
|
-
count: number;
|
|
259
513
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
514
|
+
/**
|
|
515
|
+
* Compile CSS using Lightning CSS post-processing.
|
|
516
|
+
*/
|
|
517
|
+
declare function compileCssLightning(classes: string[]): string;
|
|
518
|
+
/**
|
|
519
|
+
* Extract Tailwind state configurations from source code.
|
|
520
|
+
*/
|
|
521
|
+
declare function extractTwStateConfigsNative(source: string, filename: string): StateCssConfig[];
|
|
522
|
+
/**
|
|
523
|
+
* Generate static state CSS from configuration.
|
|
524
|
+
*/
|
|
525
|
+
declare function generateStaticStateCssNative(inputs: Array<{
|
|
526
|
+
tag: string;
|
|
527
|
+
componentName: string;
|
|
528
|
+
statesJson: string;
|
|
529
|
+
}>, resolvedCss?: string | null): GeneratedStateCss[];
|
|
530
|
+
/**
|
|
531
|
+
* Extract and generate state CSS in one step.
|
|
532
|
+
*/
|
|
533
|
+
declare function extractAndGenerateStateCssNative(source: string, filename: string): GeneratedStateCss[];
|
|
534
|
+
/**
|
|
535
|
+
* Convert layout/utility class string to CSS declarations.
|
|
536
|
+
*/
|
|
537
|
+
declare function layoutClassesToCss(classes: string): string;
|
|
538
|
+
/**
|
|
539
|
+
* Hash content for deterministic ID generation.
|
|
540
|
+
*/
|
|
541
|
+
declare function hashContent(input: string, algorithm?: string, length?: number): string;
|
|
542
|
+
/**
|
|
543
|
+
* Extract container query configurations from source.
|
|
544
|
+
*/
|
|
545
|
+
declare function extractTwContainerConfigs(source: string): {
|
|
546
|
+
tag: string;
|
|
547
|
+
containerJson: string;
|
|
548
|
+
containerName?: string;
|
|
549
|
+
breakpoints: Array<{
|
|
550
|
+
key: string;
|
|
551
|
+
classes: string;
|
|
552
|
+
}>;
|
|
266
553
|
}[];
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
554
|
+
/**
|
|
555
|
+
* Parse Tailwind class into atomic CSS representation.
|
|
556
|
+
*/
|
|
557
|
+
declare function parseAtomicClass(twClass: string): string | null;
|
|
558
|
+
/**
|
|
559
|
+
* Generate atomic CSS from rules.
|
|
560
|
+
*/
|
|
561
|
+
declare function generateAtomicCss(rulesJson: string): string;
|
|
562
|
+
/**
|
|
563
|
+
* Convert Tailwind classes to atomic CSS classes.
|
|
564
|
+
*/
|
|
565
|
+
declare function toAtomicClasses(twClasses: string): string;
|
|
566
|
+
/**
|
|
567
|
+
* Clear atomic CSS registry.
|
|
568
|
+
*/
|
|
569
|
+
declare function clearAtomicRegistry(): void;
|
|
570
|
+
/**
|
|
571
|
+
* Get atomic registry size.
|
|
572
|
+
*/
|
|
573
|
+
declare function atomicRegistrySize(): number;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* cssCompilationNative.ts
|
|
577
|
+
*
|
|
578
|
+
* Phase 5.2: Advanced CSS Compilation - Complex CSS generation and transformations
|
|
579
|
+
* Exposes 12 CSS compilation functions for animations, themes, and merging
|
|
580
|
+
*/
|
|
581
|
+
/**
|
|
582
|
+
* Compiled CSS rule result
|
|
583
|
+
*/
|
|
584
|
+
interface CompiledCssRule {
|
|
585
|
+
selector: string;
|
|
586
|
+
declarations: string;
|
|
587
|
+
properties: Array<{
|
|
588
|
+
key: string;
|
|
589
|
+
value: string;
|
|
590
|
+
}>;
|
|
591
|
+
specificity: number;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Compiled animation result
|
|
595
|
+
*/
|
|
596
|
+
interface CompiledAnimation {
|
|
597
|
+
animation_id: string;
|
|
598
|
+
keyframes_css: string;
|
|
599
|
+
animation_rule: string;
|
|
600
|
+
duration_ms: number;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Compiled theme result
|
|
604
|
+
*/
|
|
605
|
+
interface CompiledTheme {
|
|
606
|
+
selector: string;
|
|
607
|
+
variables: Array<{
|
|
608
|
+
name: string;
|
|
609
|
+
value: string;
|
|
610
|
+
}>;
|
|
611
|
+
variables_css: string;
|
|
612
|
+
theme_name: string;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* CSS compile result with metadata
|
|
616
|
+
*/
|
|
617
|
+
interface CssCompileResult {
|
|
618
|
+
css: string;
|
|
619
|
+
resolved_classes: string[];
|
|
620
|
+
unknown_classes: string[];
|
|
621
|
+
size_bytes: number;
|
|
622
|
+
duration_ms: number;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* tw_merge options
|
|
626
|
+
*/
|
|
627
|
+
interface TwMergeOptions {
|
|
628
|
+
separator?: string;
|
|
629
|
+
debug?: boolean;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Compile a single Tailwind class to CSS rule
|
|
633
|
+
* Full compilation pipeline: parse → resolve → generate
|
|
634
|
+
*
|
|
635
|
+
* @param input - Single Tailwind class (e.g., "md:hover:bg-blue-600/50")
|
|
636
|
+
* @returns Compiled CSS rule as JSON
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```ts
|
|
640
|
+
* const rule = compileClass('md:hover:bg-blue-600')
|
|
641
|
+
* // Returns: {
|
|
642
|
+
* // selector: '.md\\:hover\\:bg-blue-600',
|
|
643
|
+
* // declarations: 'background-color: #2563eb;',
|
|
644
|
+
* // ...
|
|
645
|
+
* // }
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
declare function compileClass(input: string): CompiledCssRule;
|
|
649
|
+
/**
|
|
650
|
+
* Compile multiple Tailwind classes to CSS rules
|
|
651
|
+
* Batch processing with parallel compilation
|
|
652
|
+
*
|
|
653
|
+
* @param inputs - Array of Tailwind classes
|
|
654
|
+
* @returns JSON string of compiled rules
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```ts
|
|
658
|
+
* const rules = compileClasses(['px-4', 'bg-blue-600', 'hover:opacity-80'])
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
declare function compileClasses(inputs: string[]): CssCompileResult;
|
|
662
|
+
/**
|
|
663
|
+
* One-step: class → CSS string
|
|
664
|
+
* Compiles and generates in single call
|
|
665
|
+
*
|
|
666
|
+
* @param input - Single Tailwind class
|
|
667
|
+
* @param minify - Whether to minify output (default: false)
|
|
668
|
+
* @returns Generated CSS string
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```ts
|
|
672
|
+
* const css = compileToCss('bg-blue-600')
|
|
673
|
+
* // Returns: ".bg-blue-600 { background-color: #2563eb; }"
|
|
674
|
+
*
|
|
675
|
+
* const minified = compileToCss('bg-blue-600', true)
|
|
676
|
+
* // Returns: ".bg-blue-600{background-color:#2563eb}"
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
declare function compileToCss(input: string, minify?: boolean): string;
|
|
680
|
+
/**
|
|
681
|
+
* Batch compile to CSS
|
|
682
|
+
* Compiles multiple classes and generates combined CSS
|
|
683
|
+
*
|
|
684
|
+
* @param inputs - Array of Tailwind classes
|
|
685
|
+
* @param minify - Whether to minify output
|
|
686
|
+
* @returns Combined CSS string
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* const css = compileToCssBatch(['px-4', 'bg-blue-600'], true)
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
declare function compileToCssBatch(inputs: string[], minify?: boolean): string;
|
|
694
|
+
/**
|
|
695
|
+
* Minify CSS string
|
|
696
|
+
* Removes unnecessary whitespace and formatting
|
|
697
|
+
*
|
|
698
|
+
* @param css - Raw CSS string
|
|
699
|
+
* @returns Minified CSS (40-60% size reduction)
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```ts
|
|
703
|
+
* const css = ".px-4 { padding-left: 1rem; padding-right: 1rem; }"
|
|
704
|
+
* const minified = minifyCss(css)
|
|
705
|
+
* // Returns: ".px-4{padding-left:1rem;padding-right:1rem}"
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
declare function minifyCss(css: string): string;
|
|
709
|
+
/**
|
|
710
|
+
* Compile animation from from/to states
|
|
711
|
+
* Generates @keyframes and animation rule
|
|
712
|
+
*
|
|
713
|
+
* @param animationName - Animation name
|
|
714
|
+
* @param from - From state classes (e.g., "opacity-0 scale-95")
|
|
715
|
+
* @param to - To state classes (e.g., "opacity-100 scale-100")
|
|
716
|
+
* @returns Compiled animation with keyframes
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```ts
|
|
720
|
+
* const anim = compileAnimation('fade-in', 'opacity-0', 'opacity-100')
|
|
721
|
+
* console.log(anim.keyframes_css) // @keyframes fade-in { ... }
|
|
722
|
+
* console.log(anim.animation_rule) // animation: fade-in 300ms;
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
declare function compileAnimation(animationName: string, from: string, to: string): CompiledAnimation;
|
|
726
|
+
/**
|
|
727
|
+
* Compile keyframes from stop definitions
|
|
728
|
+
* Creates @keyframes from percentage stops
|
|
729
|
+
*
|
|
730
|
+
* @param name - Keyframes name
|
|
731
|
+
* @param stopsJson - JSON array of stops: `[{"stop":"0%","classes":"opacity-0"}...]`
|
|
732
|
+
* @returns Compiled @keyframes rule
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```ts
|
|
736
|
+
* const kf = compileKeyframes('slide-in', JSON.stringify([
|
|
737
|
+
* { stop: '0%', classes: 'translate-x-full' },
|
|
738
|
+
* { stop: '100%', classes: 'translate-x-0' }
|
|
739
|
+
* ]))
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
declare function compileKeyframes(name: string, stopsJson: string): CompiledAnimation;
|
|
743
|
+
/**
|
|
744
|
+
* Compile theme to CSS variables
|
|
745
|
+
* Converts token map to CSS custom properties
|
|
746
|
+
*
|
|
747
|
+
* @param tokensJson - Theme tokens as JSON
|
|
748
|
+
* @param themeName - Theme name ("light", "dark", etc.)
|
|
749
|
+
* @param prefix - CSS variable prefix (e.g., "tw" → "--tw-color-primary")
|
|
750
|
+
* @returns Compiled theme with variables CSS
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* ```ts
|
|
754
|
+
* const theme = compileTheme(
|
|
755
|
+
* JSON.stringify({ colors: { blue: { 600: '#2563eb' } } }),
|
|
756
|
+
* 'light',
|
|
757
|
+
* 'tw'
|
|
758
|
+
* )
|
|
759
|
+
* // Returns CSS: :root { --tw-color-blue-600: #2563eb; }
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
declare function compileTheme(tokensJson: string, themeName: string, prefix: string): CompiledTheme;
|
|
763
|
+
/**
|
|
764
|
+
* Merge conflicting Tailwind classes
|
|
765
|
+
* Resolves conflicts intelligently (last-one-wins by default)
|
|
766
|
+
*
|
|
767
|
+
* @param classString - Space-separated class string (e.g., "px-4 px-8 bg-red-500 bg-blue-600")
|
|
768
|
+
* @returns Merged classes with conflicts resolved
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* const merged = twMerge('px-4 px-8 bg-red-500 bg-blue-600')
|
|
773
|
+
* // Returns: "px-8 bg-blue-600"
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
declare function twMerge(classString: string): string;
|
|
777
|
+
/**
|
|
778
|
+
* Merge multiple class strings
|
|
779
|
+
* Combines and resolves conflicts across multiple strings
|
|
780
|
+
*
|
|
781
|
+
* @param classStrings - Array of class strings
|
|
782
|
+
* @returns Merged result
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```ts
|
|
786
|
+
* const merged = twMergeMany([
|
|
787
|
+
* 'px-4 hover:bg-blue-600',
|
|
788
|
+
* 'px-8 hover:opacity-80'
|
|
789
|
+
* ])
|
|
790
|
+
* // Returns: "px-8 hover:bg-blue-600 hover:opacity-80"
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
793
|
+
declare function twMergeMany(classStrings: string[]): string;
|
|
794
|
+
/**
|
|
795
|
+
* Merge with custom separator
|
|
796
|
+
* Useful for non-standard class separators
|
|
797
|
+
*
|
|
798
|
+
* @param classString - Classes to merge
|
|
799
|
+
* @param options - Merge options (separator, debug)
|
|
800
|
+
* @returns Merged classes
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* ```ts
|
|
804
|
+
* const merged = twMergeWithSeparator(
|
|
805
|
+
* 'px-4,px-8,bg-red-500,bg-blue-600',
|
|
806
|
+
* { separator: ',' }
|
|
807
|
+
* )
|
|
808
|
+
* ```
|
|
809
|
+
*/
|
|
810
|
+
declare function twMergeWithSeparator(classString: string, options: TwMergeOptions): string;
|
|
811
|
+
/**
|
|
812
|
+
* Merge many with custom separator
|
|
813
|
+
* Batch merge with custom separator
|
|
814
|
+
*
|
|
815
|
+
* @param classStrings - Array of class strings
|
|
816
|
+
* @param options - Merge options
|
|
817
|
+
* @returns Merged result
|
|
818
|
+
*/
|
|
819
|
+
declare function twMergeManyWithSeparator(classStrings: string[], options: TwMergeOptions): string;
|
|
820
|
+
/**
|
|
821
|
+
* Raw merge from class lists
|
|
822
|
+
* Direct merge without preprocessing
|
|
823
|
+
*
|
|
824
|
+
* @param classLists - Array of class lists
|
|
825
|
+
* @returns Merged classes
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* ```ts
|
|
829
|
+
* const merged = twMergeRaw(['px-4 px-8', 'bg-red bg-blue'])
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
832
|
+
declare function twMergeRaw(classLists: string[]): string;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* idRegistryNative.ts
|
|
836
|
+
*
|
|
837
|
+
* Phase 5.2: ID Registry Management - Efficient ID generation and lookup
|
|
838
|
+
* Exposes 16 ID registry functions for deterministic class/component identification
|
|
839
|
+
*/
|
|
840
|
+
/**
|
|
841
|
+
* Registry snapshot data
|
|
842
|
+
*/
|
|
843
|
+
interface RegistrySnapshot {
|
|
844
|
+
handle: number;
|
|
845
|
+
next_id: number;
|
|
846
|
+
entries: Array<{
|
|
847
|
+
name: string;
|
|
848
|
+
id: number;
|
|
849
|
+
}>;
|
|
850
|
+
total_entries: number;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Create a new ID generator
|
|
854
|
+
* Returns a handle to be used in subsequent operations
|
|
855
|
+
*
|
|
856
|
+
* @returns Generator handle (u32)
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```ts
|
|
860
|
+
* const handle = idRegistryCreate()
|
|
861
|
+
* // Use handle for all subsequent operations
|
|
862
|
+
* try {
|
|
863
|
+
* const id = idRegistryGenerate(handle, 'MyComponent')
|
|
864
|
+
* // ... use id ...
|
|
865
|
+
* } finally {
|
|
866
|
+
* idRegistryDestroy(handle) // Clean up
|
|
867
|
+
* }
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
declare function idRegistryCreate(): number;
|
|
871
|
+
/**
|
|
872
|
+
* Generate a new ID for a name
|
|
873
|
+
* Same name always returns same ID (deterministic)
|
|
874
|
+
*
|
|
875
|
+
* @param handle - Generator handle from idRegistryCreate()
|
|
876
|
+
* @param name - Identifier name (e.g., component name, class name)
|
|
877
|
+
* @returns Generated ID
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```ts
|
|
881
|
+
* const handle = idRegistryCreate()
|
|
882
|
+
* const id1 = idRegistryGenerate(handle, 'Button') // Returns 1
|
|
883
|
+
* const id2 = idRegistryGenerate(handle, 'Button') // Returns 1 (same)
|
|
884
|
+
* const id3 = idRegistryGenerate(handle, 'Card') // Returns 2 (different)
|
|
885
|
+
* ```
|
|
886
|
+
*/
|
|
887
|
+
declare function idRegistryGenerate(handle: number, name: string): number;
|
|
888
|
+
/**
|
|
889
|
+
* Lookup existing ID for a name
|
|
890
|
+
* Returns -1 if not found
|
|
891
|
+
*
|
|
892
|
+
* @param handle - Generator handle
|
|
893
|
+
* @param name - Name to look up
|
|
894
|
+
* @returns ID if found, -1 if not found
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```ts
|
|
898
|
+
* const id = idRegistryLookup(handle, 'Button')
|
|
899
|
+
* if (id !== -1) {
|
|
900
|
+
* console.log(`Button has ID: ${id}`)
|
|
901
|
+
* } else {
|
|
902
|
+
* console.log('Button not in registry yet')
|
|
903
|
+
* }
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
906
|
+
declare function idRegistryLookup(handle: number, name: string): number;
|
|
907
|
+
/**
|
|
908
|
+
* Get the next ID that would be assigned
|
|
909
|
+
* Useful for knowing how many unique IDs exist
|
|
910
|
+
*
|
|
911
|
+
* @param handle - Generator handle
|
|
912
|
+
* @returns Next available ID
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```ts
|
|
916
|
+
* const handle = idRegistryCreate()
|
|
917
|
+
* idRegistryGenerate(handle, 'Button')
|
|
918
|
+
* idRegistryGenerate(handle, 'Card')
|
|
919
|
+
* const nextId = idRegistryNext(handle) // Returns 2 (next available)
|
|
920
|
+
* ```
|
|
921
|
+
*/
|
|
922
|
+
declare function idRegistryNext(handle: number): number;
|
|
923
|
+
/**
|
|
924
|
+
* Destroy a registry (clean up resources)
|
|
925
|
+
* Must be called when done with registry
|
|
926
|
+
*
|
|
927
|
+
* @param handle - Generator handle
|
|
928
|
+
*
|
|
929
|
+
* @example
|
|
930
|
+
* ```ts
|
|
931
|
+
* const handle = idRegistryCreate()
|
|
932
|
+
* try {
|
|
933
|
+
* // Use registry
|
|
934
|
+
* } finally {
|
|
935
|
+
* idRegistryDestroy(handle)
|
|
936
|
+
* }
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
declare function idRegistryDestroy(handle: number): void;
|
|
940
|
+
/**
|
|
941
|
+
* Reset registry to initial state
|
|
942
|
+
* Clears all entries but reuses handle
|
|
943
|
+
*
|
|
944
|
+
* @param handle - Generator handle
|
|
945
|
+
*
|
|
946
|
+
* @example
|
|
947
|
+
* ```ts
|
|
948
|
+
* const handle = idRegistryCreate()
|
|
949
|
+
* idRegistryGenerate(handle, 'Component1')
|
|
950
|
+
* idRegistryGenerate(handle, 'Component2')
|
|
951
|
+
* idRegistryReset(handle) // Clear all
|
|
952
|
+
* const id = idRegistryNext(handle) // Back to 0
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
declare function idRegistryReset(handle: number): void;
|
|
956
|
+
/**
|
|
957
|
+
* Get snapshot of current registry state
|
|
958
|
+
* Useful for serialization/debugging
|
|
959
|
+
*
|
|
960
|
+
* @param handle - Generator handle
|
|
961
|
+
* @returns Snapshot with all entries
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* ```ts
|
|
965
|
+
* const handle = idRegistryCreate()
|
|
966
|
+
* idRegistryGenerate(handle, 'Button')
|
|
967
|
+
* idRegistryGenerate(handle, 'Card')
|
|
968
|
+
* const snapshot = idRegistrySnapshot(handle)
|
|
969
|
+
* console.log(JSON.stringify(snapshot, null, 2))
|
|
970
|
+
* ```
|
|
971
|
+
*/
|
|
972
|
+
declare function idRegistrySnapshot(handle: number): RegistrySnapshot;
|
|
973
|
+
/**
|
|
974
|
+
* Get count of active registries
|
|
975
|
+
* Useful for monitoring resource usage
|
|
976
|
+
*
|
|
977
|
+
* @returns Number of active generator handles
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* ```ts
|
|
981
|
+
* console.log(`Active registries: ${idRegistryActiveCount()}`)
|
|
982
|
+
* ```
|
|
983
|
+
*/
|
|
984
|
+
declare function idRegistryActiveCount(): number;
|
|
985
|
+
/**
|
|
986
|
+
* Register a property name with global registry
|
|
987
|
+
* Maps property names to consistent IDs
|
|
988
|
+
*
|
|
989
|
+
* @param propertyName - Property name (e.g., "background-color")
|
|
990
|
+
* @returns Assigned property ID
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```ts
|
|
994
|
+
* const bgColorId = registerPropertyName('background-color')
|
|
995
|
+
* const paddingId = registerPropertyName('padding')
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
declare function registerPropertyName(propertyName: string): number;
|
|
999
|
+
/**
|
|
1000
|
+
* Register a value name with global registry
|
|
1001
|
+
* Maps values to consistent IDs
|
|
1002
|
+
*
|
|
1003
|
+
* @param valueName - Value name (e.g., "blue-600")
|
|
1004
|
+
* @returns Assigned value ID
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```ts
|
|
1008
|
+
* const blueId = registerValueName('blue-600')
|
|
1009
|
+
* const redId = registerValueName('red-500')
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
declare function registerValueName(valueName: string): number;
|
|
1013
|
+
/**
|
|
1014
|
+
* Convert property ID back to name
|
|
1015
|
+
* Reverse lookup for serialized data
|
|
1016
|
+
*
|
|
1017
|
+
* @param propertyId - Property ID
|
|
1018
|
+
* @returns Property name or empty string if not found
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```ts
|
|
1022
|
+
* const bgColorId = registerPropertyName('background-color')
|
|
1023
|
+
* const name = propertyIdToString(bgColorId)
|
|
1024
|
+
* console.log(name) // "background-color"
|
|
1025
|
+
* ```
|
|
1026
|
+
*/
|
|
1027
|
+
declare function propertyIdToString(propertyId: number): string;
|
|
1028
|
+
/**
|
|
1029
|
+
* Convert value ID back to name
|
|
1030
|
+
* Reverse lookup for serialized data
|
|
1031
|
+
*
|
|
1032
|
+
* @param valueId - Value ID
|
|
1033
|
+
* @returns Value name or empty string if not found
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```ts
|
|
1037
|
+
* const blueId = registerValueName('blue-600')
|
|
1038
|
+
* const value = valueIdToString(blueId)
|
|
1039
|
+
* console.log(value) // "blue-600"
|
|
1040
|
+
* ```
|
|
1041
|
+
*/
|
|
1042
|
+
declare function valueIdToString(valueId: number): string;
|
|
1043
|
+
/**
|
|
1044
|
+
* Reverse lookup: find property by ID
|
|
1045
|
+
* Alternative way to look up property names
|
|
1046
|
+
*
|
|
1047
|
+
* @param propertyId - Property ID to look up
|
|
1048
|
+
* @returns Property name
|
|
1049
|
+
*/
|
|
1050
|
+
declare function reverseLookupProperty(propertyId: number): string;
|
|
1051
|
+
/**
|
|
1052
|
+
* Reverse lookup: find value by ID
|
|
1053
|
+
* Alternative way to look up value names
|
|
1054
|
+
*
|
|
1055
|
+
* @param valueId - Value ID to look up
|
|
1056
|
+
* @returns Value name
|
|
1057
|
+
*/
|
|
1058
|
+
declare function reverseLookupValue(valueId: number): string;
|
|
1059
|
+
/**
|
|
1060
|
+
* Export registry state for persistence
|
|
1061
|
+
* Useful for saving/restoring registry data
|
|
1062
|
+
*
|
|
1063
|
+
* @param handle - Generator handle
|
|
1064
|
+
* @returns Serialized registry state
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
* ```ts
|
|
1068
|
+
* const exported = idRegistryExport(handle)
|
|
1069
|
+
* // Save to file/database
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
1072
|
+
declare function idRegistryExport(handle: number): string;
|
|
1073
|
+
/**
|
|
1074
|
+
* Import registry state
|
|
1075
|
+
* Restore registry from saved state
|
|
1076
|
+
*
|
|
1077
|
+
* @param importedData - Serialized registry data
|
|
1078
|
+
* @returns New handle with imported data
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```ts
|
|
1082
|
+
* const handle = idRegistryImport(savedData)
|
|
1083
|
+
* // Registry restored with same IDs
|
|
1084
|
+
* ```
|
|
1085
|
+
*/
|
|
1086
|
+
declare function idRegistryImport(importedData: string): number;
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* streamingNative.ts
|
|
1090
|
+
*
|
|
1091
|
+
* Phase 5.1: Streaming & Incremental Processing - Handle file changes efficiently
|
|
1092
|
+
* Exposes 8 functions for real-time incremental compilation
|
|
1093
|
+
*/
|
|
1094
|
+
/**
|
|
1095
|
+
* File change notification
|
|
1096
|
+
*/
|
|
1097
|
+
interface FileChangeEvent {
|
|
1098
|
+
file_path: string;
|
|
1099
|
+
event_type: "added" | "modified" | "deleted";
|
|
1100
|
+
old_content?: string;
|
|
1101
|
+
new_content?: string;
|
|
1102
|
+
timestamp_ms: number;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Processed file change result
|
|
1106
|
+
*/
|
|
1107
|
+
interface ProcessedFileChange {
|
|
1108
|
+
file_path: string;
|
|
1109
|
+
status: "processed" | "skipped" | "error";
|
|
1110
|
+
old_classes: string[];
|
|
1111
|
+
new_classes: string[];
|
|
1112
|
+
added_classes: string[];
|
|
1113
|
+
removed_classes: string[];
|
|
1114
|
+
changed: boolean;
|
|
1115
|
+
fingerprint: string;
|
|
1116
|
+
error?: string;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Diff between two scan results
|
|
1120
|
+
*/
|
|
1121
|
+
interface FileDiff {
|
|
1122
|
+
added_files: string[];
|
|
1123
|
+
removed_files: string[];
|
|
1124
|
+
modified_files: string[];
|
|
1125
|
+
added_classes: string[];
|
|
1126
|
+
removed_classes: string[];
|
|
1127
|
+
total_changes: number;
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* File fingerprint for change detection
|
|
1131
|
+
*/
|
|
1132
|
+
interface FileFingerprint {
|
|
1133
|
+
file_path: string;
|
|
1134
|
+
content_hash: string;
|
|
1135
|
+
size_bytes: number;
|
|
1136
|
+
mtime_ms: number;
|
|
1137
|
+
class_hash: string;
|
|
1138
|
+
signature: string;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Incremental diff result
|
|
1142
|
+
*/
|
|
1143
|
+
interface IncrementalDiffResult {
|
|
1144
|
+
is_changed: boolean;
|
|
1145
|
+
changes_count: number;
|
|
1146
|
+
diff: FileDiff;
|
|
1147
|
+
processing_time_ms: number;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* State injection result
|
|
1151
|
+
*/
|
|
1152
|
+
interface StateInjectionResult {
|
|
1153
|
+
injected: boolean;
|
|
1154
|
+
state_hash: string;
|
|
1155
|
+
affected_files: number;
|
|
1156
|
+
total_injected_bytes: number;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Stale entry pruning result
|
|
1160
|
+
*/
|
|
1161
|
+
interface PruneResult {
|
|
1162
|
+
entries_before: number;
|
|
1163
|
+
entries_after: number;
|
|
1164
|
+
entries_removed: number;
|
|
1165
|
+
freed_bytes: number;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Rebuilt workspace result
|
|
1169
|
+
*/
|
|
1170
|
+
interface RebuildWorkspaceResult {
|
|
1171
|
+
total_files_scanned: number;
|
|
1172
|
+
total_classes_found: number;
|
|
1173
|
+
unique_classes: number;
|
|
1174
|
+
build_time_ms: number;
|
|
1175
|
+
files_with_changes: number;
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Process a single file change event
|
|
1179
|
+
* Called when a file is added, modified, or deleted
|
|
1180
|
+
*
|
|
1181
|
+
* @param fileChangeJson - JSON string describing the file change
|
|
1182
|
+
* @returns Processing result with class changes
|
|
1183
|
+
*
|
|
1184
|
+
* @example
|
|
1185
|
+
* ```ts
|
|
1186
|
+
* const change = processFileChange(JSON.stringify({
|
|
1187
|
+
* file_path: 'src/Button.tsx',
|
|
1188
|
+
* event_type: 'modified',
|
|
1189
|
+
* new_content: 'export const Button = ...',
|
|
1190
|
+
* timestamp_ms: Date.now()
|
|
1191
|
+
* }))
|
|
1192
|
+
*
|
|
1193
|
+
* console.log('Added classes:', change.added_classes)
|
|
1194
|
+
* console.log('Removed classes:', change.removed_classes)
|
|
1195
|
+
* ```
|
|
1196
|
+
*/
|
|
1197
|
+
declare function processFileChange(fileChangeJson: string): ProcessedFileChange;
|
|
1198
|
+
/**
|
|
1199
|
+
* Compute incremental diff between old and new scan results
|
|
1200
|
+
* Efficient way to identify only what changed
|
|
1201
|
+
*
|
|
1202
|
+
* @param oldScanJson - JSON string of previous scan result
|
|
1203
|
+
* @param newScanJson - JSON string of new scan result
|
|
1204
|
+
* @returns Diff showing what changed
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* ```ts
|
|
1208
|
+
* const oldResult = scanWorkspace('./src')
|
|
1209
|
+
* // ... files changed ...
|
|
1210
|
+
* const newResult = scanWorkspace('./src')
|
|
1211
|
+
*
|
|
1212
|
+
* const diff = computeIncrementalDiff(
|
|
1213
|
+
* JSON.stringify(oldResult),
|
|
1214
|
+
* JSON.stringify(newResult)
|
|
1215
|
+
* )
|
|
1216
|
+
*
|
|
1217
|
+
* if (diff.is_changed) {
|
|
1218
|
+
* console.log(`${diff.changes_count} files changed`)
|
|
1219
|
+
* console.log('Added:', diff.diff.added_classes)
|
|
1220
|
+
* console.log('Removed:', diff.diff.removed_classes)
|
|
1221
|
+
* }
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
declare function computeIncrementalDiff(oldScanJson: string, newScanJson: string): IncrementalDiffResult;
|
|
1225
|
+
/**
|
|
1226
|
+
* Create a fingerprint of a file for change detection
|
|
1227
|
+
* Use fingerprints to quickly check if file needs reprocessing
|
|
1228
|
+
*
|
|
1229
|
+
* @param filePath - Path to file
|
|
1230
|
+
* @param fileContent - File content
|
|
1231
|
+
* @returns File fingerprint
|
|
1232
|
+
*
|
|
1233
|
+
* @example
|
|
1234
|
+
* ```ts
|
|
1235
|
+
* const fingerprint = createFingerprint('src/Button.tsx', fileContent)
|
|
1236
|
+
* // Store fingerprint, check later if content changed
|
|
1237
|
+
* const newFingerprint = createFingerprint('src/Button.tsx', newContent)
|
|
1238
|
+
* if (fingerprint.signature !== newFingerprint.signature) {
|
|
1239
|
+
* // Content changed, needs reprocessing
|
|
1240
|
+
* }
|
|
1241
|
+
* ```
|
|
1242
|
+
*/
|
|
1243
|
+
declare function createFingerprint(filePath: string, fileContent: string): FileFingerprint;
|
|
1244
|
+
/**
|
|
1245
|
+
* Inject state hash into compiled CSS
|
|
1246
|
+
* Marks CSS with version/state hash for cache busting
|
|
1247
|
+
*
|
|
1248
|
+
* @param css - Raw CSS string
|
|
1249
|
+
* @param stateHash - State hash to inject
|
|
1250
|
+
* @returns Modified CSS with injected state
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```ts
|
|
1254
|
+
* const css = compileCssNative2(['px-4', 'bg-blue-600'])
|
|
1255
|
+
* const withState = injectStateHash(css, 'v5-hash-123')
|
|
1256
|
+
* // CSS now includes version marker for cache control
|
|
1257
|
+
* ```
|
|
1258
|
+
*/
|
|
1259
|
+
declare function injectStateHash(css: string, stateHash: string): StateInjectionResult;
|
|
1260
|
+
/**
|
|
1261
|
+
* Prune stale entries from cache
|
|
1262
|
+
* Removes old/unused cache entries to free memory
|
|
1263
|
+
*
|
|
1264
|
+
* @param maxAgeSeconds - Remove entries older than this many seconds
|
|
1265
|
+
* @param maxEntries - Keep only this many most-recent entries
|
|
1266
|
+
* @returns Result of pruning operation
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* ```ts
|
|
1270
|
+
* // Remove cache entries older than 1 hour, keep max 10000 entries
|
|
1271
|
+
* const result = pruneStaleCacheEntries(3600, 10000)
|
|
1272
|
+
* console.log(`Freed ${result.freed_bytes / 1024}KB`)
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
declare function pruneStaleCacheEntries(maxAgeSeconds: number, maxEntries: number): PruneResult;
|
|
1276
|
+
/**
|
|
1277
|
+
* Rebuild workspace result from scratch
|
|
1278
|
+
* Useful after major configuration changes
|
|
1279
|
+
*
|
|
1280
|
+
* @param rootDir - Root directory to scan
|
|
1281
|
+
* @param extensions - File extensions to scan (e.g., [".tsx", ".ts"])
|
|
1282
|
+
* @returns Rebuilt workspace result
|
|
1283
|
+
*
|
|
1284
|
+
* @example
|
|
1285
|
+
* ```ts
|
|
1286
|
+
* const result = rebuildWorkspaceResult('./src', ['.tsx', '.ts'])
|
|
1287
|
+
* console.log(`Found ${result.unique_classes} unique classes`)
|
|
1288
|
+
* console.log(`${result.files_with_changes} files had changes`)
|
|
1289
|
+
* ```
|
|
1290
|
+
*/
|
|
1291
|
+
declare function rebuildWorkspaceResult(rootDir: string, extensions?: string[]): RebuildWorkspaceResult;
|
|
1292
|
+
/**
|
|
1293
|
+
* Scan a single file with incremental state
|
|
1294
|
+
* Returns only new/changed classes since last scan
|
|
1295
|
+
*
|
|
1296
|
+
* @param filePath - Path to file
|
|
1297
|
+
* @param fileContent - File content
|
|
1298
|
+
* @returns Updated classes and change status
|
|
1299
|
+
*
|
|
1300
|
+
* @example
|
|
1301
|
+
* ```ts
|
|
1302
|
+
* // On file change, get only what changed
|
|
1303
|
+
* const file = scanFileNative('src/Button.tsx', newContent)
|
|
1304
|
+
* if (file.changed) {
|
|
1305
|
+
* console.log('Added:', file.added_classes)
|
|
1306
|
+
* console.log('Removed:', file.removed_classes)
|
|
1307
|
+
* }
|
|
1308
|
+
* ```
|
|
1309
|
+
*/
|
|
1310
|
+
declare function scanFileNative(filePath: string, fileContent: string): {
|
|
1311
|
+
file: string;
|
|
1312
|
+
classes: string[];
|
|
1313
|
+
added_classes: string[];
|
|
1314
|
+
removed_classes: string[];
|
|
1315
|
+
changed: boolean;
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* Scan multiple files in batch with incremental state
|
|
1319
|
+
* Efficient batch processing of file changes
|
|
1320
|
+
*
|
|
1321
|
+
* @param filesJson - JSON array of {file, content} objects
|
|
1322
|
+
* @returns Results for each file
|
|
1323
|
+
*
|
|
1324
|
+
* @example
|
|
1325
|
+
* ```ts
|
|
1326
|
+
* const files = [
|
|
1327
|
+
* { file: 'src/Button.tsx', content: newButtonContent },
|
|
1328
|
+
* { file: 'src/Card.tsx', content: newCardContent }
|
|
1329
|
+
* ]
|
|
1330
|
+
* const results = scanFilesBatchNative(JSON.stringify(files))
|
|
1331
|
+
* ```
|
|
1332
|
+
*/
|
|
1333
|
+
declare function scanFilesBatchNative(filesJson: string): Array<{
|
|
1334
|
+
file: string;
|
|
1335
|
+
classes: string[];
|
|
1336
|
+
changed: boolean;
|
|
1337
|
+
}>;
|
|
1338
|
+
|
|
1339
|
+
interface CssPipelineResult {
|
|
1340
|
+
css: string;
|
|
1341
|
+
classes: string[];
|
|
1342
|
+
sizeBytes: number;
|
|
1343
|
+
optimized: boolean;
|
|
1344
|
+
}
|
|
1345
|
+
declare function runCssPipeline(classes: string[], cssEntryContent?: string, root?: string, minify?: boolean): Promise<CssPipelineResult>;
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Parser Sub-entry Point
|
|
1349
|
+
*
|
|
1350
|
+
* Exports class parsing and extraction functionality.
|
|
1351
|
+
* - Tailwind class parsing
|
|
1352
|
+
* - Class extraction from source
|
|
1353
|
+
* - Class normalization and deduplication
|
|
1354
|
+
* - Component analysis
|
|
1355
|
+
*/
|
|
1356
|
+
declare const parseClasses: (raw: string) => Array<{
|
|
1357
|
+
raw: string;
|
|
1358
|
+
type: string;
|
|
1359
|
+
}>;
|
|
1360
|
+
declare const extractAllClasses: (source: string) => string[];
|
|
1361
|
+
declare const extractClassesFromSource: (source: string) => string;
|
|
1362
|
+
declare const astExtractClasses: (source: string, _filename: string) => string[];
|
|
1363
|
+
declare const normalizeClasses: (raw: string) => string;
|
|
1364
|
+
declare const mergeClassesStatic: (classes: string) => string;
|
|
1365
|
+
declare const normalizeAndDedupClasses: (raw: string) => {
|
|
1366
|
+
normalized: string;
|
|
1367
|
+
duplicatesRemoved: number;
|
|
1368
|
+
uniqueCount: number;
|
|
1369
|
+
};
|
|
1370
|
+
declare const extractComponentUsage: (source: string) => Array<{
|
|
1371
|
+
component: string;
|
|
1372
|
+
propsJson: string;
|
|
1373
|
+
}>;
|
|
1374
|
+
declare const batchExtractClasses: (filePaths: string[]) => {
|
|
1375
|
+
file: string;
|
|
1376
|
+
classes: string[];
|
|
1377
|
+
contentHash: string;
|
|
1378
|
+
ok: boolean;
|
|
1379
|
+
error?: string;
|
|
1380
|
+
}[];
|
|
1381
|
+
declare const checkAgainstSafelist: (classes: string[], safelist: string[]) => {
|
|
1382
|
+
matched: string[];
|
|
1383
|
+
unmatched: string[];
|
|
1384
|
+
safelistSize: number;
|
|
1385
|
+
};
|
|
1386
|
+
declare const diffClassLists: (previous: string[], current: string[]) => {
|
|
1387
|
+
added: string[];
|
|
1388
|
+
removed: string[];
|
|
1389
|
+
unchanged: string[];
|
|
1390
|
+
hasChanges: boolean;
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* Detect dead CSS selectors in generated CSS.
|
|
1395
|
+
*/
|
|
1396
|
+
declare function detectDeadCode(scanResultJson: string, css: string): DeadCodeResult;
|
|
1397
|
+
/**
|
|
1398
|
+
* Analyze class usage across scanned files.
|
|
1399
|
+
*/
|
|
1400
|
+
declare function analyzeClassUsageNative(classes: string[], scanResultJson: string, css: string): ClassUsageItem[];
|
|
1401
|
+
/**
|
|
1402
|
+
* Analyze entire class list and generate CSS.
|
|
1403
|
+
*/
|
|
1404
|
+
declare function analyzeClassesNative(filesJson: string, cwd: string, flags?: number): {
|
|
1405
|
+
css?: string;
|
|
1406
|
+
code: string;
|
|
1407
|
+
classes: string[];
|
|
1408
|
+
changed: boolean;
|
|
1409
|
+
rscJson?: string;
|
|
1410
|
+
metadataJson?: string;
|
|
1411
|
+
safelist?: string[];
|
|
1412
|
+
} | null;
|
|
1413
|
+
/**
|
|
1414
|
+
* Analyze React Server Component requirements.
|
|
1415
|
+
*/
|
|
1416
|
+
declare function analyzeRscNative(source: string, filename: string): {
|
|
1417
|
+
isServer: boolean;
|
|
1418
|
+
needsClientDirective: boolean;
|
|
1419
|
+
clientReasons: string[];
|
|
1420
|
+
};
|
|
1421
|
+
/**
|
|
1422
|
+
* Optimize CSS by removing dead code and minifying.
|
|
1423
|
+
*/
|
|
1424
|
+
declare function optimizeCssNative(css: string): {
|
|
1425
|
+
css: string;
|
|
1426
|
+
originalSize: number;
|
|
1427
|
+
optimizedSize: number;
|
|
1428
|
+
reductionPercentage: number;
|
|
1429
|
+
};
|
|
1430
|
+
/**
|
|
1431
|
+
* Process Tailwind CSS with Lightning CSS post-processing.
|
|
1432
|
+
*/
|
|
1433
|
+
declare function processTailwindCssLightning(css: string): ProcessedCssResult;
|
|
1434
|
+
/**
|
|
1435
|
+
* Eliminate dead CSS selectors.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function eliminateDeadCssNative(css: string, deadClasses: string[]): string;
|
|
1438
|
+
/**
|
|
1439
|
+
* Hoist components from source code.
|
|
1440
|
+
*/
|
|
1441
|
+
declare function hoistComponentsNative(source: string): HoistResult;
|
|
1442
|
+
/**
|
|
1443
|
+
* Compile variant configuration table.
|
|
1444
|
+
*/
|
|
1445
|
+
declare function compileVariantTableNative(configJson: string): VariantTableResult;
|
|
1446
|
+
/**
|
|
1447
|
+
* Classify and sort classes by bucket.
|
|
1448
|
+
*/
|
|
1449
|
+
declare function classifyAndSortClassesNative(classes: string[]): ClassifyResult[];
|
|
1450
|
+
/**
|
|
1451
|
+
* Merge CSS declarations from multiple chunks.
|
|
1452
|
+
*/
|
|
1453
|
+
declare function mergeCssDeclarationsNative(cssChunks: string[]): MergeResult;
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* themeResolutionNative.ts
|
|
1457
|
+
*
|
|
1458
|
+
* Phase 5.1: Theme Resolution Extended - Advanced theme configuration handling
|
|
1459
|
+
* Exposes 7 theme resolution functions for complex Tailwind configurations
|
|
1460
|
+
*/
|
|
1461
|
+
/**
|
|
1462
|
+
* Validation result for theme config
|
|
1463
|
+
*/
|
|
1464
|
+
interface ThemeValidationResult {
|
|
1465
|
+
is_valid: boolean;
|
|
1466
|
+
errors: string[];
|
|
1467
|
+
warnings: string[];
|
|
1468
|
+
suggestions: string[];
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Resolved variant configuration
|
|
1472
|
+
*/
|
|
1473
|
+
interface ResolvedVariantConfig {
|
|
1474
|
+
variants: string[];
|
|
1475
|
+
supported: string[];
|
|
1476
|
+
deprecated: string[];
|
|
1477
|
+
conflicting: string[];
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Theme cascade resolution result
|
|
1481
|
+
*/
|
|
1482
|
+
interface ThemeCascadeResult {
|
|
1483
|
+
base_theme: Record<string, unknown>;
|
|
1484
|
+
user_overrides: Record<string, unknown>;
|
|
1485
|
+
merged_theme: Record<string, unknown>;
|
|
1486
|
+
conflict_resolutions: Array<{
|
|
1487
|
+
key: string;
|
|
1488
|
+
base_value: unknown;
|
|
1489
|
+
override_value: unknown;
|
|
1490
|
+
resolution: "override" | "merge" | "error";
|
|
1491
|
+
}>;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Class name resolution from theme
|
|
1495
|
+
*/
|
|
1496
|
+
interface ResolvedClassName {
|
|
1497
|
+
class_name: string;
|
|
1498
|
+
property: string;
|
|
1499
|
+
value: string;
|
|
1500
|
+
from_theme_path: string;
|
|
1501
|
+
is_responsive: boolean;
|
|
1502
|
+
variants: string[];
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Conflict group information
|
|
1506
|
+
*/
|
|
1507
|
+
interface ConflictGroupInfo {
|
|
1508
|
+
group_name: string;
|
|
1509
|
+
conflicting_classes: string[];
|
|
1510
|
+
description: string;
|
|
1511
|
+
resolution_strategy: string;
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Get all resolved variants from theme configuration
|
|
1515
|
+
* Parses theme config and returns all variant prefixes
|
|
1516
|
+
*
|
|
1517
|
+
* @param configJson - JSON string of theme configuration
|
|
1518
|
+
* @returns Resolved variants with metadata
|
|
1519
|
+
*
|
|
1520
|
+
* @example
|
|
1521
|
+
* ```ts
|
|
1522
|
+
* const config = {
|
|
1523
|
+
* screens: { md: '768px', lg: '1024px' },
|
|
1524
|
+
* state: { hover: '&:hover', focus: '&:focus' }
|
|
1525
|
+
* }
|
|
1526
|
+
* const variants = resolveVariants(JSON.stringify(config))
|
|
1527
|
+
* console.log(variants.variants) // ['md', 'lg', 'hover', 'focus', ...]
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
declare function resolveVariants(configJson: string): ResolvedVariantConfig;
|
|
1531
|
+
/**
|
|
1532
|
+
* Validate theme configuration for correctness
|
|
1533
|
+
* Checks for common issues and provides warnings
|
|
1534
|
+
*
|
|
1535
|
+
* @param configJson - JSON string of theme configuration
|
|
1536
|
+
* @returns Validation result with errors and suggestions
|
|
1537
|
+
*
|
|
1538
|
+
* @example
|
|
1539
|
+
* ```ts
|
|
1540
|
+
* const result = validateThemeConfig(JSON.stringify(myTheme))
|
|
1541
|
+
* if (!result.is_valid) {
|
|
1542
|
+
* console.error('Errors:', result.errors)
|
|
1543
|
+
* console.warn('Warnings:', result.warnings)
|
|
1544
|
+
* }
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
declare function validateThemeConfig(configJson: string): ThemeValidationResult;
|
|
1548
|
+
/**
|
|
1549
|
+
* Resolve theme cascade (base + overrides)
|
|
1550
|
+
* Merges base theme with user overrides intelligently
|
|
1551
|
+
*
|
|
1552
|
+
* @param baseThemeJson - Base theme configuration
|
|
1553
|
+
* @param overridesJson - User overrides configuration
|
|
1554
|
+
* @returns Merged theme with conflict information
|
|
1555
|
+
*
|
|
1556
|
+
* @example
|
|
1557
|
+
* ```ts
|
|
1558
|
+
* const cascade = resolveCascade(
|
|
1559
|
+
* JSON.stringify(baseTheme),
|
|
1560
|
+
* JSON.stringify(userOverrides)
|
|
1561
|
+
* )
|
|
1562
|
+
* console.log(cascade.merged_theme)
|
|
1563
|
+
* console.log('Conflicts resolved:', cascade.conflict_resolutions.length)
|
|
1564
|
+
* ```
|
|
1565
|
+
*/
|
|
1566
|
+
declare function resolveCascade(baseThemeJson: string, overridesJson: string): ThemeCascadeResult;
|
|
1567
|
+
/**
|
|
1568
|
+
* Resolve class names from theme
|
|
1569
|
+
* Maps Tailwind class names to theme values
|
|
1570
|
+
*
|
|
1571
|
+
* @param classNames - Array of Tailwind class names (e.g., ["text-lg", "bg-blue-600"])
|
|
1572
|
+
* @param themeJson - Theme configuration
|
|
1573
|
+
* @returns Resolved class name information
|
|
1574
|
+
*
|
|
1575
|
+
* @example
|
|
1576
|
+
* ```ts
|
|
1577
|
+
* const resolved = resolveClassNames(
|
|
1578
|
+
* ['text-lg', 'bg-blue-600', 'md:p-4'],
|
|
1579
|
+
* JSON.stringify(theme)
|
|
1580
|
+
* )
|
|
1581
|
+
* resolved.forEach(item => {
|
|
1582
|
+
* console.log(`${item.class_name} -> ${item.property}: ${item.value}`)
|
|
1583
|
+
* })
|
|
1584
|
+
* ```
|
|
1585
|
+
*/
|
|
1586
|
+
declare function resolveClassNames(classNames: string[], themeJson: string): ResolvedClassName[];
|
|
1587
|
+
/**
|
|
1588
|
+
* Get conflict group information
|
|
1589
|
+
* Identifies classes that conflict with each other
|
|
1590
|
+
*
|
|
1591
|
+
* @param groupName - Conflict group name (e.g., "display", "position", "flex-direction")
|
|
1592
|
+
* @param themeJson - Theme configuration
|
|
1593
|
+
* @returns Information about the conflict group
|
|
1594
|
+
*
|
|
1595
|
+
* @example
|
|
1596
|
+
* ```ts
|
|
1597
|
+
* const info = resolveConflictGroup('display', JSON.stringify(theme))
|
|
1598
|
+
* console.log('Conflicting classes:', info.conflicting_classes)
|
|
1599
|
+
* console.log('Strategy:', info.resolution_strategy)
|
|
1600
|
+
* ```
|
|
1601
|
+
*/
|
|
1602
|
+
declare function resolveConflictGroup(groupName: string, themeJson: string): ConflictGroupInfo;
|
|
1603
|
+
/**
|
|
1604
|
+
* Resolve theme value from key path
|
|
1605
|
+
* Navigates nested theme config to find values
|
|
1606
|
+
*
|
|
1607
|
+
* @param keyPath - Dot-separated path (e.g., "colors.blue.600")
|
|
1608
|
+
* @param themeJson - Theme configuration
|
|
1609
|
+
* @returns Resolved value or null if not found
|
|
1610
|
+
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* ```ts
|
|
1613
|
+
* const color = resolveThemeValue('colors.blue.600', JSON.stringify(theme))
|
|
1614
|
+
* console.log(color) // "#2563eb" or similar
|
|
1615
|
+
* ```
|
|
1616
|
+
*/
|
|
1617
|
+
declare function resolveThemeValue(keyPath: string, themeJson: string): string | null;
|
|
1618
|
+
/**
|
|
1619
|
+
* Get all simple variants from configuration
|
|
1620
|
+
* Returns variants that don't require complex selector nesting
|
|
1621
|
+
*
|
|
1622
|
+
* @param configJson - Theme/variant configuration
|
|
1623
|
+
* @returns Array of simple variant names
|
|
1624
|
+
*
|
|
1625
|
+
* @example
|
|
1626
|
+
* ```ts
|
|
1627
|
+
* const simpleVariants = resolveSimpleVariants(JSON.stringify(config))
|
|
1628
|
+
* console.log(simpleVariants)
|
|
1629
|
+
* // ["hover", "focus", "active", "group-hover", ...]
|
|
1630
|
+
* ```
|
|
1631
|
+
*/
|
|
1632
|
+
declare function resolveSimpleVariants(configJson: string): string[];
|
|
1633
|
+
|
|
1634
|
+
declare function scanWorkspace(root: string, extensions?: string[]): ScanWorkspaceResult;
|
|
1635
|
+
declare function extractClassesFromSourceNative(source: string): string[];
|
|
1636
|
+
declare function batchExtractClassesNative(filePaths: string[]): BatchExtractResult[];
|
|
1637
|
+
declare function checkAgainstSafelistNative(classes: string[], safelist: string[]): SafelistCheckResult;
|
|
1638
|
+
declare function scanFile(filePath: string): ScanFileResult;
|
|
1639
|
+
declare function collectFiles(root: string, extensions?: string[]): string[];
|
|
1640
|
+
declare function walkAndPrefilterSourceFiles(root: string, extensions?: string[], _parallel?: boolean): PrefilterFileResult[];
|
|
1641
|
+
declare function generateSubComponentTypes(root: string, outputPath?: string): string;
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* cacheNative.ts
|
|
1645
|
+
*
|
|
1646
|
+
* Phase 5.1: Cache Management - Advanced caching strategies and optimization
|
|
1647
|
+
* Exposes 9 cache-related Rust functions for improved performance tuning
|
|
1648
|
+
*/
|
|
1649
|
+
/**
|
|
1650
|
+
* Cache optimization hints and recommendations
|
|
1651
|
+
*/
|
|
1652
|
+
interface CacheOptimizationHints {
|
|
1653
|
+
current_strategy: string;
|
|
1654
|
+
recommended_strategy: string;
|
|
1655
|
+
estimated_improvement_percent: number;
|
|
1656
|
+
suggested_memory_mb: number;
|
|
1657
|
+
notes: string[];
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Optimal cache configuration recommendations
|
|
1661
|
+
*/
|
|
1662
|
+
interface OptimalCacheConfig {
|
|
1663
|
+
parse_cache_size: number;
|
|
1664
|
+
resolve_cache_size: number;
|
|
1665
|
+
compile_cache_size: number;
|
|
1666
|
+
css_gen_cache_size: number;
|
|
1667
|
+
recommended_eviction_policy: string;
|
|
1668
|
+
ttl_seconds: number;
|
|
1669
|
+
expected_hit_rate_percent: number;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Cache statistics from all layers
|
|
1673
|
+
*/
|
|
1674
|
+
interface CacheStatistics {
|
|
1675
|
+
parse_cache: {
|
|
1676
|
+
hits: number;
|
|
1677
|
+
misses: number;
|
|
1678
|
+
size: number;
|
|
1679
|
+
};
|
|
1680
|
+
resolve_cache: {
|
|
1681
|
+
hits: number;
|
|
1682
|
+
misses: number;
|
|
1683
|
+
size: number;
|
|
1684
|
+
};
|
|
1685
|
+
compile_cache: {
|
|
1686
|
+
hits: number;
|
|
1687
|
+
misses: number;
|
|
1688
|
+
size: number;
|
|
1689
|
+
};
|
|
1690
|
+
css_gen_cache: {
|
|
1691
|
+
hits: number;
|
|
1692
|
+
misses: number;
|
|
1693
|
+
size: number;
|
|
1694
|
+
};
|
|
1695
|
+
overall_hit_rate: number;
|
|
1696
|
+
total_memory_bytes: number;
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Get comprehensive cache statistics across all layers
|
|
1700
|
+
* Useful for monitoring and optimization
|
|
1701
|
+
*
|
|
1702
|
+
* @returns Cache stats including hit rates, sizes, and recommendations
|
|
1703
|
+
* @example
|
|
1704
|
+
* ```ts
|
|
1705
|
+
* const stats = getCacheStatistics()
|
|
1706
|
+
* console.log(`Overall hit rate: ${stats.overall_hit_rate}%`)
|
|
1707
|
+
* console.log(`Total memory used: ${stats.total_memory_bytes / 1024}KB`)
|
|
1708
|
+
* ```
|
|
1709
|
+
*/
|
|
1710
|
+
declare function getCacheStatistics(): CacheStatistics;
|
|
1711
|
+
/**
|
|
1712
|
+
* Clear all caches (parse, resolve, compile, CSS generation)
|
|
1713
|
+
* Use when switching themes or major configuration changes
|
|
1714
|
+
*
|
|
1715
|
+
* @example
|
|
1716
|
+
* ```ts
|
|
1717
|
+
* // Clear before switching themes
|
|
1718
|
+
* clearAllCaches()
|
|
1719
|
+
* const css = await generateCssNative(classes, { theme: newTheme })
|
|
1720
|
+
* ```
|
|
1721
|
+
*/
|
|
1722
|
+
declare function clearAllCaches(): void;
|
|
1723
|
+
/**
|
|
1724
|
+
* Clear only the parse cache
|
|
1725
|
+
* Useful when parser behavior changes or cache gets stale
|
|
1726
|
+
*/
|
|
1727
|
+
declare function clearParseCache(): void;
|
|
1728
|
+
/**
|
|
1729
|
+
* Clear only the resolve cache
|
|
1730
|
+
* Use when theme configuration changes
|
|
1731
|
+
*/
|
|
1732
|
+
declare function clearResolveCache(): void;
|
|
1733
|
+
/**
|
|
1734
|
+
* Clear only the compile cache
|
|
1735
|
+
* Use when Tailwind configuration changes
|
|
1736
|
+
*/
|
|
1737
|
+
declare function clearCompileCache(): void;
|
|
1738
|
+
/**
|
|
1739
|
+
* Clear only the CSS generation cache
|
|
1740
|
+
* Use when theme or layout changes
|
|
1741
|
+
*/
|
|
1742
|
+
declare function clearCssGenCache(): void;
|
|
1743
|
+
/**
|
|
1744
|
+
* Get optimization hints based on current cache performance
|
|
1745
|
+
* Analyzes hit rates and suggests improvements
|
|
1746
|
+
*
|
|
1747
|
+
* @param hitRatePercent - Current hit rate (0-100)
|
|
1748
|
+
* @param memoryUsedMb - Memory currently used in MB
|
|
1749
|
+
* @returns Optimization recommendations
|
|
1750
|
+
*
|
|
1751
|
+
* @example
|
|
1752
|
+
* ```ts
|
|
1753
|
+
* const stats = getCacheStatistics()
|
|
1754
|
+
* const hints = getCacheOptimizationHints(
|
|
1755
|
+
* stats.overall_hit_rate,
|
|
1756
|
+
* stats.total_memory_bytes / (1024 * 1024)
|
|
1757
|
+
* )
|
|
1758
|
+
* console.log(`Recommendation: ${hints.recommended_strategy}`)
|
|
1759
|
+
* console.log(`Potential improvement: ${hints.estimated_improvement_percent}%`)
|
|
1760
|
+
* ```
|
|
1761
|
+
*/
|
|
1762
|
+
declare function getCacheOptimizationHints(hitRatePercent: number, memoryUsedMb: number): CacheOptimizationHints;
|
|
1763
|
+
/**
|
|
1764
|
+
* Estimate optimal cache configuration for your workload
|
|
1765
|
+
* Analyzes typical patterns and recommends sizes
|
|
1766
|
+
*
|
|
1767
|
+
* @param totalBudgetMb - Maximum memory budget in MB
|
|
1768
|
+
* @param workloadType - "small" (< 100 files), "medium" (100-1000), "large" (1000+)
|
|
1769
|
+
* @returns Recommended cache configuration
|
|
1770
|
+
*
|
|
1771
|
+
* @example
|
|
1772
|
+
* ```ts
|
|
1773
|
+
* const config = estimateOptimalCacheConfig(512, 'large')
|
|
1774
|
+
* console.log(`Parse cache: ${config.parse_cache_size}MB`)
|
|
1775
|
+
* console.log(`Expected hit rate: ${config.expected_hit_rate_percent}%`)
|
|
1776
|
+
* ```
|
|
1777
|
+
*/
|
|
1778
|
+
declare function estimateOptimalCacheConfig(totalBudgetMb: number, workloadType: "small" | "medium" | "large"): OptimalCacheConfig;
|
|
1779
|
+
/**
|
|
1780
|
+
* Read cache from disk (persistence)
|
|
1781
|
+
* Restores cached data from previous sessions
|
|
1782
|
+
*
|
|
1783
|
+
* @param cachePath - Path to cache file
|
|
1784
|
+
* @returns Entries loaded from disk
|
|
1785
|
+
*
|
|
1786
|
+
* @example
|
|
1787
|
+
* ```ts
|
|
1788
|
+
* const entries = cacheRead('./.tw-cache/scan.json')
|
|
1789
|
+
* // Warm up cache with persisted data
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
1792
|
+
declare function cacheRead(cachePath: string): Array<{
|
|
1793
|
+
file: string;
|
|
1794
|
+
contentHash: string;
|
|
1795
|
+
classes: string[];
|
|
1796
|
+
mtimeMs: number;
|
|
1797
|
+
sizeBytes: number;
|
|
1798
|
+
}>;
|
|
1799
|
+
/**
|
|
1800
|
+
* Write cache to disk (persistence)
|
|
1801
|
+
* Saves cached data for next session
|
|
1802
|
+
*
|
|
1803
|
+
* @param cachePath - Path where cache should be written
|
|
1804
|
+
* @param entries - Cache entries to persist
|
|
1805
|
+
* @returns Success status
|
|
1806
|
+
*
|
|
1807
|
+
* @example
|
|
1808
|
+
* ```ts
|
|
1809
|
+
* const stats = getCacheStatistics()
|
|
1810
|
+
* const success = cacheWrite(
|
|
1811
|
+
* './.tw-cache/scan.json',
|
|
1812
|
+
* // entries array from previous scan
|
|
1813
|
+
* )
|
|
1814
|
+
* ```
|
|
1815
|
+
*/
|
|
1816
|
+
declare function cacheWrite(cachePath: string, entries: Array<{
|
|
1817
|
+
file: string;
|
|
1818
|
+
contentHash: string;
|
|
1819
|
+
classes: string[];
|
|
1820
|
+
mtimeMs: number;
|
|
1821
|
+
sizeBytes: number;
|
|
1822
|
+
}>): boolean;
|
|
1823
|
+
/**
|
|
1824
|
+
* Calculate cache priority score for file ordering
|
|
1825
|
+
* Useful for prioritizing which files to scan first
|
|
1826
|
+
*
|
|
1827
|
+
* @param mtimeMs - File modification time in milliseconds
|
|
1828
|
+
* @param sizeBytes - File size in bytes
|
|
1829
|
+
* @param hitCount - Number of times this file was accessed from cache
|
|
1830
|
+
* @returns Priority score (higher = process first)
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* ```ts
|
|
1834
|
+
* const priority = cachePriority(Date.now(), 2048, 5)
|
|
1835
|
+
* // Use priority to sort files for scanning
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
declare function cachePriority(mtimeMs: number, sizeBytes: number, hitCount: number): number;
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* redisNative.ts
|
|
1842
|
+
*
|
|
1843
|
+
* Phase 5.3: Redis Integration - Distributed caching and cluster support
|
|
1844
|
+
* Exposes 40 Redis functions for high-performance distributed CSS compilation caching
|
|
1845
|
+
*/
|
|
1846
|
+
/**
|
|
1847
|
+
* Redis pool configuration
|
|
1848
|
+
*/
|
|
1849
|
+
interface RedisCacheConfig {
|
|
1850
|
+
host: string;
|
|
1851
|
+
port: number;
|
|
1852
|
+
database: number;
|
|
1853
|
+
password?: string;
|
|
1854
|
+
pool_size: number;
|
|
1855
|
+
connection_timeout_ms: number;
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Redis pool statistics
|
|
1859
|
+
*/
|
|
1860
|
+
interface RedisPoolStats {
|
|
1861
|
+
connected_count: number;
|
|
1862
|
+
idle_count: number;
|
|
1863
|
+
waiting_count: number;
|
|
1864
|
+
total_requests: number;
|
|
1865
|
+
total_errors: number;
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Redis cluster node information
|
|
1869
|
+
*/
|
|
1870
|
+
interface RedisClusterNode {
|
|
1871
|
+
node_id: string;
|
|
1872
|
+
host: string;
|
|
1873
|
+
port: number;
|
|
1874
|
+
is_master: boolean;
|
|
1875
|
+
slot_range: Array<{
|
|
1876
|
+
start: number;
|
|
1877
|
+
end: number;
|
|
1878
|
+
}>;
|
|
1879
|
+
connected: boolean;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Redis cluster status
|
|
1883
|
+
*/
|
|
1884
|
+
interface RedisClusterStatus {
|
|
1885
|
+
enabled: boolean;
|
|
1886
|
+
cluster_state: string;
|
|
1887
|
+
nodes: RedisClusterNode[];
|
|
1888
|
+
slots_assigned: number;
|
|
1889
|
+
slots_ok: number;
|
|
1890
|
+
slots_fail: number;
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Key expiration information
|
|
1894
|
+
*/
|
|
1895
|
+
interface KeyExpiration {
|
|
1896
|
+
key: string;
|
|
1897
|
+
ttl_seconds: number;
|
|
1898
|
+
expiration_timestamp: number;
|
|
1899
|
+
is_persistent: boolean;
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Pub/Sub message
|
|
1903
|
+
*/
|
|
1904
|
+
interface PubSubMessage {
|
|
1905
|
+
channel: string;
|
|
1906
|
+
message: string;
|
|
1907
|
+
timestamp_ms: number;
|
|
1908
|
+
subscriber_count: number;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Connection pool information
|
|
1912
|
+
*/
|
|
1913
|
+
interface PoolInfo {
|
|
1914
|
+
host: string;
|
|
1915
|
+
port: number;
|
|
1916
|
+
pool_size: number;
|
|
1917
|
+
active_connections: number;
|
|
1918
|
+
idle_connections: number;
|
|
1919
|
+
average_latency_ms: number;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Ping Redis server for connectivity check
|
|
1923
|
+
*
|
|
1924
|
+
* @returns "PONG" if connected, error message otherwise
|
|
1925
|
+
*
|
|
1926
|
+
* @example
|
|
1927
|
+
* ```ts
|
|
1928
|
+
* const response = redisPing()
|
|
1929
|
+
* if (response === "PONG") console.log("Connected")
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
declare function redisPing(): string;
|
|
1933
|
+
/**
|
|
1934
|
+
* Get value from Redis
|
|
1935
|
+
*
|
|
1936
|
+
* @param key - Cache key
|
|
1937
|
+
* @returns Value if found, null if not found
|
|
1938
|
+
*
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```ts
|
|
1941
|
+
* const value = redisGet('compiled:bg-blue-600')
|
|
1942
|
+
* if (value) console.log(JSON.parse(value))
|
|
1943
|
+
* ```
|
|
1944
|
+
*/
|
|
1945
|
+
declare function redisGet(key: string): string | null;
|
|
1946
|
+
/**
|
|
1947
|
+
* Set value in Redis
|
|
1948
|
+
*
|
|
1949
|
+
* @param key - Cache key
|
|
1950
|
+
* @param value - Value to store
|
|
1951
|
+
* @param ttl_seconds - Time to live in seconds (optional)
|
|
1952
|
+
* @returns "OK" on success
|
|
1953
|
+
*
|
|
1954
|
+
* @example
|
|
1955
|
+
* ```ts
|
|
1956
|
+
* redisSet('compiled:bg-blue-600', JSON.stringify(css), 3600)
|
|
1957
|
+
* ```
|
|
1958
|
+
*/
|
|
1959
|
+
declare function redisSet(key: string, value: string, ttl_seconds?: number): string;
|
|
1960
|
+
/**
|
|
1961
|
+
* Delete key from Redis
|
|
1962
|
+
*
|
|
1963
|
+
* @param key - Cache key
|
|
1964
|
+
* @returns Number of keys deleted
|
|
1965
|
+
*
|
|
1966
|
+
* @example
|
|
1967
|
+
* ```ts
|
|
1968
|
+
* const deleted = redisDelete('compiled:bg-blue-600')
|
|
1969
|
+
* console.log(`Deleted ${deleted} keys`)
|
|
1970
|
+
* ```
|
|
1971
|
+
*/
|
|
1972
|
+
declare function redisDelete(key: string): number;
|
|
1973
|
+
/**
|
|
1974
|
+
* Check if key exists in Redis
|
|
1975
|
+
*
|
|
1976
|
+
* @param key - Cache key
|
|
1977
|
+
* @returns 1 if exists, 0 if not
|
|
1978
|
+
*
|
|
1979
|
+
* @example
|
|
1980
|
+
* ```ts
|
|
1981
|
+
* if (redisExists('compiled:bg-blue-600')) {
|
|
1982
|
+
* console.log('Cache hit')
|
|
1983
|
+
* }
|
|
1984
|
+
* ```
|
|
1985
|
+
*/
|
|
1986
|
+
declare function redisExists(key: string): number;
|
|
1987
|
+
/**
|
|
1988
|
+
* Get multiple values from Redis (atomic operation)
|
|
1989
|
+
*
|
|
1990
|
+
* @param keys - Array of cache keys
|
|
1991
|
+
* @returns Array of values (null for missing keys)
|
|
1992
|
+
*
|
|
1993
|
+
* @example
|
|
1994
|
+
* ```ts
|
|
1995
|
+
* const values = redisMget(['key1', 'key2', 'key3'])
|
|
1996
|
+
* ```
|
|
1997
|
+
*/
|
|
1998
|
+
declare function redisMget(keys: string[]): Array<string | null>;
|
|
1999
|
+
/**
|
|
2000
|
+
* Set multiple key-value pairs in Redis (atomic operation)
|
|
2001
|
+
*
|
|
2002
|
+
* @param pairs - Array of [key, value] tuples
|
|
2003
|
+
* @returns "OK" on success
|
|
2004
|
+
*
|
|
2005
|
+
* @example
|
|
2006
|
+
* ```ts
|
|
2007
|
+
* redisMset([
|
|
2008
|
+
* ['key1', 'value1'],
|
|
2009
|
+
* ['key2', 'value2']
|
|
2010
|
+
* ])
|
|
2011
|
+
* ```
|
|
2012
|
+
*/
|
|
2013
|
+
declare function redisMset(pairs: Array<[string, string]>): string;
|
|
2014
|
+
/**
|
|
2015
|
+
* Flush all keys from current Redis database
|
|
2016
|
+
*
|
|
2017
|
+
* @returns Number of keys deleted
|
|
2018
|
+
*
|
|
2019
|
+
* @example
|
|
2020
|
+
* ```ts
|
|
2021
|
+
* const flushed = redisFlushDb()
|
|
2022
|
+
* console.log(`Flushed ${flushed} keys from database`)
|
|
2023
|
+
* ```
|
|
2024
|
+
*/
|
|
2025
|
+
declare function redisFlushDb(): number;
|
|
2026
|
+
/**
|
|
2027
|
+
* Flush all keys from all Redis databases (cluster-wide)
|
|
2028
|
+
*
|
|
2029
|
+
* @returns Number of keys deleted
|
|
2030
|
+
*
|
|
2031
|
+
* @example
|
|
2032
|
+
* ```ts
|
|
2033
|
+
* const flushed = redisFlushAll()
|
|
2034
|
+
* console.log(`Flushed ${flushed} keys from all databases`)
|
|
2035
|
+
* ```
|
|
2036
|
+
*/
|
|
2037
|
+
declare function redisFlushAll(): number;
|
|
2038
|
+
/**
|
|
2039
|
+
* Initialize Redis connection pool
|
|
2040
|
+
*
|
|
2041
|
+
* @param host - Redis host (e.g., "localhost")
|
|
2042
|
+
* @param port - Redis port (default: 6379)
|
|
2043
|
+
* @param pool_size - Connection pool size (default: 32)
|
|
2044
|
+
* @returns Pool info JSON
|
|
2045
|
+
*
|
|
2046
|
+
* @example
|
|
2047
|
+
* ```ts
|
|
2048
|
+
* const info = redisPoolConnect('localhost', 6379, 32)
|
|
2049
|
+
* console.log(info)
|
|
2050
|
+
* ```
|
|
2051
|
+
*/
|
|
2052
|
+
declare function redisPoolConnect(host: string, port: number, pool_size?: number): string;
|
|
2053
|
+
/**
|
|
2054
|
+
* Get Redis pool statistics
|
|
2055
|
+
*
|
|
2056
|
+
* @returns Pool stats as JSON string
|
|
2057
|
+
*
|
|
2058
|
+
* @example
|
|
2059
|
+
* ```ts
|
|
2060
|
+
* const stats = redisPoolStats()
|
|
2061
|
+
* const parsed: RedisPoolStats = JSON.parse(stats)
|
|
2062
|
+
* console.log(`Connected: ${parsed.connected_count}`)
|
|
2063
|
+
* ```
|
|
2064
|
+
*/
|
|
2065
|
+
declare function redisPoolStats(): RedisPoolStats;
|
|
2066
|
+
/**
|
|
2067
|
+
* Reconnect Redis pool after disconnect
|
|
2068
|
+
*
|
|
2069
|
+
* @returns "OK" if reconnected
|
|
2070
|
+
*
|
|
2071
|
+
* @example
|
|
2072
|
+
* ```ts
|
|
2073
|
+
* const result = redisPoolReconnect()
|
|
2074
|
+
* console.log(result)
|
|
2075
|
+
* ```
|
|
2076
|
+
*/
|
|
2077
|
+
declare function redisPoolReconnect(): string;
|
|
2078
|
+
/**
|
|
2079
|
+
* Enable Redis cluster mode
|
|
2080
|
+
*
|
|
2081
|
+
* @param initial_nodes - Initial cluster nodes (host:port format)
|
|
2082
|
+
* @returns Cluster status JSON
|
|
2083
|
+
*
|
|
2084
|
+
* @example
|
|
2085
|
+
* ```ts
|
|
2086
|
+
* const status = redisEnableCluster(['localhost:6379', 'localhost:6380'])
|
|
2087
|
+
* ```
|
|
2088
|
+
*/
|
|
2089
|
+
declare function redisEnableCluster(initial_nodes: string[]): RedisClusterStatus;
|
|
2090
|
+
/**
|
|
2091
|
+
* Disable Redis cluster mode
|
|
2092
|
+
*
|
|
2093
|
+
* @returns "OK" when disabled
|
|
2094
|
+
*
|
|
2095
|
+
* @example
|
|
2096
|
+
* ```ts
|
|
2097
|
+
* const result = redisDisableCluster()
|
|
2098
|
+
* ```
|
|
2099
|
+
*/
|
|
2100
|
+
declare function redisDisableCluster(): string;
|
|
2101
|
+
/**
|
|
2102
|
+
* Get current Redis cluster status
|
|
2103
|
+
*
|
|
2104
|
+
* @returns Cluster status information
|
|
2105
|
+
*
|
|
2106
|
+
* @example
|
|
2107
|
+
* ```ts
|
|
2108
|
+
* const status = redisClusterStatus()
|
|
2109
|
+
* if (status.enabled) console.log(`Cluster has ${status.nodes.length} nodes`)
|
|
2110
|
+
* ```
|
|
2111
|
+
*/
|
|
2112
|
+
declare function redisClusterStatus(): RedisClusterStatus;
|
|
2113
|
+
/**
|
|
2114
|
+
* Subscribe to Redis pub/sub channel
|
|
2115
|
+
*
|
|
2116
|
+
* @param channel - Channel name
|
|
2117
|
+
* @param callback - Function to call on message (optional)
|
|
2118
|
+
* @returns Subscription ID
|
|
2119
|
+
*
|
|
2120
|
+
* @example
|
|
2121
|
+
* ```ts
|
|
2122
|
+
* const id = redisSubscribe('cache:updates', (msg) => {
|
|
2123
|
+
* console.log(`Update: ${msg.message}`)
|
|
2124
|
+
* })
|
|
2125
|
+
* ```
|
|
2126
|
+
*/
|
|
2127
|
+
declare function redisSubscribe(channel: string): string;
|
|
2128
|
+
/**
|
|
2129
|
+
* Publish message to Redis pub/sub channel
|
|
2130
|
+
*
|
|
2131
|
+
* @param channel - Channel name
|
|
2132
|
+
* @param message - Message to publish
|
|
2133
|
+
* @returns Number of subscribers that received the message
|
|
2134
|
+
*
|
|
2135
|
+
* @example
|
|
2136
|
+
* ```ts
|
|
2137
|
+
* const count = redisPublish('cache:updates', 'CSS compiled')
|
|
2138
|
+
* console.log(`Delivered to ${count} subscribers`)
|
|
2139
|
+
* ```
|
|
2140
|
+
*/
|
|
2141
|
+
declare function redisPublish(channel: string, message: string): number;
|
|
2142
|
+
/**
|
|
2143
|
+
* Set expiration on key
|
|
2144
|
+
*
|
|
2145
|
+
* @param key - Cache key
|
|
2146
|
+
* @param ttl_seconds - Time to live in seconds
|
|
2147
|
+
* @returns 1 if timeout set, 0 if key doesn't exist
|
|
2148
|
+
*
|
|
2149
|
+
* @example
|
|
2150
|
+
* ```ts
|
|
2151
|
+
* redisExpirationSet('compiled:bg-blue-600', 3600)
|
|
2152
|
+
* ```
|
|
2153
|
+
*/
|
|
2154
|
+
declare function redisExpirationSet(key: string, ttl_seconds: number): number;
|
|
2155
|
+
/**
|
|
2156
|
+
* Get expiration info for key
|
|
2157
|
+
*
|
|
2158
|
+
* @param key - Cache key
|
|
2159
|
+
* @returns Expiration information
|
|
2160
|
+
*
|
|
2161
|
+
* @example
|
|
2162
|
+
* ```ts
|
|
2163
|
+
* const info = redisExpirationGet('compiled:bg-blue-600')
|
|
2164
|
+
* console.log(`TTL: ${info.ttl_seconds} seconds`)
|
|
2165
|
+
* ```
|
|
2166
|
+
*/
|
|
2167
|
+
declare function redisExpirationGet(key: string): KeyExpiration;
|
|
2168
|
+
/**
|
|
2169
|
+
* Get Redis server info
|
|
2170
|
+
*
|
|
2171
|
+
* @returns Server information JSON
|
|
2172
|
+
*
|
|
2173
|
+
* @example
|
|
2174
|
+
* ```ts
|
|
2175
|
+
* const info = redisInfo()
|
|
2176
|
+
* ```
|
|
2177
|
+
*/
|
|
2178
|
+
declare function redisInfo(): string;
|
|
2179
|
+
/**
|
|
2180
|
+
* Monitor Redis operations in real-time (for debugging)
|
|
2181
|
+
*
|
|
2182
|
+
* @returns Monitor output stream
|
|
2183
|
+
*
|
|
2184
|
+
* @example
|
|
2185
|
+
* ```ts
|
|
2186
|
+
* const monitor = redisMonitor()
|
|
2187
|
+
* // Logs all Redis operations
|
|
2188
|
+
* ```
|
|
2189
|
+
*/
|
|
2190
|
+
declare function redisMonitor(): string;
|
|
2191
|
+
/**
|
|
2192
|
+
* Get size of cache in bytes
|
|
2193
|
+
*
|
|
2194
|
+
* @returns Total memory usage in bytes
|
|
2195
|
+
*
|
|
2196
|
+
* @example
|
|
2197
|
+
* ```ts
|
|
2198
|
+
* const bytes = redisCacheSize()
|
|
2199
|
+
* console.log(`Cache: ${bytes / 1024 / 1024} MB`)
|
|
2200
|
+
* ```
|
|
2201
|
+
*/
|
|
2202
|
+
declare function redisCacheSize(): number;
|
|
2203
|
+
/**
|
|
2204
|
+
* Get number of keys in cache
|
|
2205
|
+
*
|
|
2206
|
+
* @returns Total key count
|
|
2207
|
+
*
|
|
2208
|
+
* @example
|
|
2209
|
+
* ```ts
|
|
2210
|
+
* const count = redisCacheKeyCount()
|
|
2211
|
+
* console.log(`Cached keys: ${count}`)
|
|
2212
|
+
* ```
|
|
2213
|
+
*/
|
|
2214
|
+
declare function redisCacheKeyCount(): number;
|
|
2215
|
+
/**
|
|
2216
|
+
* Clear Redis cache and reset statistics
|
|
2217
|
+
*
|
|
2218
|
+
* @returns Number of keys cleared
|
|
2219
|
+
*
|
|
2220
|
+
* @example
|
|
2221
|
+
* ```ts
|
|
2222
|
+
* const cleared = redisCacheClear()
|
|
2223
|
+
* console.log(`Cleared ${cleared} keys`)
|
|
2224
|
+
* ```
|
|
2225
|
+
*/
|
|
2226
|
+
declare function redisCacheClear(): number;
|
|
2227
|
+
/**
|
|
2228
|
+
* Get Redis cache hit rate statistics
|
|
2229
|
+
*
|
|
2230
|
+
* @returns Hit rate percentage (0-100)
|
|
2231
|
+
*
|
|
2232
|
+
* @example
|
|
2233
|
+
* ```ts
|
|
2234
|
+
* const hitRate = redisCacheHitRate()
|
|
2235
|
+
* console.log(`Hit rate: ${hitRate}%`)
|
|
2236
|
+
* ```
|
|
2237
|
+
*/
|
|
2238
|
+
declare function redisCacheHitRate(): number;
|
|
2239
|
+
/**
|
|
2240
|
+
* Enable Redis persistence (AOF/RDB)
|
|
2241
|
+
*
|
|
2242
|
+
* @param mode - "aof" or "rdb"
|
|
2243
|
+
* @returns "OK" on success
|
|
2244
|
+
*
|
|
2245
|
+
* @example
|
|
2246
|
+
* ```ts
|
|
2247
|
+
* redisEnablePersistence('aof')
|
|
2248
|
+
* ```
|
|
2249
|
+
*/
|
|
2250
|
+
declare function redisEnablePersistence(mode: string): string;
|
|
2251
|
+
/**
|
|
2252
|
+
* Disable Redis persistence
|
|
2253
|
+
*
|
|
2254
|
+
* @returns "OK" on success
|
|
2255
|
+
*
|
|
2256
|
+
* @example
|
|
2257
|
+
* ```ts
|
|
2258
|
+
* redisDisablePersistence()
|
|
2259
|
+
* ```
|
|
2260
|
+
*/
|
|
2261
|
+
declare function redisDisablePersistence(): string;
|
|
2262
|
+
/**
|
|
2263
|
+
* Save Redis data to disk (snapshot)
|
|
2264
|
+
*
|
|
2265
|
+
* @returns "OK" on success
|
|
2266
|
+
*
|
|
2267
|
+
* @example
|
|
2268
|
+
* ```ts
|
|
2269
|
+
* redisSnapshot()
|
|
2270
|
+
* ```
|
|
2271
|
+
*/
|
|
2272
|
+
declare function redisSnapshot(): string;
|
|
2273
|
+
/**
|
|
2274
|
+
* Get Redis memory statistics and recommendations
|
|
2275
|
+
*
|
|
2276
|
+
* @returns Memory info JSON
|
|
2277
|
+
*
|
|
2278
|
+
* @example
|
|
2279
|
+
* ```ts
|
|
2280
|
+
* const memory = redisMemoryStats()
|
|
2281
|
+
* console.log(memory)
|
|
2282
|
+
* ```
|
|
2283
|
+
*/
|
|
2284
|
+
declare function redisMemoryStats(): string;
|
|
2285
|
+
/**
|
|
2286
|
+
* Optimize Redis memory usage
|
|
2287
|
+
*
|
|
2288
|
+
* @returns Number of keys optimized
|
|
2289
|
+
*
|
|
2290
|
+
* @example
|
|
2291
|
+
* ```ts
|
|
2292
|
+
* const optimized = redisOptimizeMemory()
|
|
2293
|
+
* console.log(`Optimized ${optimized} keys`)
|
|
2294
|
+
* ```
|
|
2295
|
+
*/
|
|
2296
|
+
declare function redisOptimizeMemory(): number;
|
|
2297
|
+
/**
|
|
2298
|
+
* Set Redis key eviction policy
|
|
2299
|
+
*
|
|
2300
|
+
* @param policy - LRU, LFU, TTL, RANDOM, etc.
|
|
2301
|
+
* @returns "OK" on success
|
|
2302
|
+
*
|
|
2303
|
+
* @example
|
|
2304
|
+
* ```ts
|
|
2305
|
+
* redisSetEvictionPolicy('allkeys-lru')
|
|
2306
|
+
* ```
|
|
2307
|
+
*/
|
|
2308
|
+
declare function redisSetEvictionPolicy(policy: string): string;
|
|
2309
|
+
/**
|
|
2310
|
+
* Get current Redis eviction policy
|
|
2311
|
+
*
|
|
2312
|
+
* @returns Current policy name
|
|
2313
|
+
*
|
|
2314
|
+
* @example
|
|
2315
|
+
* ```ts
|
|
2316
|
+
* const policy = redisGetEvictionPolicy()
|
|
2317
|
+
* console.log(`Eviction policy: ${policy}`)
|
|
2318
|
+
* ```
|
|
2319
|
+
*/
|
|
2320
|
+
declare function redisGetEvictionPolicy(): string;
|
|
2321
|
+
/**
|
|
2322
|
+
* Replicate data to another Redis instance
|
|
2323
|
+
*
|
|
2324
|
+
* @param target_host - Target host
|
|
2325
|
+
* @param target_port - Target port
|
|
2326
|
+
* @returns Number of keys replicated
|
|
2327
|
+
*
|
|
2328
|
+
* @example
|
|
2329
|
+
* ```ts
|
|
2330
|
+
* const replicated = redisReplicate('replica.example.com', 6379)
|
|
2331
|
+
* console.log(`Replicated ${replicated} keys`)
|
|
2332
|
+
* ```
|
|
2333
|
+
*/
|
|
2334
|
+
declare function redisReplicate(target_host: string, target_port: number): number;
|
|
2335
|
+
/**
|
|
2336
|
+
* Get replication status
|
|
2337
|
+
*
|
|
2338
|
+
* @returns Replication info JSON
|
|
2339
|
+
*
|
|
2340
|
+
* @example
|
|
2341
|
+
* ```ts
|
|
2342
|
+
* const status = redisReplicationStatus()
|
|
2343
|
+
* console.log(status)
|
|
2344
|
+
* ```
|
|
2345
|
+
*/
|
|
2346
|
+
declare function redisReplicationStatus(): string;
|
|
2347
|
+
/**
|
|
2348
|
+
* Sync cache between Redis instances (distributed cache sync)
|
|
2349
|
+
*
|
|
2350
|
+
* @param peers - Array of peer Redis addresses
|
|
2351
|
+
* @returns Number of keys synced
|
|
2352
|
+
*
|
|
2353
|
+
* @example
|
|
2354
|
+
* ```ts
|
|
2355
|
+
* const synced = redisCacheSync(['redis1:6379', 'redis2:6379'])
|
|
2356
|
+
* console.log(`Synced ${synced} keys`)
|
|
2357
|
+
* ```
|
|
2358
|
+
*/
|
|
2359
|
+
declare function redisCacheSync(peers: string[]): number;
|
|
2360
|
+
/**
|
|
2361
|
+
* Enable automatic cache warming
|
|
2362
|
+
*
|
|
2363
|
+
* @param key_pattern - Glob pattern for keys to warm (e.g., "compiled:*")
|
|
2364
|
+
* @returns "OK" on success
|
|
2365
|
+
*
|
|
2366
|
+
* @example
|
|
2367
|
+
* ```ts
|
|
2368
|
+
* redisEnableCacheWarming('compiled:*')
|
|
2369
|
+
* ```
|
|
2370
|
+
*/
|
|
2371
|
+
declare function redisEnableCacheWarming(key_pattern: string): string;
|
|
2372
|
+
/**
|
|
2373
|
+
* Disable cache warming
|
|
2374
|
+
*
|
|
2375
|
+
* @returns "OK" on success
|
|
2376
|
+
*
|
|
2377
|
+
* @example
|
|
2378
|
+
* ```ts
|
|
2379
|
+
* redisDisableCacheWarming()
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
declare function redisDisableCacheWarming(): string;
|
|
2383
|
+
/**
|
|
2384
|
+
* Diagnose Redis connection issues
|
|
2385
|
+
*
|
|
2386
|
+
* @returns Diagnostic report
|
|
2387
|
+
*
|
|
2388
|
+
* @example
|
|
2389
|
+
* ```ts
|
|
2390
|
+
* const diagnosis = redisDiagnose()
|
|
2391
|
+
* console.log(diagnosis)
|
|
2392
|
+
* ```
|
|
2393
|
+
*/
|
|
2394
|
+
declare function redisDiagnose(): string;
|
|
2395
|
+
|
|
2396
|
+
/**
|
|
2397
|
+
* watchSystemNative.ts
|
|
2398
|
+
*
|
|
2399
|
+
* Phase 5.4: Watch System & File Monitoring - Real-time CSS recompilation
|
|
2400
|
+
* Exposes 12 watch/monitoring functions for hot-reload and incremental compilation
|
|
2401
|
+
*/
|
|
2402
|
+
/**
|
|
2403
|
+
* File watch event
|
|
2404
|
+
*/
|
|
2405
|
+
interface WatchEvent {
|
|
2406
|
+
event_type: "create" | "modify" | "delete" | "rename";
|
|
2407
|
+
file_path: string;
|
|
2408
|
+
timestamp_ms: number;
|
|
2409
|
+
is_dir: boolean;
|
|
2410
|
+
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Watch handle for tracking active watchers
|
|
2413
|
+
*/
|
|
2414
|
+
interface WatchHandle {
|
|
2415
|
+
handle_id: number;
|
|
2416
|
+
patterns: string[];
|
|
2417
|
+
is_running: boolean;
|
|
2418
|
+
created_at_ms: number;
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* Watch statistics
|
|
2422
|
+
*/
|
|
2423
|
+
interface WatchStats {
|
|
2424
|
+
active_watchers: number;
|
|
2425
|
+
total_events: number;
|
|
2426
|
+
events_this_second: number;
|
|
2427
|
+
average_latency_ms: number;
|
|
2428
|
+
largest_batch_size: number;
|
|
2429
|
+
}
|
|
2430
|
+
/**
|
|
2431
|
+
* Start file system watcher for directory
|
|
2432
|
+
*
|
|
2433
|
+
* @param root_path - Directory to watch
|
|
2434
|
+
* @param patterns - Glob patterns to match (e.g., ["*.tsx", "*.ts"])
|
|
2435
|
+
* @returns Handle ID for the watcher
|
|
2436
|
+
*
|
|
2437
|
+
* @example
|
|
2438
|
+
* ```ts
|
|
2439
|
+
* const handle = startWatch('./src', ['*.tsx', '*.ts'])
|
|
2440
|
+
* // Watcher is now active
|
|
2441
|
+
* ```
|
|
2442
|
+
*/
|
|
2443
|
+
declare function startWatch(root_path: string, patterns?: string[]): number;
|
|
2444
|
+
/**
|
|
2445
|
+
* Poll for watch events (non-blocking)
|
|
2446
|
+
*
|
|
2447
|
+
* @param handle - Watcher handle from startWatch()
|
|
2448
|
+
* @param timeout_ms - Max time to wait for events (default: 100)
|
|
2449
|
+
* @returns Array of watch events
|
|
2450
|
+
*
|
|
2451
|
+
* @example
|
|
2452
|
+
* ```ts
|
|
2453
|
+
* const handle = startWatch('./src', ['*.tsx'])
|
|
2454
|
+
* const events = pollWatchEvents(handle, 100)
|
|
2455
|
+
* events.forEach(evt => {
|
|
2456
|
+
* console.log(`${evt.event_type}: ${evt.file_path}`)
|
|
2457
|
+
* })
|
|
2458
|
+
* ```
|
|
2459
|
+
*/
|
|
2460
|
+
declare function pollWatchEvents(handle: number, timeout_ms?: number): WatchEvent[];
|
|
2461
|
+
/**
|
|
2462
|
+
* Stop file system watcher
|
|
2463
|
+
*
|
|
2464
|
+
* @param handle - Watcher handle
|
|
2465
|
+
* @returns Number of events processed before stopping
|
|
2466
|
+
*
|
|
2467
|
+
* @example
|
|
2468
|
+
* ```ts
|
|
2469
|
+
* const eventsProcessed = stopWatch(handle)
|
|
2470
|
+
* console.log(`Watcher processed ${eventsProcessed} events`)
|
|
2471
|
+
* ```
|
|
2472
|
+
*/
|
|
2473
|
+
declare function stopWatch(handle: number): number;
|
|
2474
|
+
/**
|
|
2475
|
+
* Add pattern to active watcher
|
|
2476
|
+
*
|
|
2477
|
+
* @param handle - Watcher handle
|
|
2478
|
+
* @param pattern - Glob pattern to add (e.g., "*.md")
|
|
2479
|
+
* @returns "OK" on success
|
|
2480
|
+
*
|
|
2481
|
+
* @example
|
|
2482
|
+
* ```ts
|
|
2483
|
+
* watchAddPattern(handle, '*.md')
|
|
2484
|
+
* // Now watching markdown files too
|
|
2485
|
+
* ```
|
|
2486
|
+
*/
|
|
2487
|
+
declare function watchAddPattern(handle: number, pattern: string): string;
|
|
2488
|
+
/**
|
|
2489
|
+
* Remove pattern from watcher
|
|
2490
|
+
*
|
|
2491
|
+
* @param handle - Watcher handle
|
|
2492
|
+
* @param pattern - Pattern to remove
|
|
2493
|
+
* @returns "OK" on success
|
|
2494
|
+
*
|
|
2495
|
+
* @example
|
|
2496
|
+
* ```ts
|
|
2497
|
+
* watchRemovePattern(handle, '*.md')
|
|
2498
|
+
* ```
|
|
2499
|
+
*/
|
|
2500
|
+
declare function watchRemovePattern(handle: number, pattern: string): string;
|
|
2501
|
+
/**
|
|
2502
|
+
* Get all active watcher handles
|
|
2503
|
+
*
|
|
2504
|
+
* @returns Array of active watch handles
|
|
2505
|
+
*
|
|
2506
|
+
* @example
|
|
2507
|
+
* ```ts
|
|
2508
|
+
* const handles = watchGetActiveHandles()
|
|
2509
|
+
* console.log(`${handles.length} active watchers`)
|
|
2510
|
+
* ```
|
|
2511
|
+
*/
|
|
2512
|
+
declare function watchGetActiveHandles(): WatchHandle[];
|
|
2513
|
+
/**
|
|
2514
|
+
* Clear all active watchers
|
|
2515
|
+
*
|
|
2516
|
+
* @returns Number of watchers cleared
|
|
2517
|
+
*
|
|
2518
|
+
* @example
|
|
2519
|
+
* ```ts
|
|
2520
|
+
* const cleared = watchClearAll()
|
|
2521
|
+
* console.log(`Cleared ${cleared} watchers`)
|
|
2522
|
+
* ```
|
|
2523
|
+
*/
|
|
2524
|
+
declare function watchClearAll(): number;
|
|
2525
|
+
/**
|
|
2526
|
+
* Convert watch event type to string
|
|
2527
|
+
*
|
|
2528
|
+
* @param event_type_code - Event type code (0-3)
|
|
2529
|
+
* @returns Event type as string
|
|
2530
|
+
*
|
|
2531
|
+
* @example
|
|
2532
|
+
* ```ts
|
|
2533
|
+
* const typeStr = watchEventTypeToString(0)
|
|
2534
|
+
* console.log(typeStr) // "create"
|
|
2535
|
+
* ```
|
|
2536
|
+
*/
|
|
2537
|
+
declare function watchEventTypeToString(event_type_code: number): string;
|
|
2538
|
+
/**
|
|
2539
|
+
* Check if watcher is running
|
|
2540
|
+
*
|
|
2541
|
+
* @param handle - Watcher handle
|
|
2542
|
+
* @returns True if running
|
|
2543
|
+
*
|
|
2544
|
+
* @example
|
|
2545
|
+
* ```ts
|
|
2546
|
+
* if (isWatchRunning(handle)) {
|
|
2547
|
+
* console.log("Watcher is active")
|
|
2548
|
+
* }
|
|
2549
|
+
* ```
|
|
2550
|
+
*/
|
|
2551
|
+
declare function isWatchRunning(handle: number): boolean;
|
|
2552
|
+
/**
|
|
2553
|
+
* Get watch system statistics
|
|
2554
|
+
*
|
|
2555
|
+
* @returns Watch statistics
|
|
2556
|
+
*
|
|
2557
|
+
* @example
|
|
2558
|
+
* ```ts
|
|
2559
|
+
* const stats = getWatchStats()
|
|
2560
|
+
* console.log(`Active: ${stats.active_watchers}, Events: ${stats.total_events}`)
|
|
2561
|
+
* ```
|
|
2562
|
+
*/
|
|
2563
|
+
declare function getWatchStats(): WatchStats;
|
|
2564
|
+
/**
|
|
2565
|
+
* Pause watching (pause event delivery without stopping watcher)
|
|
2566
|
+
*
|
|
2567
|
+
* @param handle - Watcher handle
|
|
2568
|
+
* @returns "OK" on success
|
|
2569
|
+
*
|
|
2570
|
+
* @example
|
|
2571
|
+
* ```ts
|
|
2572
|
+
* watchPause(handle)
|
|
2573
|
+
* // Events still detected but not delivered
|
|
2574
|
+
* ```
|
|
2575
|
+
*/
|
|
2576
|
+
declare function watchPause(handle: number): string;
|
|
2577
|
+
/**
|
|
2578
|
+
* Resume watching after pause
|
|
2579
|
+
*
|
|
2580
|
+
* @param handle - Watcher handle
|
|
2581
|
+
* @returns "OK" on success
|
|
2582
|
+
*
|
|
2583
|
+
* @example
|
|
2584
|
+
* ```ts
|
|
2585
|
+
* watchResume(handle)
|
|
2586
|
+
* // Event delivery resumes
|
|
2587
|
+
* ```
|
|
2588
|
+
*/
|
|
2589
|
+
declare function watchResume(handle: number): string;
|
|
2590
|
+
/**
|
|
2591
|
+
* Scan cache and get optimization recommendations
|
|
2592
|
+
*
|
|
2593
|
+
* @returns Optimization hints JSON
|
|
2594
|
+
*
|
|
2595
|
+
* @example
|
|
2596
|
+
* ```ts
|
|
2597
|
+
* const hints = scanCacheOptimizations()
|
|
2598
|
+
* console.log(hints)
|
|
2599
|
+
* ```
|
|
2600
|
+
*/
|
|
2601
|
+
declare function scanCacheOptimizations(): string;
|
|
2602
|
+
/**
|
|
2603
|
+
* Get plugin hook list
|
|
2604
|
+
*
|
|
2605
|
+
* @returns Available plugin hooks
|
|
2606
|
+
*
|
|
2607
|
+
* @example
|
|
2608
|
+
* ```ts
|
|
2609
|
+
* const hooks = getPluginHooks()
|
|
2610
|
+
* console.log(hooks)
|
|
2611
|
+
* ```
|
|
2612
|
+
*/
|
|
2613
|
+
declare function getPluginHooks(): string[];
|
|
2614
|
+
/**
|
|
2615
|
+
* Register plugin hook handler
|
|
2616
|
+
*
|
|
2617
|
+
* @param hook_name - Hook name
|
|
2618
|
+
* @param handler_id - Handler identifier
|
|
2619
|
+
* @returns "OK" on success
|
|
2620
|
+
*
|
|
2621
|
+
* @example
|
|
2622
|
+
* ```ts
|
|
2623
|
+
* registerPluginHook('compile:before', 'my-handler-1')
|
|
2624
|
+
* ```
|
|
2625
|
+
*/
|
|
2626
|
+
declare function registerPluginHook(hook_name: string, handler_id: string): string;
|
|
2627
|
+
/**
|
|
2628
|
+
* Unregister plugin hook handler
|
|
2629
|
+
*
|
|
2630
|
+
* @param hook_name - Hook name
|
|
2631
|
+
* @param handler_id - Handler identifier
|
|
2632
|
+
* @returns "OK" on success
|
|
2633
|
+
*
|
|
2634
|
+
* @example
|
|
2635
|
+
* ```ts
|
|
2636
|
+
* unregisterPluginHook('compile:before', 'my-handler-1')
|
|
2637
|
+
* ```
|
|
2638
|
+
*/
|
|
2639
|
+
declare function unregisterPluginHook(hook_name: string, handler_id: string): string;
|
|
2640
|
+
/**
|
|
2641
|
+
* Emit plugin hook event
|
|
2642
|
+
*
|
|
2643
|
+
* @param hook_name - Hook name
|
|
2644
|
+
* @param data_json - Event data as JSON
|
|
2645
|
+
* @returns Modified data
|
|
2646
|
+
*
|
|
2647
|
+
* @example
|
|
2648
|
+
* ```ts
|
|
2649
|
+
* const result = emitPluginHook('compile:before', JSON.stringify({css: '...'}))
|
|
2650
|
+
* ```
|
|
2651
|
+
*/
|
|
2652
|
+
declare function emitPluginHook(hook_name: string, data_json: string): string;
|
|
2653
|
+
/**
|
|
2654
|
+
* Get compilation performance metrics
|
|
2655
|
+
*
|
|
2656
|
+
* @returns Performance metrics
|
|
2657
|
+
*
|
|
2658
|
+
* @example
|
|
2659
|
+
* ```ts
|
|
2660
|
+
* const metrics = getCompilationMetrics()
|
|
2661
|
+
* console.log(metrics)
|
|
2662
|
+
* ```
|
|
2663
|
+
*/
|
|
2664
|
+
declare function getCompilationMetrics(): string;
|
|
2665
|
+
/**
|
|
2666
|
+
* Reset compilation performance counters
|
|
2667
|
+
*
|
|
2668
|
+
* @returns "OK" on success
|
|
2669
|
+
*
|
|
2670
|
+
* @example
|
|
2671
|
+
* ```ts
|
|
2672
|
+
* resetCompilationMetrics()
|
|
2673
|
+
* ```
|
|
2674
|
+
*/
|
|
2675
|
+
declare function resetCompilationMetrics(): string;
|
|
2676
|
+
/**
|
|
2677
|
+
* Validate CSS output for errors
|
|
2678
|
+
*
|
|
2679
|
+
* @param css - CSS to validate
|
|
2680
|
+
* @returns Validation result as JSON
|
|
2681
|
+
*
|
|
2682
|
+
* @example
|
|
2683
|
+
* ```ts
|
|
2684
|
+
* const result = validateCssOutput('.test { color: red; }')
|
|
2685
|
+
* ```
|
|
2686
|
+
*/
|
|
2687
|
+
declare function validateCssOutput(css: string): string;
|
|
2688
|
+
/**
|
|
2689
|
+
* Get compiler diagnostics
|
|
2690
|
+
*
|
|
2691
|
+
* @returns Diagnostic information
|
|
2692
|
+
*
|
|
2693
|
+
* @example
|
|
2694
|
+
* ```ts
|
|
2695
|
+
* const diagnostics = getCompilerDiagnostics()
|
|
2696
|
+
* console.log(diagnostics)
|
|
2697
|
+
* ```
|
|
2698
|
+
*/
|
|
2699
|
+
declare function getCompilerDiagnostics(): string;
|
|
2700
|
+
|
|
2701
|
+
/**
|
|
2702
|
+
* tailwind-styled-v5 — Compiler Main Entry Point
|
|
2703
|
+
*
|
|
2704
|
+
* Re-exports all sub-entry points for backward compatibility.
|
|
2705
|
+
* For better tree-shaking, import from specific sub-entries:
|
|
2706
|
+
* - '@tailwind-styled/compiler/compiler' - CSS generation and compilation
|
|
2707
|
+
* - '@tailwind-styled/compiler/parser' - Class parsing and extraction
|
|
2708
|
+
* - '@tailwind-styled/compiler/analyzer' - Analysis and optimization
|
|
2709
|
+
* - '@tailwind-styled/compiler/cache' - Cache management
|
|
2710
|
+
* - '@tailwind-styled/compiler/redis' - Redis and distributed cache
|
|
2711
|
+
* - '@tailwind-styled/compiler/watch' - File watching and monitoring
|
|
2712
|
+
*/
|
|
2713
|
+
|
|
2714
|
+
declare const transformSource: (source: string, opts?: Record<string, unknown>) => NativeTransformResult;
|
|
2715
|
+
declare const hasTwUsage: (source: string) => boolean;
|
|
2716
|
+
declare const isAlreadyTransformed: (source: string) => boolean;
|
|
2717
|
+
declare const shouldProcess: (source: string) => boolean;
|
|
2718
|
+
declare const compileCssFromClasses: (classes: string[], prefix?: string | null) => NativeTransformResult;
|
|
2719
|
+
declare const buildStyleTag: (classes: string[]) => string;
|
|
2720
|
+
declare const generateCssForClasses: (classes: string[], _tailwindConfig?: Record<string, unknown>, root?: string, cssEntryContent?: string, minify?: boolean) => Promise<string>;
|
|
2721
|
+
declare const eliminateDeadCss: (css: string, deadClasses: Set<string>) => string;
|
|
2722
|
+
declare const findDeadVariants: (variantConfig: Record<string, unknown> | Array<{
|
|
2723
|
+
name: string;
|
|
2724
|
+
variants: Record<string, Record<string, string>>;
|
|
2725
|
+
defaultVariants?: Record<string, string>;
|
|
2726
|
+
}>, usage: Record<string, Set<string>>) => {
|
|
2727
|
+
unusedCount: number;
|
|
2728
|
+
unused: string[];
|
|
2729
|
+
};
|
|
2730
|
+
declare const runElimination: (css: string, scanResult: unknown) => string;
|
|
2731
|
+
declare const scanProjectUsage: (dirs: string[], cwd: string) => Record<string, Record<string, Set<string>>>;
|
|
2732
|
+
declare const generateSafelist: (scanDirs: string[], outputPath?: string, cwd?: string) => string[];
|
|
2733
|
+
declare const loadSafelist: (safelistPath: string) => string[];
|
|
2734
|
+
declare const loadTailwindConfig: (cwd?: string) => {};
|
|
2735
|
+
declare const getContentPaths: (cwd?: string) => {
|
|
2736
|
+
content: string[];
|
|
2737
|
+
};
|
|
2738
|
+
declare function extractContainerCssFromSource(source: string): string;
|
|
2739
|
+
type LoaderOutput = {
|
|
2740
|
+
code: string;
|
|
2741
|
+
changed: boolean;
|
|
2742
|
+
classes: string[];
|
|
2743
|
+
staticCss?: string;
|
|
2744
|
+
rsc?: {
|
|
2745
|
+
isServer?: boolean;
|
|
2746
|
+
needsClientDirective?: boolean;
|
|
2747
|
+
clientReasons?: string[];
|
|
2748
|
+
};
|
|
2749
|
+
engine?: string;
|
|
2750
|
+
};
|
|
2751
|
+
declare const runLoaderTransform: (ctx: {
|
|
2752
|
+
filepath: string;
|
|
2753
|
+
source: string;
|
|
2754
|
+
options?: Record<string, unknown>;
|
|
2755
|
+
}) => LoaderOutput;
|
|
2756
|
+
declare const shouldSkipFile: (filepath: string) => boolean;
|
|
2757
|
+
declare const fileToRoute: (filepath: string) => string | null;
|
|
2758
|
+
declare const getAllRoutes: () => string[];
|
|
2759
|
+
declare const getRouteClasses: (_route: string) => Set<string>;
|
|
2760
|
+
declare const registerFileClasses: (_filepath: string, _classes: string[]) => void;
|
|
2761
|
+
declare const registerGlobalClasses: (_classes: string[]) => void;
|
|
2762
|
+
declare const getIncrementalEngine: () => IncrementalEngine;
|
|
2763
|
+
declare const resetIncrementalEngine: () => void;
|
|
2764
|
+
declare class IncrementalEngine {
|
|
2765
|
+
compile(source: string): NativeTransformResult;
|
|
2766
|
+
}
|
|
2767
|
+
declare const getBucketEngine: () => {
|
|
2768
|
+
add: (className: string) => string;
|
|
2769
|
+
get: (_bucket: string) => string[];
|
|
2770
|
+
};
|
|
2771
|
+
declare const resetBucketEngine: () => void;
|
|
2772
|
+
declare class BucketEngine {
|
|
2773
|
+
add(className: string): string;
|
|
2774
|
+
}
|
|
2775
|
+
declare const classifyNode: (_node: unknown) => string;
|
|
2776
|
+
declare const detectConflicts: (_classes: string[]) => string[];
|
|
2777
|
+
declare const bucketSort: (classes: string[]) => string[];
|
|
2778
|
+
declare const analyzeFile: (source: string, filename: string) => {
|
|
2779
|
+
isServer: boolean;
|
|
2780
|
+
needsClientDirective: boolean;
|
|
2781
|
+
clientReasons: string[];
|
|
2782
|
+
interactiveClasses: never[];
|
|
2783
|
+
canStaticResolveVariants: boolean;
|
|
2784
|
+
};
|
|
2785
|
+
declare const analyzeVariantUsage: (_source: string, _componentName: string, _variantKeys: string[]) => {
|
|
2786
|
+
resolved: Record<string, string>;
|
|
2787
|
+
dynamic: string[];
|
|
2788
|
+
};
|
|
2789
|
+
declare const injectClientDirective: (source: string) => string;
|
|
2790
|
+
declare const injectServerOnlyComment: (source: string) => string;
|
|
2791
|
+
declare const analyzeClasses: (filesJson: string, cwd: string, flags: number) => {
|
|
2792
|
+
css?: string;
|
|
2793
|
+
code: string;
|
|
2794
|
+
classes: string[];
|
|
2795
|
+
changed: boolean;
|
|
2796
|
+
rscJson?: string;
|
|
2797
|
+
metadataJson?: string;
|
|
2798
|
+
safelist?: string[];
|
|
2799
|
+
} | null;
|
|
2800
|
+
interface TwStateConfigEntry {
|
|
2801
|
+
tag: string;
|
|
2802
|
+
componentName: string;
|
|
2803
|
+
statesJson: string;
|
|
2804
|
+
sourceFile: string;
|
|
2805
|
+
}
|
|
2806
|
+
interface StaticStateCssInput {
|
|
2807
|
+
tag: string;
|
|
2808
|
+
componentName: string;
|
|
2809
|
+
statesJson: string;
|
|
2810
|
+
}
|
|
2811
|
+
interface GeneratedStateRule {
|
|
2812
|
+
selector: string;
|
|
2813
|
+
declarations: string;
|
|
2814
|
+
cssRule: string;
|
|
2815
|
+
componentName: string;
|
|
2816
|
+
stateName: string;
|
|
2817
|
+
}
|
|
2818
|
+
declare const extractTwStateConfigs: (source: string, filename: string) => TwStateConfigEntry[];
|
|
2819
|
+
declare const generateStaticStateCss: (entries: TwStateConfigEntry[], _themeConfig?: Record<string, unknown>) => GeneratedStateRule[];
|
|
2820
|
+
declare const extractAndGenerateStateCss: (source: string, filename: string) => GeneratedStateRule[];
|
|
333
2821
|
|
|
334
|
-
export { BucketEngine, type ClassExtractResult, type ComponentMetadata, IncrementalEngine, type LoaderOutput, type NativeBridge, type NativeRscResult, type NativeTransformResult, adaptNativeResult,
|
|
2822
|
+
export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getNativeBridge, getPluginHooks, getRouteClasses, getWatchStats, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCompilationMetrics, resetIncrementalEngine, resetNativeBridgeCache, resolveCascade, resolveClassNames, resolveConflictGroup, resolveSimpleVariants, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
|