tailwindcss-patch 9.4.2 → 9.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/{cli-DsXcyl2O.js → cli-BztQHMRp.js} +5 -6
- package/dist/{cli-D5D3Yj69.mjs → cli-D0jXMGXf.mjs} +1 -1
- package/dist/cli.js +3 -4
- package/dist/cli.mjs +2 -2
- package/dist/commands/cli-runtime.d.mts +1 -1
- package/dist/commands/cli-runtime.d.ts +1 -1
- package/dist/commands/cli-runtime.js +2 -2
- package/dist/commands/cli-runtime.mjs +2 -2
- package/dist/{dist-B1VBpHtd.js → dist-DDcbvOwe.js} +2 -2
- package/dist/index.d.mts +100 -2
- package/dist/index.d.ts +100 -2
- package/dist/index.js +259 -4
- package/dist/index.mjs +250 -2
- package/dist/{validate-CInDiiYy.mjs → validate-Bug_WYcU.mjs} +3 -3
- package/dist/{validate-CYB-90BG.d.ts → validate-BuqRodYI.d.ts} +58 -26
- package/dist/{validate-5eUbRAzl.js → validate-DbuKewV-.js} +38 -11
- package/dist/{validate-D6MO6lZo.d.mts → validate-oAkURzUC.d.mts} +58 -25
- package/package.json +9 -9
- package/src/public-api.ts +36 -2
- package/src/style-candidates.ts +35 -0
- package/src/style-generator.ts +80 -0
- package/src/v3/index.ts +11 -0
- package/src/v3/style-generator.ts +384 -0
- package/src/v4/index.ts +13 -6
- package/src/v4/style-generator.ts +44 -0
- package/src/v4/types.ts +23 -0
- package/dist/chunk-8l464Juk.js +0 -28
- /package/dist/{dist-BjUV1yEM.mjs → dist-CxmNpfyy.mjs} +0 -0
|
@@ -3,8 +3,6 @@ import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
|
3
3
|
import { SourceEntry } from "@tailwindcss/oxide";
|
|
4
4
|
import { Node, Rule } from "postcss";
|
|
5
5
|
import { Config } from "tailwindcss";
|
|
6
|
-
import * as _$consola from "consola";
|
|
7
|
-
|
|
8
6
|
//#region src/cache/types.d.ts
|
|
9
7
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
10
8
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -159,6 +157,44 @@ interface PatchStatusReport {
|
|
|
159
157
|
entries: PatchStatusEntry[];
|
|
160
158
|
}
|
|
161
159
|
//#endregion
|
|
160
|
+
//#region src/v4/bare-arbitrary-values.d.ts
|
|
161
|
+
interface BareArbitraryValueOptions {
|
|
162
|
+
/**
|
|
163
|
+
* 允许作为无方括号任意值的单位列表。
|
|
164
|
+
*/
|
|
165
|
+
units?: string[];
|
|
166
|
+
}
|
|
167
|
+
interface BareArbitraryValueResolveResult {
|
|
168
|
+
candidate: string;
|
|
169
|
+
canonicalCandidate: string;
|
|
170
|
+
}
|
|
171
|
+
interface BareArbitraryValueSourceCandidate {
|
|
172
|
+
rawCandidate: string;
|
|
173
|
+
start: number;
|
|
174
|
+
end: number;
|
|
175
|
+
}
|
|
176
|
+
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
177
|
+
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
178
|
+
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
179
|
+
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
180
|
+
declare function escapeCssClassName(value: string): string;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/style-candidates.d.ts
|
|
183
|
+
interface TailwindStyleSource {
|
|
184
|
+
content: string;
|
|
185
|
+
extension?: string;
|
|
186
|
+
file?: string;
|
|
187
|
+
}
|
|
188
|
+
interface TailwindStyleCandidateOptions {
|
|
189
|
+
candidates?: Iterable<string>;
|
|
190
|
+
sources?: TailwindStyleSource[];
|
|
191
|
+
/**
|
|
192
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
193
|
+
*/
|
|
194
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
195
|
+
}
|
|
196
|
+
declare function collectTailwindStyleCandidates(options?: TailwindStyleCandidateOptions): Promise<Set<string>>;
|
|
197
|
+
//#endregion
|
|
162
198
|
//#region src/v4/types.d.ts
|
|
163
199
|
interface TailwindV4SourceOptions {
|
|
164
200
|
projectRoot?: string;
|
|
@@ -187,6 +223,7 @@ interface TailwindV4CandidateSource {
|
|
|
187
223
|
content: string;
|
|
188
224
|
extension?: string;
|
|
189
225
|
}
|
|
226
|
+
interface TailwindV4StyleSource extends TailwindStyleSource {}
|
|
190
227
|
interface TailwindV4GenerateOptions {
|
|
191
228
|
candidates?: Iterable<string>;
|
|
192
229
|
sources?: TailwindV4CandidateSource[];
|
|
@@ -221,6 +258,23 @@ interface TailwindV4GenerateResult {
|
|
|
221
258
|
sources: TailwindV4SourcePattern[];
|
|
222
259
|
root: TailwindV4CompiledSourceRoot;
|
|
223
260
|
}
|
|
261
|
+
interface TailwindV4StyleGenerateOptions extends TailwindV4SourceOptions {
|
|
262
|
+
source?: TailwindV4ResolvedSource;
|
|
263
|
+
candidates?: Iterable<string>;
|
|
264
|
+
sources?: TailwindV4StyleSource[];
|
|
265
|
+
/**
|
|
266
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
267
|
+
*/
|
|
268
|
+
bareArbitraryValues?: TailwindV4GenerateOptions['bareArbitraryValues'];
|
|
269
|
+
/**
|
|
270
|
+
* Scans the compiled Tailwind CSS v4 source entries in addition to in-memory sources.
|
|
271
|
+
*/
|
|
272
|
+
scanSources?: TailwindV4GenerateOptions['scanSources'];
|
|
273
|
+
}
|
|
274
|
+
interface TailwindV4StyleGenerateResult extends TailwindV4GenerateResult {
|
|
275
|
+
tokens: Set<string>;
|
|
276
|
+
source: TailwindV4ResolvedSource;
|
|
277
|
+
}
|
|
224
278
|
interface TailwindV4DesignSystem {
|
|
225
279
|
parseCandidate: (candidate: string) => unknown[];
|
|
226
280
|
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
@@ -497,28 +551,6 @@ type TailwindcssConfigResult = Awaited<ReturnType<TailwindcssConfigModule['getCo
|
|
|
497
551
|
//#region src/runtime/collector.d.ts
|
|
498
552
|
type TailwindMajorVersion = 2 | 3 | 4;
|
|
499
553
|
//#endregion
|
|
500
|
-
//#region src/v4/bare-arbitrary-values.d.ts
|
|
501
|
-
interface BareArbitraryValueOptions {
|
|
502
|
-
/**
|
|
503
|
-
* 允许作为无方括号任意值的单位列表。
|
|
504
|
-
*/
|
|
505
|
-
units?: string[];
|
|
506
|
-
}
|
|
507
|
-
interface BareArbitraryValueResolveResult {
|
|
508
|
-
candidate: string;
|
|
509
|
-
canonicalCandidate: string;
|
|
510
|
-
}
|
|
511
|
-
interface BareArbitraryValueSourceCandidate {
|
|
512
|
-
rawCandidate: string;
|
|
513
|
-
start: number;
|
|
514
|
-
end: number;
|
|
515
|
-
}
|
|
516
|
-
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
517
|
-
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
518
|
-
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
519
|
-
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
520
|
-
declare function escapeCssClassName(value: string): string;
|
|
521
|
-
//#endregion
|
|
522
554
|
//#region src/extraction/candidate-extractor.d.ts
|
|
523
555
|
interface ExtractValidCandidatesOption {
|
|
524
556
|
sources?: SourceEntry[];
|
|
@@ -604,7 +636,7 @@ declare class TailwindcssPatcher {
|
|
|
604
636
|
}
|
|
605
637
|
//#endregion
|
|
606
638
|
//#region src/logger.d.ts
|
|
607
|
-
declare const logger:
|
|
639
|
+
declare const logger: import("consola").ConsolaInstance;
|
|
608
640
|
//#endregion
|
|
609
641
|
//#region src/commands/migration-report.d.ts
|
|
610
642
|
declare const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
@@ -808,4 +840,4 @@ declare class ValidateCommandError extends Error {
|
|
|
808
840
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
809
841
|
}
|
|
810
842
|
//#endregion
|
|
811
|
-
export {
|
|
843
|
+
export { TailwindV4Engine as $, extractSourceCandidates as A, CacheClearOptions as At, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, TailwindPatchRuntime as Ct, extractProjectCandidatesWithPositions as D, TailwindTokenReport as Dt, ExtractSourceCandidate as E, TailwindTokenLocation as Et, normalizeOptions as F, CacheIndexFileV2 as Ft, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, CacheReadMeta as It, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, CacheReadResult as Lt, extractValidCandidates as M, CacheClearScope as Mt, groupTokensByFile as N, CacheContextDescriptor as Nt, extractRawCandidates as O, TailwindcssClassCache as Ot, resolveProjectSourceFiles as P, CacheContextMetadata as Pt, TailwindV4DesignSystem as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, PatchStatusReport as St, TailwindcssPatcher as T, TailwindTokenFileKey as Tt, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, TailwindV4CompiledSourceRoot as X, TailwindV4CandidateSource as Y, TailwindV4CssSource as Z, ConfigFileMigrationEntry as _, ExtractResult as _t, ValidateFailureSummary as a, TailwindV4StyleGenerateOptions as at, RestoreConfigFilesOptions as b, PatchName as bt, TailwindcssPatchCliMountOptions as c, TailwindStyleCandidateOptions as ct, TailwindcssPatchCommandContext as d, BareArbitraryValueOptions as dt, TailwindV4GenerateOptions as et, TailwindcssPatchCommandHandler as f, escapeCssClassName as ft, tailwindcssPatchCommands as g, resolveBareArbitraryValueCandidate as gt, TailwindcssPatchCommandOptions as h, isBareArbitraryValuesEnabled as ht, ValidateFailureReason as i, TailwindV4SourcePattern as it, extractSourceCandidatesWithPositions as j, CacheClearResult as jt, extractRawCandidatesWithPositions as k, TailwindcssRuntimeContext as kt, TailwindcssPatchCliOptions as l, TailwindStyleSource as lt, TailwindcssPatchCommandOptionDefinition as m, extractBareArbitraryValueSourceCandidatesWithPositions as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4ResolvedSource as nt, ValidateJsonFailurePayload as o, TailwindV4StyleGenerateResult as ot, TailwindcssPatchCommandHandlerMap as p, extractBareArbitraryValueSourceCandidates as pt, TailwindV3Options as q, ValidateCommandError as r, TailwindV4SourceOptions as rt, ValidateJsonSuccessPayload as s, TailwindV4StyleSource as st, VALIDATE_EXIT_CODES as t, TailwindV4GenerateResult as tt, TailwindcssPatchCommand as u, collectTailwindStyleCandidates as ut, ConfigFileMigrationReport as v, ILengthUnitsPatchOptions as vt, logger as w, TailwindTokenByFileMap as wt, RestoreConfigFilesResult as x, PatchStatusEntry as xt, MigrateConfigFilesOptions as y, PatchCheckStatus as yt, ExposeContextOptions as z };
|
|
@@ -1,32 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
2
23
|
let node_module = require("node:module");
|
|
3
24
|
let node_process = require("node:process");
|
|
4
|
-
node_process =
|
|
25
|
+
node_process = __toESM(node_process);
|
|
5
26
|
let fs_extra = require("fs-extra");
|
|
6
|
-
fs_extra =
|
|
27
|
+
fs_extra = __toESM(fs_extra);
|
|
7
28
|
let local_pkg = require("local-pkg");
|
|
8
29
|
let pathe = require("pathe");
|
|
9
|
-
pathe =
|
|
30
|
+
pathe = __toESM(pathe);
|
|
10
31
|
let semver = require("semver");
|
|
11
32
|
let node_crypto = require("node:crypto");
|
|
12
33
|
let consola = require("consola");
|
|
13
34
|
let node_url = require("node:url");
|
|
14
35
|
let node_fs = require("node:fs");
|
|
15
36
|
let postcss = require("postcss");
|
|
16
|
-
postcss =
|
|
37
|
+
postcss = __toESM(postcss);
|
|
17
38
|
let node_fs_promises = require("node:fs/promises");
|
|
18
39
|
let micromatch = require("micromatch");
|
|
19
|
-
micromatch =
|
|
40
|
+
micromatch = __toESM(micromatch);
|
|
20
41
|
let _babel_types = require("@babel/types");
|
|
21
|
-
_babel_types =
|
|
42
|
+
_babel_types = __toESM(_babel_types);
|
|
22
43
|
let _babel_generator = require("@babel/generator");
|
|
23
|
-
_babel_generator =
|
|
44
|
+
_babel_generator = __toESM(_babel_generator);
|
|
24
45
|
let _babel_traverse = require("@babel/traverse");
|
|
25
|
-
_babel_traverse =
|
|
46
|
+
_babel_traverse = __toESM(_babel_traverse);
|
|
26
47
|
let _babel_parser = require("@babel/parser");
|
|
27
48
|
let tailwindcss_config = require("tailwindcss-config");
|
|
28
49
|
//#region package.json
|
|
29
|
-
var version = "9.4.
|
|
50
|
+
var version = "9.4.3";
|
|
30
51
|
//#endregion
|
|
31
52
|
//#region src/constants.ts
|
|
32
53
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1447,7 +1468,7 @@ async function loadWorkspaceConfigModule() {
|
|
|
1447
1468
|
return configModulePromise;
|
|
1448
1469
|
}
|
|
1449
1470
|
async function loadWorkspaceDefu() {
|
|
1450
|
-
if (!defuPromise) defuPromise = Promise.resolve().then(() => require("./dist-
|
|
1471
|
+
if (!defuPromise) defuPromise = Promise.resolve().then(() => require("./dist-DDcbvOwe.js")).then((mod) => mod.defu).catch(async (error) => {
|
|
1451
1472
|
if (!isMissingSharedModuleError(error)) throw error;
|
|
1452
1473
|
return (await import((0, node_url.pathToFileURL)(pathe.default.resolve(__dirname, "../../../shared/src/utils.ts")).href)).defu;
|
|
1453
1474
|
});
|
|
@@ -4597,6 +4618,12 @@ Object.defineProperty(exports, "ValidateCommandError", {
|
|
|
4597
4618
|
return ValidateCommandError;
|
|
4598
4619
|
}
|
|
4599
4620
|
});
|
|
4621
|
+
Object.defineProperty(exports, "__toESM", {
|
|
4622
|
+
enumerable: true,
|
|
4623
|
+
get: function() {
|
|
4624
|
+
return __toESM;
|
|
4625
|
+
}
|
|
4626
|
+
});
|
|
4600
4627
|
Object.defineProperty(exports, "canonicalizeBareArbitraryValueCandidates", {
|
|
4601
4628
|
enumerable: true,
|
|
4602
4629
|
get: function() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
2
|
-
import * as _$consola from "consola";
|
|
3
2
|
import { Node, Rule } from "postcss";
|
|
4
3
|
import { CAC, Command } from "cac";
|
|
5
4
|
import { SourceEntry } from "@tailwindcss/oxide";
|
|
@@ -158,6 +157,44 @@ interface PatchStatusReport {
|
|
|
158
157
|
entries: PatchStatusEntry[];
|
|
159
158
|
}
|
|
160
159
|
//#endregion
|
|
160
|
+
//#region src/v4/bare-arbitrary-values.d.ts
|
|
161
|
+
interface BareArbitraryValueOptions {
|
|
162
|
+
/**
|
|
163
|
+
* 允许作为无方括号任意值的单位列表。
|
|
164
|
+
*/
|
|
165
|
+
units?: string[];
|
|
166
|
+
}
|
|
167
|
+
interface BareArbitraryValueResolveResult {
|
|
168
|
+
candidate: string;
|
|
169
|
+
canonicalCandidate: string;
|
|
170
|
+
}
|
|
171
|
+
interface BareArbitraryValueSourceCandidate {
|
|
172
|
+
rawCandidate: string;
|
|
173
|
+
start: number;
|
|
174
|
+
end: number;
|
|
175
|
+
}
|
|
176
|
+
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
177
|
+
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
178
|
+
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
179
|
+
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
180
|
+
declare function escapeCssClassName(value: string): string;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/style-candidates.d.ts
|
|
183
|
+
interface TailwindStyleSource {
|
|
184
|
+
content: string;
|
|
185
|
+
extension?: string;
|
|
186
|
+
file?: string;
|
|
187
|
+
}
|
|
188
|
+
interface TailwindStyleCandidateOptions {
|
|
189
|
+
candidates?: Iterable<string>;
|
|
190
|
+
sources?: TailwindStyleSource[];
|
|
191
|
+
/**
|
|
192
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
193
|
+
*/
|
|
194
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
195
|
+
}
|
|
196
|
+
declare function collectTailwindStyleCandidates(options?: TailwindStyleCandidateOptions): Promise<Set<string>>;
|
|
197
|
+
//#endregion
|
|
161
198
|
//#region src/v4/types.d.ts
|
|
162
199
|
interface TailwindV4SourceOptions {
|
|
163
200
|
projectRoot?: string;
|
|
@@ -186,6 +223,7 @@ interface TailwindV4CandidateSource {
|
|
|
186
223
|
content: string;
|
|
187
224
|
extension?: string;
|
|
188
225
|
}
|
|
226
|
+
interface TailwindV4StyleSource extends TailwindStyleSource {}
|
|
189
227
|
interface TailwindV4GenerateOptions {
|
|
190
228
|
candidates?: Iterable<string>;
|
|
191
229
|
sources?: TailwindV4CandidateSource[];
|
|
@@ -220,6 +258,23 @@ interface TailwindV4GenerateResult {
|
|
|
220
258
|
sources: TailwindV4SourcePattern[];
|
|
221
259
|
root: TailwindV4CompiledSourceRoot;
|
|
222
260
|
}
|
|
261
|
+
interface TailwindV4StyleGenerateOptions extends TailwindV4SourceOptions {
|
|
262
|
+
source?: TailwindV4ResolvedSource;
|
|
263
|
+
candidates?: Iterable<string>;
|
|
264
|
+
sources?: TailwindV4StyleSource[];
|
|
265
|
+
/**
|
|
266
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
267
|
+
*/
|
|
268
|
+
bareArbitraryValues?: TailwindV4GenerateOptions['bareArbitraryValues'];
|
|
269
|
+
/**
|
|
270
|
+
* Scans the compiled Tailwind CSS v4 source entries in addition to in-memory sources.
|
|
271
|
+
*/
|
|
272
|
+
scanSources?: TailwindV4GenerateOptions['scanSources'];
|
|
273
|
+
}
|
|
274
|
+
interface TailwindV4StyleGenerateResult extends TailwindV4GenerateResult {
|
|
275
|
+
tokens: Set<string>;
|
|
276
|
+
source: TailwindV4ResolvedSource;
|
|
277
|
+
}
|
|
223
278
|
interface TailwindV4DesignSystem {
|
|
224
279
|
parseCandidate: (candidate: string) => unknown[];
|
|
225
280
|
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
@@ -496,28 +551,6 @@ type TailwindcssConfigResult = Awaited<ReturnType<TailwindcssConfigModule['getCo
|
|
|
496
551
|
//#region src/runtime/collector.d.ts
|
|
497
552
|
type TailwindMajorVersion = 2 | 3 | 4;
|
|
498
553
|
//#endregion
|
|
499
|
-
//#region src/v4/bare-arbitrary-values.d.ts
|
|
500
|
-
interface BareArbitraryValueOptions {
|
|
501
|
-
/**
|
|
502
|
-
* 允许作为无方括号任意值的单位列表。
|
|
503
|
-
*/
|
|
504
|
-
units?: string[];
|
|
505
|
-
}
|
|
506
|
-
interface BareArbitraryValueResolveResult {
|
|
507
|
-
candidate: string;
|
|
508
|
-
canonicalCandidate: string;
|
|
509
|
-
}
|
|
510
|
-
interface BareArbitraryValueSourceCandidate {
|
|
511
|
-
rawCandidate: string;
|
|
512
|
-
start: number;
|
|
513
|
-
end: number;
|
|
514
|
-
}
|
|
515
|
-
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
516
|
-
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
517
|
-
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
518
|
-
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
519
|
-
declare function escapeCssClassName(value: string): string;
|
|
520
|
-
//#endregion
|
|
521
554
|
//#region src/extraction/candidate-extractor.d.ts
|
|
522
555
|
interface ExtractValidCandidatesOption {
|
|
523
556
|
sources?: SourceEntry[];
|
|
@@ -603,7 +636,7 @@ declare class TailwindcssPatcher {
|
|
|
603
636
|
}
|
|
604
637
|
//#endregion
|
|
605
638
|
//#region src/logger.d.ts
|
|
606
|
-
declare const logger:
|
|
639
|
+
declare const logger: import("consola").ConsolaInstance;
|
|
607
640
|
//#endregion
|
|
608
641
|
//#region src/commands/migration-report.d.ts
|
|
609
642
|
declare const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
@@ -807,4 +840,4 @@ declare class ValidateCommandError extends Error {
|
|
|
807
840
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
808
841
|
}
|
|
809
842
|
//#endregion
|
|
810
|
-
export {
|
|
843
|
+
export { TailwindV4Engine as $, extractSourceCandidates as A, CacheClearOptions as At, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, TailwindPatchRuntime as Ct, extractProjectCandidatesWithPositions as D, TailwindTokenReport as Dt, ExtractSourceCandidate as E, TailwindTokenLocation as Et, normalizeOptions as F, CacheIndexFileV2 as Ft, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, CacheReadMeta as It, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, CacheReadResult as Lt, extractValidCandidates as M, CacheClearScope as Mt, groupTokensByFile as N, CacheContextDescriptor as Nt, extractRawCandidates as O, TailwindcssClassCache as Ot, resolveProjectSourceFiles as P, CacheContextMetadata as Pt, TailwindV4DesignSystem as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, PatchStatusReport as St, TailwindcssPatcher as T, TailwindTokenFileKey as Tt, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, TailwindV4CompiledSourceRoot as X, TailwindV4CandidateSource as Y, TailwindV4CssSource as Z, ConfigFileMigrationEntry as _, ExtractResult as _t, ValidateFailureSummary as a, TailwindV4StyleGenerateOptions as at, RestoreConfigFilesOptions as b, PatchName as bt, TailwindcssPatchCliMountOptions as c, TailwindStyleCandidateOptions as ct, TailwindcssPatchCommandContext as d, BareArbitraryValueOptions as dt, TailwindV4GenerateOptions as et, TailwindcssPatchCommandHandler as f, escapeCssClassName as ft, tailwindcssPatchCommands as g, resolveBareArbitraryValueCandidate as gt, TailwindcssPatchCommandOptions as h, isBareArbitraryValuesEnabled as ht, ValidateFailureReason as i, TailwindV4SourcePattern as it, extractSourceCandidatesWithPositions as j, CacheClearResult as jt, extractRawCandidatesWithPositions as k, TailwindcssRuntimeContext as kt, TailwindcssPatchCliOptions as l, TailwindStyleSource as lt, TailwindcssPatchCommandOptionDefinition as m, extractBareArbitraryValueSourceCandidatesWithPositions as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4ResolvedSource as nt, ValidateJsonFailurePayload as o, TailwindV4StyleGenerateResult as ot, TailwindcssPatchCommandHandlerMap as p, extractBareArbitraryValueSourceCandidates as pt, TailwindV3Options as q, ValidateCommandError as r, TailwindV4SourceOptions as rt, ValidateJsonSuccessPayload as s, TailwindV4StyleSource as st, VALIDATE_EXIT_CODES as t, TailwindV4GenerateResult as tt, TailwindcssPatchCommand as u, collectTailwindStyleCandidates as ut, ConfigFileMigrationReport as v, ILengthUnitsPatchOptions as vt, logger as w, TailwindTokenByFileMap as wt, RestoreConfigFilesResult as x, PatchStatusEntry as xt, MigrateConfigFilesOptions as y, PatchCheckStatus as yt, ExposeContextOptions as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-patch",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.3",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@babel/generator": "^7.29.
|
|
65
|
-
"@babel/parser": "^7.29.
|
|
66
|
-
"@babel/traverse": "^7.29.
|
|
67
|
-
"@babel/types": "^7.29.
|
|
64
|
+
"@babel/generator": "^7.29.7",
|
|
65
|
+
"@babel/parser": "^7.29.7",
|
|
66
|
+
"@babel/traverse": "^7.29.7",
|
|
67
|
+
"@babel/types": "^7.29.7",
|
|
68
68
|
"@tailwindcss/node": "^4.3.0",
|
|
69
69
|
"@tailwindcss/oxide": "^4.3.0",
|
|
70
70
|
"cac": "6.7.14",
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
"micromatch": "^4.0.8",
|
|
75
75
|
"pathe": "^2.0.3",
|
|
76
76
|
"postcss": "^8.5.15",
|
|
77
|
-
"semver": "^7.8.
|
|
78
|
-
"tailwindcss-config": "^
|
|
77
|
+
"semver": "^7.8.4",
|
|
78
|
+
"tailwindcss-config": "^2.0.0",
|
|
79
79
|
"@tailwindcss-mangle/config": "7.0.2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@tailwindcss/postcss": "^4.3.0",
|
|
83
83
|
"@tailwindcss/vite": "^4.3.0",
|
|
84
|
-
"tailwindcss": "^4.
|
|
84
|
+
"tailwindcss": "^4.3.0",
|
|
85
85
|
"tailwindcss-3": "npm:tailwindcss@^3.4.19",
|
|
86
|
-
"tailwindcss-4": "npm:tailwindcss@^4.
|
|
86
|
+
"tailwindcss-4": "npm:tailwindcss@^4.3.0"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"dev": "tsdown --watch --sourcemap",
|
package/src/public-api.ts
CHANGED
|
@@ -59,9 +59,39 @@ export {
|
|
|
59
59
|
runTailwindBuild,
|
|
60
60
|
} from './install'
|
|
61
61
|
export { default as logger } from './logger'
|
|
62
|
+
export {
|
|
63
|
+
collectTailwindStyleCandidates,
|
|
64
|
+
} from './style-candidates'
|
|
65
|
+
export type {
|
|
66
|
+
TailwindStyleCandidateOptions,
|
|
67
|
+
TailwindStyleSource,
|
|
68
|
+
} from './style-candidates'
|
|
69
|
+
export {
|
|
70
|
+
generateCustomStyle,
|
|
71
|
+
generateTailwindStyle,
|
|
72
|
+
} from './style-generator'
|
|
73
|
+
export type {
|
|
74
|
+
CustomTailwindStyleGenerateContext,
|
|
75
|
+
CustomTailwindStyleGenerateOptions,
|
|
76
|
+
CustomTailwindStyleGenerateResult,
|
|
77
|
+
TailwindStyleGenerateOptions,
|
|
78
|
+
TailwindStyleGenerateResult,
|
|
79
|
+
} from './style-generator'
|
|
62
80
|
export * from './types'
|
|
81
|
+
export {
|
|
82
|
+
generateTailwindV3RawStyle,
|
|
83
|
+
generateTailwindV3Style,
|
|
84
|
+
} from './v3'
|
|
85
|
+
export type {
|
|
86
|
+
TailwindV3RawStyleGenerateOptions,
|
|
87
|
+
TailwindV3RawStyleGenerateResult,
|
|
88
|
+
TailwindV3StyleGenerateOptions,
|
|
89
|
+
TailwindV3StyleGenerateResult,
|
|
90
|
+
TailwindV3StyleLayer,
|
|
91
|
+
} from './v3'
|
|
63
92
|
export {
|
|
64
93
|
canonicalizeBareArbitraryValueCandidates,
|
|
94
|
+
collectTailwindV4StyleCandidates,
|
|
65
95
|
createTailwindV4CompiledSourceEntries,
|
|
66
96
|
createTailwindV4DefaultIgnoreSources,
|
|
67
97
|
createTailwindV4Engine,
|
|
@@ -73,16 +103,17 @@ export {
|
|
|
73
103
|
expandTailwindV4SourceEntryBraces,
|
|
74
104
|
extractBareArbitraryValueSourceCandidates,
|
|
75
105
|
extractBareArbitraryValueSourceCandidatesWithPositions,
|
|
106
|
+
generateTailwindV4Style,
|
|
107
|
+
isBareArbitraryValuesEnabled,
|
|
76
108
|
isFileExcludedByTailwindV4SourceEntries,
|
|
77
109
|
isFileMatchedByTailwindV4SourceEntries,
|
|
78
|
-
isBareArbitraryValuesEnabled,
|
|
79
110
|
loadTailwindV4DesignSystem,
|
|
80
111
|
mergeTailwindV4SourceEntries,
|
|
81
112
|
normalizeTailwindV4ScannerSources,
|
|
82
113
|
normalizeTailwindV4SourceEntries,
|
|
83
|
-
resolveSourceScanPath,
|
|
84
114
|
replaceBareArbitraryValueSelectors,
|
|
85
115
|
resolveBareArbitraryValueCandidate,
|
|
116
|
+
resolveSourceScanPath,
|
|
86
117
|
resolveTailwindV4Source,
|
|
87
118
|
resolveTailwindV4SourceBaseCandidates,
|
|
88
119
|
resolveTailwindV4SourceEntry,
|
|
@@ -104,6 +135,9 @@ export type {
|
|
|
104
135
|
TailwindV4ResolvedSource,
|
|
105
136
|
TailwindV4SourceOptions,
|
|
106
137
|
TailwindV4SourcePattern,
|
|
138
|
+
TailwindV4StyleGenerateOptions,
|
|
139
|
+
TailwindV4StyleGenerateResult,
|
|
140
|
+
TailwindV4StyleSource,
|
|
107
141
|
} from './v4'
|
|
108
142
|
|
|
109
143
|
export function defineConfig<T extends TailwindcssMangleConfig>(config: T): T {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BareArbitraryValueOptions } from './v4/bare-arbitrary-values'
|
|
2
|
+
import { extractSourceCandidates } from './extraction/candidate-extractor'
|
|
3
|
+
|
|
4
|
+
export interface TailwindStyleSource {
|
|
5
|
+
content: string
|
|
6
|
+
extension?: string
|
|
7
|
+
file?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TailwindStyleCandidateOptions {
|
|
11
|
+
candidates?: Iterable<string>
|
|
12
|
+
sources?: TailwindStyleSource[]
|
|
13
|
+
/**
|
|
14
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
15
|
+
*/
|
|
16
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function collectTailwindStyleCandidates(
|
|
20
|
+
options: TailwindStyleCandidateOptions = {},
|
|
21
|
+
): Promise<Set<string>> {
|
|
22
|
+
const candidates = new Set<string>()
|
|
23
|
+
for (const candidate of options.candidates ?? []) {
|
|
24
|
+
candidates.add(candidate)
|
|
25
|
+
}
|
|
26
|
+
for (const source of options.sources ?? []) {
|
|
27
|
+
const sourceCandidates = await extractSourceCandidates(source.content, source.extension, {
|
|
28
|
+
bareArbitraryValues: options.bareArbitraryValues,
|
|
29
|
+
})
|
|
30
|
+
for (const candidate of sourceCandidates) {
|
|
31
|
+
candidates.add(candidate)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return candidates
|
|
35
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TailwindStyleCandidateOptions,
|
|
3
|
+
TailwindStyleSource,
|
|
4
|
+
} from './style-candidates'
|
|
5
|
+
import type {
|
|
6
|
+
TailwindV3StyleGenerateOptions,
|
|
7
|
+
TailwindV3StyleGenerateResult,
|
|
8
|
+
} from './v3'
|
|
9
|
+
import type {
|
|
10
|
+
TailwindV4StyleGenerateOptions,
|
|
11
|
+
TailwindV4StyleGenerateResult,
|
|
12
|
+
} from './v4'
|
|
13
|
+
import { collectTailwindStyleCandidates } from './style-candidates'
|
|
14
|
+
import { generateTailwindV3Style } from './v3'
|
|
15
|
+
import { generateTailwindV4Style } from './v4'
|
|
16
|
+
|
|
17
|
+
export interface CustomTailwindStyleGenerateContext {
|
|
18
|
+
tokens: Set<string>
|
|
19
|
+
classSet: Set<string>
|
|
20
|
+
sources: TailwindStyleSource[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CustomTailwindStyleGenerateOptions extends TailwindStyleCandidateOptions {
|
|
24
|
+
generate: (context: CustomTailwindStyleGenerateContext) => string | Promise<string>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface CustomTailwindStyleGenerateResult {
|
|
28
|
+
version: 'custom'
|
|
29
|
+
css: string
|
|
30
|
+
tokens: Set<string>
|
|
31
|
+
classSet: Set<string>
|
|
32
|
+
sources: TailwindStyleSource[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type TailwindStyleGenerateOptions
|
|
36
|
+
= | ({ version: 3 } & TailwindV3StyleGenerateOptions)
|
|
37
|
+
| ({ version: 4 } & TailwindV4StyleGenerateOptions)
|
|
38
|
+
| ({ version: 'custom' } & CustomTailwindStyleGenerateOptions)
|
|
39
|
+
|
|
40
|
+
export type TailwindStyleGenerateResult
|
|
41
|
+
= | TailwindV3StyleGenerateResult
|
|
42
|
+
| (TailwindV4StyleGenerateResult & { version: 4 })
|
|
43
|
+
| CustomTailwindStyleGenerateResult
|
|
44
|
+
|
|
45
|
+
export async function generateCustomStyle(
|
|
46
|
+
options: CustomTailwindStyleGenerateOptions,
|
|
47
|
+
): Promise<CustomTailwindStyleGenerateResult> {
|
|
48
|
+
const tokens = await collectTailwindStyleCandidates(options)
|
|
49
|
+
const classSet = new Set(tokens)
|
|
50
|
+
const sources = options.sources ?? []
|
|
51
|
+
const css = await options.generate({
|
|
52
|
+
tokens,
|
|
53
|
+
classSet,
|
|
54
|
+
sources,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
version: 'custom',
|
|
59
|
+
css,
|
|
60
|
+
tokens,
|
|
61
|
+
classSet,
|
|
62
|
+
sources,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function generateTailwindStyle(
|
|
67
|
+
options: TailwindStyleGenerateOptions,
|
|
68
|
+
): Promise<TailwindStyleGenerateResult> {
|
|
69
|
+
if (options.version === 3) {
|
|
70
|
+
return generateTailwindV3Style(options)
|
|
71
|
+
}
|
|
72
|
+
if (options.version === 4) {
|
|
73
|
+
const result = await generateTailwindV4Style(options)
|
|
74
|
+
return {
|
|
75
|
+
...result,
|
|
76
|
+
version: 4,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return generateCustomStyle(options)
|
|
80
|
+
}
|
package/src/v3/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
generateTailwindV3RawStyle,
|
|
3
|
+
generateTailwindV3Style,
|
|
4
|
+
} from './style-generator'
|
|
5
|
+
export type {
|
|
6
|
+
TailwindV3RawStyleGenerateOptions,
|
|
7
|
+
TailwindV3RawStyleGenerateResult,
|
|
8
|
+
TailwindV3StyleGenerateOptions,
|
|
9
|
+
TailwindV3StyleGenerateResult,
|
|
10
|
+
TailwindV3StyleLayer,
|
|
11
|
+
} from './style-generator'
|