weapp-tailwindcss 5.1.3 → 5.1.5
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/auto-CrJJc5rK.mjs +13 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -10
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +1 -1
- package/dist/bundlers/vite/hot-css-modules.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -1
- package/dist/cli.js +18 -3
- package/dist/cli.mjs +16 -1
- package/dist/{context-D75pwtBW.js → context-BziwyWy1.js} +56 -9
- package/dist/{context-B07Vf584.mjs → context-rrYZuUBU.mjs} +48 -7
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro/index.d.ts +2 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-BhE26nSw.mjs → defaults-9B6aMyZb.mjs} +2 -2
- package/dist/{defaults-DQhgnnn-.js → defaults-nsf4VNMX.js} +2 -2
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/framework/platform.d.ts +2 -0
- package/dist/{generator-DNs6ekoC.mjs → generator-24-HgU9F.mjs} +5 -3
- package/dist/{generator-CV_0irKO.js → generator-CilgHtxb.js} +5 -3
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B_u8NjQL.js → gulp-CuVsZdO9.js} +7 -6
- package/dist/{gulp-aQMZ0M7c.mjs → gulp-ygWfmOqh.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DOoHun3i.js → hmr-timing-BKdCeIrn.js} +244 -229
- package/dist/{hmr-timing-DLYQTCDb.mjs → hmr-timing-Dh_nn3w5.mjs} +244 -211
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/js-string-escape.d.ts +1 -0
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-pS87mdHZ.mjs → source-candidate-scan-signature-DATRnS1X.mjs} +165 -8
- package/dist/{source-candidate-scan-signature-DzwebZrf.js → source-candidate-scan-signature-DIj9m4wB.js} +177 -7
- package/dist/style-injector/internal.d.ts +7 -0
- package/dist/style-injector/options.d.ts +25 -0
- package/dist/tailwindcss/v4/preflight.d.ts +4 -0
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
- package/dist/{tailwindcss-BSCvrs1p.js → tailwindcss-BwoNQ3t8.js} +56 -16
- package/dist/{tailwindcss-BwV3_Ryc.mjs → tailwindcss-C-uM4rB8.mjs} +51 -17
- package/dist/{transform-Clj7R818.mjs → transform-DHLemtaX.mjs} +1 -1
- package/dist/{transform-fin-OTVD.js → transform-KLD1tJdb.js} +1 -1
- package/dist/typedoc.export.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/user-defined-options/general.d.ts +2 -0
- package/dist/{v4-engine-BklH3CpJ.mjs → v4-engine-BuuYDXt1.mjs} +54 -114
- package/dist/{v4-engine-CKbS27-o.js → v4-engine-CKtsdKxK.js} +57 -111
- package/dist/{vite-CkVMSDDp.js → vite-Yp14HNyS.js} +310 -78
- package/dist/{vite-5Wn0PIzJ.mjs → vite-cH0tTMHc.mjs} +308 -76
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +363 -272
- package/dist/{webpack-DEag6ueE.mjs → webpack-DBhmJ-_P.mjs} +107 -20
- package/dist/{webpack-hvSFaicc.js → webpack-DN3tgLbF.js} +107 -20
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +16 -5
- package/dist/auto-Ba6hDrse.mjs +0 -13
|
@@ -26,7 +26,6 @@ let _babel_traverse = require("@babel/traverse");
|
|
|
26
26
|
_babel_traverse = require_watch_dependencies.__toESM(_babel_traverse);
|
|
27
27
|
let _babel_parser = require("@babel/parser");
|
|
28
28
|
require("@babel/types");
|
|
29
|
-
let _ast_core_escape = require("@ast-core/escape");
|
|
30
29
|
let debug = require("debug");
|
|
31
30
|
debug = require_watch_dependencies.__toESM(debug);
|
|
32
31
|
require("fast-glob");
|
|
@@ -151,14 +150,14 @@ function parseConfigRequest$1(params) {
|
|
|
151
150
|
function isPackageJsonImportRequest$2(request) {
|
|
152
151
|
return typeof request === "string" && request.startsWith("#");
|
|
153
152
|
}
|
|
154
|
-
function isWeappTailwindcssImportRequest
|
|
153
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
155
154
|
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
156
155
|
}
|
|
157
156
|
function isTailwindImportRequest$1(request) {
|
|
158
157
|
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
159
158
|
}
|
|
160
159
|
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
161
|
-
if (options.importFallback && isWeappTailwindcssImportRequest
|
|
160
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
162
161
|
return request;
|
|
163
162
|
}
|
|
164
163
|
function replaceImportRequest$1(params, request, replacement) {
|
|
@@ -170,7 +169,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
170
169
|
const trimmed = line.trimStart();
|
|
171
170
|
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
172
171
|
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
173
|
-
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest
|
|
172
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
174
173
|
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
175
174
|
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
176
175
|
}
|
|
@@ -178,7 +177,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
178
177
|
}
|
|
179
178
|
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
180
179
|
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
181
|
-
if (!request || !isWeappTailwindcssImportRequest
|
|
180
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
182
181
|
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
183
182
|
}
|
|
184
183
|
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
@@ -310,32 +309,18 @@ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
|
310
309
|
"utility",
|
|
311
310
|
"variant"
|
|
312
311
|
]);
|
|
313
|
-
const TAILWIND_ROOT_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
314
|
-
"config",
|
|
315
|
-
"custom-variant",
|
|
316
|
-
"plugin",
|
|
317
|
-
"source",
|
|
318
|
-
"tailwind",
|
|
319
|
-
"theme",
|
|
320
|
-
"utility",
|
|
321
|
-
"variant"
|
|
322
|
-
]);
|
|
323
312
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
324
313
|
function parseImportRequest(params) {
|
|
325
|
-
return
|
|
314
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(params);
|
|
326
315
|
}
|
|
327
316
|
function parseConfigRequest(params) {
|
|
328
|
-
return
|
|
317
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssConfigRequest)(params);
|
|
329
318
|
}
|
|
330
319
|
function isPackageJsonImportRequest$1(request) {
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
function isWeappTailwindcssImportRequest(request) {
|
|
334
|
-
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
320
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssPackageJsonImportRequest)(request);
|
|
335
321
|
}
|
|
336
322
|
function normalizeTailwindImportRequest(request, options = {}) {
|
|
337
|
-
|
|
338
|
-
return request;
|
|
323
|
+
return (0, _weapp_tailwindcss_postcss.normalizeTailwindCssImportRequest)(request, options);
|
|
339
324
|
}
|
|
340
325
|
function replaceImportRequest(params, request, replacement) {
|
|
341
326
|
const index = params.indexOf(request);
|
|
@@ -391,12 +376,11 @@ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
391
376
|
}
|
|
392
377
|
}
|
|
393
378
|
function isTailwindImportRequest(request) {
|
|
394
|
-
|
|
379
|
+
const normalized = normalizeTailwindImportRequest(request);
|
|
380
|
+
return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
|
|
395
381
|
}
|
|
396
382
|
function isTailwindImportAtRule(node, options = {}) {
|
|
397
|
-
|
|
398
|
-
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
399
|
-
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
383
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssImportAtRule)(node, options);
|
|
400
384
|
}
|
|
401
385
|
function isTailwindSourceDirective(node, options = {}) {
|
|
402
386
|
if (node.type !== "atrule") return false;
|
|
@@ -410,10 +394,18 @@ function hasGeneratedCssArtifacts(rawSource) {
|
|
|
410
394
|
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
411
395
|
}
|
|
412
396
|
function isTailwindGenerationDirective(node, options = {}) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
397
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssGenerationDirective)(node, options);
|
|
398
|
+
}
|
|
399
|
+
function analyzeParseableTailwindDirectives(rawSource, options = {}) {
|
|
400
|
+
try {
|
|
401
|
+
const ignoreLayer = options.ignoreLayer ?? hasGeneratedCssArtifacts(rawSource);
|
|
402
|
+
return (0, _weapp_tailwindcss_postcss.analyzeTailwindCssDirectives)(_weapp_tailwindcss_postcss.postcss.parse(rawSource), {
|
|
403
|
+
...options,
|
|
404
|
+
ignoreLayer
|
|
405
|
+
});
|
|
406
|
+
} catch {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
417
409
|
}
|
|
418
410
|
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
419
411
|
try {
|
|
@@ -433,56 +425,19 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
433
425
|
}
|
|
434
426
|
}
|
|
435
427
|
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
439
|
-
let found = false;
|
|
440
|
-
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
441
|
-
root.walk((node) => {
|
|
442
|
-
if (isTailwindGenerationDirective(node, {
|
|
443
|
-
...options,
|
|
444
|
-
ignoreLayer
|
|
445
|
-
})) {
|
|
446
|
-
found = true;
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
return found;
|
|
451
|
-
} catch {
|
|
452
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
453
|
-
}
|
|
428
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
429
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindSourceDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
454
430
|
}
|
|
455
431
|
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
456
432
|
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
457
|
-
|
|
458
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
459
|
-
let found = false;
|
|
460
|
-
root.walkAtRules((node) => {
|
|
461
|
-
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
462
|
-
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest$1(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
463
|
-
found = true;
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
return found;
|
|
468
|
-
} catch {
|
|
469
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
470
|
-
}
|
|
433
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindRootDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
471
434
|
}
|
|
472
435
|
function hasTailwindApplyDirective(rawSource) {
|
|
473
436
|
if (!rawSource.includes("@apply")) return false;
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
found = true;
|
|
479
|
-
return false;
|
|
480
|
-
});
|
|
481
|
-
return found;
|
|
482
|
-
} catch {
|
|
483
|
-
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
484
|
-
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
485
|
-
}
|
|
437
|
+
const analysis = analyzeParseableTailwindDirectives(rawSource);
|
|
438
|
+
if (analysis) return analysis.hasTailwindApplyDirective;
|
|
439
|
+
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
440
|
+
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
486
441
|
}
|
|
487
442
|
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
488
443
|
try {
|
|
@@ -598,6 +553,15 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
598
553
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
599
554
|
}
|
|
600
555
|
//#endregion
|
|
556
|
+
//#region src/tailwindcss/v4-engine/css-macro-source.ts
|
|
557
|
+
function resolveCssMacroTailwindV4Source(source) {
|
|
558
|
+
const css = (0, _weapp_tailwindcss_postcss.transformCssMacroTailwindV4Source)(source.css);
|
|
559
|
+
return css === source.css ? source : {
|
|
560
|
+
...source,
|
|
561
|
+
css
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
//#endregion
|
|
601
565
|
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
602
566
|
const TAILWIND_V4_COLOR_STEPS = [
|
|
603
567
|
"50",
|
|
@@ -1461,7 +1425,7 @@ function parseCssImportSpecifier$2(params) {
|
|
|
1461
1425
|
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1462
1426
|
return url?.[2] ?? url?.[3];
|
|
1463
1427
|
}
|
|
1464
|
-
function isTailwindCssImport
|
|
1428
|
+
function isTailwindCssImport(params) {
|
|
1465
1429
|
const specifier = parseCssImportSpecifier$2(params);
|
|
1466
1430
|
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1467
1431
|
}
|
|
@@ -1498,7 +1462,7 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1498
1462
|
}
|
|
1499
1463
|
root.walkAtRules((rule) => {
|
|
1500
1464
|
if (rule.name === "import") {
|
|
1501
|
-
if (!isTailwindCssImport
|
|
1465
|
+
if (!isTailwindCssImport(rule.params)) return;
|
|
1502
1466
|
hasTailwindImport = true;
|
|
1503
1467
|
const sourceParam = parseImportSourceParam$1(rule.params);
|
|
1504
1468
|
if (sourceParam?.none) hasSourceNone = true;
|
|
@@ -1662,7 +1626,7 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
1662
1626
|
};
|
|
1663
1627
|
}
|
|
1664
1628
|
function resolveStyleOptions(source, options) {
|
|
1665
|
-
return (0, _weapp_tailwindcss_postcss.
|
|
1629
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Source)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
1666
1630
|
}
|
|
1667
1631
|
function collectCustomPropertyValues(css) {
|
|
1668
1632
|
const values = /* @__PURE__ */ new Map();
|
|
@@ -1715,7 +1679,7 @@ function createTailwindV4Engine(source) {
|
|
|
1715
1679
|
async function generateOnce(generateSource, options = {}) {
|
|
1716
1680
|
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
1717
1681
|
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
1718
|
-
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(generateSource, target));
|
|
1682
|
+
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target));
|
|
1719
1683
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1720
1684
|
const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
|
|
1721
1685
|
const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await (0, _tailwindcss_mangle_engine.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
@@ -1738,13 +1702,14 @@ function createTailwindV4Engine(source) {
|
|
|
1738
1702
|
}
|
|
1739
1703
|
async function generateWithIncrementalCache(options = {}) {
|
|
1740
1704
|
const target = options.target ?? "weapp";
|
|
1741
|
-
const
|
|
1705
|
+
const cssMacroSource = resolveCssMacroTailwindV4Source(source);
|
|
1706
|
+
const compatibleSource = createCompatibleSource(cssMacroSource, target);
|
|
1742
1707
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1743
1708
|
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
1744
|
-
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(
|
|
1709
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
|
|
1745
1710
|
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
|
|
1746
1711
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1747
|
-
const generated = await generateOnce(
|
|
1712
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1748
1713
|
if (!seedIncrementalGenerateCache({
|
|
1749
1714
|
compatibleSource,
|
|
1750
1715
|
generated,
|
|
@@ -1757,7 +1722,7 @@ function createTailwindV4Engine(source) {
|
|
|
1757
1722
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
1758
1723
|
if (cached) {
|
|
1759
1724
|
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1760
|
-
const generated = await generateOnce(
|
|
1725
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1761
1726
|
if (!seedIncrementalGenerateCache({
|
|
1762
1727
|
compatibleSource,
|
|
1763
1728
|
generated,
|
|
@@ -1781,7 +1746,7 @@ function createTailwindV4Engine(source) {
|
|
|
1781
1746
|
target: cached.target
|
|
1782
1747
|
};
|
|
1783
1748
|
if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1784
|
-
const generated = await generateOnce(
|
|
1749
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1785
1750
|
if (!seedIncrementalGenerateCache({
|
|
1786
1751
|
compatibleSource,
|
|
1787
1752
|
generated,
|
|
@@ -1831,7 +1796,7 @@ function createTailwindV4Engine(source) {
|
|
|
1831
1796
|
});
|
|
1832
1797
|
}
|
|
1833
1798
|
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1834
|
-
const generated = await generateOnce(
|
|
1799
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1835
1800
|
seedIncrementalGenerateCache({
|
|
1836
1801
|
compatibleSource,
|
|
1837
1802
|
generated,
|
|
@@ -2262,10 +2227,12 @@ function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
|
|
|
2262
2227
|
...context,
|
|
2263
2228
|
generatorTarget: target
|
|
2264
2229
|
});
|
|
2230
|
+
const hasExplicitTarget = options !== void 0 && Object.hasOwn(options, "target");
|
|
2231
|
+
const webCompat = options?.webCompat ?? (!hasExplicitTarget && branch.isWeb ? true : void 0);
|
|
2265
2232
|
if (options == null) return {
|
|
2266
2233
|
target,
|
|
2267
2234
|
branch,
|
|
2268
|
-
webCompat
|
|
2235
|
+
webCompat,
|
|
2269
2236
|
importFallback: false,
|
|
2270
2237
|
bareArbitraryValues: void 0
|
|
2271
2238
|
};
|
|
@@ -2274,7 +2241,7 @@ function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
|
|
|
2274
2241
|
branch,
|
|
2275
2242
|
config: options.config,
|
|
2276
2243
|
styleOptions: options.styleOptions,
|
|
2277
|
-
webCompat
|
|
2244
|
+
webCompat,
|
|
2278
2245
|
importFallback: options.importFallback ?? false,
|
|
2279
2246
|
bareArbitraryValues: options.bareArbitraryValues
|
|
2280
2247
|
};
|
|
@@ -2285,6 +2252,41 @@ function createWeappTailwindcssGenerator(source) {
|
|
|
2285
2252
|
return createTailwindV4Engine(source);
|
|
2286
2253
|
}
|
|
2287
2254
|
//#endregion
|
|
2255
|
+
//#region src/tailwindcss/v4/preflight.ts
|
|
2256
|
+
function parseCssImportSpecifier(params) {
|
|
2257
|
+
const value = params.trim();
|
|
2258
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
2259
|
+
if (quoted) return quoted[2];
|
|
2260
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
2261
|
+
return url?.[2] ?? url?.[3];
|
|
2262
|
+
}
|
|
2263
|
+
function normalizeTailwindImportSpecifier(params) {
|
|
2264
|
+
return parseCssImportSpecifier(params)?.replaceAll("\\", "/");
|
|
2265
|
+
}
|
|
2266
|
+
function isTailwindV4CssImportParam(params) {
|
|
2267
|
+
const specifier = normalizeTailwindImportSpecifier(params);
|
|
2268
|
+
return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier?.startsWith("tailwindcss/") === true || specifier?.startsWith("tailwindcss4/") === true || specifier?.endsWith("/tailwindcss/index.css") === true;
|
|
2269
|
+
}
|
|
2270
|
+
function isTailwindV4PreflightImportParam(params) {
|
|
2271
|
+
const specifier = normalizeTailwindImportSpecifier(params);
|
|
2272
|
+
return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier === "tailwindcss/preflight" || specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss4/preflight" || specifier === "tailwindcss4/preflight.css" || specifier?.endsWith("/tailwindcss/index.css") === true || specifier?.endsWith("/tailwindcss/preflight.css") === true;
|
|
2273
|
+
}
|
|
2274
|
+
function includesTailwindV4PreflightDirective(css) {
|
|
2275
|
+
try {
|
|
2276
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2277
|
+
let includesPreflight = false;
|
|
2278
|
+
root.walkAtRules("import", (rule) => {
|
|
2279
|
+
includesPreflight ||= isTailwindV4PreflightImportParam(rule.params);
|
|
2280
|
+
});
|
|
2281
|
+
root.walkAtRules("tailwind", (rule) => {
|
|
2282
|
+
includesPreflight ||= rule.params.trim() === "base";
|
|
2283
|
+
});
|
|
2284
|
+
return includesPreflight;
|
|
2285
|
+
} catch {
|
|
2286
|
+
return /@import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/(?:preflight(?:\.css)?|index\.css))?["')\s;]/.test(css) || /@tailwind\s+base\b/.test(css);
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
//#endregion
|
|
2288
2290
|
//#region src/wxml/shared.ts
|
|
2289
2291
|
const NEWLINE_RE = /[\n\r]+/g;
|
|
2290
2292
|
function replaceWxml(original, options = {
|
|
@@ -2423,22 +2425,91 @@ function resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion) {
|
|
|
2423
2425
|
};
|
|
2424
2426
|
}
|
|
2425
2427
|
//#endregion
|
|
2428
|
+
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
2429
|
+
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
2430
|
+
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
2431
|
+
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
2432
|
+
}
|
|
2433
|
+
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
2434
|
+
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
2435
|
+
if (!from || !node_path.default.isAbsolute(from)) return;
|
|
2436
|
+
return from.replace(/[?#].*$/, "");
|
|
2437
|
+
}
|
|
2438
|
+
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
2439
|
+
return cssHandlerOptions.sourceOptions;
|
|
2440
|
+
}
|
|
2441
|
+
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
2442
|
+
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
2443
|
+
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
2444
|
+
}
|
|
2445
|
+
//#endregion
|
|
2426
2446
|
//#region src/bundlers/shared/generator-css/generation-helpers.ts
|
|
2447
|
+
function isVueScopedStyleSource(from) {
|
|
2448
|
+
if (typeof from !== "string" || from.length === 0) return false;
|
|
2449
|
+
const queryIndex = from.indexOf("?");
|
|
2450
|
+
if (queryIndex === -1) return false;
|
|
2451
|
+
const query = from.slice(queryIndex + 1);
|
|
2452
|
+
return /(?:^|&)type=style(?:&|$)/.test(query) && /(?:^|&)scoped(?:=(?:true|1))?(?:&|$)/.test(query);
|
|
2453
|
+
}
|
|
2427
2454
|
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
2428
2455
|
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
2429
2456
|
}
|
|
2430
2457
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
2431
2458
|
if (target !== "weapp") return css;
|
|
2459
|
+
if (isVueScopedStyleSource(options.styleOptions?.postcssOptions?.options?.from)) return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
2460
|
+
cssPreflight: false,
|
|
2461
|
+
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
2462
|
+
isTailwindcssV4: true,
|
|
2463
|
+
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
2464
|
+
});
|
|
2465
|
+
const hasPreflightReset = hasMiniProgramTailwindV4PreflightReset(css);
|
|
2466
|
+
const injectPreflight = options.injectPreflight !== false && !hasPreflightReset;
|
|
2467
|
+
const preservePreflight = options.preservePreflight !== false;
|
|
2432
2468
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
2433
|
-
cssPreflight: options.injectPreflight
|
|
2469
|
+
cssPreflight: cssPreflight === false || options.injectPreflight === false && (!hasPreflightReset || !preservePreflight) ? false : injectPreflight ? cssPreflight : hasPreflightReset && preservePreflight ? cssPreflight : void 0,
|
|
2470
|
+
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
2434
2471
|
isTailwindcssV4: true,
|
|
2435
2472
|
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
2436
2473
|
});
|
|
2437
2474
|
}
|
|
2438
|
-
function
|
|
2439
|
-
if (options.cssHandlerOptions
|
|
2440
|
-
|
|
2441
|
-
|
|
2475
|
+
function resolveMiniProgramPreflightModeForGeneratorCss(opts, options) {
|
|
2476
|
+
if (isVueScopedStyleSource(resolvePostcssFromOption(options.cssHandlerOptions))) return {
|
|
2477
|
+
inject: false,
|
|
2478
|
+
preserve: false
|
|
2479
|
+
};
|
|
2480
|
+
if (options.cssHandlerOptions.uniAppX === true && options.cssHandlerOptions.uniAppXCssTarget === "uvue") return {
|
|
2481
|
+
inject: false,
|
|
2482
|
+
preserve: false
|
|
2483
|
+
};
|
|
2484
|
+
const shouldInjectUniAppXLocalImportPreflight = isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
2485
|
+
if (opts.cssPreflight === false) return {
|
|
2486
|
+
inject: false,
|
|
2487
|
+
preserve: false
|
|
2488
|
+
};
|
|
2489
|
+
if (options.primaryCssSource) return {
|
|
2490
|
+
inject: true,
|
|
2491
|
+
preserve: true
|
|
2492
|
+
};
|
|
2493
|
+
if (options.explicitCssSource) return {
|
|
2494
|
+
inject: false,
|
|
2495
|
+
preserve: true
|
|
2496
|
+
};
|
|
2497
|
+
if (options.cssHandlerOptions.isMainChunk) return {
|
|
2498
|
+
inject: true,
|
|
2499
|
+
preserve: true
|
|
2500
|
+
};
|
|
2501
|
+
if (!options.cssHandlerOptions.isMainChunk && !options.primaryCssSource && !options.explicitCssSource) return {
|
|
2502
|
+
inject: shouldInjectUniAppXLocalImportPreflight,
|
|
2503
|
+
preserve: shouldInjectUniAppXLocalImportPreflight
|
|
2504
|
+
};
|
|
2505
|
+
if (!options.isolateCurrentCssCandidates) return {
|
|
2506
|
+
inject: true,
|
|
2507
|
+
preserve: true
|
|
2508
|
+
};
|
|
2509
|
+
return {
|
|
2510
|
+
inject: shouldInjectUniAppXLocalImportPreflight,
|
|
2511
|
+
preserve: shouldInjectUniAppXLocalImportPreflight
|
|
2512
|
+
};
|
|
2442
2513
|
}
|
|
2443
2514
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
2444
2515
|
if (options.isolateCssSource) {
|
|
@@ -2472,9 +2543,10 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
2472
2543
|
}
|
|
2473
2544
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
2474
2545
|
const resolvedStyleOptions = resolveStyleOptionsFromContext(opts);
|
|
2546
|
+
const scopedVueStyleSource = isVueScopedStyleSource(resolvePostcssFromOption(cssHandlerOptions));
|
|
2475
2547
|
const preflightStyleOptions = {
|
|
2476
|
-
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
2477
|
-
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
2548
|
+
cssPreflight: scopedVueStyleSource ? false : resolvedStyleOptions.cssPreflight,
|
|
2549
|
+
cssPreflightRange: scopedVueStyleSource ? void 0 : resolvedStyleOptions.cssPreflightRange
|
|
2478
2550
|
};
|
|
2479
2551
|
return {
|
|
2480
2552
|
...resolvedStyleOptions,
|
|
@@ -2780,6 +2852,22 @@ function isClassContextLiteralPath(path) {
|
|
|
2780
2852
|
return false;
|
|
2781
2853
|
}
|
|
2782
2854
|
//#endregion
|
|
2855
|
+
//#region src/js/js-string-escape.ts
|
|
2856
|
+
function jsStringEscape(value) {
|
|
2857
|
+
return String(value).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
|
|
2858
|
+
switch (character) {
|
|
2859
|
+
case "\"":
|
|
2860
|
+
case "'":
|
|
2861
|
+
case "\\": return `\\${character}`;
|
|
2862
|
+
case "\n": return "\\n";
|
|
2863
|
+
case "\r": return "\\r";
|
|
2864
|
+
case "\u2028": return "\\u2028";
|
|
2865
|
+
case "\u2029": return "\\u2029";
|
|
2866
|
+
default: return character;
|
|
2867
|
+
}
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
//#endregion
|
|
2783
2871
|
//#region src/js/replacement-cache.ts
|
|
2784
2872
|
const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
|
|
2785
2873
|
const defaultReplacementCache = /* @__PURE__ */ new Map();
|
|
@@ -2939,7 +3027,7 @@ function replaceHandleValue(path, options) {
|
|
|
2939
3027
|
return {
|
|
2940
3028
|
start,
|
|
2941
3029
|
end,
|
|
2942
|
-
value: needEscaped ?
|
|
3030
|
+
value: needEscaped ? jsStringEscape(transformed) : transformed,
|
|
2943
3031
|
path
|
|
2944
3032
|
};
|
|
2945
3033
|
}
|
|
@@ -3505,17 +3593,6 @@ function parseImportSourceParam(params) {
|
|
|
3505
3593
|
sourcePath: match[3]
|
|
3506
3594
|
};
|
|
3507
3595
|
}
|
|
3508
|
-
function parseCssImportSpecifier(params) {
|
|
3509
|
-
const value = params.trim();
|
|
3510
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
3511
|
-
if (quoted) return quoted[2];
|
|
3512
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
3513
|
-
return url?.[2] ?? url?.[3];
|
|
3514
|
-
}
|
|
3515
|
-
function isTailwindCssImport(params) {
|
|
3516
|
-
const specifier = parseCssImportSpecifier(params);
|
|
3517
|
-
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
3518
|
-
}
|
|
3519
3596
|
function resolveSourceBase(base, sourcePath) {
|
|
3520
3597
|
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
3521
3598
|
}
|
|
@@ -3590,17 +3667,22 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
3590
3667
|
let importSourceBase;
|
|
3591
3668
|
let hasSourceNone = false;
|
|
3592
3669
|
let hasTailwindCssImport = false;
|
|
3670
|
+
let includesPreflight = false;
|
|
3593
3671
|
const [sourceEntries, configEntries] = await Promise.all([resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
|
|
3594
3672
|
const entries = [...configEntries.entries, ...sourceEntries];
|
|
3595
3673
|
const hasPositiveEntries = entries.some((entry) => !entry.negated);
|
|
3596
3674
|
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
3597
3675
|
root.walkAtRules("import", (rule) => {
|
|
3598
|
-
if (!
|
|
3676
|
+
if (!isTailwindV4CssImportParam(rule.params)) return;
|
|
3599
3677
|
hasTailwindCssImport = true;
|
|
3678
|
+
includesPreflight ||= isTailwindV4PreflightImportParam(rule.params);
|
|
3600
3679
|
const sourceParam = parseImportSourceParam(rule.params);
|
|
3601
3680
|
if (sourceParam?.none) hasSourceNone = true;
|
|
3602
3681
|
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
|
|
3603
3682
|
});
|
|
3683
|
+
root.walkAtRules("tailwind", (rule) => {
|
|
3684
|
+
includesPreflight ||= rule.params.trim() === "base";
|
|
3685
|
+
});
|
|
3604
3686
|
if (importSourceBase) return {
|
|
3605
3687
|
entries: [{
|
|
3606
3688
|
base: importSourceBase,
|
|
@@ -3608,30 +3690,35 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
3608
3690
|
pattern: VITE_SOURCE_CANDIDATE_PATTERN
|
|
3609
3691
|
}, ...entries],
|
|
3610
3692
|
explicit: true,
|
|
3693
|
+
includesPreflight,
|
|
3611
3694
|
inlineCandidates,
|
|
3612
3695
|
dependencies: configEntries.dependencies
|
|
3613
3696
|
};
|
|
3614
3697
|
if (hasSourceNone) return {
|
|
3615
3698
|
entries,
|
|
3616
3699
|
explicit: true,
|
|
3700
|
+
includesPreflight,
|
|
3617
3701
|
inlineCandidates,
|
|
3618
3702
|
dependencies: configEntries.dependencies
|
|
3619
3703
|
};
|
|
3620
3704
|
if (hasPositiveEntries) return {
|
|
3621
3705
|
entries,
|
|
3622
3706
|
explicit: true,
|
|
3707
|
+
includesPreflight,
|
|
3623
3708
|
inlineCandidates,
|
|
3624
3709
|
dependencies: configEntries.dependencies
|
|
3625
3710
|
};
|
|
3626
3711
|
if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
|
|
3627
3712
|
entries: [],
|
|
3628
3713
|
explicit: true,
|
|
3714
|
+
includesPreflight,
|
|
3629
3715
|
inlineCandidates,
|
|
3630
3716
|
dependencies: configEntries.dependencies
|
|
3631
3717
|
};
|
|
3632
3718
|
return hasTailwindCssImport ? {
|
|
3633
3719
|
entries,
|
|
3634
3720
|
explicit: false,
|
|
3721
|
+
includesPreflight,
|
|
3635
3722
|
inlineCandidates,
|
|
3636
3723
|
dependencies: configEntries.dependencies
|
|
3637
3724
|
} : void 0;
|
|
@@ -3983,8 +4070,9 @@ function withGeneratorSourceMetadata(source, metadata) {
|
|
|
3983
4070
|
__weappTailwindcssMeta: metadata
|
|
3984
4071
|
};
|
|
3985
4072
|
}
|
|
3986
|
-
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
4073
|
+
function withMatchedSourceSideMetadata(source, resolvedEntrySource, metadata = {}) {
|
|
3987
4074
|
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
4075
|
+
...metadata,
|
|
3988
4076
|
isolateCssSource: true,
|
|
3989
4077
|
matchedCssSourceFile: resolvedEntrySource.file,
|
|
3990
4078
|
sourceBase: resolvedEntrySource.base,
|
|
@@ -3992,24 +4080,6 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
|
3992
4080
|
}) : source;
|
|
3993
4081
|
}
|
|
3994
4082
|
//#endregion
|
|
3995
|
-
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
3996
|
-
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
3997
|
-
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
3998
|
-
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
3999
|
-
}
|
|
4000
|
-
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
4001
|
-
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
4002
|
-
if (!from || !node_path.default.isAbsolute(from)) return;
|
|
4003
|
-
return from.replace(/[?#].*$/, "");
|
|
4004
|
-
}
|
|
4005
|
-
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
4006
|
-
return cssHandlerOptions.sourceOptions;
|
|
4007
|
-
}
|
|
4008
|
-
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
4009
|
-
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
4010
|
-
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
4011
|
-
}
|
|
4012
|
-
//#endregion
|
|
4013
4083
|
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
4014
4084
|
function createCssEntrySources(cssEntries) {
|
|
4015
4085
|
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
|
|
@@ -4043,11 +4113,15 @@ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
|
4043
4113
|
cssEntries: options.cssEntries
|
|
4044
4114
|
});
|
|
4045
4115
|
}
|
|
4046
|
-
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
4116
|
+
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options = {}) {
|
|
4047
4117
|
const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
|
|
4048
|
-
if (!(0, node_fs.existsSync)(cssEntry)) return resolveTailwindV4Source({
|
|
4118
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return withGeneratorSourceMetadata(await resolveTailwindV4Source({
|
|
4049
4119
|
...omitUndefined(singleEntrySourceOptions),
|
|
4050
4120
|
cssEntries: [cssEntry]
|
|
4121
|
+
}), {
|
|
4122
|
+
cssEntryIndex: options.index,
|
|
4123
|
+
includesPreflight: options.includesPreflight,
|
|
4124
|
+
primaryCssSource: options.index === 0
|
|
4051
4125
|
});
|
|
4052
4126
|
const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
4053
4127
|
const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
|
|
@@ -4062,7 +4136,10 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
|
4062
4136
|
css: normalizeConfigDirective(css, config),
|
|
4063
4137
|
cssEntries: [cssEntry]
|
|
4064
4138
|
}), {
|
|
4139
|
+
cssEntryIndex: options.index,
|
|
4140
|
+
includesPreflight: options.includesPreflight,
|
|
4065
4141
|
matchedCssSourceFile: cssEntry,
|
|
4142
|
+
primaryCssSource: options.index === 0,
|
|
4066
4143
|
sourceBase: base,
|
|
4067
4144
|
sourceCss: css
|
|
4068
4145
|
});
|
|
@@ -4075,12 +4152,15 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
|
4075
4152
|
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
4076
4153
|
return rawSource.includes("@apply") || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
|
|
4077
4154
|
}
|
|
4078
|
-
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
4155
|
+
async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
4079
4156
|
const cssEntries = sourceOptions.cssEntries;
|
|
4080
4157
|
if (!cssEntries?.length) return;
|
|
4081
4158
|
const normalizedFile = node_path.default.resolve(file.replace(/[?#].*$/, ""));
|
|
4082
4159
|
const pathMatchedEntries = cssEntries.filter((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === normalizedFile);
|
|
4083
|
-
if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions
|
|
4160
|
+
if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions, {
|
|
4161
|
+
includesPreflight: await resolveTailwindV4CssEntryIncludesPreflight(pathMatchedEntries[0]),
|
|
4162
|
+
index: cssEntries.indexOf(pathMatchedEntries[0])
|
|
4163
|
+
});
|
|
4084
4164
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
4085
4165
|
const matches = cssEntries.map((cssEntry) => {
|
|
4086
4166
|
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
@@ -4099,7 +4179,10 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
|
4099
4179
|
const bestScore = matches[0]?.score;
|
|
4100
4180
|
const matchingEntry = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssEntry : void 0;
|
|
4101
4181
|
if (!matchingEntry) return;
|
|
4102
|
-
return resolveTailwindV4CssEntrySource(matchingEntry, sourceOptions
|
|
4182
|
+
return resolveTailwindV4CssEntrySource(matchingEntry, sourceOptions, {
|
|
4183
|
+
includesPreflight: await resolveTailwindV4CssEntryIncludesPreflight(matchingEntry),
|
|
4184
|
+
index: cssEntries.indexOf(matchingEntry)
|
|
4185
|
+
});
|
|
4103
4186
|
}
|
|
4104
4187
|
function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
|
|
4105
4188
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
|
|
@@ -4149,7 +4232,7 @@ function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
|
|
|
4149
4232
|
cssSources
|
|
4150
4233
|
} : sourceOptions;
|
|
4151
4234
|
}
|
|
4152
|
-
async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions) {
|
|
4235
|
+
async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions, selectionOptions) {
|
|
4153
4236
|
const cssSources = sourceOptions.cssSources;
|
|
4154
4237
|
if (!cssSources?.length) return;
|
|
4155
4238
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
@@ -4170,7 +4253,12 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
|
|
|
4170
4253
|
const bestScore = matches[0]?.score;
|
|
4171
4254
|
const matchingSource = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssSource : void 0;
|
|
4172
4255
|
if (!matchingSource) return;
|
|
4173
|
-
return resolveSingleTailwindV4CssSource(matchingSource, sourceOptions, {
|
|
4256
|
+
return resolveSingleTailwindV4CssSource(matchingSource, sourceOptions, {
|
|
4257
|
+
includesPreflight: await resolveTailwindV4CssSourceEntries(matchingSource, sourceOptions).then((resolved) => resolved?.includesPreflight),
|
|
4258
|
+
index: matches[0]?.index,
|
|
4259
|
+
matched: true,
|
|
4260
|
+
primary: isSameTailwindV4CssSource(matchingSource, selectionOptions?.cssSources?.[0])
|
|
4261
|
+
});
|
|
4174
4262
|
}
|
|
4175
4263
|
function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
4176
4264
|
try {
|
|
@@ -4182,14 +4270,24 @@ function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
|
4182
4270
|
function hasConfiguredTailwindV4CssSource(sourceOptions) {
|
|
4183
4271
|
return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
|
|
4184
4272
|
}
|
|
4273
|
+
function isSameTailwindV4CssSource(a, b) {
|
|
4274
|
+
if (!a || !b) return false;
|
|
4275
|
+
if (typeof a.file === "string" && typeof b.file === "string") return node_path.default.resolve(a.file) === node_path.default.resolve(b.file);
|
|
4276
|
+
return typeof a.css === "string" && typeof b.css === "string" && normalizeCssSourceForCompare(a.css) === normalizeCssSourceForCompare(b.css);
|
|
4277
|
+
}
|
|
4185
4278
|
async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
|
|
4186
4279
|
const sourceBase = resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
4187
4280
|
const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
|
|
4188
|
-
|
|
4281
|
+
const source = await resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
|
|
4189
4282
|
base: sourceBase,
|
|
4190
4283
|
css: normalizedCssSource.css
|
|
4191
|
-
}))
|
|
4284
|
+
}));
|
|
4285
|
+
const resolvedEntries = options.includesPreflight === void 0 ? await resolveTailwindV4CssSourceEntries(normalizedCssSource, sourceOptions) : void 0;
|
|
4286
|
+
return withGeneratorSourceMetadata(source, {
|
|
4287
|
+
cssSourceIndex: options.index,
|
|
4288
|
+
includesPreflight: options.includesPreflight ?? resolvedEntries?.includesPreflight,
|
|
4192
4289
|
matchedCssSourceFile: options.matched && typeof normalizedCssSource.file === "string" ? normalizedCssSource.file : void 0,
|
|
4290
|
+
primaryCssSource: options.primary === true || !sourceOptions.cssEntries?.length && options.index === 0 || void 0,
|
|
4193
4291
|
sourceBase,
|
|
4194
4292
|
sourceCss: normalizedCssSource.css
|
|
4195
4293
|
});
|
|
@@ -4218,6 +4316,7 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
4218
4316
|
if (runtimeHits === 0) return;
|
|
4219
4317
|
matches.push({
|
|
4220
4318
|
cssSource,
|
|
4319
|
+
includesPreflight: resolved.includesPreflight,
|
|
4221
4320
|
index,
|
|
4222
4321
|
runtimeHits,
|
|
4223
4322
|
totalCandidates: scopedCandidates.size
|
|
@@ -4229,10 +4328,53 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
4229
4328
|
const second = matches[1];
|
|
4230
4329
|
if (!best) return;
|
|
4231
4330
|
if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
|
|
4232
|
-
return resolveSingleTailwindV4CssSource(best.cssSource, sourceOptions, {
|
|
4331
|
+
return resolveSingleTailwindV4CssSource(best.cssSource, sourceOptions, {
|
|
4332
|
+
includesPreflight: best.includesPreflight,
|
|
4333
|
+
index: best.index,
|
|
4334
|
+
matched: true,
|
|
4335
|
+
primary: isSameTailwindV4CssSource(best.cssSource, selectionOptions?.cssSources?.[0])
|
|
4336
|
+
});
|
|
4337
|
+
}
|
|
4338
|
+
async function resolveTailwindV4CssEntryEntries(cssEntry) {
|
|
4339
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
4340
|
+
const file = node_path.default.resolve(cssEntry);
|
|
4341
|
+
return resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(file, "utf8"), node_path.default.dirname(file));
|
|
4342
|
+
}
|
|
4343
|
+
async function resolveTailwindV4CssEntryIncludesPreflight(cssEntry) {
|
|
4344
|
+
return resolveTailwindV4CssEntryEntries(cssEntry).then((resolved) => resolved?.includesPreflight);
|
|
4345
|
+
}
|
|
4346
|
+
async function resolveCandidateMatchedTailwindV4CssEntry(sourceOptions, selectionOptions) {
|
|
4347
|
+
const cssEntries = sourceOptions.cssEntries;
|
|
4348
|
+
const getSourceCandidatesForEntries = selectionOptions?.getSourceCandidatesForEntries;
|
|
4349
|
+
if (!cssEntries?.length || !getSourceCandidatesForEntries) return;
|
|
4350
|
+
const matches = [];
|
|
4351
|
+
await Promise.all(cssEntries.map(async (cssEntry, index) => {
|
|
4352
|
+
const resolved = await resolveTailwindV4CssEntryEntries(cssEntry);
|
|
4353
|
+
if (resolved?.entries === void 0) return;
|
|
4354
|
+
const scopedCandidates = getSourceCandidatesForEntries(resolved.entries);
|
|
4355
|
+
const runtimeHits = countRuntimeCandidateHits(scopedCandidates, selectionOptions?.runtime);
|
|
4356
|
+
if (runtimeHits === 0) return;
|
|
4357
|
+
matches.push({
|
|
4358
|
+
cssEntry,
|
|
4359
|
+
includesPreflight: resolved.includesPreflight,
|
|
4360
|
+
index,
|
|
4361
|
+
runtimeHits,
|
|
4362
|
+
totalCandidates: scopedCandidates.size
|
|
4363
|
+
});
|
|
4364
|
+
}));
|
|
4365
|
+
if (matches.length === 0) return;
|
|
4366
|
+
matches.sort((a, b) => b.runtimeHits - a.runtimeHits || b.totalCandidates - a.totalCandidates || a.index - b.index);
|
|
4367
|
+
const best = matches[0];
|
|
4368
|
+
const second = matches[1];
|
|
4369
|
+
if (!best) return;
|
|
4370
|
+
if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
|
|
4371
|
+
return resolveTailwindV4CssEntrySource(best.cssEntry, sourceOptions, {
|
|
4372
|
+
includesPreflight: best.includesPreflight,
|
|
4373
|
+
index: best.index
|
|
4374
|
+
});
|
|
4233
4375
|
}
|
|
4234
4376
|
function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
|
|
4235
|
-
return (cssSource) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions).then((source) => generatorOptions?.config ? {
|
|
4377
|
+
return (cssSource, index) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions, { index }).then((source) => generatorOptions?.config ? {
|
|
4236
4378
|
...source,
|
|
4237
4379
|
css: prependConfigDirective(source.css, generatorOptions.config)
|
|
4238
4380
|
} : source);
|
|
@@ -4245,11 +4387,19 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
|
|
|
4245
4387
|
sourceFile: resolvedEntrySource.file
|
|
4246
4388
|
});
|
|
4247
4389
|
const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
4248
|
-
|
|
4390
|
+
const source = await resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
|
|
4249
4391
|
base: resolvedEntrySource.base,
|
|
4250
4392
|
css,
|
|
4251
4393
|
cssEntries: [resolvedEntrySource.file]
|
|
4252
|
-
}))
|
|
4394
|
+
}));
|
|
4395
|
+
const cssEntryIndex = sourceOptions.cssEntries?.findIndex((cssEntry) => typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
|
|
4396
|
+
const cssSourceIndex = sourceOptions.cssSources?.findIndex((cssSource) => typeof cssSource.file === "string" && typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssSource.file.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
|
|
4397
|
+
return withMatchedSourceSideMetadata(source, resolvedEntrySource, {
|
|
4398
|
+
cssEntryIndex,
|
|
4399
|
+
cssSourceIndex,
|
|
4400
|
+
includesPreflight: (await resolveTailwindV4EntriesFromCss(resolvedEntrySource.css, resolvedEntrySource.base))?.includesPreflight,
|
|
4401
|
+
primaryCssSource: cssEntryIndex === 0 || !sourceOptions.cssEntries?.length && cssSourceIndex === 0
|
|
4402
|
+
});
|
|
4253
4403
|
}
|
|
4254
4404
|
async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
4255
4405
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
@@ -4267,7 +4417,7 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
4267
4417
|
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
4268
4418
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
4269
4419
|
cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
|
|
4270
|
-
cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
4420
|
+
cssSources: mergeCssSources(mergeCssSources(sourceOptions.cssSources, selectionOptions?.cssSources), sourceOptions.cssSources?.length || selectionOptions?.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
4271
4421
|
}) : void 0;
|
|
4272
4422
|
const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
|
|
4273
4423
|
if (applyEntrySource && !cssHandlerOptions.isMainChunk && !hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
|
|
@@ -4282,16 +4432,20 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
4282
4432
|
const sourceSideCssSource = sourceSideEntrySource?.file && normalizedSourceOptions.cssEntries?.some((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(sourceSideEntrySource.file)) ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file) : void 0;
|
|
4283
4433
|
if (sourceSideCssSource) return sourceSideCssSource;
|
|
4284
4434
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
4285
|
-
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
|
|
4435
|
+
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
4436
|
+
const candidateMatchedCssEntrySource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssEntry(normalizedSourceOptions, selectionOptions) : void 0;
|
|
4286
4437
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
4287
|
-
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, {
|
|
4438
|
+
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, {
|
|
4439
|
+
index: 0,
|
|
4440
|
+
matched: true
|
|
4441
|
+
}) : void 0;
|
|
4288
4442
|
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await resolveTailwindV4Source(normalizedSourceOptions) : void 0;
|
|
4289
4443
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
4290
4444
|
...configuredCssSource,
|
|
4291
4445
|
css: prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
4292
4446
|
} : configuredCssSource;
|
|
4293
4447
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
4294
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
4448
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
4295
4449
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
4296
4450
|
...preferredCssEntrySource,
|
|
4297
4451
|
css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -4347,19 +4501,20 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
4347
4501
|
} : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
4348
4502
|
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
4349
4503
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
4350
|
-
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
4504
|
+
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
4505
|
+
const candidateMatchedCssEntrySource = await resolveCandidateMatchedTailwindV4CssEntry(sourceOptions, selectionOptions);
|
|
4351
4506
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
4352
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
|
|
4507
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource;
|
|
4353
4508
|
if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
|
|
4354
4509
|
...preferredCssEntrySource,
|
|
4355
4510
|
css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
4356
4511
|
} : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
4357
4512
|
if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
|
|
4358
|
-
if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions)).then((source) => generatorOptions?.config ? {
|
|
4513
|
+
if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions), { index: 0 }).then((source) => generatorOptions?.config ? {
|
|
4359
4514
|
...source,
|
|
4360
4515
|
css: prependConfigDirective(source.css, generatorOptions.config)
|
|
4361
4516
|
} : source)];
|
|
4362
|
-
if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0]), sourceOptions.cssSources[0]?.file, sourceOptions)];
|
|
4517
|
+
if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0], 0), sourceOptions.cssSources[0]?.file, sourceOptions)];
|
|
4363
4518
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
4364
4519
|
return resolved ? [resolved] : [];
|
|
4365
4520
|
}
|
|
@@ -4368,7 +4523,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
4368
4523
|
return resolved ? [resolved] : [];
|
|
4369
4524
|
}
|
|
4370
4525
|
const normalizedCssSourceOptions = normalizeTailwindV4CssSourceConfigs(sourceOptions);
|
|
4371
|
-
const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions).then((source) => generatorOptions?.config ? {
|
|
4526
|
+
const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry, index) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions, { index }).then((source) => generatorOptions?.config ? {
|
|
4372
4527
|
...source,
|
|
4373
4528
|
css: prependConfigDirective(source.css, generatorOptions.config)
|
|
4374
4529
|
} : source)));
|
|
@@ -5158,96 +5313,6 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
|
5158
5313
|
}
|
|
5159
5314
|
}
|
|
5160
5315
|
//#endregion
|
|
5161
|
-
//#region src/bundlers/shared/generator-css/local-imports.ts
|
|
5162
|
-
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
5163
|
-
function createCssSourceOrderAppend(base, extra) {
|
|
5164
|
-
if (!base) return extra;
|
|
5165
|
-
if (!extra) return base;
|
|
5166
|
-
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
5167
|
-
return `${base}\n${extra}`;
|
|
5168
|
-
}
|
|
5169
|
-
function isLocalImportRequest(request) {
|
|
5170
|
-
return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
|
|
5171
|
-
}
|
|
5172
|
-
function isPureLocalCssImportWrapper(css) {
|
|
5173
|
-
let hasImport = false;
|
|
5174
|
-
try {
|
|
5175
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5176
|
-
for (const node of root.nodes) {
|
|
5177
|
-
if (node.type === "comment") continue;
|
|
5178
|
-
if (node.type !== "atrule" || node.name !== "import") return false;
|
|
5179
|
-
const request = parseImportRequest(node.params);
|
|
5180
|
-
if (!request || !isLocalImportRequest(request)) return false;
|
|
5181
|
-
hasImport = true;
|
|
5182
|
-
}
|
|
5183
|
-
} catch {
|
|
5184
|
-
return false;
|
|
5185
|
-
}
|
|
5186
|
-
return hasImport;
|
|
5187
|
-
}
|
|
5188
|
-
function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
5189
|
-
let hasLocalImport = false;
|
|
5190
|
-
let hasTailwindDirective = false;
|
|
5191
|
-
try {
|
|
5192
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5193
|
-
for (const node of root.nodes) {
|
|
5194
|
-
if (node.type === "comment") continue;
|
|
5195
|
-
if (node.type === "atrule" && node.name === "import") {
|
|
5196
|
-
const request = parseImportRequest(node.params);
|
|
5197
|
-
if (!request || !isLocalImportRequest(request)) return;
|
|
5198
|
-
hasLocalImport = true;
|
|
5199
|
-
continue;
|
|
5200
|
-
}
|
|
5201
|
-
if (node.type === "atrule" && node.name === "source") {
|
|
5202
|
-
hasTailwindDirective = true;
|
|
5203
|
-
continue;
|
|
5204
|
-
}
|
|
5205
|
-
return;
|
|
5206
|
-
}
|
|
5207
|
-
} catch {
|
|
5208
|
-
return;
|
|
5209
|
-
}
|
|
5210
|
-
return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
|
|
5211
|
-
}
|
|
5212
|
-
function prefixLocalCssImportsWithWebpackIgnore(css) {
|
|
5213
|
-
try {
|
|
5214
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5215
|
-
root.walkAtRules("import", (atRule) => {
|
|
5216
|
-
const request = parseImportRequest(atRule.params);
|
|
5217
|
-
if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
|
|
5218
|
-
});
|
|
5219
|
-
return root.toString();
|
|
5220
|
-
} catch {
|
|
5221
|
-
return css;
|
|
5222
|
-
}
|
|
5223
|
-
}
|
|
5224
|
-
function splitLocalCssImports(source) {
|
|
5225
|
-
try {
|
|
5226
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5227
|
-
const importRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
5228
|
-
let changed = false;
|
|
5229
|
-
for (const node of [...root.nodes]) {
|
|
5230
|
-
if (node.type !== "atrule" || node.name !== "import") continue;
|
|
5231
|
-
const request = parseImportRequest(node.params);
|
|
5232
|
-
if (!request || !isLocalImportRequest(request)) continue;
|
|
5233
|
-
importRoot.append(node.clone());
|
|
5234
|
-
node.remove();
|
|
5235
|
-
changed = true;
|
|
5236
|
-
}
|
|
5237
|
-
const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
|
|
5238
|
-
return changed ? {
|
|
5239
|
-
imports,
|
|
5240
|
-
source: root.toString()
|
|
5241
|
-
} : void 0;
|
|
5242
|
-
} catch {
|
|
5243
|
-
return;
|
|
5244
|
-
}
|
|
5245
|
-
}
|
|
5246
|
-
function restoreLocalCssImports(css, imports) {
|
|
5247
|
-
if (!imports?.trim()) return css;
|
|
5248
|
-
return createCssSourceOrderAppend(imports, css);
|
|
5249
|
-
}
|
|
5250
|
-
//#endregion
|
|
5251
5316
|
//#region src/bundlers/shared/generator-css/user-layer-order.ts
|
|
5252
5317
|
const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
|
|
5253
5318
|
const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
|
|
@@ -5354,6 +5419,23 @@ function intersectCandidateSets(left, right) {
|
|
|
5354
5419
|
for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
|
|
5355
5420
|
return matched;
|
|
5356
5421
|
}
|
|
5422
|
+
function parseCssSourceRoot(rawSource) {
|
|
5423
|
+
try {
|
|
5424
|
+
return _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
5425
|
+
} catch {
|
|
5426
|
+
return;
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
function cleanLocalCssImportWrapperFromParsedRoot(rawSource, root) {
|
|
5430
|
+
if (!root) return (0, _weapp_tailwindcss_postcss.cleanLocalCssImportWrapperTailwindDirectives)(rawSource);
|
|
5431
|
+
return (0, _weapp_tailwindcss_postcss.cleanLocalCssImportWrapperTailwindDirectivesRoot)(root) ? root.toString() : void 0;
|
|
5432
|
+
}
|
|
5433
|
+
function isPureLocalCssImportWrapperFromParsedRoot(rawSource, root) {
|
|
5434
|
+
return root ? (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapperRoot)(root) : (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(rawSource);
|
|
5435
|
+
}
|
|
5436
|
+
function splitLocalCssImportsFromParsedRoot(rawSource, root) {
|
|
5437
|
+
return root ? (0, _weapp_tailwindcss_postcss.splitLocalCssImportsRoot)(root) : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawSource);
|
|
5438
|
+
}
|
|
5357
5439
|
function collectCssRuleIdentityMarkers(source) {
|
|
5358
5440
|
const markers = /* @__PURE__ */ new Set();
|
|
5359
5441
|
try {
|
|
@@ -5402,20 +5484,8 @@ async function generateCssByGenerator(options) {
|
|
|
5402
5484
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
5403
5485
|
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
5404
5486
|
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
5405
|
-
const
|
|
5406
|
-
const
|
|
5407
|
-
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
5408
|
-
return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
5409
|
-
};
|
|
5410
|
-
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
5411
|
-
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
5412
|
-
const userSource = splitLocalCssImports(rawUserSource)?.source ?? rawUserSource;
|
|
5413
|
-
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
5414
|
-
const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
5415
|
-
const generatedUserCssRawSource = generatedUserCssOrderSource ? createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
5416
|
-
const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
5417
|
-
const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
|
|
5418
|
-
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
|
|
5487
|
+
const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
|
|
5488
|
+
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
5419
5489
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
5420
5490
|
css: shouldUseMiniProgramCssBranch(generatorBranch) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
5421
5491
|
classSet: /* @__PURE__ */ new Set(),
|
|
@@ -5427,7 +5497,20 @@ async function generateCssByGenerator(options) {
|
|
|
5427
5497
|
majorVersion
|
|
5428
5498
|
}
|
|
5429
5499
|
};
|
|
5430
|
-
if (
|
|
5500
|
+
if (isPureLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot)) return;
|
|
5501
|
+
const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
5502
|
+
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
5503
|
+
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
5504
|
+
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
5505
|
+
};
|
|
5506
|
+
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
5507
|
+
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
5508
|
+
const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
|
|
5509
|
+
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
5510
|
+
const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
5511
|
+
const generatedUserCssRawSource = generatedUserCssOrderSource ? createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
5512
|
+
const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
5513
|
+
const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
|
|
5431
5514
|
const hasGeneratedCss = hasTailwindGeneratedCss(generatorRawSource);
|
|
5432
5515
|
const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
5433
5516
|
const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
@@ -5451,7 +5534,7 @@ async function generateCssByGenerator(options) {
|
|
|
5451
5534
|
});
|
|
5452
5535
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
5453
5536
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
5454
|
-
cssEntries: opts.cssEntries,
|
|
5537
|
+
cssEntries: cssHandlerOptions.sourceOptions?.cssEntries ?? opts.cssEntries,
|
|
5455
5538
|
cssSources: options.cssSources,
|
|
5456
5539
|
getSourceCandidatesForEntries,
|
|
5457
5540
|
runtime: runtimeWithCurrentCss
|
|
@@ -5495,7 +5578,7 @@ async function generateCssByGenerator(options) {
|
|
|
5495
5578
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
5496
5579
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
5497
5580
|
const incrementalCss = stripTailwindBanner(generated.incrementalCss);
|
|
5498
|
-
const finalCss = finalizeWebGeneratorCss(restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
5581
|
+
const finalCss = finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
5499
5582
|
injectPreflight: false,
|
|
5500
5583
|
styleOptions: generatorStyleOptions
|
|
5501
5584
|
})) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
|
|
@@ -5520,6 +5603,19 @@ async function generateCssByGenerator(options) {
|
|
|
5520
5603
|
const generatedCssSource = generated.target === "web" ? generated.css : stripTailwindBanner(generated.css);
|
|
5521
5604
|
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
5522
5605
|
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
5606
|
+
const hasExplicitCssSource = sources.some((source) => {
|
|
5607
|
+
const metadata = source.__weappTailwindcssMeta;
|
|
5608
|
+
return metadata?.cssEntryIndex !== void 0 || metadata?.cssSourceIndex !== void 0;
|
|
5609
|
+
});
|
|
5610
|
+
const hasPreflightCssSource = sources.some((source) => source.__weappTailwindcssMeta?.includesPreflight === true);
|
|
5611
|
+
const hasPreflightRawSource = includesTailwindV4PreflightDirective(generatorRawSource);
|
|
5612
|
+
const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
|
|
5613
|
+
cssHandlerOptions,
|
|
5614
|
+
isolateCurrentCssCandidates,
|
|
5615
|
+
localImports,
|
|
5616
|
+
explicitCssSource: hasExplicitCssSource,
|
|
5617
|
+
primaryCssSource: sources.length > 0 && sources.every((source) => source.__weappTailwindcssMeta?.primaryCssSource === true) || hasPreflightCssSource || hasPreflightRawSource
|
|
5618
|
+
});
|
|
5523
5619
|
const orderedExtraCss = splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
|
|
5524
5620
|
const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
|
|
5525
5621
|
if (orderedExtraCss) {
|
|
@@ -5567,11 +5663,8 @@ async function generateCssByGenerator(options) {
|
|
|
5567
5663
|
}
|
|
5568
5664
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
5569
5665
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
5570
|
-
injectPreflight:
|
|
5571
|
-
|
|
5572
|
-
isolateCurrentCssCandidates,
|
|
5573
|
-
localImports
|
|
5574
|
-
}),
|
|
5666
|
+
injectPreflight: preflightMode.inject,
|
|
5667
|
+
preservePreflight: preflightMode.preserve,
|
|
5575
5668
|
styleOptions: generatorStyleOptions
|
|
5576
5669
|
});
|
|
5577
5670
|
return {
|
|
@@ -5675,11 +5768,8 @@ async function generateCssByGenerator(options) {
|
|
|
5675
5768
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
5676
5769
|
}
|
|
5677
5770
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
5678
|
-
injectPreflight:
|
|
5679
|
-
|
|
5680
|
-
isolateCurrentCssCandidates,
|
|
5681
|
-
localImports
|
|
5682
|
-
}),
|
|
5771
|
+
injectPreflight: preflightMode.inject,
|
|
5772
|
+
preservePreflight: preflightMode.preserve,
|
|
5683
5773
|
styleOptions: generatorStyleOptions
|
|
5684
5774
|
});
|
|
5685
5775
|
return {
|
|
@@ -5712,11 +5802,8 @@ async function generateCssByGenerator(options) {
|
|
|
5712
5802
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
5713
5803
|
}
|
|
5714
5804
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
5715
|
-
injectPreflight:
|
|
5716
|
-
|
|
5717
|
-
isolateCurrentCssCandidates,
|
|
5718
|
-
localImports
|
|
5719
|
-
}),
|
|
5805
|
+
injectPreflight: preflightMode.inject,
|
|
5806
|
+
preservePreflight: preflightMode.preserve,
|
|
5720
5807
|
styleOptions: generatorStyleOptions
|
|
5721
5808
|
});
|
|
5722
5809
|
return {
|
|
@@ -5972,7 +6059,7 @@ function createEvalReplacementToken(path, updated) {
|
|
|
5972
6059
|
return {
|
|
5973
6060
|
start,
|
|
5974
6061
|
end,
|
|
5975
|
-
value: path.isStringLiteral() ?
|
|
6062
|
+
value: path.isStringLiteral() ? jsStringEscape(updated) : updated,
|
|
5976
6063
|
path
|
|
5977
6064
|
};
|
|
5978
6065
|
}
|
|
@@ -7252,8 +7339,12 @@ function normalizeCssConfigDirectives(source, resourcePath) {
|
|
|
7252
7339
|
});
|
|
7253
7340
|
}
|
|
7254
7341
|
function createCssHandlerOptions(options, majorVersion, file, appType) {
|
|
7342
|
+
const tailwindOptions = resolveTailwindcssOptions(options.tailwindRuntimeOptions);
|
|
7343
|
+
const cssEntries = [...options.cssEntries ?? [], ...tailwindOptions?.v4?.cssEntries ?? []].filter((entry) => typeof entry === "string" && entry.length > 0).map((entry) => node_path.default.resolve(entry));
|
|
7344
|
+
const resolvedFile = node_path.default.resolve(file);
|
|
7345
|
+
const matchedCssEntryIndex = cssEntries.findIndex((entry) => entry === resolvedFile);
|
|
7255
7346
|
return {
|
|
7256
|
-
isMainChunk: options.mainCssChunkMatcher(file, appType),
|
|
7347
|
+
isMainChunk: matchedCssEntryIndex >= 0 ? matchedCssEntryIndex === 0 : options.mainCssChunkMatcher(file, appType),
|
|
7257
7348
|
postcssOptions: { options: { from: file } },
|
|
7258
7349
|
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
7259
7350
|
};
|