tailwind-styled-v4 5.0.8 → 5.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +204 -416
- package/README.md +45 -15
- package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
- package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
- package/dist/analyzer.d.mts +5 -3
- package/dist/analyzer.d.ts +5 -3
- package/dist/analyzer.js +563 -468
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +562 -467
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -7
- package/dist/animate.d.ts +4 -7
- package/dist/animate.js +171 -265
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +165 -264
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.d.mts +22 -1
- package/dist/atomic.d.ts +22 -1
- package/dist/atomic.js +221 -165
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +200 -165
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.d.mts +60 -1
- package/dist/cli.d.ts +60 -1
- package/dist/cli.js +1261 -1517
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1238 -1513
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +38 -7
- package/dist/compiler.d.ts +38 -7
- package/dist/compiler.js +174 -197
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +151 -194
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +7 -31
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +7 -31
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +134 -63
- package/dist/engine.d.ts +134 -63
- package/dist/engine.js +2863 -2482
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2852 -2485
- package/dist/engine.mjs.map +1 -1
- package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
- package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
- package/dist/index.d.mts +63 -32
- package/dist/index.d.ts +63 -32
- package/dist/index.js +335 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -169
- package/dist/index.mjs.map +1 -1
- package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
- package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
- package/dist/next.d.mts +10 -4
- package/dist/next.d.ts +10 -4
- package/dist/next.js +32 -45
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +30 -43
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.d.mts +8 -2
- package/dist/plugin-api.d.ts +8 -2
- package/dist/plugin-api.js +14 -2
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +14 -3
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +51 -11
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +51 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.d.mts +5 -7
- package/dist/plugin.d.ts +5 -7
- package/dist/plugin.js +16 -15
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +16 -16
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js +17 -38
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +15 -36
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/scanner.d.mts +10 -1
- package/dist/scanner.d.ts +10 -1
- package/dist/scanner.js +298 -124
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +296 -124
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +104 -176
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -176
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.d.mts +1 -1
- package/dist/storybook-addon.d.ts +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +166 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +21 -21
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +21 -21
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +9 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +9 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +40 -112
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +37 -110
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +84 -126
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +68 -124
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +1256 -1517
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +1236 -1513
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1783 -823
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1767 -821
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +165 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +141 -1
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +69 -108
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +49 -104
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +22 -24
package/dist/engine.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as AnalyzerSemanticReport, d as AnalyzerReport, h as analyzeWorkspace$1 } from './analyzeWorkspace-
|
|
1
|
+
import { e as AnalyzerSemanticReport, d as AnalyzerReport, h as analyzeWorkspace$1 } from './analyzeWorkspace-BS5O4rhC.mjs';
|
|
2
2
|
import { b as ScanWorkspaceResult, a as ScanWorkspaceOptions } from './schemas-DR-SLxZZ.mjs';
|
|
3
3
|
export { S as ScanFileResult } from './schemas-DR-SLxZZ.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -149,34 +149,71 @@ interface SourceLocation {
|
|
|
149
149
|
line: number;
|
|
150
150
|
column: number;
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Generate a short fingerprint string from a list of ordered parts.
|
|
154
|
+
*
|
|
155
|
+
* Hot path — called on every class conflict check and IR node creation.
|
|
156
|
+
* Delegates to Rust `create_fingerprint()` (FNV-1a, base-36 output) when the
|
|
157
|
+
* native binding is available; falls back to the pure-JS djb2 variant otherwise.
|
|
158
|
+
*/
|
|
152
159
|
declare function createFingerprint(parts: string[]): string;
|
|
153
|
-
declare function compareCascadeOrder(a: RuleIR, b: RuleIR): number;
|
|
154
160
|
declare function createResolutionReason(causes: ResolutionCause[], finalDecision: string): ResolutionReason;
|
|
155
161
|
|
|
162
|
+
/**
|
|
163
|
+
* tailwind-styled-v4 — Cascade Resolver
|
|
164
|
+
*
|
|
165
|
+
* JS layer: state management (rule collection, class registration).
|
|
166
|
+
* Rust layer: cascade algorithm (sort, compare, resolve winner/loser).
|
|
167
|
+
*
|
|
168
|
+
* Moved to native: compareCascade, resolveProperty, buildResolutionReason,
|
|
169
|
+
* determineCascadeStage — all pure computation, zero browser API.
|
|
170
|
+
*
|
|
171
|
+
* Rust #[napi] fn: resolve_cascade(rules_json: String) -> String
|
|
172
|
+
*/
|
|
173
|
+
|
|
156
174
|
declare class CascadeResolver {
|
|
157
|
-
private
|
|
158
|
-
private
|
|
159
|
-
private styleGraph;
|
|
160
|
-
private resolutions;
|
|
161
|
-
private classRules;
|
|
175
|
+
private readonly rules;
|
|
176
|
+
private readonly classRules;
|
|
177
|
+
private readonly styleGraph;
|
|
162
178
|
addRule(rule: RuleIR): void;
|
|
163
179
|
addRules(rules: RuleIR[]): void;
|
|
164
|
-
resolveProperty(property: PropertyId): CascadeResolutionIR | null;
|
|
165
|
-
resolveAllProperties(): Map<PropertyId, CascadeResolutionIR>;
|
|
166
|
-
resolveForClass(classRuleIds: RuleId[]): Map<PropertyId, CascadeResolutionIR>;
|
|
167
|
-
getStyleGraph(): StyleGraphIR;
|
|
168
|
-
getRule(ruleId: RuleId): RuleIR | undefined;
|
|
169
|
-
getBucket(property: PropertyId): PropertyBucketIR | undefined;
|
|
170
|
-
getAllBuckets(): Map<PropertyId, PropertyBucketIR>;
|
|
171
|
-
getResolution(id: CascadeResolutionId): CascadeResolutionIR | undefined;
|
|
172
180
|
registerClass(className: string, ruleIds: RuleId[]): void;
|
|
181
|
+
getRule(ruleId: RuleId): RuleIR | undefined;
|
|
173
182
|
getClassRules(className: string): RuleId[] | undefined;
|
|
183
|
+
getStyleGraph(): StyleGraphIR;
|
|
184
|
+
/**
|
|
185
|
+
* Resolve cascade for a specific class.
|
|
186
|
+
* Delegates sort + winner selection to Rust.
|
|
187
|
+
*/
|
|
174
188
|
resolveByClassName(className: string): {
|
|
175
189
|
resolvedProperties: Map<PropertyId, CascadeResolutionIR>;
|
|
176
190
|
} | null;
|
|
177
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Resolve cascade for all rules.
|
|
193
|
+
* Delegates sort + winner selection to Rust.
|
|
194
|
+
*/
|
|
195
|
+
resolveAllProperties(): Map<PropertyId, CascadeResolutionIR>;
|
|
196
|
+
/**
|
|
197
|
+
* Resolve cascade for a specific set of rule IDs.
|
|
198
|
+
*/
|
|
199
|
+
resolveForClass(classRuleIds: RuleId[]): Map<PropertyId, CascadeResolutionIR>;
|
|
200
|
+
/**
|
|
201
|
+
* Resolve cascade for a single property bucket.
|
|
202
|
+
*/
|
|
203
|
+
resolveProperty(property: PropertyId): CascadeResolutionIR | null;
|
|
204
|
+
getResolution(_id: CascadeResolutionId): CascadeResolutionIR | undefined;
|
|
178
205
|
}
|
|
179
206
|
|
|
207
|
+
/**
|
|
208
|
+
* tailwind-styled-v4 — Cascade Tracer
|
|
209
|
+
*
|
|
210
|
+
* Delegates cascade resolution to CascadeResolver (Rust-backed).
|
|
211
|
+
* JS layer: format trace output only.
|
|
212
|
+
*
|
|
213
|
+
* Removed from JS: resolvePropertyTraced, compareCascadeTraced,
|
|
214
|
+
* buildResolutionReasonTraced, determineCascadeStageTraced.
|
|
215
|
+
*/
|
|
216
|
+
|
|
180
217
|
interface VariantTrace {
|
|
181
218
|
name: string;
|
|
182
219
|
value: string;
|
|
@@ -300,12 +337,6 @@ declare class BundleAnalyzer {
|
|
|
300
337
|
analyzeAll(scanResult: ScanWorkspaceResult, css: string): Map<string, BundleAnalysisResult>;
|
|
301
338
|
calculateBundleContribution(className: string, css: string): number;
|
|
302
339
|
detectDeadCode(scanResult: ScanWorkspaceResult, css: string): string[];
|
|
303
|
-
private countClassUsage;
|
|
304
|
-
private getFilesUsingClass;
|
|
305
|
-
private extractVariantChains;
|
|
306
|
-
private extractDependencies;
|
|
307
|
-
private checkIsDeadCode;
|
|
308
|
-
private extractClassesFromCss;
|
|
309
340
|
}
|
|
310
341
|
|
|
311
342
|
interface ImpactReport {
|
|
@@ -325,40 +356,66 @@ interface ComponentImpact {
|
|
|
325
356
|
usageType: "direct" | "variant" | "component";
|
|
326
357
|
variant?: string;
|
|
327
358
|
}
|
|
359
|
+
interface NativeImpactScore {
|
|
360
|
+
className: string;
|
|
361
|
+
usageScore: number;
|
|
362
|
+
sizeScore: number;
|
|
363
|
+
impactScore: number;
|
|
364
|
+
usageCount: number;
|
|
365
|
+
sizeBytes: number;
|
|
366
|
+
}
|
|
328
367
|
declare class ImpactTracker {
|
|
329
368
|
private bundleAnalyzer;
|
|
330
|
-
private criticalPatterns;
|
|
331
369
|
constructor();
|
|
370
|
+
analyzeWithBundle(className: string, scanResult: ScanWorkspaceResult, css?: string): ImpactReport;
|
|
371
|
+
analyzeAll(scanResult: ScanWorkspaceResult, css?: string): Map<string, ImpactReport>;
|
|
372
|
+
calculateImpact(className: string, bundleAnalysis: BundleAnalysisResult, scanResult: ScanWorkspaceResult | null | undefined, nativeScore?: NativeImpactScore): ImpactReport;
|
|
373
|
+
findAffectedComponents(className: string, scanResult: ScanWorkspaceResult | null | undefined): ComponentImpact[];
|
|
332
374
|
/**
|
|
333
|
-
*
|
|
334
|
-
* data akurat tentang bundle size contribution.
|
|
375
|
+
* Cek apakah sebuah class dianggap "critical" (tidak boleh dihapus).
|
|
335
376
|
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
377
|
+
* Native: Rust `is_critical_class()` — O(n) pattern match di CRITICAL_PATTERNS.
|
|
378
|
+
* Lebih cepat dari regex JS untuk daftar panjang karena no backtracking.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* tracker.isCriticalClass("sr-only") // true
|
|
382
|
+
* tracker.isCriticalClass("hidden") // true
|
|
383
|
+
* tracker.isCriticalClass("bg-red-500") // false
|
|
339
384
|
*/
|
|
340
|
-
|
|
385
|
+
isCriticalClass(className: string): boolean;
|
|
341
386
|
/**
|
|
342
|
-
*
|
|
387
|
+
* Generate human-readable suggestions berdasarkan impact analysis.
|
|
388
|
+
*
|
|
389
|
+
* Native: `generate_suggestions()` di Rust — pattern matching di CRITICAL_PATTERNS
|
|
390
|
+
* + threshold-based risk categories.
|
|
391
|
+
*
|
|
392
|
+
* Biasanya dipanggil setelah `calculateImpact` yang sudah set riskLevel.
|
|
343
393
|
*/
|
|
344
|
-
|
|
345
|
-
calculateImpact(className: string, bundleAnalysis: BundleAnalysisResult, scanResult: ScanWorkspaceResult | null | undefined): ImpactReport;
|
|
346
|
-
findAffectedComponents(className: string, scanResult: ScanWorkspaceResult | null | undefined): ComponentImpact[];
|
|
347
|
-
calculateRisk(className: string, impact: ImpactReport): "low" | "medium" | "high";
|
|
348
|
-
generateSuggestions(className: string, impact: ImpactReport): string[];
|
|
349
|
-
private isCriticalClass;
|
|
350
|
-
private calculateSavings;
|
|
394
|
+
generateSuggestions(className: string, report: ImpactReport): string[];
|
|
351
395
|
private createEmptyReport;
|
|
352
396
|
}
|
|
353
397
|
|
|
354
398
|
/**
|
|
355
399
|
* Apply an incremental file-change event to an existing scan result.
|
|
356
400
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
401
|
+
* Semua tiga helper internal sekarang native-first:
|
|
402
|
+
* rebuildWorkspaceResult → Rust rebuild_workspace_result
|
|
403
|
+
* applyClassDiff → Rust apply_class_diff
|
|
404
|
+
* areClassSetsEqual → Rust are_class_sets_equal
|
|
359
405
|
*/
|
|
360
406
|
declare function applyIncrementalChange(previous: ScanWorkspaceResult, filePath: string, type: "change" | "unlink", scanner?: ScanWorkspaceOptions): ScanWorkspaceResult;
|
|
361
407
|
|
|
408
|
+
/**
|
|
409
|
+
* tailwind-styled-v4 — Reverse Lookup
|
|
410
|
+
*
|
|
411
|
+
* JS layer: thin wrapper, cache management.
|
|
412
|
+
* Rust layer: reverseLookupFromCss, reverseLookupByProperty,
|
|
413
|
+
* reverseLookupFindDependents (DashMap-backed).
|
|
414
|
+
*
|
|
415
|
+
* Removed from JS: parseCSS(), JS filter loops, pruneCache().
|
|
416
|
+
* All lookup computation is now in native.
|
|
417
|
+
*/
|
|
418
|
+
|
|
362
419
|
interface ClassUsage {
|
|
363
420
|
className: string;
|
|
364
421
|
source: SourceLocation;
|
|
@@ -372,38 +429,47 @@ interface ReverseLookupResult {
|
|
|
372
429
|
usedInClasses: ClassUsage[];
|
|
373
430
|
}
|
|
374
431
|
declare class ReverseLookup {
|
|
375
|
-
private parsedCache;
|
|
376
|
-
private static readonly MAX_CACHE_SIZE;
|
|
377
|
-
/** Jumlah karakter total yang disimpan di cache (approx) */
|
|
378
|
-
private cacheSizeBytes;
|
|
379
|
-
private static readonly MAX_CACHE_BYTES;
|
|
380
|
-
private parseCSS;
|
|
381
|
-
private findClosingBrace;
|
|
382
|
-
private calculateSpecificity;
|
|
383
432
|
fromCSS(cssProperty: string, cssValue: string, css: string): ReverseLookupResult[];
|
|
384
|
-
fromBundle(className: string, css: string): RuleIR[];
|
|
385
|
-
findDependents(className: string, css: string): string[];
|
|
386
433
|
findByProperty(property: string, css: string): ReverseLookupResult[];
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
* Panggil ini saat CSS berubah (watch mode) atau saat memory pressure.
|
|
390
|
-
*/
|
|
434
|
+
findDependents(className: string, css: string): string[];
|
|
435
|
+
fromBundle(className: string, css: string): RuleIR[];
|
|
391
436
|
clearCache(): void;
|
|
392
|
-
/**
|
|
393
|
-
* Hapus entri cache lama sampai di bawah threshold.
|
|
394
|
-
* Dipakai oleh parseCSS secara internal.
|
|
395
|
-
*/
|
|
396
|
-
private pruneCache;
|
|
397
|
-
/** Cache size untuk observability/diagnostics */
|
|
398
437
|
get cacheSize(): number;
|
|
399
438
|
}
|
|
400
439
|
|
|
440
|
+
/**
|
|
441
|
+
* tailwind-styled-v4 — CSS → IR converter
|
|
442
|
+
*
|
|
443
|
+
* Native handles: CSS parsing, class extraction, variant splitting, specificity.
|
|
444
|
+
* JS handles: ID generation, layer detection, RuleIR assembly.
|
|
445
|
+
*
|
|
446
|
+
* Removed from JS: parseSelector, calculateSpecificity
|
|
447
|
+
* (native parseCssRules already returns className/variants/specificity).
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
interface ParseCssToIrOptions {
|
|
451
|
+
prefix?: string;
|
|
452
|
+
}
|
|
453
|
+
declare function parseCssToIr(css: string, options?: ParseCssToIrOptions): {
|
|
454
|
+
rules: RuleIR[];
|
|
455
|
+
classToRuleIds: Map<string, RuleId[]>;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* watch.ts — File system watcher for tailwind-styled-v4.
|
|
460
|
+
*
|
|
461
|
+
* Native-only: uses Rust `notify`-based watcher via NAPI
|
|
462
|
+
* (`start_watch` / `poll_watch_events` / `stop_watch` from watch_api.rs).
|
|
463
|
+
*
|
|
464
|
+
* Polling interval: 200ms (configurable via `pollIntervalMs`).
|
|
465
|
+
*/
|
|
401
466
|
interface WatcherOptions {
|
|
467
|
+
/** Directories to ignore (currently not enforced by native watcher, kept for API compatibility). */
|
|
402
468
|
ignoreDirectories?: string[];
|
|
403
|
-
/**
|
|
404
|
-
* Delay before emitting change event to reduce noisy bursts.
|
|
405
|
-
*/
|
|
469
|
+
/** Delay before emitting change event to reduce noisy bursts (applied in Rust layer). */
|
|
406
470
|
debounceMs?: number;
|
|
471
|
+
/** Polling interval in ms for the Rust native watcher (default: 200). */
|
|
472
|
+
pollIntervalMs?: number;
|
|
407
473
|
onError?: (error: Error, directory: string) => void;
|
|
408
474
|
}
|
|
409
475
|
interface WatcherEvent {
|
|
@@ -413,6 +479,11 @@ interface WatcherEvent {
|
|
|
413
479
|
interface WorkspaceWatcher {
|
|
414
480
|
close(): void;
|
|
415
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* watchWorkspace — watches `rootDir` recursively for file changes.
|
|
484
|
+
*
|
|
485
|
+
* Requires native Rust watcher. Throws if native binding unavailable.
|
|
486
|
+
*/
|
|
416
487
|
declare function watchWorkspace$1(rootDir: string, onEvent: (event: WatcherEvent) => void, options?: WatcherOptions): WorkspaceWatcher;
|
|
417
488
|
|
|
418
489
|
/**
|
|
@@ -662,4 +733,4 @@ interface InspectionReport {
|
|
|
662
733
|
*/
|
|
663
734
|
declare function inspectClass(className: string, scanResult: ScanWorkspaceResult, css?: string): Promise<InspectionReport>;
|
|
664
735
|
|
|
665
|
-
export { type BuildResult, type BuildResultInput, BuildResultSchema, type BundleAnalysisResult, BundleAnalyzer, type CascadeResolutionIR, CascadeResolutionId, CascadeStage, type ClassBundleInfo, type ClassUsage, type ComponentImpact, type ConditionIR, ConditionId, ConditionResult, type ConflictTrace, EngineMetricsCollector, type EngineMetricsSnapshot, type EngineOptions, type EngineOptionsInput, EngineOptionsSchema, type EnginePlugin, type EnginePluginContext, type EngineWatchContext, type EngineWatchEvent, type EngineWatchOptions, type EngineWatchOptionsInput, EngineWatchOptionsSchema, type FinalComputedStyleIR, type FinalStyleProperty, type ImpactReport, ImpactTracker, Importance, type InspectionReport, LayerId, Origin, type PropertyBucketIR, PropertyId, type ResolutionCause, type ResolutionReason, ReverseLookup, type ReverseLookupResult, type RuleIR, RuleId, type RuleTrace, ScanWorkspaceOptions, ScanWorkspaceResult, type SelectorIR, SelectorId, type SourceLocation, type StyleGraphIR, type TailwindStyledEngine, type TraceResult, ValueId, type VariantChainIR, VariantChainId, type VariantTrace, type WatchCallback, type WatchEvent, type WatchEventKind, type WatchHandle, type WorkspaceWatcher, analyzeWorkspace, applyIncrementalChange, build, buildProvenanceChain,
|
|
736
|
+
export { type BuildResult, type BuildResultInput, BuildResultSchema, type BundleAnalysisResult, BundleAnalyzer, type CascadeResolutionIR, CascadeResolutionId, CascadeResolver, CascadeStage, type ClassBundleInfo, type ClassUsage, type ComponentImpact, type ConditionIR, ConditionId, ConditionResult, type ConflictTrace, EngineMetricsCollector, type EngineMetricsSnapshot, type EngineOptions, type EngineOptionsInput, EngineOptionsSchema, type EnginePlugin, type EnginePluginContext, type EngineWatchContext, type EngineWatchEvent, type EngineWatchOptions, type EngineWatchOptionsInput, EngineWatchOptionsSchema, type FinalComputedStyleIR, type FinalStyleProperty, type ImpactReport, ImpactTracker, Importance, type InspectionReport, LayerId, Origin, type PropertyBucketIR, PropertyId, type ResolutionCause, type ResolutionReason, ReverseLookup, type ReverseLookupResult, type RuleIR, RuleId, type RuleTrace, ScanWorkspaceOptions, ScanWorkspaceResult, type SelectorIR, SelectorId, type SourceLocation, type StyleGraphIR, type TailwindStyledEngine, type TraceResult, ValueId, type VariantChainIR, VariantChainId, type VariantTrace, type WatchCallback, type WatchEvent, type WatchEventKind, type WatchHandle, type WorkspaceWatcher, analyzeWorkspace, applyIncrementalChange, build, buildProvenanceChain, createEngine, createFingerprint, createResolutionReason, generateSafelist, inspectClass, parseCssToIr, parseEngineOptions, parseEngineWatchOptions, runAfterBuild, runAfterScan, runAfterWatch, runBeforeBuild, runBeforeScan, runBeforeWatch, runOnError, runTransformClasses, scanWorkspace, trace, traceClass, traceClasses, watchWorkspace$1 as watchWorkspaceLegacy, watchWorkspace as watchWorkspaceNative };
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as AnalyzerSemanticReport, d as AnalyzerReport, h as analyzeWorkspace$1 } from './analyzeWorkspace-
|
|
1
|
+
import { e as AnalyzerSemanticReport, d as AnalyzerReport, h as analyzeWorkspace$1 } from './analyzeWorkspace-DDOQdzzI.js';
|
|
2
2
|
import { b as ScanWorkspaceResult, a as ScanWorkspaceOptions } from './schemas-DR-SLxZZ.js';
|
|
3
3
|
export { S as ScanFileResult } from './schemas-DR-SLxZZ.js';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -149,34 +149,71 @@ interface SourceLocation {
|
|
|
149
149
|
line: number;
|
|
150
150
|
column: number;
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Generate a short fingerprint string from a list of ordered parts.
|
|
154
|
+
*
|
|
155
|
+
* Hot path — called on every class conflict check and IR node creation.
|
|
156
|
+
* Delegates to Rust `create_fingerprint()` (FNV-1a, base-36 output) when the
|
|
157
|
+
* native binding is available; falls back to the pure-JS djb2 variant otherwise.
|
|
158
|
+
*/
|
|
152
159
|
declare function createFingerprint(parts: string[]): string;
|
|
153
|
-
declare function compareCascadeOrder(a: RuleIR, b: RuleIR): number;
|
|
154
160
|
declare function createResolutionReason(causes: ResolutionCause[], finalDecision: string): ResolutionReason;
|
|
155
161
|
|
|
162
|
+
/**
|
|
163
|
+
* tailwind-styled-v4 — Cascade Resolver
|
|
164
|
+
*
|
|
165
|
+
* JS layer: state management (rule collection, class registration).
|
|
166
|
+
* Rust layer: cascade algorithm (sort, compare, resolve winner/loser).
|
|
167
|
+
*
|
|
168
|
+
* Moved to native: compareCascade, resolveProperty, buildResolutionReason,
|
|
169
|
+
* determineCascadeStage — all pure computation, zero browser API.
|
|
170
|
+
*
|
|
171
|
+
* Rust #[napi] fn: resolve_cascade(rules_json: String) -> String
|
|
172
|
+
*/
|
|
173
|
+
|
|
156
174
|
declare class CascadeResolver {
|
|
157
|
-
private
|
|
158
|
-
private
|
|
159
|
-
private styleGraph;
|
|
160
|
-
private resolutions;
|
|
161
|
-
private classRules;
|
|
175
|
+
private readonly rules;
|
|
176
|
+
private readonly classRules;
|
|
177
|
+
private readonly styleGraph;
|
|
162
178
|
addRule(rule: RuleIR): void;
|
|
163
179
|
addRules(rules: RuleIR[]): void;
|
|
164
|
-
resolveProperty(property: PropertyId): CascadeResolutionIR | null;
|
|
165
|
-
resolveAllProperties(): Map<PropertyId, CascadeResolutionIR>;
|
|
166
|
-
resolveForClass(classRuleIds: RuleId[]): Map<PropertyId, CascadeResolutionIR>;
|
|
167
|
-
getStyleGraph(): StyleGraphIR;
|
|
168
|
-
getRule(ruleId: RuleId): RuleIR | undefined;
|
|
169
|
-
getBucket(property: PropertyId): PropertyBucketIR | undefined;
|
|
170
|
-
getAllBuckets(): Map<PropertyId, PropertyBucketIR>;
|
|
171
|
-
getResolution(id: CascadeResolutionId): CascadeResolutionIR | undefined;
|
|
172
180
|
registerClass(className: string, ruleIds: RuleId[]): void;
|
|
181
|
+
getRule(ruleId: RuleId): RuleIR | undefined;
|
|
173
182
|
getClassRules(className: string): RuleId[] | undefined;
|
|
183
|
+
getStyleGraph(): StyleGraphIR;
|
|
184
|
+
/**
|
|
185
|
+
* Resolve cascade for a specific class.
|
|
186
|
+
* Delegates sort + winner selection to Rust.
|
|
187
|
+
*/
|
|
174
188
|
resolveByClassName(className: string): {
|
|
175
189
|
resolvedProperties: Map<PropertyId, CascadeResolutionIR>;
|
|
176
190
|
} | null;
|
|
177
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Resolve cascade for all rules.
|
|
193
|
+
* Delegates sort + winner selection to Rust.
|
|
194
|
+
*/
|
|
195
|
+
resolveAllProperties(): Map<PropertyId, CascadeResolutionIR>;
|
|
196
|
+
/**
|
|
197
|
+
* Resolve cascade for a specific set of rule IDs.
|
|
198
|
+
*/
|
|
199
|
+
resolveForClass(classRuleIds: RuleId[]): Map<PropertyId, CascadeResolutionIR>;
|
|
200
|
+
/**
|
|
201
|
+
* Resolve cascade for a single property bucket.
|
|
202
|
+
*/
|
|
203
|
+
resolveProperty(property: PropertyId): CascadeResolutionIR | null;
|
|
204
|
+
getResolution(_id: CascadeResolutionId): CascadeResolutionIR | undefined;
|
|
178
205
|
}
|
|
179
206
|
|
|
207
|
+
/**
|
|
208
|
+
* tailwind-styled-v4 — Cascade Tracer
|
|
209
|
+
*
|
|
210
|
+
* Delegates cascade resolution to CascadeResolver (Rust-backed).
|
|
211
|
+
* JS layer: format trace output only.
|
|
212
|
+
*
|
|
213
|
+
* Removed from JS: resolvePropertyTraced, compareCascadeTraced,
|
|
214
|
+
* buildResolutionReasonTraced, determineCascadeStageTraced.
|
|
215
|
+
*/
|
|
216
|
+
|
|
180
217
|
interface VariantTrace {
|
|
181
218
|
name: string;
|
|
182
219
|
value: string;
|
|
@@ -300,12 +337,6 @@ declare class BundleAnalyzer {
|
|
|
300
337
|
analyzeAll(scanResult: ScanWorkspaceResult, css: string): Map<string, BundleAnalysisResult>;
|
|
301
338
|
calculateBundleContribution(className: string, css: string): number;
|
|
302
339
|
detectDeadCode(scanResult: ScanWorkspaceResult, css: string): string[];
|
|
303
|
-
private countClassUsage;
|
|
304
|
-
private getFilesUsingClass;
|
|
305
|
-
private extractVariantChains;
|
|
306
|
-
private extractDependencies;
|
|
307
|
-
private checkIsDeadCode;
|
|
308
|
-
private extractClassesFromCss;
|
|
309
340
|
}
|
|
310
341
|
|
|
311
342
|
interface ImpactReport {
|
|
@@ -325,40 +356,66 @@ interface ComponentImpact {
|
|
|
325
356
|
usageType: "direct" | "variant" | "component";
|
|
326
357
|
variant?: string;
|
|
327
358
|
}
|
|
359
|
+
interface NativeImpactScore {
|
|
360
|
+
className: string;
|
|
361
|
+
usageScore: number;
|
|
362
|
+
sizeScore: number;
|
|
363
|
+
impactScore: number;
|
|
364
|
+
usageCount: number;
|
|
365
|
+
sizeBytes: number;
|
|
366
|
+
}
|
|
328
367
|
declare class ImpactTracker {
|
|
329
368
|
private bundleAnalyzer;
|
|
330
|
-
private criticalPatterns;
|
|
331
369
|
constructor();
|
|
370
|
+
analyzeWithBundle(className: string, scanResult: ScanWorkspaceResult, css?: string): ImpactReport;
|
|
371
|
+
analyzeAll(scanResult: ScanWorkspaceResult, css?: string): Map<string, ImpactReport>;
|
|
372
|
+
calculateImpact(className: string, bundleAnalysis: BundleAnalysisResult, scanResult: ScanWorkspaceResult | null | undefined, nativeScore?: NativeImpactScore): ImpactReport;
|
|
373
|
+
findAffectedComponents(className: string, scanResult: ScanWorkspaceResult | null | undefined): ComponentImpact[];
|
|
332
374
|
/**
|
|
333
|
-
*
|
|
334
|
-
* data akurat tentang bundle size contribution.
|
|
375
|
+
* Cek apakah sebuah class dianggap "critical" (tidak boleh dihapus).
|
|
335
376
|
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
377
|
+
* Native: Rust `is_critical_class()` — O(n) pattern match di CRITICAL_PATTERNS.
|
|
378
|
+
* Lebih cepat dari regex JS untuk daftar panjang karena no backtracking.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* tracker.isCriticalClass("sr-only") // true
|
|
382
|
+
* tracker.isCriticalClass("hidden") // true
|
|
383
|
+
* tracker.isCriticalClass("bg-red-500") // false
|
|
339
384
|
*/
|
|
340
|
-
|
|
385
|
+
isCriticalClass(className: string): boolean;
|
|
341
386
|
/**
|
|
342
|
-
*
|
|
387
|
+
* Generate human-readable suggestions berdasarkan impact analysis.
|
|
388
|
+
*
|
|
389
|
+
* Native: `generate_suggestions()` di Rust — pattern matching di CRITICAL_PATTERNS
|
|
390
|
+
* + threshold-based risk categories.
|
|
391
|
+
*
|
|
392
|
+
* Biasanya dipanggil setelah `calculateImpact` yang sudah set riskLevel.
|
|
343
393
|
*/
|
|
344
|
-
|
|
345
|
-
calculateImpact(className: string, bundleAnalysis: BundleAnalysisResult, scanResult: ScanWorkspaceResult | null | undefined): ImpactReport;
|
|
346
|
-
findAffectedComponents(className: string, scanResult: ScanWorkspaceResult | null | undefined): ComponentImpact[];
|
|
347
|
-
calculateRisk(className: string, impact: ImpactReport): "low" | "medium" | "high";
|
|
348
|
-
generateSuggestions(className: string, impact: ImpactReport): string[];
|
|
349
|
-
private isCriticalClass;
|
|
350
|
-
private calculateSavings;
|
|
394
|
+
generateSuggestions(className: string, report: ImpactReport): string[];
|
|
351
395
|
private createEmptyReport;
|
|
352
396
|
}
|
|
353
397
|
|
|
354
398
|
/**
|
|
355
399
|
* Apply an incremental file-change event to an existing scan result.
|
|
356
400
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
401
|
+
* Semua tiga helper internal sekarang native-first:
|
|
402
|
+
* rebuildWorkspaceResult → Rust rebuild_workspace_result
|
|
403
|
+
* applyClassDiff → Rust apply_class_diff
|
|
404
|
+
* areClassSetsEqual → Rust are_class_sets_equal
|
|
359
405
|
*/
|
|
360
406
|
declare function applyIncrementalChange(previous: ScanWorkspaceResult, filePath: string, type: "change" | "unlink", scanner?: ScanWorkspaceOptions): ScanWorkspaceResult;
|
|
361
407
|
|
|
408
|
+
/**
|
|
409
|
+
* tailwind-styled-v4 — Reverse Lookup
|
|
410
|
+
*
|
|
411
|
+
* JS layer: thin wrapper, cache management.
|
|
412
|
+
* Rust layer: reverseLookupFromCss, reverseLookupByProperty,
|
|
413
|
+
* reverseLookupFindDependents (DashMap-backed).
|
|
414
|
+
*
|
|
415
|
+
* Removed from JS: parseCSS(), JS filter loops, pruneCache().
|
|
416
|
+
* All lookup computation is now in native.
|
|
417
|
+
*/
|
|
418
|
+
|
|
362
419
|
interface ClassUsage {
|
|
363
420
|
className: string;
|
|
364
421
|
source: SourceLocation;
|
|
@@ -372,38 +429,47 @@ interface ReverseLookupResult {
|
|
|
372
429
|
usedInClasses: ClassUsage[];
|
|
373
430
|
}
|
|
374
431
|
declare class ReverseLookup {
|
|
375
|
-
private parsedCache;
|
|
376
|
-
private static readonly MAX_CACHE_SIZE;
|
|
377
|
-
/** Jumlah karakter total yang disimpan di cache (approx) */
|
|
378
|
-
private cacheSizeBytes;
|
|
379
|
-
private static readonly MAX_CACHE_BYTES;
|
|
380
|
-
private parseCSS;
|
|
381
|
-
private findClosingBrace;
|
|
382
|
-
private calculateSpecificity;
|
|
383
432
|
fromCSS(cssProperty: string, cssValue: string, css: string): ReverseLookupResult[];
|
|
384
|
-
fromBundle(className: string, css: string): RuleIR[];
|
|
385
|
-
findDependents(className: string, css: string): string[];
|
|
386
433
|
findByProperty(property: string, css: string): ReverseLookupResult[];
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
* Panggil ini saat CSS berubah (watch mode) atau saat memory pressure.
|
|
390
|
-
*/
|
|
434
|
+
findDependents(className: string, css: string): string[];
|
|
435
|
+
fromBundle(className: string, css: string): RuleIR[];
|
|
391
436
|
clearCache(): void;
|
|
392
|
-
/**
|
|
393
|
-
* Hapus entri cache lama sampai di bawah threshold.
|
|
394
|
-
* Dipakai oleh parseCSS secara internal.
|
|
395
|
-
*/
|
|
396
|
-
private pruneCache;
|
|
397
|
-
/** Cache size untuk observability/diagnostics */
|
|
398
437
|
get cacheSize(): number;
|
|
399
438
|
}
|
|
400
439
|
|
|
440
|
+
/**
|
|
441
|
+
* tailwind-styled-v4 — CSS → IR converter
|
|
442
|
+
*
|
|
443
|
+
* Native handles: CSS parsing, class extraction, variant splitting, specificity.
|
|
444
|
+
* JS handles: ID generation, layer detection, RuleIR assembly.
|
|
445
|
+
*
|
|
446
|
+
* Removed from JS: parseSelector, calculateSpecificity
|
|
447
|
+
* (native parseCssRules already returns className/variants/specificity).
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
interface ParseCssToIrOptions {
|
|
451
|
+
prefix?: string;
|
|
452
|
+
}
|
|
453
|
+
declare function parseCssToIr(css: string, options?: ParseCssToIrOptions): {
|
|
454
|
+
rules: RuleIR[];
|
|
455
|
+
classToRuleIds: Map<string, RuleId[]>;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* watch.ts — File system watcher for tailwind-styled-v4.
|
|
460
|
+
*
|
|
461
|
+
* Native-only: uses Rust `notify`-based watcher via NAPI
|
|
462
|
+
* (`start_watch` / `poll_watch_events` / `stop_watch` from watch_api.rs).
|
|
463
|
+
*
|
|
464
|
+
* Polling interval: 200ms (configurable via `pollIntervalMs`).
|
|
465
|
+
*/
|
|
401
466
|
interface WatcherOptions {
|
|
467
|
+
/** Directories to ignore (currently not enforced by native watcher, kept for API compatibility). */
|
|
402
468
|
ignoreDirectories?: string[];
|
|
403
|
-
/**
|
|
404
|
-
* Delay before emitting change event to reduce noisy bursts.
|
|
405
|
-
*/
|
|
469
|
+
/** Delay before emitting change event to reduce noisy bursts (applied in Rust layer). */
|
|
406
470
|
debounceMs?: number;
|
|
471
|
+
/** Polling interval in ms for the Rust native watcher (default: 200). */
|
|
472
|
+
pollIntervalMs?: number;
|
|
407
473
|
onError?: (error: Error, directory: string) => void;
|
|
408
474
|
}
|
|
409
475
|
interface WatcherEvent {
|
|
@@ -413,6 +479,11 @@ interface WatcherEvent {
|
|
|
413
479
|
interface WorkspaceWatcher {
|
|
414
480
|
close(): void;
|
|
415
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* watchWorkspace — watches `rootDir` recursively for file changes.
|
|
484
|
+
*
|
|
485
|
+
* Requires native Rust watcher. Throws if native binding unavailable.
|
|
486
|
+
*/
|
|
416
487
|
declare function watchWorkspace$1(rootDir: string, onEvent: (event: WatcherEvent) => void, options?: WatcherOptions): WorkspaceWatcher;
|
|
417
488
|
|
|
418
489
|
/**
|
|
@@ -662,4 +733,4 @@ interface InspectionReport {
|
|
|
662
733
|
*/
|
|
663
734
|
declare function inspectClass(className: string, scanResult: ScanWorkspaceResult, css?: string): Promise<InspectionReport>;
|
|
664
735
|
|
|
665
|
-
export { type BuildResult, type BuildResultInput, BuildResultSchema, type BundleAnalysisResult, BundleAnalyzer, type CascadeResolutionIR, CascadeResolutionId, CascadeStage, type ClassBundleInfo, type ClassUsage, type ComponentImpact, type ConditionIR, ConditionId, ConditionResult, type ConflictTrace, EngineMetricsCollector, type EngineMetricsSnapshot, type EngineOptions, type EngineOptionsInput, EngineOptionsSchema, type EnginePlugin, type EnginePluginContext, type EngineWatchContext, type EngineWatchEvent, type EngineWatchOptions, type EngineWatchOptionsInput, EngineWatchOptionsSchema, type FinalComputedStyleIR, type FinalStyleProperty, type ImpactReport, ImpactTracker, Importance, type InspectionReport, LayerId, Origin, type PropertyBucketIR, PropertyId, type ResolutionCause, type ResolutionReason, ReverseLookup, type ReverseLookupResult, type RuleIR, RuleId, type RuleTrace, ScanWorkspaceOptions, ScanWorkspaceResult, type SelectorIR, SelectorId, type SourceLocation, type StyleGraphIR, type TailwindStyledEngine, type TraceResult, ValueId, type VariantChainIR, VariantChainId, type VariantTrace, type WatchCallback, type WatchEvent, type WatchEventKind, type WatchHandle, type WorkspaceWatcher, analyzeWorkspace, applyIncrementalChange, build, buildProvenanceChain,
|
|
736
|
+
export { type BuildResult, type BuildResultInput, BuildResultSchema, type BundleAnalysisResult, BundleAnalyzer, type CascadeResolutionIR, CascadeResolutionId, CascadeResolver, CascadeStage, type ClassBundleInfo, type ClassUsage, type ComponentImpact, type ConditionIR, ConditionId, ConditionResult, type ConflictTrace, EngineMetricsCollector, type EngineMetricsSnapshot, type EngineOptions, type EngineOptionsInput, EngineOptionsSchema, type EnginePlugin, type EnginePluginContext, type EngineWatchContext, type EngineWatchEvent, type EngineWatchOptions, type EngineWatchOptionsInput, EngineWatchOptionsSchema, type FinalComputedStyleIR, type FinalStyleProperty, type ImpactReport, ImpactTracker, Importance, type InspectionReport, LayerId, Origin, type PropertyBucketIR, PropertyId, type ResolutionCause, type ResolutionReason, ReverseLookup, type ReverseLookupResult, type RuleIR, RuleId, type RuleTrace, ScanWorkspaceOptions, ScanWorkspaceResult, type SelectorIR, SelectorId, type SourceLocation, type StyleGraphIR, type TailwindStyledEngine, type TraceResult, ValueId, type VariantChainIR, VariantChainId, type VariantTrace, type WatchCallback, type WatchEvent, type WatchEventKind, type WatchHandle, type WorkspaceWatcher, analyzeWorkspace, applyIncrementalChange, build, buildProvenanceChain, createEngine, createFingerprint, createResolutionReason, generateSafelist, inspectClass, parseCssToIr, parseEngineOptions, parseEngineWatchOptions, runAfterBuild, runAfterScan, runAfterWatch, runBeforeBuild, runBeforeScan, runBeforeWatch, runOnError, runTransformClasses, scanWorkspace, trace, traceClass, traceClasses, watchWorkspace$1 as watchWorkspaceLegacy, watchWorkspace as watchWorkspaceNative };
|