weapp-tailwindcss 5.1.4 → 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/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
- package/dist/bundlers/vite/hot-css-modules.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-DCVMkTRj.js → context-BziwyWy1.js} +21 -6
- package/dist/{context-Bkpmt3ja.mjs → context-rrYZuUBU.mjs} +18 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/index.d.ts +2 -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/{gulp-Bogfnoki.js → gulp-CuVsZdO9.js} +3 -3
- package/dist/{gulp-0RsqkF_d.mjs → gulp-ygWfmOqh.mjs} +3 -3
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BV6nFPoT.js → hmr-timing-BKdCeIrn.js} +207 -67
- package/dist/{hmr-timing-BRNaz8Od.mjs → hmr-timing-Dh_nn3w5.mjs} +207 -67
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/js/js-string-escape.d.ts +1 -0
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-BB1hvW68.mjs → source-candidate-scan-signature-DATRnS1X.mjs} +157 -6
- package/dist/{source-candidate-scan-signature-CaDT0gkj.js → source-candidate-scan-signature-DIj9m4wB.js} +168 -5
- 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-D2xs4OEu.js → tailwindcss-BwoNQ3t8.js} +52 -12
- package/dist/{tailwindcss-D0JF0fuZ.mjs → tailwindcss-C-uM4rB8.mjs} +47 -13
- package/dist/{transform-BP86eSZp.mjs → transform-DHLemtaX.mjs} +1 -1
- package/dist/{transform-CXCQ28Tc.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/{vite-BYgT1ir9.js → vite-Yp14HNyS.js} +101 -37
- package/dist/{vite-B1SlBmqO.mjs → vite-cH0tTMHc.mjs} +101 -37
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +276 -83
- package/dist/{webpack-Bg6pefpb.mjs → webpack-DBhmJ-_P.mjs} +62 -18
- package/dist/{webpack-khSwkXP5.js → webpack-DN3tgLbF.js} +61 -17
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +16 -5
|
@@ -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");
|
|
@@ -1426,7 +1425,7 @@ function parseCssImportSpecifier$2(params) {
|
|
|
1426
1425
|
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1427
1426
|
return url?.[2] ?? url?.[3];
|
|
1428
1427
|
}
|
|
1429
|
-
function isTailwindCssImport
|
|
1428
|
+
function isTailwindCssImport(params) {
|
|
1430
1429
|
const specifier = parseCssImportSpecifier$2(params);
|
|
1431
1430
|
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1432
1431
|
}
|
|
@@ -1463,7 +1462,7 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1463
1462
|
}
|
|
1464
1463
|
root.walkAtRules((rule) => {
|
|
1465
1464
|
if (rule.name === "import") {
|
|
1466
|
-
if (!isTailwindCssImport
|
|
1465
|
+
if (!isTailwindCssImport(rule.params)) return;
|
|
1467
1466
|
hasTailwindImport = true;
|
|
1468
1467
|
const sourceParam = parseImportSourceParam$1(rule.params);
|
|
1469
1468
|
if (sourceParam?.none) hasSourceNone = true;
|
|
@@ -2253,6 +2252,41 @@ function createWeappTailwindcssGenerator(source) {
|
|
|
2253
2252
|
return createTailwindV4Engine(source);
|
|
2254
2253
|
}
|
|
2255
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
|
|
2256
2290
|
//#region src/wxml/shared.ts
|
|
2257
2291
|
const NEWLINE_RE = /[\n\r]+/g;
|
|
2258
2292
|
function replaceWxml(original, options = {
|
|
@@ -2391,24 +2425,91 @@ function resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion) {
|
|
|
2391
2425
|
};
|
|
2392
2426
|
}
|
|
2393
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
|
|
2394
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
|
+
}
|
|
2395
2454
|
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
2396
2455
|
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
2397
2456
|
}
|
|
2398
2457
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
2399
2458
|
if (target !== "weapp") return css;
|
|
2400
|
-
|
|
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;
|
|
2401
2468
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
2402
|
-
cssPreflight: cssPreflight === false ? false : injectPreflight ? cssPreflight : void 0,
|
|
2469
|
+
cssPreflight: cssPreflight === false || options.injectPreflight === false && (!hasPreflightReset || !preservePreflight) ? false : injectPreflight ? cssPreflight : hasPreflightReset && preservePreflight ? cssPreflight : void 0,
|
|
2403
2470
|
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
2404
2471
|
isTailwindcssV4: true,
|
|
2405
2472
|
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
2406
2473
|
});
|
|
2407
2474
|
}
|
|
2408
|
-
function
|
|
2409
|
-
if (options.cssHandlerOptions
|
|
2410
|
-
|
|
2411
|
-
|
|
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
|
+
};
|
|
2412
2513
|
}
|
|
2413
2514
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
2414
2515
|
if (options.isolateCssSource) {
|
|
@@ -2442,9 +2543,10 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
2442
2543
|
}
|
|
2443
2544
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
2444
2545
|
const resolvedStyleOptions = resolveStyleOptionsFromContext(opts);
|
|
2546
|
+
const scopedVueStyleSource = isVueScopedStyleSource(resolvePostcssFromOption(cssHandlerOptions));
|
|
2445
2547
|
const preflightStyleOptions = {
|
|
2446
|
-
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
2447
|
-
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
2548
|
+
cssPreflight: scopedVueStyleSource ? false : resolvedStyleOptions.cssPreflight,
|
|
2549
|
+
cssPreflightRange: scopedVueStyleSource ? void 0 : resolvedStyleOptions.cssPreflightRange
|
|
2448
2550
|
};
|
|
2449
2551
|
return {
|
|
2450
2552
|
...resolvedStyleOptions,
|
|
@@ -2750,6 +2852,22 @@ function isClassContextLiteralPath(path) {
|
|
|
2750
2852
|
return false;
|
|
2751
2853
|
}
|
|
2752
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
|
|
2753
2871
|
//#region src/js/replacement-cache.ts
|
|
2754
2872
|
const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
|
|
2755
2873
|
const defaultReplacementCache = /* @__PURE__ */ new Map();
|
|
@@ -2909,7 +3027,7 @@ function replaceHandleValue(path, options) {
|
|
|
2909
3027
|
return {
|
|
2910
3028
|
start,
|
|
2911
3029
|
end,
|
|
2912
|
-
value: needEscaped ?
|
|
3030
|
+
value: needEscaped ? jsStringEscape(transformed) : transformed,
|
|
2913
3031
|
path
|
|
2914
3032
|
};
|
|
2915
3033
|
}
|
|
@@ -3475,17 +3593,6 @@ function parseImportSourceParam(params) {
|
|
|
3475
3593
|
sourcePath: match[3]
|
|
3476
3594
|
};
|
|
3477
3595
|
}
|
|
3478
|
-
function parseCssImportSpecifier(params) {
|
|
3479
|
-
const value = params.trim();
|
|
3480
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
3481
|
-
if (quoted) return quoted[2];
|
|
3482
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
3483
|
-
return url?.[2] ?? url?.[3];
|
|
3484
|
-
}
|
|
3485
|
-
function isTailwindCssImport(params) {
|
|
3486
|
-
const specifier = parseCssImportSpecifier(params);
|
|
3487
|
-
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
3488
|
-
}
|
|
3489
3596
|
function resolveSourceBase(base, sourcePath) {
|
|
3490
3597
|
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
3491
3598
|
}
|
|
@@ -3560,17 +3667,22 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
3560
3667
|
let importSourceBase;
|
|
3561
3668
|
let hasSourceNone = false;
|
|
3562
3669
|
let hasTailwindCssImport = false;
|
|
3670
|
+
let includesPreflight = false;
|
|
3563
3671
|
const [sourceEntries, configEntries] = await Promise.all([resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
|
|
3564
3672
|
const entries = [...configEntries.entries, ...sourceEntries];
|
|
3565
3673
|
const hasPositiveEntries = entries.some((entry) => !entry.negated);
|
|
3566
3674
|
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
3567
3675
|
root.walkAtRules("import", (rule) => {
|
|
3568
|
-
if (!
|
|
3676
|
+
if (!isTailwindV4CssImportParam(rule.params)) return;
|
|
3569
3677
|
hasTailwindCssImport = true;
|
|
3678
|
+
includesPreflight ||= isTailwindV4PreflightImportParam(rule.params);
|
|
3570
3679
|
const sourceParam = parseImportSourceParam(rule.params);
|
|
3571
3680
|
if (sourceParam?.none) hasSourceNone = true;
|
|
3572
3681
|
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
|
|
3573
3682
|
});
|
|
3683
|
+
root.walkAtRules("tailwind", (rule) => {
|
|
3684
|
+
includesPreflight ||= rule.params.trim() === "base";
|
|
3685
|
+
});
|
|
3574
3686
|
if (importSourceBase) return {
|
|
3575
3687
|
entries: [{
|
|
3576
3688
|
base: importSourceBase,
|
|
@@ -3578,30 +3690,35 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
3578
3690
|
pattern: VITE_SOURCE_CANDIDATE_PATTERN
|
|
3579
3691
|
}, ...entries],
|
|
3580
3692
|
explicit: true,
|
|
3693
|
+
includesPreflight,
|
|
3581
3694
|
inlineCandidates,
|
|
3582
3695
|
dependencies: configEntries.dependencies
|
|
3583
3696
|
};
|
|
3584
3697
|
if (hasSourceNone) return {
|
|
3585
3698
|
entries,
|
|
3586
3699
|
explicit: true,
|
|
3700
|
+
includesPreflight,
|
|
3587
3701
|
inlineCandidates,
|
|
3588
3702
|
dependencies: configEntries.dependencies
|
|
3589
3703
|
};
|
|
3590
3704
|
if (hasPositiveEntries) return {
|
|
3591
3705
|
entries,
|
|
3592
3706
|
explicit: true,
|
|
3707
|
+
includesPreflight,
|
|
3593
3708
|
inlineCandidates,
|
|
3594
3709
|
dependencies: configEntries.dependencies
|
|
3595
3710
|
};
|
|
3596
3711
|
if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
|
|
3597
3712
|
entries: [],
|
|
3598
3713
|
explicit: true,
|
|
3714
|
+
includesPreflight,
|
|
3599
3715
|
inlineCandidates,
|
|
3600
3716
|
dependencies: configEntries.dependencies
|
|
3601
3717
|
};
|
|
3602
3718
|
return hasTailwindCssImport ? {
|
|
3603
3719
|
entries,
|
|
3604
3720
|
explicit: false,
|
|
3721
|
+
includesPreflight,
|
|
3605
3722
|
inlineCandidates,
|
|
3606
3723
|
dependencies: configEntries.dependencies
|
|
3607
3724
|
} : void 0;
|
|
@@ -3953,8 +4070,9 @@ function withGeneratorSourceMetadata(source, metadata) {
|
|
|
3953
4070
|
__weappTailwindcssMeta: metadata
|
|
3954
4071
|
};
|
|
3955
4072
|
}
|
|
3956
|
-
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
4073
|
+
function withMatchedSourceSideMetadata(source, resolvedEntrySource, metadata = {}) {
|
|
3957
4074
|
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
4075
|
+
...metadata,
|
|
3958
4076
|
isolateCssSource: true,
|
|
3959
4077
|
matchedCssSourceFile: resolvedEntrySource.file,
|
|
3960
4078
|
sourceBase: resolvedEntrySource.base,
|
|
@@ -3962,24 +4080,6 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
|
3962
4080
|
}) : source;
|
|
3963
4081
|
}
|
|
3964
4082
|
//#endregion
|
|
3965
|
-
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
3966
|
-
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
3967
|
-
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
3968
|
-
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
3969
|
-
}
|
|
3970
|
-
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
3971
|
-
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
3972
|
-
if (!from || !node_path.default.isAbsolute(from)) return;
|
|
3973
|
-
return from.replace(/[?#].*$/, "");
|
|
3974
|
-
}
|
|
3975
|
-
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
3976
|
-
return cssHandlerOptions.sourceOptions;
|
|
3977
|
-
}
|
|
3978
|
-
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
3979
|
-
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
3980
|
-
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
3981
|
-
}
|
|
3982
|
-
//#endregion
|
|
3983
4083
|
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
3984
4084
|
function createCssEntrySources(cssEntries) {
|
|
3985
4085
|
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
|
|
@@ -4013,11 +4113,15 @@ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
|
4013
4113
|
cssEntries: options.cssEntries
|
|
4014
4114
|
});
|
|
4015
4115
|
}
|
|
4016
|
-
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
4116
|
+
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options = {}) {
|
|
4017
4117
|
const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
|
|
4018
|
-
if (!(0, node_fs.existsSync)(cssEntry)) return resolveTailwindV4Source({
|
|
4118
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return withGeneratorSourceMetadata(await resolveTailwindV4Source({
|
|
4019
4119
|
...omitUndefined(singleEntrySourceOptions),
|
|
4020
4120
|
cssEntries: [cssEntry]
|
|
4121
|
+
}), {
|
|
4122
|
+
cssEntryIndex: options.index,
|
|
4123
|
+
includesPreflight: options.includesPreflight,
|
|
4124
|
+
primaryCssSource: options.index === 0
|
|
4021
4125
|
});
|
|
4022
4126
|
const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
4023
4127
|
const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
|
|
@@ -4032,7 +4136,10 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
|
4032
4136
|
css: normalizeConfigDirective(css, config),
|
|
4033
4137
|
cssEntries: [cssEntry]
|
|
4034
4138
|
}), {
|
|
4139
|
+
cssEntryIndex: options.index,
|
|
4140
|
+
includesPreflight: options.includesPreflight,
|
|
4035
4141
|
matchedCssSourceFile: cssEntry,
|
|
4142
|
+
primaryCssSource: options.index === 0,
|
|
4036
4143
|
sourceBase: base,
|
|
4037
4144
|
sourceCss: css
|
|
4038
4145
|
});
|
|
@@ -4045,12 +4152,15 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
|
4045
4152
|
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
4046
4153
|
return rawSource.includes("@apply") || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
|
|
4047
4154
|
}
|
|
4048
|
-
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
4155
|
+
async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
4049
4156
|
const cssEntries = sourceOptions.cssEntries;
|
|
4050
4157
|
if (!cssEntries?.length) return;
|
|
4051
4158
|
const normalizedFile = node_path.default.resolve(file.replace(/[?#].*$/, ""));
|
|
4052
4159
|
const pathMatchedEntries = cssEntries.filter((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === normalizedFile);
|
|
4053
|
-
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
|
+
});
|
|
4054
4164
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
4055
4165
|
const matches = cssEntries.map((cssEntry) => {
|
|
4056
4166
|
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
@@ -4069,7 +4179,10 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
|
4069
4179
|
const bestScore = matches[0]?.score;
|
|
4070
4180
|
const matchingEntry = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssEntry : void 0;
|
|
4071
4181
|
if (!matchingEntry) return;
|
|
4072
|
-
return resolveTailwindV4CssEntrySource(matchingEntry, sourceOptions
|
|
4182
|
+
return resolveTailwindV4CssEntrySource(matchingEntry, sourceOptions, {
|
|
4183
|
+
includesPreflight: await resolveTailwindV4CssEntryIncludesPreflight(matchingEntry),
|
|
4184
|
+
index: cssEntries.indexOf(matchingEntry)
|
|
4185
|
+
});
|
|
4073
4186
|
}
|
|
4074
4187
|
function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
|
|
4075
4188
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
|
|
@@ -4119,7 +4232,7 @@ function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
|
|
|
4119
4232
|
cssSources
|
|
4120
4233
|
} : sourceOptions;
|
|
4121
4234
|
}
|
|
4122
|
-
async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions) {
|
|
4235
|
+
async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions, selectionOptions) {
|
|
4123
4236
|
const cssSources = sourceOptions.cssSources;
|
|
4124
4237
|
if (!cssSources?.length) return;
|
|
4125
4238
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
@@ -4140,7 +4253,12 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
|
|
|
4140
4253
|
const bestScore = matches[0]?.score;
|
|
4141
4254
|
const matchingSource = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssSource : void 0;
|
|
4142
4255
|
if (!matchingSource) return;
|
|
4143
|
-
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
|
+
});
|
|
4144
4262
|
}
|
|
4145
4263
|
function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
4146
4264
|
try {
|
|
@@ -4152,14 +4270,24 @@ function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
|
4152
4270
|
function hasConfiguredTailwindV4CssSource(sourceOptions) {
|
|
4153
4271
|
return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
|
|
4154
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
|
+
}
|
|
4155
4278
|
async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
|
|
4156
4279
|
const sourceBase = resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
4157
4280
|
const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
|
|
4158
|
-
|
|
4281
|
+
const source = await resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
|
|
4159
4282
|
base: sourceBase,
|
|
4160
4283
|
css: normalizedCssSource.css
|
|
4161
|
-
}))
|
|
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,
|
|
4162
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,
|
|
4163
4291
|
sourceBase,
|
|
4164
4292
|
sourceCss: normalizedCssSource.css
|
|
4165
4293
|
});
|
|
@@ -4188,6 +4316,47 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
4188
4316
|
if (runtimeHits === 0) return;
|
|
4189
4317
|
matches.push({
|
|
4190
4318
|
cssSource,
|
|
4319
|
+
includesPreflight: resolved.includesPreflight,
|
|
4320
|
+
index,
|
|
4321
|
+
runtimeHits,
|
|
4322
|
+
totalCandidates: scopedCandidates.size
|
|
4323
|
+
});
|
|
4324
|
+
}));
|
|
4325
|
+
if (matches.length === 0) return;
|
|
4326
|
+
matches.sort((a, b) => b.runtimeHits - a.runtimeHits || b.totalCandidates - a.totalCandidates || a.index - b.index);
|
|
4327
|
+
const best = matches[0];
|
|
4328
|
+
const second = matches[1];
|
|
4329
|
+
if (!best) return;
|
|
4330
|
+
if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
|
|
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,
|
|
4191
4360
|
index,
|
|
4192
4361
|
runtimeHits,
|
|
4193
4362
|
totalCandidates: scopedCandidates.size
|
|
@@ -4199,10 +4368,13 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
4199
4368
|
const second = matches[1];
|
|
4200
4369
|
if (!best) return;
|
|
4201
4370
|
if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
|
|
4202
|
-
return
|
|
4371
|
+
return resolveTailwindV4CssEntrySource(best.cssEntry, sourceOptions, {
|
|
4372
|
+
includesPreflight: best.includesPreflight,
|
|
4373
|
+
index: best.index
|
|
4374
|
+
});
|
|
4203
4375
|
}
|
|
4204
4376
|
function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
|
|
4205
|
-
return (cssSource) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions).then((source) => generatorOptions?.config ? {
|
|
4377
|
+
return (cssSource, index) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions, { index }).then((source) => generatorOptions?.config ? {
|
|
4206
4378
|
...source,
|
|
4207
4379
|
css: prependConfigDirective(source.css, generatorOptions.config)
|
|
4208
4380
|
} : source);
|
|
@@ -4215,11 +4387,19 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
|
|
|
4215
4387
|
sourceFile: resolvedEntrySource.file
|
|
4216
4388
|
});
|
|
4217
4389
|
const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
4218
|
-
|
|
4390
|
+
const source = await resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
|
|
4219
4391
|
base: resolvedEntrySource.base,
|
|
4220
4392
|
css,
|
|
4221
4393
|
cssEntries: [resolvedEntrySource.file]
|
|
4222
|
-
}))
|
|
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
|
+
});
|
|
4223
4403
|
}
|
|
4224
4404
|
async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
4225
4405
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
@@ -4237,7 +4417,7 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
4237
4417
|
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
4238
4418
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
4239
4419
|
cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
|
|
4240
|
-
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))
|
|
4241
4421
|
}) : void 0;
|
|
4242
4422
|
const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
|
|
4243
4423
|
if (applyEntrySource && !cssHandlerOptions.isMainChunk && !hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
|
|
@@ -4252,16 +4432,20 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
4252
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;
|
|
4253
4433
|
if (sourceSideCssSource) return sourceSideCssSource;
|
|
4254
4434
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
4255
|
-
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;
|
|
4256
4437
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
4257
|
-
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;
|
|
4258
4442
|
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await resolveTailwindV4Source(normalizedSourceOptions) : void 0;
|
|
4259
4443
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
4260
4444
|
...configuredCssSource,
|
|
4261
4445
|
css: prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
4262
4446
|
} : configuredCssSource;
|
|
4263
4447
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
4264
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
4448
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
4265
4449
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
4266
4450
|
...preferredCssEntrySource,
|
|
4267
4451
|
css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -4317,19 +4501,20 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
4317
4501
|
} : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
4318
4502
|
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
4319
4503
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
4320
|
-
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);
|
|
4321
4506
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
4322
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
|
|
4507
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource;
|
|
4323
4508
|
if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
|
|
4324
4509
|
...preferredCssEntrySource,
|
|
4325
4510
|
css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
4326
4511
|
} : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
4327
4512
|
if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
|
|
4328
|
-
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 ? {
|
|
4329
4514
|
...source,
|
|
4330
4515
|
css: prependConfigDirective(source.css, generatorOptions.config)
|
|
4331
4516
|
} : source)];
|
|
4332
|
-
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)];
|
|
4333
4518
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
4334
4519
|
return resolved ? [resolved] : [];
|
|
4335
4520
|
}
|
|
@@ -4338,7 +4523,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
4338
4523
|
return resolved ? [resolved] : [];
|
|
4339
4524
|
}
|
|
4340
4525
|
const normalizedCssSourceOptions = normalizeTailwindV4CssSourceConfigs(sourceOptions);
|
|
4341
|
-
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 ? {
|
|
4342
4527
|
...source,
|
|
4343
4528
|
css: prependConfigDirective(source.css, generatorOptions.config)
|
|
4344
4529
|
} : source)));
|
|
@@ -5349,7 +5534,7 @@ async function generateCssByGenerator(options) {
|
|
|
5349
5534
|
});
|
|
5350
5535
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
5351
5536
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
5352
|
-
cssEntries: opts.cssEntries,
|
|
5537
|
+
cssEntries: cssHandlerOptions.sourceOptions?.cssEntries ?? opts.cssEntries,
|
|
5353
5538
|
cssSources: options.cssSources,
|
|
5354
5539
|
getSourceCandidatesForEntries,
|
|
5355
5540
|
runtime: runtimeWithCurrentCss
|
|
@@ -5418,6 +5603,19 @@ async function generateCssByGenerator(options) {
|
|
|
5418
5603
|
const generatedCssSource = generated.target === "web" ? generated.css : stripTailwindBanner(generated.css);
|
|
5419
5604
|
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
5420
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
|
+
});
|
|
5421
5619
|
const orderedExtraCss = splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
|
|
5422
5620
|
const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
|
|
5423
5621
|
if (orderedExtraCss) {
|
|
@@ -5465,11 +5663,8 @@ async function generateCssByGenerator(options) {
|
|
|
5465
5663
|
}
|
|
5466
5664
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
5467
5665
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
5468
|
-
injectPreflight:
|
|
5469
|
-
|
|
5470
|
-
isolateCurrentCssCandidates,
|
|
5471
|
-
localImports
|
|
5472
|
-
}),
|
|
5666
|
+
injectPreflight: preflightMode.inject,
|
|
5667
|
+
preservePreflight: preflightMode.preserve,
|
|
5473
5668
|
styleOptions: generatorStyleOptions
|
|
5474
5669
|
});
|
|
5475
5670
|
return {
|
|
@@ -5573,11 +5768,8 @@ async function generateCssByGenerator(options) {
|
|
|
5573
5768
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
5574
5769
|
}
|
|
5575
5770
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
5576
|
-
injectPreflight:
|
|
5577
|
-
|
|
5578
|
-
isolateCurrentCssCandidates,
|
|
5579
|
-
localImports
|
|
5580
|
-
}),
|
|
5771
|
+
injectPreflight: preflightMode.inject,
|
|
5772
|
+
preservePreflight: preflightMode.preserve,
|
|
5581
5773
|
styleOptions: generatorStyleOptions
|
|
5582
5774
|
});
|
|
5583
5775
|
return {
|
|
@@ -5610,11 +5802,8 @@ async function generateCssByGenerator(options) {
|
|
|
5610
5802
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
5611
5803
|
}
|
|
5612
5804
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
5613
|
-
injectPreflight:
|
|
5614
|
-
|
|
5615
|
-
isolateCurrentCssCandidates,
|
|
5616
|
-
localImports
|
|
5617
|
-
}),
|
|
5805
|
+
injectPreflight: preflightMode.inject,
|
|
5806
|
+
preservePreflight: preflightMode.preserve,
|
|
5618
5807
|
styleOptions: generatorStyleOptions
|
|
5619
5808
|
});
|
|
5620
5809
|
return {
|
|
@@ -5870,7 +6059,7 @@ function createEvalReplacementToken(path, updated) {
|
|
|
5870
6059
|
return {
|
|
5871
6060
|
start,
|
|
5872
6061
|
end,
|
|
5873
|
-
value: path.isStringLiteral() ?
|
|
6062
|
+
value: path.isStringLiteral() ? jsStringEscape(updated) : updated,
|
|
5874
6063
|
path
|
|
5875
6064
|
};
|
|
5876
6065
|
}
|
|
@@ -7150,8 +7339,12 @@ function normalizeCssConfigDirectives(source, resourcePath) {
|
|
|
7150
7339
|
});
|
|
7151
7340
|
}
|
|
7152
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);
|
|
7153
7346
|
return {
|
|
7154
|
-
isMainChunk: options.mainCssChunkMatcher(file, appType),
|
|
7347
|
+
isMainChunk: matchedCssEntryIndex >= 0 ? matchedCssEntryIndex === 0 : options.mainCssChunkMatcher(file, appType),
|
|
7155
7348
|
postcssOptions: { options: { from: file } },
|
|
7156
7349
|
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
7157
7350
|
};
|