tailwindcss-patch 9.4.4 → 9.5.1
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-CLvyx3xl.mjs → cli-Bv15iTiT.mjs} +1 -1
- package/dist/{cli-srv0kRlt.js → cli-Db2YAbkN.js} +3 -2
- package/dist/cli.js +2 -2
- 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-Dn7cMVhi.js → dist-wp0o36Ns.js} +1 -1
- package/dist/index.d.mts +7 -149
- package/dist/index.d.ts +8 -150
- package/dist/index.js +294 -521
- package/dist/index.mjs +6 -471
- package/dist/{validate-oAkURzUC.d.mts → validate-B5-08lrU.d.ts} +8 -252
- package/dist/{validate-RpdgpjgT.js → validate-C8oLv32F.js} +79 -1705
- package/dist/{validate-BuqRodYI.d.ts → validate-CgrG4aAY.d.mts} +8 -252
- package/dist/{validate-CUNJFfHh.mjs → validate-Cu1G06lO.mjs} +5 -1402
- package/package.json +5 -7
- package/src/api/tailwindcss-patcher.ts +3 -2
- package/src/extraction/candidate-extractor.ts +17 -701
- package/src/extraction/split-candidate-tokens.ts +5 -101
- package/src/options/types.ts +1 -2
- package/src/style-candidates.ts +5 -35
- package/src/style-generator.ts +11 -80
- package/src/types.ts +21 -95
- package/src/v3/index.ts +2 -2
- package/src/v4/index.ts +104 -28
- package/src/v3/style-generator.ts +0 -384
- package/src/v4/bare-arbitrary-values.ts +0 -545
- package/src/v4/candidates.ts +0 -316
- package/src/v4/engine.ts +0 -112
- package/src/v4/node-adapter.ts +0 -207
- package/src/v4/source-scan.ts +0 -432
- package/src/v4/source.ts +0 -235
- package/src/v4/style-generator.ts +0 -44
- package/src/v4/types.ts +0 -103
|
@@ -1,101 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 (char === undefined) {
|
|
40
|
-
continue
|
|
41
|
-
}
|
|
42
|
-
if (bracketDepth > 0 && char === '\\') {
|
|
43
|
-
index++
|
|
44
|
-
continue
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (bracketDepth > 0 && (char === '"' || char === '\'')) {
|
|
48
|
-
if (bracketQuote === char) {
|
|
49
|
-
bracketQuote = undefined
|
|
50
|
-
}
|
|
51
|
-
else if (bracketQuote === undefined && hasClosingQuotedArbitraryValue(code, index + 1, char)) {
|
|
52
|
-
bracketQuote = char
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (bracketQuote === undefined) {
|
|
57
|
-
if (char === '[' && code.includes(']', index + 1)) {
|
|
58
|
-
bracketDepth++
|
|
59
|
-
}
|
|
60
|
-
else if (char === ']' && bracketDepth > 0) {
|
|
61
|
-
bracketDepth--
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!isSplitter(char, bracketDepth)) {
|
|
66
|
-
continue
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const candidate = code.slice(start, index)
|
|
70
|
-
if (isValidCandidateToken(candidate)) {
|
|
71
|
-
result.push(candidate)
|
|
72
|
-
}
|
|
73
|
-
start = index + 1
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const candidate = code.slice(start)
|
|
77
|
-
if (isValidCandidateToken(candidate)) {
|
|
78
|
-
result.push(candidate)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return result
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function splitCandidateTokens(code: string) {
|
|
85
|
-
const cached = splitCache.get(code)
|
|
86
|
-
if (cached) {
|
|
87
|
-
return cached
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// 把压缩产物中的转义空白字符(\n \r \t)先还原成空格,避免被粘连到类名上。
|
|
91
|
-
const normalized = code.includes('\\') ? code.replace(ESCAPED_WHITESPACE_RE, ' ') : code
|
|
92
|
-
const result = splitBracketAware(normalized)
|
|
93
|
-
|
|
94
|
-
// 防止缓存无限增长。
|
|
95
|
-
if (splitCache.size >= SPLIT_CACHE_LIMIT) {
|
|
96
|
-
splitCache.clear()
|
|
97
|
-
}
|
|
98
|
-
splitCache.set(code, result)
|
|
99
|
-
|
|
100
|
-
return result
|
|
101
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
isValidCandidateToken,
|
|
3
|
+
splitCandidateTokens,
|
|
4
|
+
validateCandidateTokenRE,
|
|
5
|
+
} from '@tailwindcss-mangle/engine'
|
package/src/options/types.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { SourceEntry } from '@tailwindcss/
|
|
1
|
+
import type { TailwindV4SourcePattern as SourceEntry, TailwindV4CssSource } from '@tailwindcss-mangle/engine/v4'
|
|
2
2
|
import type { PackageResolvingOptions } from 'local-pkg'
|
|
3
3
|
import type { ILengthUnitsPatchOptions } from '../types'
|
|
4
|
-
import type { TailwindV4CssSource } from '../v4/types'
|
|
5
4
|
|
|
6
5
|
export type CacheStrategy = 'merge' | 'overwrite'
|
|
7
6
|
export type CacheDriver = 'file' | 'memory' | 'noop'
|
package/src/style-candidates.ts
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
}
|
|
1
|
+
export { collectTailwindStyleCandidates } from '@tailwindcss-mangle/engine'
|
|
2
|
+
export type {
|
|
3
|
+
TailwindStyleCandidateOptions,
|
|
4
|
+
TailwindStyleSource,
|
|
5
|
+
} from '@tailwindcss-mangle/engine'
|
package/src/style-generator.ts
CHANGED
|
@@ -1,80 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
generateCustomStyle,
|
|
3
|
+
generateTailwindStyle,
|
|
4
|
+
} from '@tailwindcss-mangle/engine'
|
|
5
|
+
export type {
|
|
6
|
+
CustomTailwindStyleGenerateContext,
|
|
7
|
+
CustomTailwindStyleGenerateOptions,
|
|
8
|
+
CustomTailwindStyleGenerateResult,
|
|
9
|
+
TailwindStyleGenerateOptions,
|
|
10
|
+
TailwindStyleGenerateResult,
|
|
11
|
+
} from '@tailwindcss-mangle/engine'
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { SourceEntry } from '@tailwindcss/oxide'
|
|
2
|
-
import type { Node, Rule } from 'postcss'
|
|
3
|
-
import type { Config } from 'tailwindcss'
|
|
4
1
|
import type {
|
|
5
2
|
ApplyOptions,
|
|
6
3
|
CacheOptions,
|
|
@@ -16,96 +13,19 @@ import type {
|
|
|
16
13
|
TailwindV4Options,
|
|
17
14
|
} from './options/types'
|
|
18
15
|
|
|
19
|
-
type TailwindcssClassCacheEntry = Rule | {
|
|
20
|
-
layer: string
|
|
21
|
-
options: Record<string, any>
|
|
22
|
-
sort: Record<string, any>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type TailwindcssClassCache = Map<string, TailwindcssClassCacheEntry[]>
|
|
26
|
-
|
|
27
|
-
export interface TailwindcssRuntimeContext {
|
|
28
|
-
applyClassCache: Map<any, any>
|
|
29
|
-
candidateRuleCache: Map<
|
|
30
|
-
string,
|
|
31
|
-
Set<
|
|
32
|
-
[
|
|
33
|
-
{
|
|
34
|
-
arbitrary: any
|
|
35
|
-
index: any
|
|
36
|
-
layer: string
|
|
37
|
-
options: any[]
|
|
38
|
-
parallelIndex: any
|
|
39
|
-
parentLayer: string
|
|
40
|
-
variants: any
|
|
41
|
-
},
|
|
42
|
-
Node,
|
|
43
|
-
]
|
|
44
|
-
>
|
|
45
|
-
>
|
|
46
|
-
candidateRuleMap: Map<string | string, [object, Node][]>
|
|
47
|
-
changedContent: any[]
|
|
48
|
-
classCache: TailwindcssClassCache
|
|
49
|
-
disposables: any[]
|
|
50
|
-
getClassList: (...args: any[]) => any
|
|
51
|
-
getClassOrder: (...args: any[]) => any
|
|
52
|
-
getVariants: (...args: any[]) => any
|
|
53
|
-
markInvalidUtilityCandidate: (...args: any[]) => any
|
|
54
|
-
markInvalidUtilityNode: (...args: any[]) => any
|
|
55
|
-
notClassCache: Set<string>
|
|
56
|
-
offsets: {
|
|
57
|
-
layerPositions: object
|
|
58
|
-
offsets: object
|
|
59
|
-
reservedVariantBits: any
|
|
60
|
-
variantOffsets: Map<string, any>
|
|
61
|
-
}
|
|
62
|
-
postCssNodeCache: Map<object, [Node]>
|
|
63
|
-
ruleCache: Set<[object, Node]>
|
|
64
|
-
stylesheetCache: Record<string, Set<any>>
|
|
65
|
-
tailwindConfig: Config
|
|
66
|
-
userConfigPath: string | null
|
|
67
|
-
variantMap: Map<string, [[object, (...args: any[]) => unknown]]>
|
|
68
|
-
variantOptions: Map<string, object>
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface ExtractResult {
|
|
72
|
-
classList: string[]
|
|
73
|
-
classSet: Set<string>
|
|
74
|
-
filename?: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface TailwindTokenLocation {
|
|
78
|
-
rawCandidate: string
|
|
79
|
-
file: string
|
|
80
|
-
relativeFile: string
|
|
81
|
-
extension: string
|
|
82
|
-
start: number
|
|
83
|
-
end: number
|
|
84
|
-
length: number
|
|
85
|
-
line: number
|
|
86
|
-
column: number
|
|
87
|
-
lineText: string
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type TailwindTokenFileKey = 'relative' | 'absolute'
|
|
91
|
-
|
|
92
|
-
export interface TailwindTokenReport {
|
|
93
|
-
entries: TailwindTokenLocation[]
|
|
94
|
-
filesScanned: number
|
|
95
|
-
sources: SourceEntry[]
|
|
96
|
-
skippedFiles: {
|
|
97
|
-
file: string
|
|
98
|
-
reason: string
|
|
99
|
-
}[]
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export type TailwindTokenByFileMap = Record<string, TailwindTokenLocation[]>
|
|
103
|
-
|
|
104
16
|
export interface TailwindPatchRuntime {
|
|
105
17
|
options: NormalizedTailwindCssPatchOptions
|
|
106
18
|
majorVersion: 2 | 3 | 4
|
|
107
19
|
}
|
|
108
20
|
|
|
21
|
+
export type {
|
|
22
|
+
CacheClearOptions,
|
|
23
|
+
CacheClearResult,
|
|
24
|
+
CacheClearScope,
|
|
25
|
+
CacheContextMetadata,
|
|
26
|
+
CacheReadMeta,
|
|
27
|
+
} from './cache/types'
|
|
28
|
+
|
|
109
29
|
export type {
|
|
110
30
|
ApplyOptions,
|
|
111
31
|
CacheOptions,
|
|
@@ -129,7 +49,11 @@ export interface ILengthUnitsPatchOptions {
|
|
|
129
49
|
destPath?: string
|
|
130
50
|
}
|
|
131
51
|
|
|
132
|
-
export type PatchCheckStatus
|
|
52
|
+
export type PatchCheckStatus
|
|
53
|
+
= | 'applied'
|
|
54
|
+
| 'not-applied'
|
|
55
|
+
| 'skipped'
|
|
56
|
+
| 'unsupported'
|
|
133
57
|
|
|
134
58
|
export type PatchName = 'exposeContext' | 'extendLengthUnits'
|
|
135
59
|
|
|
@@ -151,9 +75,11 @@ export interface PatchStatusReport {
|
|
|
151
75
|
}
|
|
152
76
|
|
|
153
77
|
export type {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
78
|
+
ExtractResult,
|
|
79
|
+
TailwindcssClassCache,
|
|
80
|
+
TailwindcssRuntimeContext,
|
|
81
|
+
TailwindTokenByFileMap,
|
|
82
|
+
TailwindTokenFileKey,
|
|
83
|
+
TailwindTokenLocation,
|
|
84
|
+
TailwindTokenReport,
|
|
85
|
+
} from '@tailwindcss-mangle/engine'
|
package/src/v3/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export {
|
|
2
2
|
generateTailwindV3RawStyle,
|
|
3
3
|
generateTailwindV3Style,
|
|
4
|
-
} from '
|
|
4
|
+
} from '@tailwindcss-mangle/engine/v3'
|
|
5
5
|
export type {
|
|
6
6
|
TailwindV3RawStyleGenerateOptions,
|
|
7
7
|
TailwindV3RawStyleGenerateResult,
|
|
8
8
|
TailwindV3StyleGenerateOptions,
|
|
9
9
|
TailwindV3StyleGenerateResult,
|
|
10
10
|
TailwindV3StyleLayer,
|
|
11
|
-
} from '
|
|
11
|
+
} from '@tailwindcss-mangle/engine/v3'
|
package/src/v4/index.ts
CHANGED
|
@@ -1,53 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type {
|
|
2
|
+
TailwindV4ResolvedSource,
|
|
3
|
+
TailwindV4SourceOptions,
|
|
4
|
+
} from '@tailwindcss-mangle/engine/v4'
|
|
5
|
+
import type {
|
|
6
|
+
NormalizedTailwindCssPatchOptions,
|
|
7
|
+
TailwindCssPatchOptions,
|
|
8
|
+
} from '../config'
|
|
9
|
+
import { resolveTailwindV4Source } from '@tailwindcss-mangle/engine/v4'
|
|
10
|
+
import path from 'pathe'
|
|
11
|
+
import { normalizeOptions } from '../config'
|
|
12
|
+
|
|
8
13
|
export {
|
|
9
14
|
canonicalizeBareArbitraryValueCandidates,
|
|
10
|
-
|
|
11
|
-
replaceBareArbitraryValueSelectors,
|
|
12
|
-
resolveValidTailwindV4Candidates,
|
|
13
|
-
} from './candidates'
|
|
14
|
-
export { createTailwindV4Engine } from './engine'
|
|
15
|
-
export {
|
|
15
|
+
collectTailwindV4StyleCandidates,
|
|
16
16
|
compileTailwindV4Source,
|
|
17
|
-
loadTailwindV4DesignSystem,
|
|
18
|
-
loadTailwindV4NodeModule,
|
|
19
|
-
} from './node-adapter'
|
|
20
|
-
export {
|
|
21
|
-
resolveTailwindV4Source,
|
|
22
|
-
resolveTailwindV4SourceFromPatchOptions,
|
|
23
|
-
tailwindV4SourceOptionsFromPatchOptions,
|
|
24
|
-
} from './source'
|
|
25
|
-
export {
|
|
26
17
|
createTailwindV4CompiledSourceEntries,
|
|
27
18
|
createTailwindV4DefaultIgnoreSources,
|
|
19
|
+
createTailwindV4Engine,
|
|
28
20
|
createTailwindV4RootSources,
|
|
29
21
|
createTailwindV4SourceEntryMatcher,
|
|
30
22
|
createTailwindV4SourceExclusionMatcher,
|
|
23
|
+
escapeCssClassName,
|
|
31
24
|
expandTailwindV4SourceEntries,
|
|
32
25
|
expandTailwindV4SourceEntryBraces,
|
|
26
|
+
extractBareArbitraryValueSourceCandidates,
|
|
27
|
+
extractBareArbitraryValueSourceCandidatesWithPositions,
|
|
28
|
+
extractTailwindV4InlineSourceCandidates,
|
|
29
|
+
generateTailwindV4Style,
|
|
30
|
+
getTailwindV4DesignSystemCacheKey,
|
|
31
|
+
groupTailwindV4SourceEntriesByBase,
|
|
32
|
+
isBareArbitraryValuesEnabled,
|
|
33
33
|
isFileExcludedByTailwindV4SourceEntries,
|
|
34
34
|
isFileMatchedByTailwindV4SourceEntries,
|
|
35
|
+
loadTailwindV4DesignSystem,
|
|
36
|
+
loadTailwindV4NodeModule,
|
|
35
37
|
mergeTailwindV4SourceEntries,
|
|
38
|
+
normalizeGlobPattern,
|
|
36
39
|
normalizeTailwindV4ScannerSources,
|
|
37
40
|
normalizeTailwindV4SourceEntries,
|
|
41
|
+
replaceBareArbitraryValueSelectors,
|
|
42
|
+
resolveBareArbitraryValueCandidate,
|
|
38
43
|
resolveSourceScanPath,
|
|
44
|
+
resolveTailwindV4Source,
|
|
39
45
|
resolveTailwindV4SourceBaseCandidates,
|
|
40
46
|
resolveTailwindV4SourceEntry,
|
|
47
|
+
resolveValidTailwindV4Candidates,
|
|
41
48
|
TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN,
|
|
42
49
|
TAILWIND_V4_IGNORED_CONTENT_DIRS,
|
|
43
50
|
TAILWIND_V4_IGNORED_EXTENSIONS,
|
|
44
51
|
TAILWIND_V4_IGNORED_FILES,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
collectTailwindV4StyleCandidates,
|
|
48
|
-
generateTailwindV4Style,
|
|
49
|
-
} from './style-generator'
|
|
52
|
+
toPosixPath,
|
|
53
|
+
} from '@tailwindcss-mangle/engine/v4'
|
|
50
54
|
export type {
|
|
55
|
+
BareArbitraryValueOptions,
|
|
56
|
+
BareArbitraryValueResolveResult,
|
|
57
|
+
BareArbitraryValueSourceCandidate,
|
|
51
58
|
TailwindV4CandidateSource,
|
|
52
59
|
TailwindV4CompiledSourceRoot,
|
|
53
60
|
TailwindV4CssSource,
|
|
@@ -61,4 +68,73 @@ export type {
|
|
|
61
68
|
TailwindV4StyleGenerateOptions,
|
|
62
69
|
TailwindV4StyleGenerateResult,
|
|
63
70
|
TailwindV4StyleSource,
|
|
64
|
-
} from '
|
|
71
|
+
} from '@tailwindcss-mangle/engine/v4'
|
|
72
|
+
|
|
73
|
+
function uniquePaths(values: Iterable<string | undefined>) {
|
|
74
|
+
const result: string[] = []
|
|
75
|
+
for (const value of values) {
|
|
76
|
+
if (!value) {
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
const resolved = path.resolve(value)
|
|
80
|
+
if (!result.includes(resolved)) {
|
|
81
|
+
result.push(resolved)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function resolveConfigDir(config: string | undefined, projectRoot: string) {
|
|
88
|
+
if (!config) {
|
|
89
|
+
return undefined
|
|
90
|
+
}
|
|
91
|
+
const configPath = path.isAbsolute(config)
|
|
92
|
+
? config
|
|
93
|
+
: path.resolve(projectRoot, config)
|
|
94
|
+
return path.dirname(configPath)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function createSourceOptionsFromNormalizedPatchOptions(
|
|
98
|
+
options: NormalizedTailwindCssPatchOptions,
|
|
99
|
+
): TailwindV4SourceOptions {
|
|
100
|
+
const v4 = options.tailwind.v4
|
|
101
|
+
const configDir = resolveConfigDir(
|
|
102
|
+
options.tailwind.config,
|
|
103
|
+
options.projectRoot,
|
|
104
|
+
)
|
|
105
|
+
const baseFallbacks = uniquePaths([
|
|
106
|
+
v4?.configuredBase,
|
|
107
|
+
options.tailwind.cwd,
|
|
108
|
+
options.projectRoot,
|
|
109
|
+
configDir,
|
|
110
|
+
])
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
projectRoot: options.projectRoot,
|
|
114
|
+
...(options.tailwind.cwd === undefined
|
|
115
|
+
? {}
|
|
116
|
+
: { cwd: options.tailwind.cwd }),
|
|
117
|
+
...(v4?.configuredBase === undefined ? {} : { base: v4.configuredBase }),
|
|
118
|
+
baseFallbacks,
|
|
119
|
+
...(v4?.css === undefined ? {} : { css: v4.css }),
|
|
120
|
+
...(v4?.cssSources === undefined ? {} : { cssSources: v4.cssSources }),
|
|
121
|
+
...(v4?.cssEntries === undefined ? {} : { cssEntries: v4.cssEntries }),
|
|
122
|
+
packageName: options.tailwind.packageName,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function tailwindV4SourceOptionsFromPatchOptions(
|
|
127
|
+
options: TailwindCssPatchOptions,
|
|
128
|
+
): TailwindV4SourceOptions {
|
|
129
|
+
return createSourceOptionsFromNormalizedPatchOptions(
|
|
130
|
+
normalizeOptions(options),
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function resolveTailwindV4SourceFromPatchOptions(
|
|
135
|
+
options: TailwindCssPatchOptions,
|
|
136
|
+
): Promise<TailwindV4ResolvedSource> {
|
|
137
|
+
return resolveTailwindV4Source(
|
|
138
|
+
tailwindV4SourceOptionsFromPatchOptions(options),
|
|
139
|
+
)
|
|
140
|
+
}
|