tailwindcss-patch 9.3.7 → 9.4.0
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/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/commands/cli-runtime.js +1 -1
- package/dist/commands/cli-runtime.mjs +1 -1
- package/dist/{index.bundle-CuqnqGSX.js → index.bundle-CGaLDIgy.js} +1 -1
- package/dist/{index.bundle-ByoXMvTR.mjs → index.bundle-D6yHhQ-W.mjs} +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{validate-B7mTl9eT.mjs → validate-Ci0W2Fuu.mjs} +1 -1
- package/dist/{validate-D7h8SP0T.js → validate-D9fDrE9I.js} +1 -1
- package/package.json +1 -1
- package/src/extraction/split-candidate-tokens.ts +98 -0
- package/src/index.ts +5 -0
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-
|
|
3
|
-
const require_index_bundle = require("./index.bundle-
|
|
2
|
+
const require_validate = require("./validate-D9fDrE9I.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-CGaLDIgy.js");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
6
6
|
//#region src/cli.bundle.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as logger, r as ValidateCommandError } from "./validate-
|
|
2
|
-
import { t as createTailwindcssPatchCli } from "./index.bundle-
|
|
1
|
+
import { F as logger, r as ValidateCommandError } from "./validate-Ci0W2Fuu.mjs";
|
|
2
|
+
import { t as createTailwindcssPatchCli } from "./index.bundle-D6yHhQ-W.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
//#region src/cli.bundle.ts
|
|
5
5
|
async function main() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../chunk-8l464Juk.js");
|
|
3
|
-
const require_validate = require("../validate-
|
|
3
|
+
const require_validate = require("../validate-D9fDrE9I.js");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
6
6
|
let fs_extra = require("fs-extra");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as logger, M as loadWorkspaceConfigModule, S as groupTokensByFile, a as tailwindcssPatchCommands, i as classifyValidateError, j as loadPatchOptionsForWorkspace, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher } from "../validate-
|
|
1
|
+
import { F as logger, M as loadWorkspaceConfigModule, S as groupTokensByFile, a as tailwindcssPatchCommands, i as classifyValidateError, j as loadPatchOptionsForWorkspace, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher } from "../validate-Ci0W2Fuu.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
import path from "pathe";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-
|
|
2
|
+
const require_validate = require("./validate-D9fDrE9I.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as resolveValidTailwindV4Candidates, D as canonicalizeBareArbitraryValueCandidates, E as loadTailwindV4DesignSystem, N as normalizeOptions, O as extractTailwindV4InlineSourceCandidates, T as compileTailwindV4Source, _ as extractRawCandidates, k as replaceBareArbitraryValueSelectors, v as extractRawCandidatesWithPositions, w as createTailwindV4CompiledSourceEntries } from "./validate-
|
|
1
|
+
import { A as resolveValidTailwindV4Candidates, D as canonicalizeBareArbitraryValueCandidates, E as loadTailwindV4DesignSystem, N as normalizeOptions, O as extractTailwindV4InlineSourceCandidates, T as compileTailwindV4Source, _ as extractRawCandidates, k as replaceBareArbitraryValueSelectors, v as extractRawCandidatesWithPositions, w as createTailwindV4CompiledSourceEntries } from "./validate-Ci0W2Fuu.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import path from "pathe";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validate = require("./validate-
|
|
3
|
-
const require_index_bundle = require("./index.bundle-
|
|
2
|
+
const require_validate = require("./validate-D9fDrE9I.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-CGaLDIgy.js");
|
|
4
4
|
exports.CacheStore = require_validate.CacheStore;
|
|
5
5
|
exports.MIGRATION_REPORT_KIND = require_validate.MIGRATION_REPORT_KIND;
|
|
6
6
|
exports.MIGRATION_REPORT_SCHEMA_VERSION = require_validate.MIGRATION_REPORT_SCHEMA_VERSION;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as resolveValidTailwindV4Candidates, C as resolveProjectSourceFiles, E as loadTailwindV4DesignSystem, F as logger, N as normalizeOptions, P as CacheStore, S as groupTokensByFile, _ as extractRawCandidates, a as tailwindcssPatchCommands, b as extractSourceCandidatesWithPositions, c as MIGRATION_REPORT_KIND, d as getPatchStatusReport, f as runTailwindBuild, g as extractProjectCandidatesWithPositions, h as collectClassesFromTailwindV4, l as MIGRATION_REPORT_SCHEMA_VERSION, m as collectClassesFromContexts, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, p as loadRuntimeContexts, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher, v as extractRawCandidatesWithPositions, x as extractValidCandidates, y as extractSourceCandidates } from "./validate-
|
|
2
|
-
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-
|
|
1
|
+
import { A as resolveValidTailwindV4Candidates, C as resolveProjectSourceFiles, E as loadTailwindV4DesignSystem, F as logger, N as normalizeOptions, P as CacheStore, S as groupTokensByFile, _ as extractRawCandidates, a as tailwindcssPatchCommands, b as extractSourceCandidatesWithPositions, c as MIGRATION_REPORT_KIND, d as getPatchStatusReport, f as runTailwindBuild, g as extractProjectCandidatesWithPositions, h as collectClassesFromTailwindV4, l as MIGRATION_REPORT_SCHEMA_VERSION, m as collectClassesFromContexts, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, p as loadRuntimeContexts, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher, v as extractRawCandidatesWithPositions, x as extractValidCandidates, y as extractSourceCandidates } from "./validate-Ci0W2Fuu.mjs";
|
|
2
|
+
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-D6yHhQ-W.mjs";
|
|
3
3
|
export { CacheStore, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, TailwindcssPatcher, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
@@ -17,7 +17,7 @@ import _babelTraverse from "@babel/traverse";
|
|
|
17
17
|
import { parse, parse as parse$1 } from "@babel/parser";
|
|
18
18
|
import { loadConfig } from "tailwindcss-config";
|
|
19
19
|
//#region package.json
|
|
20
|
-
var version = "9.
|
|
20
|
+
var version = "9.4.0";
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/constants.ts
|
|
23
23
|
const pkgName = "tailwindcss-patch";
|
|
@@ -24,7 +24,7 @@ _babel_traverse = require_chunk.__toESM(_babel_traverse);
|
|
|
24
24
|
let _babel_parser = require("@babel/parser");
|
|
25
25
|
let tailwindcss_config = require("tailwindcss-config");
|
|
26
26
|
//#region package.json
|
|
27
|
-
var version = "9.
|
|
27
|
+
var version = "9.4.0";
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/constants.ts
|
|
30
30
|
const pkgName = "tailwindcss-patch";
|
package/package.json
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// 参考链接:https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/regex.js
|
|
2
|
+
// eslint-disable-next-line regexp/no-obscure-range
|
|
3
|
+
export const validateCandidateTokenRE = /[\w\u00A0-\uFFFF%-?]/
|
|
4
|
+
|
|
5
|
+
export function isValidCandidateToken(token = ''): token is string {
|
|
6
|
+
return validateCandidateTokenRE.test(token)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const SPLIT_CACHE_LIMIT = 8192
|
|
10
|
+
const ESCAPED_WHITESPACE_RE = /\\[nrt]/g
|
|
11
|
+
const splitCache = new Map<string, string[]>()
|
|
12
|
+
|
|
13
|
+
function isSplitter(char: string, bracketDepth: number) {
|
|
14
|
+
return bracketDepth === 0 && (char === '"' || /\s/.test(char))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function hasClosingQuotedArbitraryValue(code: string, start: number, quote: string) {
|
|
18
|
+
for (let index = start; index < code.length; index++) {
|
|
19
|
+
if (code[index] === '\\') {
|
|
20
|
+
index++
|
|
21
|
+
continue
|
|
22
|
+
}
|
|
23
|
+
if (code[index] === quote) {
|
|
24
|
+
return code.includes(']', index + 1)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function splitBracketAware(code: string) {
|
|
32
|
+
const result: string[] = []
|
|
33
|
+
let bracketDepth = 0
|
|
34
|
+
let bracketQuote: string | undefined
|
|
35
|
+
let start = 0
|
|
36
|
+
|
|
37
|
+
for (let index = 0; index < code.length; index++) {
|
|
38
|
+
const char = code[index]
|
|
39
|
+
if (bracketDepth > 0 && char === '\\') {
|
|
40
|
+
index++
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (bracketDepth > 0 && (char === '"' || char === '\'')) {
|
|
45
|
+
if (bracketQuote === char) {
|
|
46
|
+
bracketQuote = undefined
|
|
47
|
+
}
|
|
48
|
+
else if (bracketQuote === undefined && hasClosingQuotedArbitraryValue(code, index + 1, char)) {
|
|
49
|
+
bracketQuote = char
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (bracketQuote === undefined) {
|
|
54
|
+
if (char === '[' && code.includes(']', index + 1)) {
|
|
55
|
+
bracketDepth++
|
|
56
|
+
}
|
|
57
|
+
else if (char === ']' && bracketDepth > 0) {
|
|
58
|
+
bracketDepth--
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isSplitter(char, bracketDepth)) {
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const candidate = code.slice(start, index)
|
|
67
|
+
if (isValidCandidateToken(candidate)) {
|
|
68
|
+
result.push(candidate)
|
|
69
|
+
}
|
|
70
|
+
start = index + 1
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const candidate = code.slice(start)
|
|
74
|
+
if (isValidCandidateToken(candidate)) {
|
|
75
|
+
result.push(candidate)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return result
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function splitCandidateTokens(code: string) {
|
|
82
|
+
const cached = splitCache.get(code)
|
|
83
|
+
if (cached) {
|
|
84
|
+
return cached
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 把压缩产物中的转义空白字符(\n \r \t)先还原成空格,避免被粘连到类名上。
|
|
88
|
+
const normalized = code.includes('\\') ? code.replace(ESCAPED_WHITESPACE_RE, ' ') : code
|
|
89
|
+
const result = splitBracketAware(normalized)
|
|
90
|
+
|
|
91
|
+
// 防止缓存无限增长。
|
|
92
|
+
if (splitCache.size >= SPLIT_CACHE_LIMIT) {
|
|
93
|
+
splitCache.clear()
|
|
94
|
+
}
|
|
95
|
+
splitCache.set(code, result)
|
|
96
|
+
|
|
97
|
+
return result
|
|
98
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -46,6 +46,11 @@ export {
|
|
|
46
46
|
resolveProjectSourceFiles,
|
|
47
47
|
type ExtractSourceCandidate,
|
|
48
48
|
} from './extraction/candidate-extractor'
|
|
49
|
+
export {
|
|
50
|
+
isValidCandidateToken,
|
|
51
|
+
splitCandidateTokens,
|
|
52
|
+
validateCandidateTokenRE,
|
|
53
|
+
} from './extraction/split-candidate-tokens'
|
|
49
54
|
export {
|
|
50
55
|
collectClassesFromContexts,
|
|
51
56
|
collectClassesFromTailwindV4,
|