tailwindcss-patch 9.0.0-alpha.2 → 9.0.0-alpha.4

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.
@@ -0,0 +1,677 @@
1
+ import { SourceEntry } from '@tailwindcss/oxide';
2
+ import { Rule, Node } from 'postcss';
3
+ import { Config } from 'tailwindcss';
4
+ import { PackageResolvingOptions, PackageInfo } from 'local-pkg';
5
+ import { Command, CAC } from 'cac';
6
+ import * as consola from 'consola';
7
+
8
+ type CacheStrategy = 'merge' | 'overwrite';
9
+ type CacheDriver = 'file' | 'memory' | 'noop';
10
+ /**
11
+ * Configures how the Tailwind class cache is stored and where it lives on disk.
12
+ */
13
+ interface CacheOptions {
14
+ /** Whether caching is enabled. */
15
+ enabled?: boolean;
16
+ /** Working directory used when resolving cache paths. */
17
+ cwd?: string;
18
+ /** Directory where cache files are written. */
19
+ dir?: string;
20
+ /**
21
+ * Cache filename. Defaults to `class-cache.json` inside the derived cache folder
22
+ * when omitted.
23
+ */
24
+ file?: string;
25
+ /** Strategy used when merging new class lists with an existing cache. */
26
+ strategy?: CacheStrategy;
27
+ /** Backend used to persist the cache (`file`, `memory`, or `noop`). Defaults to `file`. */
28
+ driver?: CacheDriver;
29
+ }
30
+ /**
31
+ * Preferred options for extraction output behavior.
32
+ */
33
+ interface ExtractOptions {
34
+ /** Whether to produce an output file. */
35
+ write?: boolean;
36
+ /** Optional absolute or relative path to the output file. */
37
+ file?: string;
38
+ /** Output format, defaults to JSON when omitted. */
39
+ format?: 'json' | 'lines';
40
+ /** Pretty-print spacing (truthy value enables indentation). */
41
+ pretty?: number | boolean;
42
+ /** Whether to strip the universal selector (`*`) from the final list. */
43
+ removeUniversalSelector?: boolean;
44
+ }
45
+ /**
46
+ * Options controlling how Tailwind contexts are exposed during runtime patching.
47
+ */
48
+ interface ExposeContextOptions {
49
+ /** Name of the property used to reference an exposed context. */
50
+ refProperty?: string;
51
+ }
52
+ /**
53
+ * Extends the built-in length-unit patch with custom defaults.
54
+ */
55
+ interface ExtendLengthUnitsOptions extends Partial<ILengthUnitsPatchOptions> {
56
+ /** Enables or disables the length-unit patch. */
57
+ enabled?: boolean;
58
+ }
59
+ /**
60
+ * Preferred options for runtime patch behavior.
61
+ */
62
+ interface ApplyOptions {
63
+ /** Whether patched files can be overwritten on disk. */
64
+ overwrite?: boolean;
65
+ /** Whether to expose runtime Tailwind contexts (or configure how they are exposed). */
66
+ exposeContext?: boolean | ExposeContextOptions;
67
+ /** Extends the length-unit patch or disables it entirely. */
68
+ extendLengthUnits?: false | ExtendLengthUnitsOptions;
69
+ }
70
+ interface TailwindRuntimeOptionsBase {
71
+ /** Path to a Tailwind config file when auto-detection is insufficient. */
72
+ config?: string;
73
+ /** Custom working directory used when resolving config-relative paths. */
74
+ cwd?: string;
75
+ /** Optional PostCSS plugin name to use instead of the default. */
76
+ postcssPlugin?: string;
77
+ }
78
+ /**
79
+ * Configuration specific to Tailwind CSS v2 patching flows.
80
+ */
81
+ interface TailwindV2Options extends TailwindRuntimeOptionsBase {
82
+ }
83
+ /**
84
+ * Configuration specific to Tailwind CSS v3 patching flows.
85
+ */
86
+ interface TailwindV3Options extends TailwindRuntimeOptionsBase {
87
+ }
88
+ /**
89
+ * Additional configuration specific to Tailwind CSS v4 extraction.
90
+ */
91
+ interface TailwindV4Options {
92
+ /** Base directory used when resolving v4 content sources and configs. */
93
+ base?: string;
94
+ /** Raw CSS passed directly to the v4 design system. */
95
+ css?: string;
96
+ /** Set of CSS entry files that should be scanned for `@config` directives. */
97
+ cssEntries?: string[];
98
+ /** Overrides the content sources scanned by the oxide scanner. */
99
+ sources?: SourceEntry[];
100
+ }
101
+ /**
102
+ * High-level Tailwind patch configuration shared across versions.
103
+ */
104
+ interface TailwindCssOptions extends TailwindRuntimeOptionsBase {
105
+ /** Explicit Tailwind CSS major version used by the current project. When omitted, the installed package version is inferred. */
106
+ version?: 2 | 3 | 4;
107
+ /** Tailwind package name if the project uses a fork. */
108
+ packageName?: string;
109
+ /** Package resolution options forwarded to `local-pkg`. */
110
+ resolve?: PackageResolvingOptions;
111
+ /** Overrides applied when patching Tailwind CSS v2. */
112
+ v2?: TailwindV2Options;
113
+ /** Overrides applied when patching Tailwind CSS v3. */
114
+ v3?: TailwindV3Options;
115
+ /** Options specific to Tailwind CSS v4 patching. */
116
+ v4?: TailwindV4Options;
117
+ }
118
+ /**
119
+ * Root configuration consumed by the Tailwind CSS patch runner.
120
+ */
121
+ interface TailwindCssPatchOptions {
122
+ /**
123
+ * Base directory used when resolving Tailwind resources.
124
+ * Defaults to `process.cwd()`.
125
+ */
126
+ projectRoot?: string;
127
+ /** Preferred Tailwind runtime configuration. */
128
+ tailwindcss?: TailwindCssOptions;
129
+ /** Preferred patch toggles. */
130
+ apply?: ApplyOptions;
131
+ /** Preferred extraction output settings. */
132
+ extract?: ExtractOptions;
133
+ /** Optional function that filters final class names. */
134
+ filter?: (className: string) => boolean;
135
+ /** Cache configuration or boolean to enable/disable quickly. */
136
+ cache?: boolean | CacheOptions;
137
+ }
138
+ /**
139
+ * Stable shape for output configuration after normalization.
140
+ */
141
+ interface NormalizedOutputOptions {
142
+ enabled: boolean;
143
+ file?: string;
144
+ format: 'json' | 'lines';
145
+ pretty: number | false;
146
+ removeUniversalSelector: boolean;
147
+ }
148
+ /**
149
+ * Stable cache configuration used internally after defaults are applied.
150
+ */
151
+ interface NormalizedCacheOptions {
152
+ enabled: boolean;
153
+ cwd: string;
154
+ dir: string;
155
+ file: string;
156
+ path: string;
157
+ strategy: CacheStrategy;
158
+ driver: CacheDriver;
159
+ }
160
+ /** Tracks whether runtime contexts should be exposed and via which property. */
161
+ interface NormalizedExposeContextOptions {
162
+ enabled: boolean;
163
+ refProperty: string;
164
+ }
165
+ /** Normalized representation of the extend-length-units feature flag. */
166
+ interface NormalizedExtendLengthUnitsOptions extends ILengthUnitsPatchOptions {
167
+ enabled: boolean;
168
+ }
169
+ /** Normalized Tailwind v4 configuration consumed by runtime helpers. */
170
+ interface NormalizedTailwindV4Options {
171
+ base: string;
172
+ configuredBase?: string;
173
+ css?: string;
174
+ cssEntries: string[];
175
+ sources: SourceEntry[];
176
+ hasUserDefinedSources: boolean;
177
+ }
178
+ /**
179
+ * Tailwind configuration ready for consumption by the runtime after normalization.
180
+ */
181
+ interface NormalizedTailwindConfigOptions extends TailwindRuntimeOptionsBase {
182
+ packageName: string;
183
+ versionHint?: 2 | 3 | 4;
184
+ resolve?: PackageResolvingOptions;
185
+ v2?: TailwindV2Options;
186
+ v3?: TailwindV3Options;
187
+ v4?: NormalizedTailwindV4Options;
188
+ }
189
+ /** Grouped normalized feature flags. */
190
+ interface NormalizedFeatureOptions {
191
+ exposeContext: NormalizedExposeContextOptions;
192
+ extendLengthUnits: NormalizedExtendLengthUnitsOptions | null;
193
+ }
194
+ /** Final normalized shape consumed throughout the patch runtime. */
195
+ interface NormalizedTailwindCssPatchOptions {
196
+ projectRoot: string;
197
+ overwrite: boolean;
198
+ tailwind: NormalizedTailwindConfigOptions;
199
+ features: NormalizedFeatureOptions;
200
+ output: NormalizedOutputOptions;
201
+ cache: NormalizedCacheOptions;
202
+ filter: (className: string) => boolean;
203
+ }
204
+
205
+ declare const CACHE_SCHEMA_VERSION = 2;
206
+ declare const CACHE_FINGERPRINT_VERSION = 1;
207
+ type CacheSchemaVersion = typeof CACHE_SCHEMA_VERSION;
208
+ type CacheFingerprintVersion = typeof CACHE_FINGERPRINT_VERSION;
209
+ type CacheClearScope = 'current' | 'all';
210
+ interface CacheContextMetadata {
211
+ fingerprintVersion: CacheFingerprintVersion;
212
+ projectRootRealpath: string;
213
+ processCwdRealpath: string;
214
+ cacheCwdRealpath: string;
215
+ tailwindConfigPath?: string;
216
+ tailwindConfigMtimeMs?: number;
217
+ tailwindPackageRootRealpath: string;
218
+ tailwindPackageVersion: string;
219
+ patcherVersion: string;
220
+ majorVersion: 2 | 3 | 4;
221
+ optionsHash: string;
222
+ }
223
+ interface CacheContextDescriptor {
224
+ fingerprint: string;
225
+ metadata: CacheContextMetadata;
226
+ }
227
+ interface CacheIndexEntry {
228
+ context: CacheContextMetadata;
229
+ values: string[];
230
+ updatedAt: string;
231
+ }
232
+ interface CacheIndexFileV2 {
233
+ schemaVersion: CacheSchemaVersion;
234
+ updatedAt: string;
235
+ contexts: Record<string, CacheIndexEntry>;
236
+ }
237
+ type CacheReadReason = 'hit' | 'cache-disabled' | 'noop-driver' | 'file-missing' | 'context-not-found' | 'context-mismatch' | 'legacy-schema' | 'invalid-schema';
238
+ interface CacheReadMeta {
239
+ hit: boolean;
240
+ reason: CacheReadReason;
241
+ fingerprint?: string;
242
+ schemaVersion?: number;
243
+ details: string[];
244
+ }
245
+ interface CacheReadResult {
246
+ data: Set<string>;
247
+ meta: CacheReadMeta;
248
+ }
249
+ interface CacheClearOptions {
250
+ scope?: CacheClearScope;
251
+ }
252
+ interface CacheClearResult {
253
+ scope: CacheClearScope;
254
+ filesRemoved: number;
255
+ entriesRemoved: number;
256
+ contextsRemoved: number;
257
+ }
258
+
259
+ type TailwindcssClassCacheEntry = Rule | {
260
+ layer: string;
261
+ options: Record<string, any>;
262
+ sort: Record<string, any>;
263
+ };
264
+ type TailwindcssClassCache = Map<string, TailwindcssClassCacheEntry[]>;
265
+ interface TailwindcssRuntimeContext {
266
+ applyClassCache: Map<any, any>;
267
+ candidateRuleCache: Map<string, Set<[
268
+ {
269
+ arbitrary: any;
270
+ index: any;
271
+ layer: string;
272
+ options: any[];
273
+ parallelIndex: any;
274
+ parentLayer: string;
275
+ variants: any;
276
+ },
277
+ Node
278
+ ]>>;
279
+ candidateRuleMap: Map<string | string, [object, Node][]>;
280
+ changedContent: any[];
281
+ classCache: TailwindcssClassCache;
282
+ disposables: any[];
283
+ getClassList: (...args: any[]) => any;
284
+ getClassOrder: (...args: any[]) => any;
285
+ getVariants: (...args: any[]) => any;
286
+ markInvalidUtilityCandidate: (...args: any[]) => any;
287
+ markInvalidUtilityNode: (...args: any[]) => any;
288
+ notClassCache: Set<string>;
289
+ offsets: {
290
+ layerPositions: object;
291
+ offsets: object;
292
+ reservedVariantBits: any;
293
+ variantOffsets: Map<string, any>;
294
+ };
295
+ postCssNodeCache: Map<object, [Node]>;
296
+ ruleCache: Set<[object, Node]>;
297
+ stylesheetCache: Record<string, Set<any>>;
298
+ tailwindConfig: Config;
299
+ userConfigPath: string | null;
300
+ variantMap: Map<string, [[object, (...args: any[]) => unknown]]>;
301
+ variantOptions: Map<string, object>;
302
+ }
303
+ interface ExtractResult {
304
+ classList: string[];
305
+ classSet: Set<string>;
306
+ filename?: string;
307
+ }
308
+ interface TailwindTokenLocation {
309
+ rawCandidate: string;
310
+ file: string;
311
+ relativeFile: string;
312
+ extension: string;
313
+ start: number;
314
+ end: number;
315
+ length: number;
316
+ line: number;
317
+ column: number;
318
+ lineText: string;
319
+ }
320
+ type TailwindTokenFileKey = 'relative' | 'absolute';
321
+ interface TailwindTokenReport {
322
+ entries: TailwindTokenLocation[];
323
+ filesScanned: number;
324
+ sources: SourceEntry[];
325
+ skippedFiles: {
326
+ file: string;
327
+ reason: string;
328
+ }[];
329
+ }
330
+ type TailwindTokenByFileMap = Record<string, TailwindTokenLocation[]>;
331
+ interface TailwindPatchRuntime {
332
+ options: NormalizedTailwindCssPatchOptions;
333
+ majorVersion: 2 | 3 | 4;
334
+ }
335
+
336
+ interface ILengthUnitsPatchOptions {
337
+ units: string[];
338
+ lengthUnitsFilePath?: string;
339
+ variableName?: string;
340
+ overwrite?: boolean;
341
+ destPath?: string;
342
+ }
343
+ type PatchCheckStatus = 'applied' | 'not-applied' | 'skipped' | 'unsupported';
344
+ type PatchName = 'exposeContext' | 'extendLengthUnits';
345
+ interface PatchStatusEntry {
346
+ name: PatchName;
347
+ status: PatchCheckStatus;
348
+ reason?: string;
349
+ files: string[];
350
+ }
351
+ interface PatchStatusReport {
352
+ package: {
353
+ name?: string;
354
+ version?: string;
355
+ root: string;
356
+ };
357
+ majorVersion: 2 | 3 | 4;
358
+ entries: PatchStatusEntry[];
359
+ }
360
+
361
+ interface ExposeContextPatchParams {
362
+ rootDir: string;
363
+ refProperty: string;
364
+ overwrite: boolean;
365
+ majorVersion: 2 | 3;
366
+ }
367
+ interface ExposeContextPatchResult {
368
+ applied: boolean;
369
+ files: Record<string, string>;
370
+ }
371
+ declare function applyExposeContextPatch(params: ExposeContextPatchParams): ExposeContextPatchResult;
372
+
373
+ declare function applyExtendLengthUnitsPatchV3(rootDir: string, options: NormalizedExtendLengthUnitsOptions): {
374
+ changed: boolean;
375
+ code: undefined;
376
+ } | {
377
+ changed: boolean;
378
+ code: string;
379
+ };
380
+ interface V4FilePatch {
381
+ file: string;
382
+ code: string;
383
+ hasPatched: boolean;
384
+ }
385
+ interface V4Candidate extends V4FilePatch {
386
+ match: RegExpExecArray;
387
+ }
388
+ declare function applyExtendLengthUnitsPatchV4(rootDir: string, options: NormalizedExtendLengthUnitsOptions): {
389
+ changed: boolean;
390
+ files: V4Candidate[];
391
+ };
392
+
393
+ interface PatchRunnerResult {
394
+ exposeContext?: ReturnType<typeof applyExposeContextPatch>;
395
+ extendLengthUnits?: ReturnType<typeof applyExtendLengthUnitsPatchV3> | ReturnType<typeof applyExtendLengthUnitsPatchV4>;
396
+ }
397
+
398
+ interface TailwindcssConfigModule {
399
+ CONFIG_NAME: string;
400
+ getConfig: (cwd?: string) => Promise<{
401
+ config?: {
402
+ registry?: unknown;
403
+ patch?: unknown;
404
+ };
405
+ }>;
406
+ initConfig: (cwd: string) => Promise<unknown>;
407
+ }
408
+ type TailwindcssConfigResult = Awaited<ReturnType<TailwindcssConfigModule['getConfig']>>;
409
+
410
+ interface ExtractValidCandidatesOption {
411
+ sources?: SourceEntry[];
412
+ base?: string;
413
+ baseFallbacks?: string[];
414
+ css?: string;
415
+ cwd?: string;
416
+ }
417
+ declare function extractRawCandidatesWithPositions(content: string, extension?: string): Promise<{
418
+ rawCandidate: string;
419
+ start: number;
420
+ end: number;
421
+ }[]>;
422
+ declare function extractRawCandidates(sources?: SourceEntry[]): Promise<string[]>;
423
+ declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
424
+ interface ExtractProjectCandidatesOptions {
425
+ cwd?: string;
426
+ sources?: SourceEntry[];
427
+ }
428
+ declare function extractProjectCandidatesWithPositions(options?: ExtractProjectCandidatesOptions): Promise<TailwindTokenReport>;
429
+ declare function groupTokensByFile(report: TailwindTokenReport, options?: {
430
+ key?: TailwindTokenFileKey;
431
+ stripAbsolutePaths?: boolean;
432
+ }): TailwindTokenByFileMap;
433
+
434
+ type TailwindMajorVersion = 2 | 3 | 4;
435
+
436
+ declare class TailwindcssPatcher {
437
+ readonly options: NormalizedTailwindCssPatchOptions;
438
+ readonly packageInfo: PackageInfo;
439
+ readonly majorVersion: TailwindMajorVersion;
440
+ private readonly cacheContext;
441
+ private readonly cacheStore;
442
+ private readonly collector;
443
+ private patchMemo;
444
+ constructor(options?: TailwindCssPatchOptions);
445
+ patch(): Promise<PatchRunnerResult>;
446
+ getPatchStatus(): Promise<PatchStatusReport>;
447
+ getContexts(): TailwindcssRuntimeContext[];
448
+ private createPatchSnapshot;
449
+ private collectClassSet;
450
+ private runTailwindBuildIfNeeded;
451
+ private debugCacheRead;
452
+ private mergeWithCache;
453
+ private mergeWithCacheSync;
454
+ private areSetsEqual;
455
+ getClassSet(): Promise<Set<string>>;
456
+ getClassSetSync(): Set<string> | undefined;
457
+ extract(options?: {
458
+ write?: boolean;
459
+ }): Promise<ExtractResult>;
460
+ clearCache(options?: CacheClearOptions): Promise<CacheClearResult>;
461
+ extractValidCandidates: typeof extractValidCandidates;
462
+ collectContentTokens(options?: {
463
+ cwd?: string;
464
+ sources?: SourceEntry[];
465
+ }): Promise<TailwindTokenReport>;
466
+ collectContentTokensByFile(options?: {
467
+ cwd?: string;
468
+ sources?: SourceEntry[];
469
+ key?: TailwindTokenFileKey;
470
+ stripAbsolutePaths?: boolean;
471
+ }): Promise<TailwindTokenByFileMap>;
472
+ }
473
+
474
+ declare const logger: consola.ConsolaInstance;
475
+
476
+ declare const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
477
+ declare const MIGRATION_REPORT_SCHEMA_VERSION = 1;
478
+
479
+ interface ConfigFileMigrationEntry {
480
+ file: string;
481
+ changed: boolean;
482
+ written: boolean;
483
+ rolledBack: boolean;
484
+ backupFile?: string;
485
+ changes: string[];
486
+ }
487
+ interface ConfigFileMigrationReport {
488
+ reportKind: typeof MIGRATION_REPORT_KIND;
489
+ schemaVersion: typeof MIGRATION_REPORT_SCHEMA_VERSION;
490
+ generatedAt: string;
491
+ tool: {
492
+ name: string;
493
+ version: string;
494
+ };
495
+ cwd: string;
496
+ dryRun: boolean;
497
+ rollbackOnError: boolean;
498
+ backupDirectory?: string;
499
+ scannedFiles: number;
500
+ changedFiles: number;
501
+ writtenFiles: number;
502
+ backupsWritten: number;
503
+ unchangedFiles: number;
504
+ missingFiles: number;
505
+ entries: ConfigFileMigrationEntry[];
506
+ }
507
+ interface MigrateConfigFilesOptions {
508
+ cwd: string;
509
+ files?: string[];
510
+ dryRun?: boolean;
511
+ workspace?: boolean;
512
+ maxDepth?: number;
513
+ rollbackOnError?: boolean;
514
+ backupDir?: string;
515
+ include?: string[];
516
+ exclude?: string[];
517
+ }
518
+ interface RestoreConfigFilesOptions {
519
+ cwd: string;
520
+ reportFile: string;
521
+ dryRun?: boolean;
522
+ strict?: boolean;
523
+ }
524
+ interface RestoreConfigFilesResult {
525
+ cwd: string;
526
+ reportFile: string;
527
+ reportKind?: string;
528
+ reportSchemaVersion?: number;
529
+ dryRun: boolean;
530
+ strict: boolean;
531
+ scannedEntries: number;
532
+ restorableEntries: number;
533
+ restoredFiles: number;
534
+ missingBackups: number;
535
+ skippedEntries: number;
536
+ restored: string[];
537
+ }
538
+
539
+ type TokenOutputFormat = 'json' | 'lines' | 'grouped-json';
540
+ type TokenGroupKey = 'relative' | 'absolute';
541
+
542
+ type TailwindcssPatchCommand = 'install' | 'extract' | 'tokens' | 'init' | 'migrate' | 'restore' | 'validate' | 'status';
543
+ declare const tailwindcssPatchCommands: TailwindcssPatchCommand[];
544
+ type CacOptionConfig = Parameters<Command['option']>[2];
545
+ interface TailwindcssPatchCommandOptionDefinition {
546
+ flags: string;
547
+ description?: string;
548
+ config?: CacOptionConfig;
549
+ }
550
+ interface TailwindcssPatchCommandOptions {
551
+ name?: string;
552
+ aliases?: string[];
553
+ description?: string;
554
+ optionDefs?: TailwindcssPatchCommandOptionDefinition[];
555
+ appendDefaultOptions?: boolean;
556
+ }
557
+ interface BaseCommandArgs {
558
+ cwd: string;
559
+ }
560
+ interface InstallCommandArgs extends BaseCommandArgs {
561
+ }
562
+ interface ExtractCommandArgs extends BaseCommandArgs {
563
+ output?: string;
564
+ format?: 'json' | 'lines';
565
+ css?: string;
566
+ write?: boolean;
567
+ }
568
+ interface TokensCommandArgs extends BaseCommandArgs {
569
+ output?: string;
570
+ format?: TokenOutputFormat;
571
+ groupKey?: TokenGroupKey;
572
+ write?: boolean;
573
+ }
574
+ interface InitCommandArgs extends BaseCommandArgs {
575
+ }
576
+ interface MigrateCommandArgs extends BaseCommandArgs {
577
+ config?: string;
578
+ dryRun?: boolean;
579
+ workspace?: boolean;
580
+ maxDepth?: string | number;
581
+ include?: string | string[];
582
+ exclude?: string | string[];
583
+ reportFile?: string;
584
+ backupDir?: string;
585
+ check?: boolean;
586
+ json?: boolean;
587
+ }
588
+ interface RestoreCommandArgs extends BaseCommandArgs {
589
+ reportFile?: string;
590
+ dryRun?: boolean;
591
+ strict?: boolean;
592
+ json?: boolean;
593
+ }
594
+ interface ValidateCommandArgs extends BaseCommandArgs {
595
+ reportFile?: string;
596
+ strict?: boolean;
597
+ json?: boolean;
598
+ }
599
+ interface StatusCommandArgs extends BaseCommandArgs {
600
+ json?: boolean;
601
+ }
602
+ interface TailwindcssPatchCommandArgMap {
603
+ install: InstallCommandArgs;
604
+ extract: ExtractCommandArgs;
605
+ tokens: TokensCommandArgs;
606
+ init: InitCommandArgs;
607
+ migrate: MigrateCommandArgs;
608
+ restore: RestoreCommandArgs;
609
+ validate: ValidateCommandArgs;
610
+ status: StatusCommandArgs;
611
+ }
612
+ interface TailwindcssPatchCommandResultMap {
613
+ install: void;
614
+ extract: ExtractResult;
615
+ tokens: TailwindTokenReport;
616
+ init: void;
617
+ migrate: ConfigFileMigrationReport;
618
+ restore: RestoreConfigFilesResult;
619
+ validate: RestoreConfigFilesResult;
620
+ status: PatchStatusReport;
621
+ }
622
+ interface TailwindcssPatchCommandContext<TCommand extends TailwindcssPatchCommand> {
623
+ cli: CAC;
624
+ command: Command;
625
+ commandName: TCommand;
626
+ args: TailwindcssPatchCommandArgMap[TCommand];
627
+ cwd: string;
628
+ logger: typeof logger;
629
+ loadConfig: () => Promise<TailwindcssConfigResult>;
630
+ loadPatchOptions: (overrides?: TailwindCssPatchOptions) => Promise<TailwindCssPatchOptions>;
631
+ createPatcher: (overrides?: TailwindCssPatchOptions) => Promise<TailwindcssPatcher>;
632
+ }
633
+ type TailwindcssPatchCommandHandler<TCommand extends TailwindcssPatchCommand> = (context: TailwindcssPatchCommandContext<TCommand>, next: () => Promise<TailwindcssPatchCommandResultMap[TCommand]>) => Promise<TailwindcssPatchCommandResultMap[TCommand]> | TailwindcssPatchCommandResultMap[TCommand];
634
+ type TailwindcssPatchCommandHandlerMap = Partial<{
635
+ [K in TailwindcssPatchCommand]: TailwindcssPatchCommandHandler<K>;
636
+ }>;
637
+ interface TailwindcssPatchCliMountOptions {
638
+ commandPrefix?: string;
639
+ commands?: TailwindcssPatchCommand[];
640
+ commandOptions?: Partial<Record<TailwindcssPatchCommand, TailwindcssPatchCommandOptions>>;
641
+ commandHandlers?: TailwindcssPatchCommandHandlerMap;
642
+ }
643
+ interface TailwindcssPatchCliOptions {
644
+ name?: string;
645
+ mountOptions?: TailwindcssPatchCliMountOptions;
646
+ }
647
+
648
+ declare const VALIDATE_EXIT_CODES: {
649
+ readonly OK: 0;
650
+ readonly REPORT_INCOMPATIBLE: 21;
651
+ readonly MISSING_BACKUPS: 22;
652
+ readonly IO_ERROR: 23;
653
+ readonly UNKNOWN_ERROR: 24;
654
+ };
655
+ declare const VALIDATE_FAILURE_REASONS: readonly ["report-incompatible", "missing-backups", "io-error", "unknown-error"];
656
+ type ValidateFailureReason = (typeof VALIDATE_FAILURE_REASONS)[number];
657
+ interface ValidateFailureSummary {
658
+ reason: ValidateFailureReason;
659
+ exitCode: number;
660
+ message: string;
661
+ }
662
+ interface ValidateJsonSuccessPayload extends RestoreConfigFilesResult {
663
+ ok: true;
664
+ }
665
+ interface ValidateJsonFailurePayload {
666
+ ok: false;
667
+ reason: ValidateFailureReason;
668
+ exitCode: number;
669
+ message: string;
670
+ }
671
+ declare class ValidateCommandError extends Error {
672
+ reason: ValidateFailureReason;
673
+ exitCode: number;
674
+ constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
675
+ }
676
+
677
+ export { type TailwindV2Options as $, type ApplyOptions as A, type CacheOptions as B, type CacheContextDescriptor as C, type CacheStrategy as D, type ConfigFileMigrationEntry as E, type ExposeContextOptions as F, type ExtendLengthUnitsOptions as G, type ExtractOptions as H, type ExtractResult as I, type ILengthUnitsPatchOptions as J, MIGRATION_REPORT_KIND as K, MIGRATION_REPORT_SCHEMA_VERSION as L, type MigrateConfigFilesOptions as M, type NormalizedTailwindCssPatchOptions as N, type PatchCheckStatus as O, type PatchStatusReport as P, type PatchName as Q, type RestoreConfigFilesOptions as R, type PatchStatusEntry as S, type TailwindcssPatchCliOptions as T, type TailwindCssOptions as U, VALIDATE_EXIT_CODES as V, type TailwindPatchRuntime as W, type TailwindTokenByFileMap as X, type TailwindTokenFileKey as Y, type TailwindTokenLocation as Z, type TailwindTokenReport as _, type TailwindcssPatchCliMountOptions as a, type TailwindV3Options as a0, type TailwindV4Options as a1, type TailwindcssClassCache as a2, TailwindcssPatcher as a3, extractProjectCandidatesWithPositions as a4, extractRawCandidates as a5, extractRawCandidatesWithPositions as a6, extractValidCandidates as a7, groupTokensByFile as a8, logger as a9, type TailwindcssPatchCommand as b, type TailwindcssPatchCommandContext as c, type TailwindcssPatchCommandHandler as d, type TailwindcssPatchCommandHandlerMap as e, type TailwindcssPatchCommandOptionDefinition as f, type TailwindcssPatchCommandOptions as g, VALIDATE_FAILURE_REASONS as h, ValidateCommandError as i, type ValidateFailureReason as j, type ValidateFailureSummary as k, type ValidateJsonFailurePayload as l, type ValidateJsonSuccessPayload as m, type TailwindCssPatchOptions as n, type NormalizedCacheOptions as o, type CacheReadResult as p, type CacheReadMeta as q, type CacheClearOptions as r, type CacheClearResult as s, tailwindcssPatchCommands as t, type CacheIndexFileV2 as u, type ConfigFileMigrationReport as v, type RestoreConfigFilesResult as w, type TailwindcssRuntimeContext as x, type CacheClearScope as y, type CacheContextMetadata as z };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "9.0.0-alpha.2",
3
+ "version": "9.0.0-alpha.4",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
7
+ "engines": {
8
+ "node": ">=18.0.0"
9
+ },
7
10
  "homepage": "https://mangle.icebreaker.top/",
8
11
  "repository": {
9
12
  "type": "git",
@@ -63,7 +66,7 @@
63
66
  "@babel/traverse": "^7.29.0",
64
67
  "@babel/types": "^7.29.0",
65
68
  "@tailwindcss/node": "^4.2.1",
66
- "cac": "^7.0.0",
69
+ "cac": "6.7.14",
67
70
  "consola": "^3.4.2",
68
71
  "fs-extra": "^11.3.4",
69
72
  "local-pkg": "^1.1.2",