tailwindcss-patch 9.4.2 → 9.4.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.
- package/README.md +69 -0
- package/dist/{cli-D5D3Yj69.mjs → cli-CLvyx3xl.mjs} +1 -1
- package/dist/{cli-DsXcyl2O.js → cli-srv0kRlt.js} +5 -6
- 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-Dn7cMVhi.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-CYB-90BG.d.ts → validate-BuqRodYI.d.ts} +58 -26
- package/dist/{validate-CInDiiYy.mjs → validate-CUNJFfHh.mjs} +6 -6
- package/dist/{validate-5eUbRAzl.js → validate-RpdgpjgT.js} +41 -14
- package/dist/{validate-D6MO6lZo.d.mts → validate-oAkURzUC.d.mts} +58 -25
- package/package.json +13 -13
- package/src/api/tailwindcss-patcher.ts +5 -3
- 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 };
|
|
@@ -18,7 +18,7 @@ import _babelTraverse from "@babel/traverse";
|
|
|
18
18
|
import { parse, parse as parse$1 } from "@babel/parser";
|
|
19
19
|
import { loadConfig } from "tailwindcss-config";
|
|
20
20
|
//#region package.json
|
|
21
|
-
var version = "9.4.
|
|
21
|
+
var version = "9.4.4";
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/constants.ts
|
|
24
24
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1412,7 +1412,7 @@ function normalizeOptions(options = {}) {
|
|
|
1412
1412
|
};
|
|
1413
1413
|
}
|
|
1414
1414
|
//#endregion
|
|
1415
|
-
//#region ../../node_modules/.pnpm/tsdown@0.22.
|
|
1415
|
+
//#region ../../node_modules/.pnpm/tsdown@0.22.2_tsx@4.22.4_typescript@6.0.3_unrun@0.2.37_synckit@0.11.13_/node_modules/tsdown/esm-shims.js
|
|
1416
1416
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
1417
1417
|
const getDirname = () => path$1.dirname(getFilename());
|
|
1418
1418
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -1444,7 +1444,7 @@ async function loadWorkspaceConfigModule() {
|
|
|
1444
1444
|
return configModulePromise;
|
|
1445
1445
|
}
|
|
1446
1446
|
async function loadWorkspaceDefu() {
|
|
1447
|
-
if (!defuPromise) defuPromise = import("./dist-
|
|
1447
|
+
if (!defuPromise) defuPromise = import("./dist-CxmNpfyy.mjs").then((mod) => mod.defu).catch(async (error) => {
|
|
1448
1448
|
if (!isMissingSharedModuleError(error)) throw error;
|
|
1449
1449
|
return (await import(pathToFileURL(path.resolve(__dirname, "../../../shared/src/utils.ts")).href)).defu;
|
|
1450
1450
|
});
|
|
@@ -3720,9 +3720,9 @@ function createCollector(packageInfo, options, majorVersion, snapshotFactory) {
|
|
|
3720
3720
|
if (majorVersion === 4) return new TailwindV4Collector(packageInfo, options, snapshotFactory);
|
|
3721
3721
|
return new RuntimeCollector(packageInfo, options, majorVersion, snapshotFactory);
|
|
3722
3722
|
}
|
|
3723
|
-
function getPackageInfoFromCwd(packageName, cwd) {
|
|
3723
|
+
function getPackageInfoFromCwd(packageName, cwd, resolvePaths = []) {
|
|
3724
3724
|
try {
|
|
3725
|
-
const packageJsonPath = createRequire(path.join(cwd, "package.json")).resolve(`${packageName}/package.json
|
|
3725
|
+
const packageJsonPath = createRequire(path.join(cwd, "package.json")).resolve(`${packageName}/package.json`, { paths: resolvePaths });
|
|
3726
3726
|
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
3727
3727
|
return {
|
|
3728
3728
|
name: packageName,
|
|
@@ -3737,7 +3737,7 @@ function getPackageInfoFromCwd(packageName, cwd) {
|
|
|
3737
3737
|
}
|
|
3738
3738
|
function getTailwindPackageInfo(options) {
|
|
3739
3739
|
const cwd = options.tailwind.cwd ?? options.projectRoot;
|
|
3740
|
-
return (options.tailwind.resolve?.paths?.length ? getPackageInfoFromCwd(options.tailwind.packageName, cwd) : void 0) ?? getPackageInfoSync(options.tailwind.packageName, options.tailwind.resolve);
|
|
3740
|
+
return (options.tailwind.resolve?.paths?.length ? getPackageInfoFromCwd(options.tailwind.packageName, cwd, options.tailwind.resolve.paths) : void 0) ?? getPackageInfoSync(options.tailwind.packageName, options.tailwind.resolve);
|
|
3741
3741
|
}
|
|
3742
3742
|
var TailwindcssPatcher = class {
|
|
3743
3743
|
options;
|
|
@@ -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.4";
|
|
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-Dn7cMVhi.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
|
});
|
|
@@ -3723,9 +3744,9 @@ function createCollector(packageInfo, options, majorVersion, snapshotFactory) {
|
|
|
3723
3744
|
if (majorVersion === 4) return new TailwindV4Collector(packageInfo, options, snapshotFactory);
|
|
3724
3745
|
return new RuntimeCollector(packageInfo, options, majorVersion, snapshotFactory);
|
|
3725
3746
|
}
|
|
3726
|
-
function getPackageInfoFromCwd(packageName, cwd) {
|
|
3747
|
+
function getPackageInfoFromCwd(packageName, cwd, resolvePaths = []) {
|
|
3727
3748
|
try {
|
|
3728
|
-
const packageJsonPath = (0, node_module.createRequire)(pathe.default.join(cwd, "package.json")).resolve(`${packageName}/package.json
|
|
3749
|
+
const packageJsonPath = (0, node_module.createRequire)(pathe.default.join(cwd, "package.json")).resolve(`${packageName}/package.json`, { paths: resolvePaths });
|
|
3729
3750
|
const packageJson = fs_extra.default.readJSONSync(packageJsonPath);
|
|
3730
3751
|
return {
|
|
3731
3752
|
name: packageName,
|
|
@@ -3740,7 +3761,7 @@ function getPackageInfoFromCwd(packageName, cwd) {
|
|
|
3740
3761
|
}
|
|
3741
3762
|
function getTailwindPackageInfo(options) {
|
|
3742
3763
|
const cwd = options.tailwind.cwd ?? options.projectRoot;
|
|
3743
|
-
return (options.tailwind.resolve?.paths?.length ? getPackageInfoFromCwd(options.tailwind.packageName, cwd) : void 0) ?? (0, local_pkg.getPackageInfoSync)(options.tailwind.packageName, options.tailwind.resolve);
|
|
3764
|
+
return (options.tailwind.resolve?.paths?.length ? getPackageInfoFromCwd(options.tailwind.packageName, cwd, options.tailwind.resolve.paths) : void 0) ?? (0, local_pkg.getPackageInfoSync)(options.tailwind.packageName, options.tailwind.resolve);
|
|
3744
3765
|
}
|
|
3745
3766
|
var TailwindcssPatcher = class {
|
|
3746
3767
|
options;
|
|
@@ -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.4",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,12 +61,12 @@
|
|
|
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.
|
|
68
|
-
"@tailwindcss/node": "^4.3.
|
|
69
|
-
"@tailwindcss/oxide": "^4.3.
|
|
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
|
+
"@tailwindcss/node": "^4.3.1",
|
|
69
|
+
"@tailwindcss/oxide": "^4.3.1",
|
|
70
70
|
"cac": "6.7.14",
|
|
71
71
|
"consola": "^3.4.2",
|
|
72
72
|
"fs-extra": "^11.3.5",
|
|
@@ -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
|
-
"@tailwindcss/postcss": "^4.3.
|
|
83
|
-
"@tailwindcss/vite": "^4.3.
|
|
84
|
-
"tailwindcss": "^4.1
|
|
82
|
+
"@tailwindcss/postcss": "^4.3.1",
|
|
83
|
+
"@tailwindcss/vite": "^4.3.1",
|
|
84
|
+
"tailwindcss": "^4.3.1",
|
|
85
85
|
"tailwindcss-3": "npm:tailwindcss@^3.4.19",
|
|
86
|
-
"tailwindcss-4": "npm:tailwindcss@^4.1
|
|
86
|
+
"tailwindcss-4": "npm:tailwindcss@^4.3.1"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"dev": "tsdown --watch --sourcemap",
|
|
@@ -104,9 +104,11 @@ function createCollector(
|
|
|
104
104
|
return new RuntimeCollector(packageInfo, options, majorVersion, snapshotFactory)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function getPackageInfoFromCwd(packageName: string, cwd: string): PackageInfo | undefined {
|
|
107
|
+
function getPackageInfoFromCwd(packageName: string, cwd: string, resolvePaths: string[] = []): PackageInfo | undefined {
|
|
108
108
|
try {
|
|
109
|
-
const packageJsonPath = createRequire(path.join(cwd, 'package.json')).resolve(`${packageName}/package.json
|
|
109
|
+
const packageJsonPath = createRequire(path.join(cwd, 'package.json')).resolve(`${packageName}/package.json`, {
|
|
110
|
+
paths: resolvePaths,
|
|
111
|
+
})
|
|
110
112
|
const packageJson = fs.readJSONSync(packageJsonPath) as PackageInfo['packageJson']
|
|
111
113
|
return {
|
|
112
114
|
name: packageName,
|
|
@@ -124,7 +126,7 @@ function getPackageInfoFromCwd(packageName: string, cwd: string): PackageInfo |
|
|
|
124
126
|
function getTailwindPackageInfo(options: NormalizedTailwindCssPatchOptions) {
|
|
125
127
|
const cwd = options.tailwind.cwd ?? options.projectRoot
|
|
126
128
|
const cwdPackageInfo = options.tailwind.resolve?.paths?.length
|
|
127
|
-
? getPackageInfoFromCwd(options.tailwind.packageName, cwd)
|
|
129
|
+
? getPackageInfoFromCwd(options.tailwind.packageName, cwd, options.tailwind.resolve.paths)
|
|
128
130
|
: undefined
|
|
129
131
|
return cwdPackageInfo
|
|
130
132
|
?? getPackageInfoSync(
|
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
|
+
}
|