tailwindcss-patch 9.4.0 → 9.4.2
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-D5D3Yj69.mjs +655 -0
- package/dist/cli-DsXcyl2O.js +671 -0
- package/dist/cli.js +4 -4
- package/dist/cli.mjs +3 -3
- package/dist/commands/cli-runtime.d.mts +1 -1
- package/dist/commands/cli-runtime.d.ts +1 -1
- package/dist/commands/cli-runtime.js +4 -661
- package/dist/commands/cli-runtime.mjs +2 -654
- package/dist/index.d.mts +39 -3
- package/dist/index.d.ts +39 -3
- package/dist/index.js +320 -8
- package/dist/index.mjs +283 -3
- package/dist/{validate-D9fDrE9I.js → validate-5eUbRAzl.js} +468 -19
- package/dist/{validate-Ci0W2Fuu.mjs → validate-CInDiiYy.mjs} +331 -21
- package/dist/{validate-DFiRmBtJ.d.ts → validate-CYB-90BG.d.ts} +22 -5
- package/dist/{validate-CDegYLlg.d.mts → validate-D6MO6lZo.d.mts} +22 -5
- package/package.json +1 -1
- package/src/extraction/candidate-extractor.ts +76 -12
- package/src/extraction/split-candidate-tokens.ts +3 -0
- package/src/index.bundle.ts +1 -112
- package/src/index.ts +1 -100
- package/src/public-api.ts +111 -0
- package/src/v4/bare-arbitrary-values.ts +127 -2
- package/src/v4/engine.ts +5 -2
- package/src/v4/index.ts +14 -5
- package/src/v4/node-adapter.ts +1 -1
- package/src/v4/source-scan.ts +1 -1
- package/dist/index.bundle-CGaLDIgy.js +0 -259
- package/dist/index.bundle-D6yHhQ-W.mjs +0 -221
- package/src/cli.bundle.ts +0 -20
|
@@ -10,6 +10,12 @@ export interface BareArbitraryValueResolveResult {
|
|
|
10
10
|
canonicalCandidate: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface BareArbitraryValueSourceCandidate {
|
|
14
|
+
rawCandidate: string
|
|
15
|
+
start: number
|
|
16
|
+
end: number
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
|
|
14
20
|
'%',
|
|
15
21
|
'px',
|
|
@@ -41,6 +47,8 @@ const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
|
|
|
41
47
|
const NUMBER_RE = /^-?(?:\d+|\d*\.\d+)$/
|
|
42
48
|
const FUNCTION_VALUE_RE = /^[a-z_-][\w-]*\(/i
|
|
43
49
|
const HEX_ESCAPE_RE = /^[\da-f]$/i
|
|
50
|
+
const ASPECT_RATIO_RE = /^\d+\/\d+$/
|
|
51
|
+
const ESCAPED_WHITESPACE_RE = /\\[nrt]/g
|
|
44
52
|
|
|
45
53
|
function splitVariantPrefix(candidate: string) {
|
|
46
54
|
let depth = 0
|
|
@@ -221,6 +229,10 @@ function normalizeBareArbitraryValueOptions(options: boolean | BareArbitraryValu
|
|
|
221
229
|
}
|
|
222
230
|
}
|
|
223
231
|
|
|
232
|
+
export function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined) {
|
|
233
|
+
return normalizeBareArbitraryValueOptions(options) !== undefined
|
|
234
|
+
}
|
|
235
|
+
|
|
224
236
|
function normalizeEscapedValue(value: string) {
|
|
225
237
|
let result = ''
|
|
226
238
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -276,13 +288,17 @@ function resolveValueWithUnit(body: string, units: string[]) {
|
|
|
276
288
|
}
|
|
277
289
|
}
|
|
278
290
|
|
|
279
|
-
function resolveArbitraryValue(body: string, units: string[]) {
|
|
291
|
+
function resolveArbitraryValue(utility: string, body: string, units: string[]) {
|
|
280
292
|
const value = normalizeEscapedValue(body)
|
|
281
293
|
const withUnit = resolveValueWithUnit(value, units)
|
|
282
294
|
if (withUnit) {
|
|
283
295
|
return withUnit
|
|
284
296
|
}
|
|
285
297
|
|
|
298
|
+
if (utility === 'aspect' && ASPECT_RATIO_RE.test(value)) {
|
|
299
|
+
return value
|
|
300
|
+
}
|
|
301
|
+
|
|
286
302
|
if (isHexColorValue(value)) {
|
|
287
303
|
return value
|
|
288
304
|
}
|
|
@@ -292,6 +308,9 @@ function resolveArbitraryValue(body: string, units: string[]) {
|
|
|
292
308
|
}
|
|
293
309
|
|
|
294
310
|
if (FUNCTION_VALUE_RE.test(value) && value.endsWith(')') && isBalancedFunctionValue(value)) {
|
|
311
|
+
if (utility === 'text' && /^var\(/i.test(value)) {
|
|
312
|
+
return `color:${value}`
|
|
313
|
+
}
|
|
295
314
|
return value
|
|
296
315
|
}
|
|
297
316
|
}
|
|
@@ -339,7 +358,7 @@ function resolveUtilityAndValue(body: string, units: string[]) {
|
|
|
339
358
|
continue
|
|
340
359
|
}
|
|
341
360
|
|
|
342
|
-
const value = resolveArbitraryValue(rawValue, units)
|
|
361
|
+
const value = resolveArbitraryValue(utility, rawValue, units)
|
|
343
362
|
if (value) {
|
|
344
363
|
return {
|
|
345
364
|
utility,
|
|
@@ -380,6 +399,112 @@ export function resolveBareArbitraryValueCandidate(
|
|
|
380
399
|
}
|
|
381
400
|
}
|
|
382
401
|
|
|
402
|
+
function isBareArbitrarySourceSplitter(char: string) {
|
|
403
|
+
return /\s/.test(char)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function isQuoteBoundary(content: string, start: number, index: number) {
|
|
407
|
+
const tokenPrefix = content.slice(start, index)
|
|
408
|
+
return tokenPrefix.length === 0 || !tokenPrefix.endsWith('-')
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function trimBareArbitrarySourceToken(token: string, start: number) {
|
|
412
|
+
let nextToken = token
|
|
413
|
+
let nextStart = start
|
|
414
|
+
while (nextToken.length > 0 && /^[<{([]$/.test(nextToken[0]!)) {
|
|
415
|
+
nextToken = nextToken.slice(1)
|
|
416
|
+
nextStart++
|
|
417
|
+
}
|
|
418
|
+
while (nextToken.length > 0 && /^[>\],;]$/.test(nextToken[nextToken.length - 1]!)) {
|
|
419
|
+
nextToken = nextToken.slice(0, -1)
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
token: nextToken,
|
|
423
|
+
start: nextStart,
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function pushBareArbitrarySourceCandidate(
|
|
428
|
+
result: BareArbitraryValueSourceCandidate[],
|
|
429
|
+
token: string,
|
|
430
|
+
start: number,
|
|
431
|
+
options: boolean | BareArbitraryValueOptions | undefined,
|
|
432
|
+
) {
|
|
433
|
+
const trimmed = trimBareArbitrarySourceToken(token, start)
|
|
434
|
+
if (!trimmed.token || trimmed.token.includes('=') || trimmed.token.includes('[') || trimmed.token.includes(']')) {
|
|
435
|
+
return
|
|
436
|
+
}
|
|
437
|
+
if (!resolveBareArbitraryValueCandidate(trimmed.token, options)) {
|
|
438
|
+
return
|
|
439
|
+
}
|
|
440
|
+
result.push({
|
|
441
|
+
rawCandidate: trimmed.token,
|
|
442
|
+
start: trimmed.start,
|
|
443
|
+
end: trimmed.start + trimmed.token.length,
|
|
444
|
+
})
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export function extractBareArbitraryValueSourceCandidatesWithPositions(
|
|
448
|
+
content: string,
|
|
449
|
+
options?: boolean | BareArbitraryValueOptions,
|
|
450
|
+
): BareArbitraryValueSourceCandidate[] {
|
|
451
|
+
if (!isBareArbitraryValuesEnabled(options)) {
|
|
452
|
+
return []
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const normalized = content.includes('\\') ? content.replace(ESCAPED_WHITESPACE_RE, ' ') : content
|
|
456
|
+
const result: BareArbitraryValueSourceCandidate[] = []
|
|
457
|
+
let depth = 0
|
|
458
|
+
let quote: string | undefined
|
|
459
|
+
let start = 0
|
|
460
|
+
|
|
461
|
+
for (let index = 0; index < normalized.length; index++) {
|
|
462
|
+
const char = normalized[index]
|
|
463
|
+
if (char === undefined) {
|
|
464
|
+
continue
|
|
465
|
+
}
|
|
466
|
+
if (char === '\\') {
|
|
467
|
+
index++
|
|
468
|
+
continue
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (quote) {
|
|
472
|
+
if (char === quote) {
|
|
473
|
+
quote = undefined
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
else if ((char === '"' || char === '\'' || char === '`') && !isQuoteBoundary(normalized, start, index)) {
|
|
477
|
+
quote = char
|
|
478
|
+
}
|
|
479
|
+
else if (char === '(' || char === '{' || char === '[') {
|
|
480
|
+
depth++
|
|
481
|
+
}
|
|
482
|
+
else if (char === ')' || char === '}' || char === ']') {
|
|
483
|
+
depth = Math.max(0, depth - 1)
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (!isBareArbitrarySourceSplitter(char) && !((char === '"' || char === '\'' || char === '`') && depth === 0 && isQuoteBoundary(normalized, start, index))) {
|
|
487
|
+
continue
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
pushBareArbitrarySourceCandidate(result, normalized.slice(start, index), start, options)
|
|
491
|
+
start = index + 1
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
pushBareArbitrarySourceCandidate(result, normalized.slice(start), start, options)
|
|
495
|
+
return result
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export function extractBareArbitraryValueSourceCandidates(
|
|
499
|
+
content: string,
|
|
500
|
+
options?: boolean | BareArbitraryValueOptions,
|
|
501
|
+
) {
|
|
502
|
+
return [...new Set(
|
|
503
|
+
extractBareArbitraryValueSourceCandidatesWithPositions(content, options)
|
|
504
|
+
.map(candidate => candidate.rawCandidate),
|
|
505
|
+
)]
|
|
506
|
+
}
|
|
507
|
+
|
|
383
508
|
// Based on the CSS.escape algorithm, scoped to class selector escaping.
|
|
384
509
|
export function escapeCssClassName(value: string) {
|
|
385
510
|
let result = ''
|
package/src/v4/engine.ts
CHANGED
|
@@ -37,13 +37,16 @@ async function collectRawCandidates(
|
|
|
37
37
|
compiledSources: TailwindV4SourcePattern[] = [],
|
|
38
38
|
) {
|
|
39
39
|
const rawCandidates = new Set<string>()
|
|
40
|
+
const extractOptions = options?.bareArbitraryValues === undefined
|
|
41
|
+
? undefined
|
|
42
|
+
: { bareArbitraryValues: options.bareArbitraryValues }
|
|
40
43
|
|
|
41
44
|
for (const candidate of options?.candidates ?? []) {
|
|
42
45
|
rawCandidates.add(candidate)
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
for (const candidateSource of options?.sources ?? []) {
|
|
46
|
-
const candidates = await extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension)
|
|
49
|
+
const candidates = await extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension, extractOptions)
|
|
47
50
|
for (const candidate of candidates) {
|
|
48
51
|
rawCandidates.add(candidate.rawCandidate)
|
|
49
52
|
}
|
|
@@ -51,7 +54,7 @@ async function collectRawCandidates(
|
|
|
51
54
|
|
|
52
55
|
const filesystemSources = resolveScanSources(options, source, compiledRoot, compiledSources)
|
|
53
56
|
if (filesystemSources.length > 0) {
|
|
54
|
-
for (const candidate of await extractRawCandidates(filesystemSources)) {
|
|
57
|
+
for (const candidate of await extractRawCandidates(filesystemSources, extractOptions)) {
|
|
55
58
|
rawCandidates.add(candidate)
|
|
56
59
|
}
|
|
57
60
|
}
|
package/src/v4/index.ts
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
export {
|
|
2
|
+
canonicalizeBareArbitraryValueCandidates,
|
|
2
3
|
extractTailwindV4InlineSourceCandidates,
|
|
4
|
+
replaceBareArbitraryValueSelectors,
|
|
3
5
|
resolveValidTailwindV4Candidates,
|
|
4
6
|
} from './candidates'
|
|
7
|
+
export {
|
|
8
|
+
escapeCssClassName,
|
|
9
|
+
extractBareArbitraryValueSourceCandidates,
|
|
10
|
+
extractBareArbitraryValueSourceCandidatesWithPositions,
|
|
11
|
+
isBareArbitraryValuesEnabled,
|
|
12
|
+
resolveBareArbitraryValueCandidate,
|
|
13
|
+
} from './bare-arbitrary-values'
|
|
5
14
|
export { createTailwindV4Engine } from './engine'
|
|
6
15
|
export {
|
|
7
16
|
compileTailwindV4Source,
|
|
8
17
|
loadTailwindV4DesignSystem,
|
|
9
18
|
loadTailwindV4NodeModule,
|
|
10
19
|
} from './node-adapter'
|
|
20
|
+
export {
|
|
21
|
+
resolveTailwindV4Source,
|
|
22
|
+
resolveTailwindV4SourceFromPatchOptions,
|
|
23
|
+
tailwindV4SourceOptionsFromPatchOptions,
|
|
24
|
+
} from './source'
|
|
11
25
|
export {
|
|
12
26
|
createTailwindV4CompiledSourceEntries,
|
|
13
27
|
createTailwindV4DefaultIgnoreSources,
|
|
@@ -29,11 +43,6 @@ export {
|
|
|
29
43
|
TAILWIND_V4_IGNORED_EXTENSIONS,
|
|
30
44
|
TAILWIND_V4_IGNORED_FILES,
|
|
31
45
|
} from './source-scan'
|
|
32
|
-
export {
|
|
33
|
-
resolveTailwindV4Source,
|
|
34
|
-
resolveTailwindV4SourceFromPatchOptions,
|
|
35
|
-
tailwindV4SourceOptionsFromPatchOptions,
|
|
36
|
-
} from './source'
|
|
37
46
|
export type {
|
|
38
47
|
TailwindV4CandidateSource,
|
|
39
48
|
TailwindV4CompiledSourceRoot,
|
package/src/v4/node-adapter.ts
CHANGED
package/src/v4/source-scan.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { TailwindV4CompiledSourceRoot, TailwindV4SourcePattern } from './ty
|
|
|
3
3
|
import { realpathSync } from 'node:fs'
|
|
4
4
|
import { stat } from 'node:fs/promises'
|
|
5
5
|
import process from 'node:process'
|
|
6
|
-
import path from 'pathe'
|
|
7
6
|
import micromatch from 'micromatch'
|
|
7
|
+
import path from 'pathe'
|
|
8
8
|
|
|
9
9
|
export const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
|
|
10
10
|
'.git',
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-D9fDrE9I.js");
|
|
3
|
-
let node_module = require("node:module");
|
|
4
|
-
let node_process = require("node:process");
|
|
5
|
-
node_process = require_chunk.__toESM(node_process);
|
|
6
|
-
let pathe = require("pathe");
|
|
7
|
-
pathe = require_chunk.__toESM(pathe);
|
|
8
|
-
let node_fs = require("node:fs");
|
|
9
|
-
//#region src/v4/engine.ts
|
|
10
|
-
function resolveScanSources(options, source, compiledRoot, compiledSources) {
|
|
11
|
-
if (Array.isArray(options?.scanSources)) return options.scanSources;
|
|
12
|
-
if (options?.scanSources === true) return require_validate.createTailwindV4CompiledSourceEntries(compiledRoot, compiledSources, source.base);
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
async function collectRawCandidates(source, options, compiledRoot, compiledSources = []) {
|
|
16
|
-
const rawCandidates = /* @__PURE__ */ new Set();
|
|
17
|
-
for (const candidate of options?.candidates ?? []) rawCandidates.add(candidate);
|
|
18
|
-
for (const candidateSource of options?.sources ?? []) {
|
|
19
|
-
const candidates = await require_validate.extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension);
|
|
20
|
-
for (const candidate of candidates) rawCandidates.add(candidate.rawCandidate);
|
|
21
|
-
}
|
|
22
|
-
const filesystemSources = resolveScanSources(options, source, compiledRoot, compiledSources);
|
|
23
|
-
if (filesystemSources.length > 0) for (const candidate of await require_validate.extractRawCandidates(filesystemSources)) rawCandidates.add(candidate);
|
|
24
|
-
const inlineSources = require_validate.extractTailwindV4InlineSourceCandidates(source.css);
|
|
25
|
-
for (const candidate of inlineSources.included) rawCandidates.add(candidate);
|
|
26
|
-
for (const candidate of inlineSources.excluded) rawCandidates.delete(candidate);
|
|
27
|
-
return rawCandidates;
|
|
28
|
-
}
|
|
29
|
-
function createTailwindV4Engine(source) {
|
|
30
|
-
return {
|
|
31
|
-
source,
|
|
32
|
-
loadDesignSystem() {
|
|
33
|
-
return require_validate.loadTailwindV4DesignSystem(source);
|
|
34
|
-
},
|
|
35
|
-
async validateCandidates(candidates) {
|
|
36
|
-
return require_validate.resolveValidTailwindV4Candidates(await require_validate.loadTailwindV4DesignSystem(source), candidates);
|
|
37
|
-
},
|
|
38
|
-
async generate(options) {
|
|
39
|
-
const { compiled, dependencies } = await require_validate.compileTailwindV4Source(source);
|
|
40
|
-
const rawCandidates = await collectRawCandidates(source, options, compiled.root, compiled.sources);
|
|
41
|
-
const classSet = require_validate.resolveValidTailwindV4Candidates(await require_validate.loadTailwindV4DesignSystem(source), rawCandidates, { ...options?.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
42
|
-
const inlineSources = require_validate.extractTailwindV4InlineSourceCandidates(source.css);
|
|
43
|
-
for (const candidate of inlineSources.excluded) classSet.delete(candidate);
|
|
44
|
-
const buildCandidates = require_validate.canonicalizeBareArbitraryValueCandidates(classSet, options?.bareArbitraryValues);
|
|
45
|
-
return {
|
|
46
|
-
css: require_validate.replaceBareArbitraryValueSelectors(compiled.build(buildCandidates), classSet, options?.bareArbitraryValues),
|
|
47
|
-
classSet,
|
|
48
|
-
rawCandidates,
|
|
49
|
-
dependencies: Array.from(dependencies),
|
|
50
|
-
sources: compiled.sources,
|
|
51
|
-
root: compiled.root
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/v4/source.ts
|
|
58
|
-
function resolveBase(value, fallback) {
|
|
59
|
-
return value === void 0 ? fallback : pathe.default.isAbsolute(value) ? pathe.default.resolve(value) : pathe.default.resolve(fallback, value);
|
|
60
|
-
}
|
|
61
|
-
function uniquePaths(values) {
|
|
62
|
-
const result = [];
|
|
63
|
-
for (const value of values) {
|
|
64
|
-
if (!value) continue;
|
|
65
|
-
const resolved = pathe.default.resolve(value);
|
|
66
|
-
if (!result.includes(resolved)) result.push(resolved);
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
function toCssImportPath(value) {
|
|
71
|
-
return value.replaceAll("\\", "/");
|
|
72
|
-
}
|
|
73
|
-
function quoteCssImport(value) {
|
|
74
|
-
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
75
|
-
}
|
|
76
|
-
function isPostcssPluginSpecifier(packageName) {
|
|
77
|
-
return packageName === "@tailwindcss/postcss" || /(?:^|[/\\])@tailwindcss[/\\]postcss(?:[/\\]|$)/.test(packageName) || /(?:^|[/\\])postcss(?:[/\\]|$)/i.test(packageName) || /postcss\.config\.[cm]?[jt]s$/i.test(packageName);
|
|
78
|
-
}
|
|
79
|
-
function createDefaultCss(packageName) {
|
|
80
|
-
return `@import "${quoteCssImport(toCssImportPath(packageName && !isPostcssPluginSpecifier(packageName) ? packageName : "tailwindcss"))}";`;
|
|
81
|
-
}
|
|
82
|
-
async function pathExists(filePath) {
|
|
83
|
-
try {
|
|
84
|
-
await node_fs.promises.access(filePath);
|
|
85
|
-
return true;
|
|
86
|
-
} catch {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async function resolveCssEntries(entries, projectRoot, base) {
|
|
91
|
-
const resolvedEntries = entries.map((entry) => ({
|
|
92
|
-
original: entry,
|
|
93
|
-
absolute: pathe.default.isAbsolute(entry) ? pathe.default.resolve(entry) : pathe.default.resolve(projectRoot, entry)
|
|
94
|
-
}));
|
|
95
|
-
const resolvedBase = base ?? pathe.default.dirname(resolvedEntries[0]?.absolute ?? projectRoot);
|
|
96
|
-
const dependencies = resolvedEntries.map((entry) => entry.absolute);
|
|
97
|
-
const cssParts = [];
|
|
98
|
-
for (const entry of resolvedEntries) {
|
|
99
|
-
if (await pathExists(entry.absolute)) {
|
|
100
|
-
cssParts.push(await node_fs.promises.readFile(entry.absolute, "utf8"));
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const importPath = pathe.default.isAbsolute(entry.original) ? entry.absolute : pathe.default.relative(resolvedBase, entry.absolute);
|
|
104
|
-
cssParts.push(`@import "${quoteCssImport(toCssImportPath(importPath))}";`);
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
base: resolvedBase,
|
|
108
|
-
css: cssParts.join("\n"),
|
|
109
|
-
dependencies
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function resolveCssSources(sources, projectRoot, base) {
|
|
113
|
-
const resolvedSources = sources.map((source) => ({
|
|
114
|
-
...source,
|
|
115
|
-
base: source.base === void 0 ? void 0 : resolveBase(source.base, projectRoot),
|
|
116
|
-
file: source.file === void 0 ? void 0 : pathe.default.isAbsolute(source.file) ? pathe.default.resolve(source.file) : pathe.default.resolve(projectRoot, source.file),
|
|
117
|
-
dependencies: source.dependencies?.map((dependency) => pathe.default.isAbsolute(dependency) ? pathe.default.resolve(dependency) : pathe.default.resolve(projectRoot, dependency)) ?? []
|
|
118
|
-
}));
|
|
119
|
-
const firstSource = resolvedSources[0];
|
|
120
|
-
const resolvedBase = base ?? firstSource?.base ?? (firstSource?.file ? pathe.default.dirname(firstSource.file) : projectRoot);
|
|
121
|
-
const dependencies = resolvedSources.flatMap((source) => [source.file, ...source.dependencies]).filter((dependency) => Boolean(dependency));
|
|
122
|
-
return {
|
|
123
|
-
base: resolvedBase,
|
|
124
|
-
css: resolvedSources.map((source) => source.css).join("\n"),
|
|
125
|
-
dependencies
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function normalizeResolvedSource(source) {
|
|
129
|
-
const baseFallbacks = uniquePaths([
|
|
130
|
-
...source.baseFallbacks,
|
|
131
|
-
source.projectRoot,
|
|
132
|
-
source.cwd
|
|
133
|
-
]).filter((base) => base !== source.base);
|
|
134
|
-
return {
|
|
135
|
-
projectRoot: source.projectRoot,
|
|
136
|
-
base: source.base,
|
|
137
|
-
baseFallbacks,
|
|
138
|
-
css: source.css,
|
|
139
|
-
dependencies: Array.from(new Set(source.dependencies.map((dependency) => pathe.default.resolve(dependency))))
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
async function resolveTailwindV4Source(options = {}) {
|
|
143
|
-
const projectRoot = resolveBase(options.projectRoot, node_process.default.cwd());
|
|
144
|
-
const cwd = resolveBase(options.cwd, projectRoot);
|
|
145
|
-
const configuredBase = options.base === void 0 ? void 0 : resolveBase(options.base, projectRoot);
|
|
146
|
-
const baseFallbacks = uniquePaths(options.baseFallbacks?.map((base) => resolveBase(base, projectRoot)) ?? []);
|
|
147
|
-
if (options.css !== void 0) return normalizeResolvedSource({
|
|
148
|
-
projectRoot,
|
|
149
|
-
cwd,
|
|
150
|
-
base: configuredBase ?? cwd,
|
|
151
|
-
baseFallbacks,
|
|
152
|
-
css: options.css,
|
|
153
|
-
dependencies: []
|
|
154
|
-
});
|
|
155
|
-
if (options.cssEntries?.length || options.cssSources?.length) {
|
|
156
|
-
const entries = options.cssEntries?.length ? await resolveCssEntries(options.cssEntries, projectRoot, configuredBase) : void 0;
|
|
157
|
-
const sources = options.cssSources?.length ? resolveCssSources(options.cssSources, projectRoot, configuredBase) : void 0;
|
|
158
|
-
const css = [entries?.css, sources?.css].filter(Boolean).join("\n");
|
|
159
|
-
return normalizeResolvedSource({
|
|
160
|
-
projectRoot,
|
|
161
|
-
cwd,
|
|
162
|
-
base: configuredBase ?? entries?.base ?? sources?.base ?? cwd,
|
|
163
|
-
baseFallbacks,
|
|
164
|
-
css,
|
|
165
|
-
dependencies: [...entries?.dependencies ?? [], ...sources?.dependencies ?? []]
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return normalizeResolvedSource({
|
|
169
|
-
projectRoot,
|
|
170
|
-
cwd,
|
|
171
|
-
base: configuredBase ?? cwd,
|
|
172
|
-
baseFallbacks,
|
|
173
|
-
css: createDefaultCss(options.packageName),
|
|
174
|
-
dependencies: []
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function resolveConfigDir(config, projectRoot) {
|
|
178
|
-
if (!config) return;
|
|
179
|
-
const configPath = pathe.default.isAbsolute(config) ? config : pathe.default.resolve(projectRoot, config);
|
|
180
|
-
return pathe.default.dirname(configPath);
|
|
181
|
-
}
|
|
182
|
-
function createSourceOptionsFromNormalizedPatchOptions(options) {
|
|
183
|
-
const v4 = options.tailwind.v4;
|
|
184
|
-
const configDir = resolveConfigDir(options.tailwind.config, options.projectRoot);
|
|
185
|
-
const baseFallbacks = uniquePaths([
|
|
186
|
-
v4?.configuredBase,
|
|
187
|
-
options.tailwind.cwd,
|
|
188
|
-
options.projectRoot,
|
|
189
|
-
configDir
|
|
190
|
-
]);
|
|
191
|
-
return {
|
|
192
|
-
projectRoot: options.projectRoot,
|
|
193
|
-
...options.tailwind.cwd === void 0 ? {} : { cwd: options.tailwind.cwd },
|
|
194
|
-
...v4?.configuredBase === void 0 ? {} : { base: v4.configuredBase },
|
|
195
|
-
baseFallbacks,
|
|
196
|
-
...v4?.css === void 0 ? {} : { css: v4.css },
|
|
197
|
-
...v4?.cssSources === void 0 ? {} : { cssSources: v4.cssSources },
|
|
198
|
-
...v4?.cssEntries === void 0 ? {} : { cssEntries: v4.cssEntries },
|
|
199
|
-
packageName: options.tailwind.packageName
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function tailwindV4SourceOptionsFromPatchOptions(options) {
|
|
203
|
-
return createSourceOptionsFromNormalizedPatchOptions(require_validate.normalizeOptions(options));
|
|
204
|
-
}
|
|
205
|
-
async function resolveTailwindV4SourceFromPatchOptions(options) {
|
|
206
|
-
return resolveTailwindV4Source(tailwindV4SourceOptionsFromPatchOptions(options));
|
|
207
|
-
}
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region src/index.bundle.ts
|
|
210
|
-
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
211
|
-
function loadCliModule() {
|
|
212
|
-
return require$1("./commands/cli-runtime.js");
|
|
213
|
-
}
|
|
214
|
-
function mountTailwindcssPatchCommands(cli, options = {}) {
|
|
215
|
-
return loadCliModule().mountTailwindcssPatchCommands(cli, options);
|
|
216
|
-
}
|
|
217
|
-
function createTailwindcssPatchCli(options = {}) {
|
|
218
|
-
return loadCliModule().createTailwindcssPatchCli(options);
|
|
219
|
-
}
|
|
220
|
-
function defineConfig(config) {
|
|
221
|
-
return config;
|
|
222
|
-
}
|
|
223
|
-
//#endregion
|
|
224
|
-
Object.defineProperty(exports, "createTailwindV4Engine", {
|
|
225
|
-
enumerable: true,
|
|
226
|
-
get: function() {
|
|
227
|
-
return createTailwindV4Engine;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
Object.defineProperty(exports, "createTailwindcssPatchCli", {
|
|
231
|
-
enumerable: true,
|
|
232
|
-
get: function() {
|
|
233
|
-
return createTailwindcssPatchCli;
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
Object.defineProperty(exports, "defineConfig", {
|
|
237
|
-
enumerable: true,
|
|
238
|
-
get: function() {
|
|
239
|
-
return defineConfig;
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
Object.defineProperty(exports, "mountTailwindcssPatchCommands", {
|
|
243
|
-
enumerable: true,
|
|
244
|
-
get: function() {
|
|
245
|
-
return mountTailwindcssPatchCommands;
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
Object.defineProperty(exports, "resolveTailwindV4Source", {
|
|
249
|
-
enumerable: true,
|
|
250
|
-
get: function() {
|
|
251
|
-
return resolveTailwindV4Source;
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
Object.defineProperty(exports, "resolveTailwindV4SourceFromPatchOptions", {
|
|
255
|
-
enumerable: true,
|
|
256
|
-
get: function() {
|
|
257
|
-
return resolveTailwindV4SourceFromPatchOptions;
|
|
258
|
-
}
|
|
259
|
-
});
|