weapp-tailwindcss 5.0.12 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/auto-Ba6hDrse.mjs +13 -0
- package/dist/auto-DtU6f3X6.js +18 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +27 -10
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +6 -23
- package/dist/bundlers/shared/generator-css/types.d.ts +15 -1
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
- package/dist/bundlers/shared/run-tasks.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
- package/dist/bundlers/vite/css-memory.d.ts +37 -0
- package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +9 -7
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +63 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +80 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +5 -2
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +30 -0
- package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -1
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
- package/dist/bundlers/vite/map-cache.d.ts +2 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
- package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
- package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
- package/dist/bundlers/vite/source-candidates.d.ts +12 -2
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +3 -6
- package/dist/bundlers/vite/source-scan.d.ts +3 -3
- package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
- package/dist/bundlers/vite/utils.d.ts +1 -0
- package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -10
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +15 -1
- package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cli/mount-options.d.ts +2 -2
- package/dist/cli.js +126 -439
- package/dist/cli.mjs +121 -434
- package/dist/context/index.d.ts +3 -3
- package/dist/context/style-options.d.ts +4 -1
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/{precheck-30zNPRlI.js → context-BHxLe743.js} +484 -175
- package/dist/{precheck-CsFr1q2l.mjs → context-Mbzkek1q.mjs} +461 -159
- package/dist/core.js +15 -12
- package/dist/core.mjs +10 -7
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/{defaults-Boc26eel.js → defaults-CVcKbXBG.js} +6 -50
- package/dist/{defaults-DH0ZQRhy.mjs → defaults-ZElj1zKc.mjs} +7 -45
- package/dist/defaults.d.ts +1 -7
- package/dist/defaults.js +1 -2
- package/dist/defaults.mjs +2 -2
- package/dist/framework/index.d.ts +59 -0
- package/dist/framework.d.ts +1 -0
- package/dist/framework.js +198 -0
- package/dist/framework.mjs +180 -0
- package/dist/generator/index.d.ts +6 -7
- package/dist/generator/options.d.ts +3 -3
- package/dist/generator/types.d.ts +9 -10
- package/dist/generator-9rUz4Hcb.js +170 -0
- package/dist/generator-Dc4qaPmT.mjs +123 -0
- package/dist/generator.js +10 -16
- package/dist/generator.mjs +3 -3
- package/dist/{gulp-CxGZU0-v.js → gulp-B_sdP6dx.js} +80 -92
- package/dist/{gulp-BfZpaYSQ.mjs → gulp-uM36oIJs.mjs} +73 -85
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DNjF8bWA.mjs → hmr-timing-BXMLsF4b.mjs} +1289 -909
- package/dist/{hmr-timing-DFR51wgo.js → hmr-timing-CogqkFaF.js} +1397 -939
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -4
- package/dist/index.mjs +6 -5
- package/dist/js/fast-path/oxc.d.ts +4 -0
- package/dist/js/precheck.d.ts +1 -0
- package/dist/postcss.js +3 -4
- package/dist/postcss.mjs +2 -3
- package/dist/presets.js +10 -20
- package/dist/presets.mjs +9 -19
- package/dist/runtime-branch/create-branch.d.ts +2 -0
- package/dist/runtime-branch/generator-target-env.d.ts +4 -0
- package/dist/runtime-branch/index.d.ts +6 -0
- package/dist/runtime-branch/mini-program.d.ts +2 -0
- package/dist/runtime-branch/native-app.d.ts +2 -0
- package/dist/runtime-branch/platform.d.ts +6 -0
- package/dist/runtime-branch/tailwind-version.d.ts +2 -0
- package/dist/runtime-branch/types.d.ts +37 -0
- package/dist/runtime-branch/web.d.ts +2 -0
- package/dist/runtime-branch.d.ts +1 -0
- package/dist/{bundle-state-DU2ATDhw.js → source-candidate-scan-signature-2ybpptAK.js} +262 -20
- package/dist/{bundle-state-BxMNKjBV.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
- package/dist/tailwindcss/candidates.d.ts +7 -0
- package/dist/tailwindcss/index.d.ts +2 -2
- package/dist/tailwindcss/runtime/cache.d.ts +6 -6
- package/dist/tailwindcss/runtime-factory.d.ts +12 -0
- package/dist/tailwindcss/runtime-options.d.ts +8 -0
- package/dist/tailwindcss/runtime-types.d.ts +86 -0
- package/dist/tailwindcss/runtime.d.ts +6 -6
- package/dist/tailwindcss/source-scan.d.ts +1 -1
- package/dist/tailwindcss/targets.d.ts +2 -2
- package/dist/tailwindcss/v4/config.d.ts +3 -3
- package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
- package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
- package/dist/tailwindcss/v4/index.d.ts +1 -1
- package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
- package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
- package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
- package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
- package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
- package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
- package/dist/tailwindcss/version.d.ts +1 -1
- package/dist/tailwindcss-DHIYcqXT.js +1523 -0
- package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
- package/dist/{transform-CaVEBOuR.js → transform-CQVOgmzM.js} +45 -37
- package/dist/{transform-Cju08-aJ.mjs → transform-tExdt40m.mjs} +30 -22
- package/dist/typedoc.export.d.ts +1 -1
- package/dist/types/index.d.ts +16 -17
- package/dist/types/shared.d.ts +1 -1
- package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
- package/dist/types/user-defined-options/general.d.ts +8 -4
- package/dist/types/user-defined-options/important.d.ts +2 -2
- package/dist/uni-app-x/style-asset.d.ts +1 -0
- package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
- package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
- package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
- package/dist/v4-engine-D4ubP7N5.js +2778 -0
- package/dist/{vite-BBGOjh9e.js → vite-CP0ylSxZ.js} +2887 -1683
- package/dist/{vite-CS5DE-HD.mjs → vite-CPO83EhA.mjs} +2753 -1548
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5741 -4396
- package/dist/weapp-tw-runtime-classset-loader.js +36 -0
- package/dist/webpack-Bsek8VhR.js +2094 -0
- package/dist/webpack-BzqhJ8yK.mjs +2082 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +11 -7
- package/dist/auto-CTp6wE5a.js +0 -33
- package/dist/auto-Cl8_hsG6.mjs +0 -22
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
- package/dist/context/tailwindcss/rax.d.ts +0 -2
- package/dist/generator-Cb1Zp3Al.js +0 -92
- package/dist/generator-mvNFUvns.mjs +0 -67
- package/dist/tailwindcss/patcher-options.d.ts +0 -8
- package/dist/tailwindcss/patcher.d.ts +0 -12
- package/dist/tailwindcss/runtime-patch.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
- package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
- package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
- package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher.d.ts +0 -15
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
- package/dist/tailwindcss-CK84uGBp.mjs +0 -556
- package/dist/tailwindcss-Clpkz1oR.js +0 -613
- package/dist/v3-engine-CQE5JJNZ.js +0 -4639
- package/dist/v3-engine-DKBaKWGL.mjs +0 -4231
- package/dist/webpack-DIWrcpRo.js +0 -1066
- package/dist/webpack-SPcri_D8.mjs +0 -1054
- /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
|
@@ -0,0 +1,2778 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
+
require("./auto-DtU6f3X6.js");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
node_fs = require_chunk.__toESM(node_fs);
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_chunk.__toESM(node_path);
|
|
7
|
+
let node_process = require("node:process");
|
|
8
|
+
node_process = require_chunk.__toESM(node_process);
|
|
9
|
+
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
10
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
11
|
+
let lru_cache = require("lru-cache");
|
|
12
|
+
let node_fs_promises = require("node:fs/promises");
|
|
13
|
+
let micromatch = require("micromatch");
|
|
14
|
+
micromatch = require_chunk.__toESM(micromatch);
|
|
15
|
+
let node_module = require("node:module");
|
|
16
|
+
//#region src/runtime-branch/generator-target-env.ts
|
|
17
|
+
const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
|
|
18
|
+
const uniWebPlatformEnvKeys = ["UNI_PLATFORM", "UNI_UTS_PLATFORM"];
|
|
19
|
+
const mpxWebPlatformEnvKeys = ["MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE"];
|
|
20
|
+
function getEnvValue(key) {
|
|
21
|
+
return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
|
|
22
|
+
}
|
|
23
|
+
function normalizeGeneratorTargetValue(value) {
|
|
24
|
+
return value === "weapp" || value === "web" ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
function isUniWebPlatform(value) {
|
|
27
|
+
const normalized = value?.trim().toLowerCase();
|
|
28
|
+
return normalized === "h5" || normalized?.startsWith("web") === true;
|
|
29
|
+
}
|
|
30
|
+
function isUniAppWebViewPlatform(value) {
|
|
31
|
+
const normalized = value?.trim().toLowerCase();
|
|
32
|
+
return normalized === "app" || normalized === "app-plus";
|
|
33
|
+
}
|
|
34
|
+
function isUniNativeAppPlatform(value) {
|
|
35
|
+
return (value?.trim().toLowerCase())?.startsWith("app-") === true;
|
|
36
|
+
}
|
|
37
|
+
function isMpxWebPlatform(value) {
|
|
38
|
+
return value?.trim().toLowerCase() === "web";
|
|
39
|
+
}
|
|
40
|
+
function inferGeneratorTargetFromExplicitEnv() {
|
|
41
|
+
for (const key of explicitGeneratorTargetEnvKeys) {
|
|
42
|
+
const target = normalizeGeneratorTargetValue(getEnvValue(key));
|
|
43
|
+
if (target !== void 0) return target;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function shouldUseWebGeneratorTargetFromEnv() {
|
|
47
|
+
return uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5";
|
|
48
|
+
}
|
|
49
|
+
function inferGeneratorTargetFromEnv() {
|
|
50
|
+
return inferGeneratorTargetFromExplicitEnv() ?? (shouldUseWebGeneratorTargetFromEnv() ? "web" : "weapp");
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/utils/object.ts
|
|
54
|
+
function definedEntries(value) {
|
|
55
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
56
|
+
}
|
|
57
|
+
function omitUndefined(value) {
|
|
58
|
+
return Object.fromEntries(definedEntries(value));
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/tailwindcss/v4-engine/candidates.ts
|
|
62
|
+
const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:in|not-in)-\[/;
|
|
63
|
+
function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
|
|
64
|
+
return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
|
|
65
|
+
}
|
|
66
|
+
function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
67
|
+
if (!candidates) return;
|
|
68
|
+
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
72
|
+
const TAILWIND_V4_COLOR_STEPS = [
|
|
73
|
+
"50",
|
|
74
|
+
"100",
|
|
75
|
+
"200",
|
|
76
|
+
"300",
|
|
77
|
+
"400",
|
|
78
|
+
"500",
|
|
79
|
+
"600",
|
|
80
|
+
"700",
|
|
81
|
+
"800",
|
|
82
|
+
"900",
|
|
83
|
+
"950"
|
|
84
|
+
];
|
|
85
|
+
const TAILWIND_V4_COLOR_PALETTE = {
|
|
86
|
+
slate: [
|
|
87
|
+
"#f8fafc",
|
|
88
|
+
"#f1f5f9",
|
|
89
|
+
"#e2e8f0",
|
|
90
|
+
"#cad5e2",
|
|
91
|
+
"#90a1b9",
|
|
92
|
+
"#62748e",
|
|
93
|
+
"#45556c",
|
|
94
|
+
"#314158",
|
|
95
|
+
"#1d293d",
|
|
96
|
+
"#0f172b",
|
|
97
|
+
"#020618"
|
|
98
|
+
],
|
|
99
|
+
gray: [
|
|
100
|
+
"#f9fafb",
|
|
101
|
+
"#f3f4f6",
|
|
102
|
+
"#e5e7eb",
|
|
103
|
+
"#d1d5dc",
|
|
104
|
+
"#99a1af",
|
|
105
|
+
"#6a7282",
|
|
106
|
+
"#4a5565",
|
|
107
|
+
"#364153",
|
|
108
|
+
"#1e2939",
|
|
109
|
+
"#101828",
|
|
110
|
+
"#030712"
|
|
111
|
+
],
|
|
112
|
+
zinc: [
|
|
113
|
+
"#fafafa",
|
|
114
|
+
"#f4f4f5",
|
|
115
|
+
"#e4e4e7",
|
|
116
|
+
"#d4d4d8",
|
|
117
|
+
"#9f9fa9",
|
|
118
|
+
"#71717b",
|
|
119
|
+
"#52525c",
|
|
120
|
+
"#3f3f46",
|
|
121
|
+
"#27272a",
|
|
122
|
+
"#18181b",
|
|
123
|
+
"#09090b"
|
|
124
|
+
],
|
|
125
|
+
neutral: [
|
|
126
|
+
"#fafafa",
|
|
127
|
+
"#f5f5f5",
|
|
128
|
+
"#e5e5e5",
|
|
129
|
+
"#d4d4d4",
|
|
130
|
+
"#a1a1a1",
|
|
131
|
+
"#737373",
|
|
132
|
+
"#525252",
|
|
133
|
+
"#404040",
|
|
134
|
+
"#262626",
|
|
135
|
+
"#171717",
|
|
136
|
+
"#0a0a0a"
|
|
137
|
+
],
|
|
138
|
+
stone: [
|
|
139
|
+
"#fafaf9",
|
|
140
|
+
"#f5f5f4",
|
|
141
|
+
"#e7e5e4",
|
|
142
|
+
"#d6d3d1",
|
|
143
|
+
"#a6a09b",
|
|
144
|
+
"#79716b",
|
|
145
|
+
"#57534d",
|
|
146
|
+
"#44403b",
|
|
147
|
+
"#292524",
|
|
148
|
+
"#1c1917",
|
|
149
|
+
"#0c0a09"
|
|
150
|
+
],
|
|
151
|
+
mauve: [
|
|
152
|
+
"#fafafa",
|
|
153
|
+
"#f3f1f3",
|
|
154
|
+
"#e7e4e7",
|
|
155
|
+
"#d7d0d7",
|
|
156
|
+
"#a89ea9",
|
|
157
|
+
"#79697b",
|
|
158
|
+
"#594c5b",
|
|
159
|
+
"#463947",
|
|
160
|
+
"#2a212c",
|
|
161
|
+
"#1d161e",
|
|
162
|
+
"#0c090c"
|
|
163
|
+
],
|
|
164
|
+
olive: [
|
|
165
|
+
"#fbfbf9",
|
|
166
|
+
"#f4f4f0",
|
|
167
|
+
"#e8e8e3",
|
|
168
|
+
"#d8d8d0",
|
|
169
|
+
"#abab9c",
|
|
170
|
+
"#7c7c67",
|
|
171
|
+
"#5b5b4b",
|
|
172
|
+
"#474739",
|
|
173
|
+
"#2b2b22",
|
|
174
|
+
"#1d1d16",
|
|
175
|
+
"#0c0c09"
|
|
176
|
+
],
|
|
177
|
+
mist: [
|
|
178
|
+
"#f9fbfb",
|
|
179
|
+
"#f1f3f3",
|
|
180
|
+
"#e3e7e8",
|
|
181
|
+
"#d0d6d8",
|
|
182
|
+
"#9ca8ab",
|
|
183
|
+
"#67787c",
|
|
184
|
+
"#4b585b",
|
|
185
|
+
"#394447",
|
|
186
|
+
"#22292b",
|
|
187
|
+
"#161b1d",
|
|
188
|
+
"#090b0c"
|
|
189
|
+
],
|
|
190
|
+
taupe: [
|
|
191
|
+
"#fbfaf9",
|
|
192
|
+
"#f3f1f1",
|
|
193
|
+
"#e8e4e3",
|
|
194
|
+
"#d8d2d0",
|
|
195
|
+
"#aba09c",
|
|
196
|
+
"#7c6d67",
|
|
197
|
+
"#5b4f4b",
|
|
198
|
+
"#473c39",
|
|
199
|
+
"#2b2422",
|
|
200
|
+
"#1d1816",
|
|
201
|
+
"#0c0a09"
|
|
202
|
+
],
|
|
203
|
+
red: [
|
|
204
|
+
"#fef2f2",
|
|
205
|
+
"#ffe2e2",
|
|
206
|
+
"#ffc9c9",
|
|
207
|
+
"#ffa2a2",
|
|
208
|
+
"#ff6467",
|
|
209
|
+
"#fb2c36",
|
|
210
|
+
"#e7000b",
|
|
211
|
+
"#c10007",
|
|
212
|
+
"#9f0712",
|
|
213
|
+
"#82181a",
|
|
214
|
+
"#460809"
|
|
215
|
+
],
|
|
216
|
+
orange: [
|
|
217
|
+
"#fff7ed",
|
|
218
|
+
"#ffedd4",
|
|
219
|
+
"#ffd6a7",
|
|
220
|
+
"#ffb86a",
|
|
221
|
+
"#ff8904",
|
|
222
|
+
"#ff6900",
|
|
223
|
+
"#f54900",
|
|
224
|
+
"#ca3500",
|
|
225
|
+
"#9f2d00",
|
|
226
|
+
"#7e2a0c",
|
|
227
|
+
"#441306"
|
|
228
|
+
],
|
|
229
|
+
amber: [
|
|
230
|
+
"#fffbeb",
|
|
231
|
+
"#fef3c6",
|
|
232
|
+
"#fee685",
|
|
233
|
+
"#ffd230",
|
|
234
|
+
"#ffb900",
|
|
235
|
+
"#fe9a00",
|
|
236
|
+
"#e17100",
|
|
237
|
+
"#bb4d00",
|
|
238
|
+
"#973c00",
|
|
239
|
+
"#7b3306",
|
|
240
|
+
"#461901"
|
|
241
|
+
],
|
|
242
|
+
yellow: [
|
|
243
|
+
"#fefce8",
|
|
244
|
+
"#fef9c2",
|
|
245
|
+
"#fff085",
|
|
246
|
+
"#ffdf20",
|
|
247
|
+
"#fdc700",
|
|
248
|
+
"#f0b100",
|
|
249
|
+
"#d08700",
|
|
250
|
+
"#a65f00",
|
|
251
|
+
"#894b00",
|
|
252
|
+
"#733e0a",
|
|
253
|
+
"#432004"
|
|
254
|
+
],
|
|
255
|
+
lime: [
|
|
256
|
+
"#f7fee7",
|
|
257
|
+
"#ecfcca",
|
|
258
|
+
"#d8f999",
|
|
259
|
+
"#bbf451",
|
|
260
|
+
"#9ae600",
|
|
261
|
+
"#7ccf00",
|
|
262
|
+
"#5ea500",
|
|
263
|
+
"#497d00",
|
|
264
|
+
"#3c6300",
|
|
265
|
+
"#35530e",
|
|
266
|
+
"#192e03"
|
|
267
|
+
],
|
|
268
|
+
green: [
|
|
269
|
+
"#f0fdf4",
|
|
270
|
+
"#dcfce7",
|
|
271
|
+
"#b9f8cf",
|
|
272
|
+
"#7bf1a8",
|
|
273
|
+
"#05df72",
|
|
274
|
+
"#00c950",
|
|
275
|
+
"#00a63e",
|
|
276
|
+
"#008236",
|
|
277
|
+
"#016630",
|
|
278
|
+
"#0d542b",
|
|
279
|
+
"#032e15"
|
|
280
|
+
],
|
|
281
|
+
emerald: [
|
|
282
|
+
"#ecfdf5",
|
|
283
|
+
"#d0fae5",
|
|
284
|
+
"#a4f4cf",
|
|
285
|
+
"#5ee9b5",
|
|
286
|
+
"#00d492",
|
|
287
|
+
"#00bc7d",
|
|
288
|
+
"#009966",
|
|
289
|
+
"#007a55",
|
|
290
|
+
"#006045",
|
|
291
|
+
"#004f3b",
|
|
292
|
+
"#002c22"
|
|
293
|
+
],
|
|
294
|
+
teal: [
|
|
295
|
+
"#f0fdfa",
|
|
296
|
+
"#cbfbf1",
|
|
297
|
+
"#96f7e4",
|
|
298
|
+
"#46ecd5",
|
|
299
|
+
"#00d5be",
|
|
300
|
+
"#00bba7",
|
|
301
|
+
"#009689",
|
|
302
|
+
"#00786f",
|
|
303
|
+
"#005f5a",
|
|
304
|
+
"#0b4f4a",
|
|
305
|
+
"#022f2e"
|
|
306
|
+
],
|
|
307
|
+
cyan: [
|
|
308
|
+
"#ecfeff",
|
|
309
|
+
"#cefafe",
|
|
310
|
+
"#a2f4fd",
|
|
311
|
+
"#53eafd",
|
|
312
|
+
"#00d3f2",
|
|
313
|
+
"#00b8db",
|
|
314
|
+
"#0092b8",
|
|
315
|
+
"#007595",
|
|
316
|
+
"#005f78",
|
|
317
|
+
"#104e64",
|
|
318
|
+
"#053345"
|
|
319
|
+
],
|
|
320
|
+
sky: [
|
|
321
|
+
"#f0f9ff",
|
|
322
|
+
"#dff2fe",
|
|
323
|
+
"#b8e6fe",
|
|
324
|
+
"#74d4ff",
|
|
325
|
+
"#00bcff",
|
|
326
|
+
"#00a6f4",
|
|
327
|
+
"#0084d1",
|
|
328
|
+
"#0069a8",
|
|
329
|
+
"#00598a",
|
|
330
|
+
"#024a70",
|
|
331
|
+
"#052f4a"
|
|
332
|
+
],
|
|
333
|
+
blue: [
|
|
334
|
+
"#eff6ff",
|
|
335
|
+
"#dbeafe",
|
|
336
|
+
"#bedbff",
|
|
337
|
+
"#8ec5ff",
|
|
338
|
+
"#51a2ff",
|
|
339
|
+
"#2b7fff",
|
|
340
|
+
"#155dfc",
|
|
341
|
+
"#1447e6",
|
|
342
|
+
"#193cb8",
|
|
343
|
+
"#1c398e",
|
|
344
|
+
"#162456"
|
|
345
|
+
],
|
|
346
|
+
indigo: [
|
|
347
|
+
"#eef2ff",
|
|
348
|
+
"#e0e7ff",
|
|
349
|
+
"#c6d2ff",
|
|
350
|
+
"#a3b3ff",
|
|
351
|
+
"#7c86ff",
|
|
352
|
+
"#615fff",
|
|
353
|
+
"#4f39f6",
|
|
354
|
+
"#432dd7",
|
|
355
|
+
"#372aac",
|
|
356
|
+
"#312c85",
|
|
357
|
+
"#1e1a4d"
|
|
358
|
+
],
|
|
359
|
+
violet: [
|
|
360
|
+
"#f5f3ff",
|
|
361
|
+
"#ede9fe",
|
|
362
|
+
"#ddd6ff",
|
|
363
|
+
"#c4b4ff",
|
|
364
|
+
"#a684ff",
|
|
365
|
+
"#8e51ff",
|
|
366
|
+
"#7f22fe",
|
|
367
|
+
"#7008e7",
|
|
368
|
+
"#5d0ec0",
|
|
369
|
+
"#4d179a",
|
|
370
|
+
"#2f0d68"
|
|
371
|
+
],
|
|
372
|
+
purple: [
|
|
373
|
+
"#faf5ff",
|
|
374
|
+
"#f3e8ff",
|
|
375
|
+
"#e9d4ff",
|
|
376
|
+
"#dab2ff",
|
|
377
|
+
"#c27aff",
|
|
378
|
+
"#ad46ff",
|
|
379
|
+
"#9810fa",
|
|
380
|
+
"#8200db",
|
|
381
|
+
"#6e11b0",
|
|
382
|
+
"#59168b",
|
|
383
|
+
"#3c0366"
|
|
384
|
+
],
|
|
385
|
+
fuchsia: [
|
|
386
|
+
"#fdf4ff",
|
|
387
|
+
"#fae8ff",
|
|
388
|
+
"#f6cfff",
|
|
389
|
+
"#f4a8ff",
|
|
390
|
+
"#ed6aff",
|
|
391
|
+
"#e12afb",
|
|
392
|
+
"#c800de",
|
|
393
|
+
"#a800b7",
|
|
394
|
+
"#8a0194",
|
|
395
|
+
"#721378",
|
|
396
|
+
"#4b004f"
|
|
397
|
+
],
|
|
398
|
+
pink: [
|
|
399
|
+
"#fdf2f8",
|
|
400
|
+
"#fce7f3",
|
|
401
|
+
"#fccee8",
|
|
402
|
+
"#fda5d5",
|
|
403
|
+
"#fb64b6",
|
|
404
|
+
"#f6339a",
|
|
405
|
+
"#e60076",
|
|
406
|
+
"#c6005c",
|
|
407
|
+
"#a3004c",
|
|
408
|
+
"#861043",
|
|
409
|
+
"#510424"
|
|
410
|
+
],
|
|
411
|
+
rose: [
|
|
412
|
+
"#fff1f2",
|
|
413
|
+
"#ffe4e6",
|
|
414
|
+
"#ffccd3",
|
|
415
|
+
"#ffa1ad",
|
|
416
|
+
"#ff637e",
|
|
417
|
+
"#ff2056",
|
|
418
|
+
"#ec003f",
|
|
419
|
+
"#c70036",
|
|
420
|
+
"#a50036",
|
|
421
|
+
"#8b0836",
|
|
422
|
+
"#4d0218"
|
|
423
|
+
]
|
|
424
|
+
};
|
|
425
|
+
function createTailwindV4DefaultColorThemeCss() {
|
|
426
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
427
|
+
for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
|
|
428
|
+
return [
|
|
429
|
+
"@theme {",
|
|
430
|
+
...declarations,
|
|
431
|
+
"}"
|
|
432
|
+
].join("\n");
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/tailwindcss/v4-engine/generator/css-compat.ts
|
|
436
|
+
function findLeadingImportInsertionIndex(css) {
|
|
437
|
+
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
438
|
+
let insertionIndex = 0;
|
|
439
|
+
let match = importPattern.exec(css);
|
|
440
|
+
while (match !== null) {
|
|
441
|
+
insertionIndex = match.index + match[0].length;
|
|
442
|
+
match = importPattern.exec(css);
|
|
443
|
+
}
|
|
444
|
+
return insertionIndex;
|
|
445
|
+
}
|
|
446
|
+
function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
447
|
+
const themeCss = createTailwindV4DefaultColorThemeCss();
|
|
448
|
+
const insertionIndex = findLeadingImportInsertionIndex(css);
|
|
449
|
+
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
450
|
+
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
451
|
+
}
|
|
452
|
+
function parseCssImportSpecifier$2(params) {
|
|
453
|
+
const value = params.trim();
|
|
454
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
455
|
+
if (quoted) return quoted[2];
|
|
456
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
457
|
+
return url?.[2] ?? url?.[3];
|
|
458
|
+
}
|
|
459
|
+
function isTailwindCssPreflightImport(params) {
|
|
460
|
+
const specifier = parseCssImportSpecifier$2(params);
|
|
461
|
+
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
462
|
+
}
|
|
463
|
+
function removeTailwindV4PreflightImports(css) {
|
|
464
|
+
if (!css.includes("preflight")) return css;
|
|
465
|
+
let root;
|
|
466
|
+
try {
|
|
467
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
468
|
+
} catch {
|
|
469
|
+
return css;
|
|
470
|
+
}
|
|
471
|
+
let changed = false;
|
|
472
|
+
root.walkAtRules("import", (rule) => {
|
|
473
|
+
if (isTailwindCssPreflightImport(rule.params)) {
|
|
474
|
+
rule.remove();
|
|
475
|
+
changed = true;
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
return changed ? root.toString() : css;
|
|
479
|
+
}
|
|
480
|
+
function hasThemeParent(rule) {
|
|
481
|
+
let parent = rule.parent;
|
|
482
|
+
while (parent) {
|
|
483
|
+
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
484
|
+
parent = parent.parent;
|
|
485
|
+
}
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
function isVendorPrefixedKeyframes(rule) {
|
|
489
|
+
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
490
|
+
}
|
|
491
|
+
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
492
|
+
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
493
|
+
let root;
|
|
494
|
+
try {
|
|
495
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
496
|
+
} catch {
|
|
497
|
+
return css;
|
|
498
|
+
}
|
|
499
|
+
let changed = false;
|
|
500
|
+
root.walkAtRules((rule) => {
|
|
501
|
+
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
502
|
+
rule.remove();
|
|
503
|
+
changed = true;
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
return changed ? root.toString() : css;
|
|
507
|
+
}
|
|
508
|
+
function createCompatibleSource(source, target) {
|
|
509
|
+
const filteredSourceCss = target === "weapp" ? removeTailwindV4PreflightImports(source.css) : source.css;
|
|
510
|
+
const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
|
|
511
|
+
return compatibleSourceCss === source.css ? source : {
|
|
512
|
+
...source,
|
|
513
|
+
css: compatibleSourceCss
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
|
|
518
|
+
const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
|
|
519
|
+
const BARE_RPX_LENGTH_CANDIDATE_RE = new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
|
|
520
|
+
const BARE_RPX_LENGTH_HINT_CANDIDATE_RE = new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
|
|
521
|
+
const RPX_LENGTH_SELECTOR_RE = new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
|
|
522
|
+
function normalizeRpxLengthCandidate(candidate) {
|
|
523
|
+
return candidate.replace(BARE_RPX_LENGTH_CANDIDATE_RE, (_match, prefix, important, utility, value, suffix) => {
|
|
524
|
+
return `${prefix}${important}${utility}-[length:${value}]${suffix}`;
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function normalizeRpxLengthCandidates(candidates) {
|
|
528
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
529
|
+
const restoreCandidates = /* @__PURE__ */ new Map();
|
|
530
|
+
for (const candidate of candidates) {
|
|
531
|
+
const normalizedCandidate = normalizeRpxLengthCandidate(candidate);
|
|
532
|
+
normalized.add(normalizedCandidate);
|
|
533
|
+
if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
candidates: normalized,
|
|
537
|
+
restoreCandidates
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function restoreRpxLengthCandidates(candidates, restoreCandidates) {
|
|
541
|
+
if (restoreCandidates.size === 0) return new Set(candidates);
|
|
542
|
+
return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
|
|
543
|
+
}
|
|
544
|
+
function normalizeCssEscapedRpxSelectorValue(value) {
|
|
545
|
+
return value.replace(/\\([.+-])/g, "$1");
|
|
546
|
+
}
|
|
547
|
+
function restoreRpxLengthCssSelectors(css, restoreCandidates) {
|
|
548
|
+
if (restoreCandidates.size === 0 || !css.includes("\\[length\\:")) return css;
|
|
549
|
+
const restoredUtilities = new Set([...restoreCandidates.keys()].map((candidate) => {
|
|
550
|
+
const match = BARE_RPX_LENGTH_HINT_CANDIDATE_RE.exec(candidate);
|
|
551
|
+
return match ? `${match[1]}:${match[2]}` : void 0;
|
|
552
|
+
}).filter((value) => Boolean(value)));
|
|
553
|
+
return css.replace(RPX_LENGTH_SELECTOR_RE, (match, utility, value) => {
|
|
554
|
+
return restoredUtilities.has(`${utility}:${normalizeCssEscapedRpxSelectorValue(value)}`) ? `${utility}-\\[${value}\\]` : match;
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region src/tailwindcss/source-scan/inline-source.ts
|
|
559
|
+
const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
560
|
+
function segmentTopLevel(input, separator, options = {}) {
|
|
561
|
+
const parts = [];
|
|
562
|
+
const stack = [];
|
|
563
|
+
let lastPos = 0;
|
|
564
|
+
let quote;
|
|
565
|
+
for (let index = 0; index < input.length; index++) {
|
|
566
|
+
const char = input[index];
|
|
567
|
+
if (char === "\\") {
|
|
568
|
+
index += 1;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
if (quote) {
|
|
572
|
+
if (char === quote) quote = void 0;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if (char === "\"" || char === "'") {
|
|
576
|
+
quote = char;
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
if (char === "(") {
|
|
580
|
+
stack.push(")");
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
if (char === "[") {
|
|
584
|
+
stack.push("]");
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (char === "{") {
|
|
588
|
+
stack.push("}");
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (stack.length > 0 && char === stack[stack.length - 1]) {
|
|
592
|
+
stack.pop();
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
if (stack.length === 0 && char === separator) {
|
|
596
|
+
const part = input.slice(lastPos, index);
|
|
597
|
+
if (part || options.keepEmpty) parts.push(part);
|
|
598
|
+
lastPos = index + 1;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const part = input.slice(lastPos);
|
|
602
|
+
if (part || options.keepEmpty) parts.push(part);
|
|
603
|
+
return parts;
|
|
604
|
+
}
|
|
605
|
+
function isSequence(value) {
|
|
606
|
+
return NUMERICAL_RANGE_RE.test(value);
|
|
607
|
+
}
|
|
608
|
+
function expandSequence(value) {
|
|
609
|
+
const match = value.match(NUMERICAL_RANGE_RE);
|
|
610
|
+
if (!match) return [value];
|
|
611
|
+
const [, start, end, stepValue] = match;
|
|
612
|
+
if (start === void 0 || end === void 0) return [value];
|
|
613
|
+
let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
|
|
614
|
+
const startNumber = Number.parseInt(start, 10);
|
|
615
|
+
const endNumber = Number.parseInt(end, 10);
|
|
616
|
+
const increasing = startNumber < endNumber;
|
|
617
|
+
if (step === void 0) step = increasing ? 1 : -1;
|
|
618
|
+
if (step === 0) return [];
|
|
619
|
+
if (increasing && step < 0) step = -step;
|
|
620
|
+
if (!increasing && step > 0) step = -step;
|
|
621
|
+
const result = [];
|
|
622
|
+
for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
function expandInlineSourceCandidatePattern(pattern) {
|
|
626
|
+
const index = pattern.indexOf("{");
|
|
627
|
+
if (index === -1) return [pattern];
|
|
628
|
+
const prefix = pattern.slice(0, index);
|
|
629
|
+
const rest = pattern.slice(index);
|
|
630
|
+
let depth = 0;
|
|
631
|
+
let endIndex = -1;
|
|
632
|
+
for (let index = 0; index < rest.length; index++) {
|
|
633
|
+
const char = rest[index];
|
|
634
|
+
if (char === "{") depth += 1;
|
|
635
|
+
else if (char === "}") {
|
|
636
|
+
depth -= 1;
|
|
637
|
+
if (depth === 0) {
|
|
638
|
+
endIndex = index;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
if (endIndex === -1) return [pattern];
|
|
644
|
+
const inner = rest.slice(1, endIndex);
|
|
645
|
+
const suffix = rest.slice(endIndex + 1);
|
|
646
|
+
const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
|
|
647
|
+
return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
|
|
648
|
+
}
|
|
649
|
+
function parseSourceInlineParam(params) {
|
|
650
|
+
let value = params.trim();
|
|
651
|
+
const negated = value.startsWith("not ");
|
|
652
|
+
if (negated) value = value.slice(4).trim();
|
|
653
|
+
if (!value.startsWith("inline(") || !value.endsWith(")")) return;
|
|
654
|
+
const inlineValue = value.slice(7, -1).trim();
|
|
655
|
+
const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
|
|
656
|
+
if (!match) return;
|
|
657
|
+
const source = match[2];
|
|
658
|
+
if (source === void 0) return;
|
|
659
|
+
return {
|
|
660
|
+
negated,
|
|
661
|
+
source
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
function collectCssInlineSourceCandidates(root) {
|
|
665
|
+
const included = /* @__PURE__ */ new Set();
|
|
666
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
667
|
+
root.walkAtRules("source", (rule) => {
|
|
668
|
+
const parsed = parseSourceInlineParam(rule.params);
|
|
669
|
+
if (!parsed) return;
|
|
670
|
+
const target = parsed.negated ? excluded : included;
|
|
671
|
+
for (const source of segmentTopLevel(parsed.source, " ")) {
|
|
672
|
+
const trimmed = source.trim();
|
|
673
|
+
if (!trimmed) continue;
|
|
674
|
+
for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
|
|
675
|
+
const normalized = candidate.trim();
|
|
676
|
+
if (normalized) target.add(normalized);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
for (const candidate of excluded) included.delete(candidate);
|
|
681
|
+
return {
|
|
682
|
+
included,
|
|
683
|
+
excluded
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/tailwindcss/source-scan.ts
|
|
688
|
+
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
689
|
+
"html",
|
|
690
|
+
"wxml",
|
|
691
|
+
"axml",
|
|
692
|
+
"jxml",
|
|
693
|
+
"ksml",
|
|
694
|
+
"ttml",
|
|
695
|
+
"qml",
|
|
696
|
+
"tyml",
|
|
697
|
+
"xhsml",
|
|
698
|
+
"swan",
|
|
699
|
+
"vue",
|
|
700
|
+
"mpx",
|
|
701
|
+
"js",
|
|
702
|
+
"jsx",
|
|
703
|
+
"ts",
|
|
704
|
+
"tsx"
|
|
705
|
+
];
|
|
706
|
+
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
707
|
+
"js",
|
|
708
|
+
"jsx",
|
|
709
|
+
"mjs",
|
|
710
|
+
"cjs",
|
|
711
|
+
"ts",
|
|
712
|
+
"tsx",
|
|
713
|
+
"mts",
|
|
714
|
+
"cts",
|
|
715
|
+
"vue",
|
|
716
|
+
"uvue",
|
|
717
|
+
"nvue",
|
|
718
|
+
"svelte",
|
|
719
|
+
"mpx",
|
|
720
|
+
"html",
|
|
721
|
+
"wxml",
|
|
722
|
+
"axml",
|
|
723
|
+
"jxml",
|
|
724
|
+
"ksml",
|
|
725
|
+
"ttml",
|
|
726
|
+
"qml",
|
|
727
|
+
"tyml",
|
|
728
|
+
"xhsml",
|
|
729
|
+
"swan",
|
|
730
|
+
"css",
|
|
731
|
+
"wxss",
|
|
732
|
+
"acss",
|
|
733
|
+
"jxss",
|
|
734
|
+
"ttss",
|
|
735
|
+
"qss",
|
|
736
|
+
"tyss",
|
|
737
|
+
"scss",
|
|
738
|
+
"sass",
|
|
739
|
+
"less",
|
|
740
|
+
"styl",
|
|
741
|
+
"stylus"
|
|
742
|
+
];
|
|
743
|
+
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
744
|
+
return `**/*.{${extensions.join(",")}}`;
|
|
745
|
+
}
|
|
746
|
+
const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
747
|
+
const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
748
|
+
function toPosixPath(value) {
|
|
749
|
+
return value.split(node_path.default.sep).join("/");
|
|
750
|
+
}
|
|
751
|
+
function resolveSourceScanPath(value) {
|
|
752
|
+
const resolved = node_path.default.resolve(value);
|
|
753
|
+
try {
|
|
754
|
+
return node_fs.realpathSync.native(resolved);
|
|
755
|
+
} catch {
|
|
756
|
+
return resolved;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function normalizeEntryPattern(entry) {
|
|
760
|
+
return node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), entry.pattern)) : entry.pattern;
|
|
761
|
+
}
|
|
762
|
+
function isFileMatchedByTailwindSourceEntry(file, entry) {
|
|
763
|
+
const relative = toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), file));
|
|
764
|
+
return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeEntryPattern(entry));
|
|
765
|
+
}
|
|
766
|
+
function isFileExcludedByTailwindSourceEntries(file, entries) {
|
|
767
|
+
if (!entries?.length) return false;
|
|
768
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
769
|
+
return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
770
|
+
}
|
|
771
|
+
function isFileMatchedByTailwindSourceEntries(file, entries) {
|
|
772
|
+
if (!entries?.length) return true;
|
|
773
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
774
|
+
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
775
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
776
|
+
if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
777
|
+
if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
|
|
778
|
+
return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
779
|
+
}
|
|
780
|
+
function createTailwindSourceEntryMatcher(entries) {
|
|
781
|
+
if (!entries?.length) return;
|
|
782
|
+
return (file) => isFileMatchedByTailwindSourceEntries(file, entries);
|
|
783
|
+
}
|
|
784
|
+
function resolveTailwindV4CssSourceBase(source, fallbackBase) {
|
|
785
|
+
if (typeof source.base === "string" && source.base.length > 0) return source.base;
|
|
786
|
+
if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
|
|
787
|
+
return fallbackBase;
|
|
788
|
+
}
|
|
789
|
+
function parseConfigParam(params) {
|
|
790
|
+
const value = params.trim();
|
|
791
|
+
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
792
|
+
}
|
|
793
|
+
function isLegacyContentObject(value) {
|
|
794
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
795
|
+
}
|
|
796
|
+
function normalizeGlobPattern(pattern) {
|
|
797
|
+
return pattern.startsWith("./") ? pattern.slice(2) : pattern;
|
|
798
|
+
}
|
|
799
|
+
function hasGlobMagic(value) {
|
|
800
|
+
return /[*?[\]{}()!+@]/.test(value);
|
|
801
|
+
}
|
|
802
|
+
function splitStaticGlobPrefix(pattern) {
|
|
803
|
+
const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
|
|
804
|
+
const prefix = [];
|
|
805
|
+
const rest = [];
|
|
806
|
+
let reachedGlob = false;
|
|
807
|
+
for (const segment of segments) {
|
|
808
|
+
if (!reachedGlob && segment && !hasGlobMagic(segment)) {
|
|
809
|
+
prefix.push(segment);
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
reachedGlob = true;
|
|
813
|
+
rest.push(segment);
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
prefix,
|
|
817
|
+
rest
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
821
|
+
if (typeof content === "string") {
|
|
822
|
+
const negated = content.startsWith("!");
|
|
823
|
+
return [{
|
|
824
|
+
base,
|
|
825
|
+
negated,
|
|
826
|
+
pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
|
|
827
|
+
}];
|
|
828
|
+
}
|
|
829
|
+
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
|
|
830
|
+
if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
|
|
831
|
+
return [];
|
|
832
|
+
}
|
|
833
|
+
async function pathExistsAsDirectory(file) {
|
|
834
|
+
try {
|
|
835
|
+
return (await (0, node_fs_promises.stat)(file)).isDirectory();
|
|
836
|
+
} catch {
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
|
|
841
|
+
const absoluteSource = node_path.default.isAbsolute(sourcePath) ? node_path.default.resolve(sourcePath) : node_path.default.resolve(base, sourcePath);
|
|
842
|
+
if (await pathExistsAsDirectory(absoluteSource)) return {
|
|
843
|
+
base: absoluteSource,
|
|
844
|
+
negated,
|
|
845
|
+
pattern: normalizeGlobPattern(defaultPattern)
|
|
846
|
+
};
|
|
847
|
+
if (node_path.default.isAbsolute(sourcePath) && hasGlobMagic(sourcePath)) {
|
|
848
|
+
const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
|
|
849
|
+
const root = node_path.default.parse(sourcePath).root;
|
|
850
|
+
const normalizedPrefix = prefix[0] === "" ? prefix.slice(1) : prefix;
|
|
851
|
+
if (rest.length > 0) return {
|
|
852
|
+
base: node_path.default.resolve(root, ...normalizedPrefix),
|
|
853
|
+
negated,
|
|
854
|
+
pattern: normalizeGlobPattern(rest.join("/"))
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
if (node_path.default.isAbsolute(sourcePath)) return {
|
|
858
|
+
base: node_path.default.dirname(absoluteSource),
|
|
859
|
+
negated,
|
|
860
|
+
pattern: normalizeGlobPattern(node_path.default.basename(absoluteSource))
|
|
861
|
+
};
|
|
862
|
+
const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
|
|
863
|
+
if (prefix.length > 0 && rest.length > 0) return {
|
|
864
|
+
base: node_path.default.resolve(base, ...prefix),
|
|
865
|
+
negated,
|
|
866
|
+
pattern: normalizeGlobPattern(rest.join("/"))
|
|
867
|
+
};
|
|
868
|
+
return {
|
|
869
|
+
base,
|
|
870
|
+
negated,
|
|
871
|
+
pattern: normalizeGlobPattern(sourcePath)
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
function parseSourceFileParam(params) {
|
|
875
|
+
const value = params.trim();
|
|
876
|
+
if (!value || value === "none" || value.startsWith("inline(")) return;
|
|
877
|
+
const negated = value.startsWith("not ");
|
|
878
|
+
const sourceValue = negated ? value.slice(4).trim() : value;
|
|
879
|
+
if (sourceValue.startsWith("inline(")) return;
|
|
880
|
+
const match = /^(['"])(.+)\1$/.exec(sourceValue);
|
|
881
|
+
return match?.[2] ? {
|
|
882
|
+
negated,
|
|
883
|
+
sourcePath: match[2]
|
|
884
|
+
} : void 0;
|
|
885
|
+
}
|
|
886
|
+
async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
|
|
887
|
+
const entries = [];
|
|
888
|
+
const tasks = [];
|
|
889
|
+
root.walkAtRules("source", (rule) => {
|
|
890
|
+
const parsed = parseSourceFileParam(rule.params);
|
|
891
|
+
if (!parsed) return;
|
|
892
|
+
tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
|
|
893
|
+
});
|
|
894
|
+
entries.push(...await Promise.all(tasks));
|
|
895
|
+
return entries;
|
|
896
|
+
}
|
|
897
|
+
async function expandTailwindSourceEntries(entries, options = {}) {
|
|
898
|
+
if (entries.length === 0) return [];
|
|
899
|
+
const files = /* @__PURE__ */ new Set();
|
|
900
|
+
const entriesByBase = /* @__PURE__ */ new Map();
|
|
901
|
+
for (const entry of entries) {
|
|
902
|
+
const base = node_path.default.resolve(entry.base);
|
|
903
|
+
const group = entriesByBase.get(base) ?? [];
|
|
904
|
+
group.push({
|
|
905
|
+
...entry,
|
|
906
|
+
base
|
|
907
|
+
});
|
|
908
|
+
entriesByBase.set(base, group);
|
|
909
|
+
}
|
|
910
|
+
await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
|
|
911
|
+
const ignoredSources = options.ignore?.map((pattern) => ({
|
|
912
|
+
base,
|
|
913
|
+
pattern: normalizeGlobPattern(pattern),
|
|
914
|
+
negated: true
|
|
915
|
+
}));
|
|
916
|
+
const matched = await (0, _tailwindcss_mangle_engine.resolveProjectSourceFiles)({
|
|
917
|
+
cwd: base,
|
|
918
|
+
sources: group,
|
|
919
|
+
...ignoredSources === void 0 ? {} : { ignoredSources }
|
|
920
|
+
});
|
|
921
|
+
for (const file of matched) files.add(node_path.default.resolve(file));
|
|
922
|
+
}));
|
|
923
|
+
return [...files].filter((file) => !isFileExcludedByTailwindSourceEntries(file, entries));
|
|
924
|
+
}
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region src/tailwindcss/v4-engine/generator/scan-sources.ts
|
|
927
|
+
const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
|
|
928
|
+
"**/.git/**",
|
|
929
|
+
"**/.hg/**",
|
|
930
|
+
"**/.jj/**",
|
|
931
|
+
"**/.next/**",
|
|
932
|
+
"**/.parcel-cache/**",
|
|
933
|
+
"**/.pnpm-store/**",
|
|
934
|
+
"**/.svelte-kit/**",
|
|
935
|
+
"**/.svn/**",
|
|
936
|
+
"**/.turbo/**",
|
|
937
|
+
"**/.venv/**",
|
|
938
|
+
"**/.vercel/**",
|
|
939
|
+
"**/.yarn/**",
|
|
940
|
+
"**/__pycache__/**",
|
|
941
|
+
"**/node_modules/**",
|
|
942
|
+
"**/venv/**",
|
|
943
|
+
"**/*.less",
|
|
944
|
+
"**/*.lock",
|
|
945
|
+
"**/*.sass",
|
|
946
|
+
"**/*.scss",
|
|
947
|
+
"**/*.styl",
|
|
948
|
+
"**/*.log",
|
|
949
|
+
"**/package-lock.json",
|
|
950
|
+
"**/pnpm-lock.yaml",
|
|
951
|
+
"**/bun.lockb",
|
|
952
|
+
"**/.gitignore",
|
|
953
|
+
"**/.env",
|
|
954
|
+
"**/.env.*"
|
|
955
|
+
];
|
|
956
|
+
function parseImportSourceParam(params) {
|
|
957
|
+
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
958
|
+
if (!match) return;
|
|
959
|
+
return {
|
|
960
|
+
none: match[1] === "none",
|
|
961
|
+
sourcePath: match[3]
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function parseCssImportSpecifier$1(params) {
|
|
965
|
+
const value = params.trim();
|
|
966
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
967
|
+
if (quoted) return quoted[2];
|
|
968
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
969
|
+
return url?.[2] ?? url?.[3];
|
|
970
|
+
}
|
|
971
|
+
function isTailwindCssImport(params) {
|
|
972
|
+
const specifier = parseCssImportSpecifier$1(params);
|
|
973
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
974
|
+
}
|
|
975
|
+
function resolveSourceBase(base, sourcePath) {
|
|
976
|
+
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
977
|
+
}
|
|
978
|
+
function createDefaultIgnoredScanSources(base) {
|
|
979
|
+
return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
|
|
980
|
+
base,
|
|
981
|
+
pattern,
|
|
982
|
+
negated: true
|
|
983
|
+
}));
|
|
984
|
+
}
|
|
985
|
+
function normalizeCssDefinedScanSources(base, entries) {
|
|
986
|
+
return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
|
|
987
|
+
base,
|
|
988
|
+
pattern: "**/*",
|
|
989
|
+
negated: false
|
|
990
|
+
}, ...entries] : entries;
|
|
991
|
+
}
|
|
992
|
+
function resolveDefaultSourceBase(source) {
|
|
993
|
+
return source.projectRoot ?? source.cwd ?? source.base;
|
|
994
|
+
}
|
|
995
|
+
async function resolveCssDefinedScanSources(source) {
|
|
996
|
+
let importSourceBase;
|
|
997
|
+
let hasSourceNone = false;
|
|
998
|
+
let hasTailwindImport = false;
|
|
999
|
+
const from = source.dependencies[0];
|
|
1000
|
+
let root;
|
|
1001
|
+
try {
|
|
1002
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(source.css, { from });
|
|
1003
|
+
} catch {
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
root.walkAtRules((rule) => {
|
|
1007
|
+
if (rule.name === "import") {
|
|
1008
|
+
if (!isTailwindCssImport(rule.params)) return;
|
|
1009
|
+
hasTailwindImport = true;
|
|
1010
|
+
const sourceParam = parseImportSourceParam(rule.params);
|
|
1011
|
+
if (sourceParam?.none) hasSourceNone = true;
|
|
1012
|
+
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(source.base, sourceParam.sourcePath);
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
const sourcePatterns = await resolveCssSourceEntries(root, source.base, "**/*");
|
|
1016
|
+
if (!importSourceBase) {
|
|
1017
|
+
if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
|
|
1018
|
+
if (hasSourceNone) return false;
|
|
1019
|
+
if (hasTailwindImport) {
|
|
1020
|
+
const defaultBase = resolveDefaultSourceBase(source);
|
|
1021
|
+
return [await resolveTailwindSourceEntry(".", defaultBase, false, "**/*"), ...createDefaultIgnoredScanSources(defaultBase)];
|
|
1022
|
+
}
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
return [
|
|
1026
|
+
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1027
|
+
...sourcePatterns,
|
|
1028
|
+
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1029
|
+
];
|
|
1030
|
+
}
|
|
1031
|
+
async function resolveScanSources(source, scanSources) {
|
|
1032
|
+
if (scanSources !== true) return scanSources;
|
|
1033
|
+
return await resolveCssDefinedScanSources(source) ?? false;
|
|
1034
|
+
}
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
1037
|
+
const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
1038
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1039
|
+
cssRemoveHoverPseudoClass: true,
|
|
1040
|
+
isMainChunk: true,
|
|
1041
|
+
majorVersion: 4
|
|
1042
|
+
});
|
|
1043
|
+
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
1044
|
+
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
1045
|
+
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
1046
|
+
try {
|
|
1047
|
+
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
1048
|
+
} catch {
|
|
1049
|
+
return match;
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
async function transformTailwindV4CssToWeapp(css, options) {
|
|
1054
|
+
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
1055
|
+
const result = await defaultStyleHandler(protectedCss.css, {
|
|
1056
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1057
|
+
cssRemoveHoverPseudoClass: true,
|
|
1058
|
+
isMainChunk: true,
|
|
1059
|
+
majorVersion: 4,
|
|
1060
|
+
...options
|
|
1061
|
+
});
|
|
1062
|
+
const pruneOptions = {
|
|
1063
|
+
preservePreflight: true,
|
|
1064
|
+
preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options)
|
|
1065
|
+
};
|
|
1066
|
+
return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
|
|
1067
|
+
}
|
|
1068
|
+
function transformTailwindV4WebRpxCss(css) {
|
|
1069
|
+
if (!css.includes("rpx")) return css;
|
|
1070
|
+
try {
|
|
1071
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1072
|
+
return (0, _weapp_tailwindcss_postcss.normalizeTailwindcssWebRpxDeclarations)(root, { majorVersion: 4 }) ? root.toString() : css;
|
|
1073
|
+
} catch {
|
|
1074
|
+
return css;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function shouldTransformWebRpxCss(options) {
|
|
1078
|
+
return options?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
|
|
1079
|
+
}
|
|
1080
|
+
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
1081
|
+
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
1082
|
+
const resolvedWebCss = await ((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css);
|
|
1083
|
+
return shouldTransformWebRpxCss(options) ? transformTailwindV4WebRpxCss(resolvedWebCss) : resolvedWebCss;
|
|
1084
|
+
}
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1087
|
+
const INCREMENTAL_GENERATE_CACHE_MAX = 8;
|
|
1088
|
+
const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
|
|
1089
|
+
const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 128;
|
|
1090
|
+
const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 256 * 1024;
|
|
1091
|
+
const incrementalGenerateCache = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
|
|
1092
|
+
const incrementalGenerateTaskCache = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
|
|
1093
|
+
function collectCandidates(candidates) {
|
|
1094
|
+
return new Set(candidates ?? []);
|
|
1095
|
+
}
|
|
1096
|
+
function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
1097
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
function createStableJson(value) {
|
|
1101
|
+
if (value === void 0) return "undefined";
|
|
1102
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1103
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
1104
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
1105
|
+
const record = value;
|
|
1106
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
1107
|
+
}).join(",")}}`;
|
|
1108
|
+
}
|
|
1109
|
+
function createDependencyFingerprint(files) {
|
|
1110
|
+
return files.map((file) => {
|
|
1111
|
+
try {
|
|
1112
|
+
const stat = node_fs.default.statSync(file);
|
|
1113
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
1114
|
+
} catch {
|
|
1115
|
+
return `${file}:missing`;
|
|
1116
|
+
}
|
|
1117
|
+
}).join("|");
|
|
1118
|
+
}
|
|
1119
|
+
function createIncrementalGenerateCacheKey(source, target, styleOptions) {
|
|
1120
|
+
return [
|
|
1121
|
+
source.projectRoot,
|
|
1122
|
+
source.base,
|
|
1123
|
+
createStableJson(source.baseFallbacks),
|
|
1124
|
+
source.css,
|
|
1125
|
+
createDependencyFingerprint(source.dependencies),
|
|
1126
|
+
target,
|
|
1127
|
+
createStableJson(styleOptions)
|
|
1128
|
+
].join("\0");
|
|
1129
|
+
}
|
|
1130
|
+
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
1131
|
+
return [
|
|
1132
|
+
cacheKey,
|
|
1133
|
+
scanSources === true ? "scan:1" : "scan:0",
|
|
1134
|
+
[...requestedCandidates].sort().join("\n")
|
|
1135
|
+
].join("\0");
|
|
1136
|
+
}
|
|
1137
|
+
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
1138
|
+
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
1139
|
+
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
1140
|
+
if (cachedTask) return cachedTask;
|
|
1141
|
+
const promise = task();
|
|
1142
|
+
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
1143
|
+
promise.finally(() => {
|
|
1144
|
+
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
1145
|
+
});
|
|
1146
|
+
return promise;
|
|
1147
|
+
}
|
|
1148
|
+
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
1149
|
+
const promise = (0, _tailwindcss_mangle_engine.loadTailwindV4DesignSystem)(source);
|
|
1150
|
+
promise.catch(() => {
|
|
1151
|
+
if (incrementalGenerateCache.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache.delete(cacheKey);
|
|
1152
|
+
});
|
|
1153
|
+
return promise;
|
|
1154
|
+
}
|
|
1155
|
+
function resolveTargetCandidates(candidates, target) {
|
|
1156
|
+
const collected = collectCandidates(candidates);
|
|
1157
|
+
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
1158
|
+
}
|
|
1159
|
+
function collectSeenCandidates(generated, requestedCandidates) {
|
|
1160
|
+
return new Set([
|
|
1161
|
+
...requestedCandidates,
|
|
1162
|
+
...generated.rawCandidates,
|
|
1163
|
+
...generated.classSet
|
|
1164
|
+
]);
|
|
1165
|
+
}
|
|
1166
|
+
function shouldDelegateWebSourceScanToTailwind(target, scanSources) {
|
|
1167
|
+
return target === "web" && scanSources !== false;
|
|
1168
|
+
}
|
|
1169
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
1170
|
+
return {
|
|
1171
|
+
...styleOptions,
|
|
1172
|
+
isMainChunk: false
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
function resolveStyleOptions(source, options) {
|
|
1176
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Directive)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
1177
|
+
}
|
|
1178
|
+
function collectCustomPropertyValues(css) {
|
|
1179
|
+
const values = /* @__PURE__ */ new Map();
|
|
1180
|
+
try {
|
|
1181
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkDecls((decl) => {
|
|
1182
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1183
|
+
});
|
|
1184
|
+
} catch {}
|
|
1185
|
+
return values;
|
|
1186
|
+
}
|
|
1187
|
+
function mergeCustomPropertyValues(target, css) {
|
|
1188
|
+
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1189
|
+
}
|
|
1190
|
+
function createStableTextSignature(input) {
|
|
1191
|
+
let hash = 2166136261;
|
|
1192
|
+
for (let i = 0; i < input.length; i++) {
|
|
1193
|
+
hash ^= input.charCodeAt(i);
|
|
1194
|
+
hash = Math.imul(hash, 16777619);
|
|
1195
|
+
}
|
|
1196
|
+
return (hash >>> 0).toString(36);
|
|
1197
|
+
}
|
|
1198
|
+
function summarizeIncrementalCacheKey(key) {
|
|
1199
|
+
return {
|
|
1200
|
+
keyHash: createStableTextSignature(key),
|
|
1201
|
+
keyBytes: key.length
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
|
|
1205
|
+
return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX;
|
|
1206
|
+
}
|
|
1207
|
+
function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
|
|
1208
|
+
return requestedCandidates.size <= INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX && generated.css.length <= INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX && generated.rawCss.length <= INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX;
|
|
1209
|
+
}
|
|
1210
|
+
function seedIncrementalGenerateCache(options) {
|
|
1211
|
+
if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
|
|
1212
|
+
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
|
|
1213
|
+
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1214
|
+
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1215
|
+
incrementalGenerateCache.set(cacheKey, {
|
|
1216
|
+
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1217
|
+
classSet: new Set(options.generated.classSet),
|
|
1218
|
+
css: options.generated.css,
|
|
1219
|
+
rawCss: options.generated.rawCss,
|
|
1220
|
+
customPropertyValues,
|
|
1221
|
+
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1222
|
+
dependencies: options.generated.dependencies,
|
|
1223
|
+
sources: options.generated.sources,
|
|
1224
|
+
root: options.generated.root,
|
|
1225
|
+
target: options.generated.target
|
|
1226
|
+
});
|
|
1227
|
+
return true;
|
|
1228
|
+
}
|
|
1229
|
+
function shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) {
|
|
1230
|
+
if (target !== "web") return true;
|
|
1231
|
+
return styleOptions?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
|
|
1232
|
+
}
|
|
1233
|
+
function normalizeTargetRpxLengthCandidates(candidates, target, styleOptions) {
|
|
1234
|
+
return shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) ? normalizeRpxLengthCandidates(candidates) : {
|
|
1235
|
+
candidates: new Set(candidates),
|
|
1236
|
+
restoreCandidates: /* @__PURE__ */ new Map()
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
function createTailwindV4Engine(source) {
|
|
1240
|
+
async function generateOnce(generateSource, options = {}) {
|
|
1241
|
+
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
1242
|
+
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
1243
|
+
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(generateSource, target));
|
|
1244
|
+
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1245
|
+
const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
|
|
1246
|
+
const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await (0, _tailwindcss_mangle_engine.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
1247
|
+
const normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target), target, resolvedStyleOptions);
|
|
1248
|
+
const result = await engine.generate(omitUndefined({
|
|
1249
|
+
scanSources: delegateSourceScan ? resolvedScanSources : false,
|
|
1250
|
+
...patchOptions,
|
|
1251
|
+
candidates: normalizedCandidates.candidates
|
|
1252
|
+
}));
|
|
1253
|
+
const rawCss = restoreRpxLengthCssSelectors(result.css, normalizedCandidates.restoreCandidates);
|
|
1254
|
+
const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
|
|
1255
|
+
return {
|
|
1256
|
+
...result,
|
|
1257
|
+
classSet: restoreRpxLengthCandidates(result.classSet, normalizedCandidates.restoreCandidates),
|
|
1258
|
+
rawCandidates: restoreRpxLengthCandidates(result.rawCandidates, normalizedCandidates.restoreCandidates),
|
|
1259
|
+
css,
|
|
1260
|
+
rawCss,
|
|
1261
|
+
target
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
async function generateWithIncrementalCache(options = {}) {
|
|
1265
|
+
const target = options.target ?? "weapp";
|
|
1266
|
+
const compatibleSource = createCompatibleSource(source, target);
|
|
1267
|
+
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1268
|
+
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
1269
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
|
|
1270
|
+
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
|
|
1271
|
+
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1272
|
+
const generated = await generateOnce(source, options);
|
|
1273
|
+
if (!seedIncrementalGenerateCache({
|
|
1274
|
+
compatibleSource,
|
|
1275
|
+
generated,
|
|
1276
|
+
requestedCandidates,
|
|
1277
|
+
styleOptions: options.styleOptions,
|
|
1278
|
+
target
|
|
1279
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
1280
|
+
return generated;
|
|
1281
|
+
});
|
|
1282
|
+
const cached = incrementalGenerateCache.get(cacheKey);
|
|
1283
|
+
if (cached) {
|
|
1284
|
+
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1285
|
+
const generated = await generateOnce(source, options);
|
|
1286
|
+
if (!seedIncrementalGenerateCache({
|
|
1287
|
+
compatibleSource,
|
|
1288
|
+
generated,
|
|
1289
|
+
requestedCandidates,
|
|
1290
|
+
styleOptions,
|
|
1291
|
+
target
|
|
1292
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
1293
|
+
return generated;
|
|
1294
|
+
});
|
|
1295
|
+
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
1296
|
+
if (missingCandidates.length === 0) return {
|
|
1297
|
+
css: cached.css,
|
|
1298
|
+
rawCss: cached.rawCss,
|
|
1299
|
+
incrementalCss: "",
|
|
1300
|
+
incrementalRawCss: "",
|
|
1301
|
+
classSet: new Set(cached.classSet),
|
|
1302
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
1303
|
+
dependencies: cached.dependencies,
|
|
1304
|
+
sources: cached.sources,
|
|
1305
|
+
root: cached.root,
|
|
1306
|
+
target: cached.target
|
|
1307
|
+
};
|
|
1308
|
+
if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1309
|
+
const generated = await generateOnce(source, options);
|
|
1310
|
+
if (!seedIncrementalGenerateCache({
|
|
1311
|
+
compatibleSource,
|
|
1312
|
+
generated,
|
|
1313
|
+
requestedCandidates,
|
|
1314
|
+
styleOptions,
|
|
1315
|
+
target
|
|
1316
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
1317
|
+
return generated;
|
|
1318
|
+
});
|
|
1319
|
+
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1320
|
+
const designSystem = await cached.designSystemPromise;
|
|
1321
|
+
const normalizedMissing = normalizeTargetRpxLengthCandidates(missingCandidates, target, styleOptions);
|
|
1322
|
+
const normalizedMissingCandidates = [...normalizedMissing.candidates];
|
|
1323
|
+
const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
|
|
1324
|
+
const rawCssParts = [];
|
|
1325
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
1326
|
+
for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
|
|
1327
|
+
const candidate = normalizedMissingCandidates[index];
|
|
1328
|
+
const css = cssByCandidate[index];
|
|
1329
|
+
if (candidate && typeof css === "string" && css.trim().length > 0) {
|
|
1330
|
+
rawCssParts.push(restoreRpxLengthCssSelectors(css, normalizedMissing.restoreCandidates));
|
|
1331
|
+
classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
const rawCss = rawCssParts.join("\n");
|
|
1335
|
+
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
|
|
1336
|
+
...createIncrementalStyleOptions(styleOptions),
|
|
1337
|
+
customPropertyValues: cached.customPropertyValues
|
|
1338
|
+
}) : "";
|
|
1339
|
+
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
1340
|
+
for (const className of classSet) cached.classSet.add(className);
|
|
1341
|
+
cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
|
|
1342
|
+
cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
|
|
1343
|
+
mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
|
|
1344
|
+
return {
|
|
1345
|
+
css: cached.css,
|
|
1346
|
+
rawCss: cached.rawCss,
|
|
1347
|
+
incrementalCss,
|
|
1348
|
+
incrementalRawCss: rawCss,
|
|
1349
|
+
classSet: new Set(cached.classSet),
|
|
1350
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
1351
|
+
dependencies: cached.dependencies,
|
|
1352
|
+
sources: cached.sources,
|
|
1353
|
+
root: cached.root,
|
|
1354
|
+
target: cached.target
|
|
1355
|
+
};
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1359
|
+
const generated = await generateOnce(source, options);
|
|
1360
|
+
seedIncrementalGenerateCache({
|
|
1361
|
+
compatibleSource,
|
|
1362
|
+
generated,
|
|
1363
|
+
requestedCandidates,
|
|
1364
|
+
styleOptions,
|
|
1365
|
+
target
|
|
1366
|
+
});
|
|
1367
|
+
return generated;
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
async function generate(options = {}) {
|
|
1371
|
+
return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
|
|
1372
|
+
}
|
|
1373
|
+
return {
|
|
1374
|
+
source,
|
|
1375
|
+
loadDesignSystem: (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(source).loadDesignSystem,
|
|
1376
|
+
validateCandidates: (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(source).validateCandidates,
|
|
1377
|
+
generate
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function getTailwindV4IncrementalGenerateCacheStats() {
|
|
1381
|
+
return {
|
|
1382
|
+
max: INCREMENTAL_GENERATE_CACHE_MAX,
|
|
1383
|
+
entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
|
|
1384
|
+
entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
|
|
1385
|
+
size: incrementalGenerateCache.size,
|
|
1386
|
+
taskMax: INCREMENTAL_GENERATE_TASK_CACHE_MAX,
|
|
1387
|
+
taskSize: incrementalGenerateTaskCache.size,
|
|
1388
|
+
entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
|
|
1389
|
+
...summarizeIncrementalCacheKey(key),
|
|
1390
|
+
candidates: entry.seenCandidates.size,
|
|
1391
|
+
classSet: entry.classSet.size,
|
|
1392
|
+
cssBytes: entry.css.length,
|
|
1393
|
+
rawCssBytes: entry.rawCss.length
|
|
1394
|
+
})),
|
|
1395
|
+
keys: [...incrementalGenerateCache.keys()].map(summarizeIncrementalCacheKey),
|
|
1396
|
+
taskKeys: [...incrementalGenerateTaskCache.keys()].map(summarizeIncrementalCacheKey)
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
//#endregion
|
|
1400
|
+
//#region src/bundlers/shared/generator-css/config-directive.ts
|
|
1401
|
+
function quoteCssString(value) {
|
|
1402
|
+
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
1403
|
+
}
|
|
1404
|
+
function toCssPath(value) {
|
|
1405
|
+
return value.replaceAll("\\", "/");
|
|
1406
|
+
}
|
|
1407
|
+
function prependConfigDirective(css, config) {
|
|
1408
|
+
if (!config || /@config\s+/.test(css)) return css;
|
|
1409
|
+
return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
|
|
1410
|
+
}
|
|
1411
|
+
function normalizeConfigDirective(css, config) {
|
|
1412
|
+
if (!config || !/@config\s+/.test(css)) return css;
|
|
1413
|
+
return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
|
|
1414
|
+
}
|
|
1415
|
+
//#endregion
|
|
1416
|
+
//#region src/bundlers/shared/generator-css/markers.ts
|
|
1417
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
1418
|
+
const TAILWIND_ESCAPED_UTILITY_MARKER_RE = /\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
1419
|
+
const TAILWIND_ROOT_THEME_MARKER_RE = /(?::host|page|\.tw-root|wx-root-portal-content)[^{]{0,256}\{[^}]{0,4096}--(?:color|spacing|text|font-weight|radius)-/;
|
|
1420
|
+
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
1421
|
+
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
1422
|
+
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
1423
|
+
const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
|
|
1424
|
+
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
1425
|
+
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
1426
|
+
function createCssAppend(base, extra) {
|
|
1427
|
+
if (!base) return extra;
|
|
1428
|
+
if (!extra) return base;
|
|
1429
|
+
return `${base}\n${extra}`;
|
|
1430
|
+
}
|
|
1431
|
+
function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
1432
|
+
const trimmedRaw = rawSource.trim();
|
|
1433
|
+
const trimmedTailwind = rawTailwindCss.trim();
|
|
1434
|
+
if (trimmedRaw === trimmedTailwind) return {
|
|
1435
|
+
before: "",
|
|
1436
|
+
after: ""
|
|
1437
|
+
};
|
|
1438
|
+
if (trimmedTailwind.startsWith(trimmedRaw)) return {
|
|
1439
|
+
before: "",
|
|
1440
|
+
after: ""
|
|
1441
|
+
};
|
|
1442
|
+
const start = rawSource.indexOf(rawTailwindCss);
|
|
1443
|
+
if (start === -1) return;
|
|
1444
|
+
return {
|
|
1445
|
+
before: rawSource.slice(0, start),
|
|
1446
|
+
after: rawSource.slice(start + rawTailwindCss.length)
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
1450
|
+
const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
|
|
1451
|
+
if (!match || match.index === void 0) return;
|
|
1452
|
+
let afterStart = match.index + match[0].length;
|
|
1453
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
1454
|
+
if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
|
|
1455
|
+
afterStart += rawTailwindCss.length;
|
|
1456
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
1457
|
+
}
|
|
1458
|
+
return {
|
|
1459
|
+
before: rawSource.slice(0, match.index),
|
|
1460
|
+
after: rawSource.slice(afterStart)
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
function splitTailwindGeneratedCssByBanner(rawSource, start) {
|
|
1464
|
+
const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
|
|
1465
|
+
if (!match || match.index === void 0) return;
|
|
1466
|
+
return {
|
|
1467
|
+
before: rawSource.slice(0, match.index),
|
|
1468
|
+
after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1471
|
+
function stripTailwindBanner(css) {
|
|
1472
|
+
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
1473
|
+
}
|
|
1474
|
+
function stripTailwindBanners(css) {
|
|
1475
|
+
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
1476
|
+
}
|
|
1477
|
+
function stripGeneratorPlaceholderMarkers(css) {
|
|
1478
|
+
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
1479
|
+
}
|
|
1480
|
+
function hasTailwindGeneratedCss(rawSource) {
|
|
1481
|
+
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
1482
|
+
}
|
|
1483
|
+
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
1484
|
+
if (rawSource.includes("--tw-") || rawSource.includes("tailwindcss v") || rawSource.includes(":not(#\\#)") || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1485
|
+
if (!rawSource.includes("\\:") && !rawSource.includes("\\[") && !rawSource.includes("\\#") && !rawSource.includes("--color-") && !rawSource.includes("--spacing-") && !rawSource.includes("--text-") && !rawSource.includes("--font-weight-") && !rawSource.includes("--radius-")) return false;
|
|
1486
|
+
return TAILWIND_ESCAPED_UTILITY_MARKER_RE.test(rawSource) || TAILWIND_ROOT_THEME_MARKER_RE.test(rawSource);
|
|
1487
|
+
}
|
|
1488
|
+
//#endregion
|
|
1489
|
+
//#region src/bundlers/shared/generator-css/directives/fallback.ts
|
|
1490
|
+
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
1491
|
+
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
1492
|
+
const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant|plugin)\b[\s\S]*\{/;
|
|
1493
|
+
function parseImportRequest$1(params) {
|
|
1494
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
1495
|
+
}
|
|
1496
|
+
function parseConfigRequest$1(params) {
|
|
1497
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
1498
|
+
}
|
|
1499
|
+
function isPackageJsonImportRequest$1(request) {
|
|
1500
|
+
return typeof request === "string" && request.startsWith("#");
|
|
1501
|
+
}
|
|
1502
|
+
function isWeappTailwindcssImportRequest$1(request) {
|
|
1503
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
1504
|
+
}
|
|
1505
|
+
function isTailwindImportRequest$1(request) {
|
|
1506
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
1507
|
+
}
|
|
1508
|
+
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
1509
|
+
if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
1510
|
+
return request;
|
|
1511
|
+
}
|
|
1512
|
+
function replaceImportRequest$1(params, request, replacement) {
|
|
1513
|
+
const index = params.indexOf(request);
|
|
1514
|
+
if (index === -1) return params;
|
|
1515
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
1516
|
+
}
|
|
1517
|
+
function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
1518
|
+
const trimmed = line.trimStart();
|
|
1519
|
+
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
1520
|
+
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
1521
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
|
|
1522
|
+
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
1523
|
+
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
1524
|
+
}
|
|
1525
|
+
return line;
|
|
1526
|
+
}
|
|
1527
|
+
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
1528
|
+
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
1529
|
+
if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
|
|
1530
|
+
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
1531
|
+
}
|
|
1532
|
+
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
1533
|
+
const directives = [];
|
|
1534
|
+
const seenImports = /* @__PURE__ */ new Set();
|
|
1535
|
+
for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
1536
|
+
const trimmed = line.trim();
|
|
1537
|
+
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
1538
|
+
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
|
|
1539
|
+
if (!directive) continue;
|
|
1540
|
+
if (TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(directive)) continue;
|
|
1541
|
+
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
1542
|
+
const normalizedTrimmed = normalized.trim();
|
|
1543
|
+
if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
|
|
1544
|
+
const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
|
|
1545
|
+
if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$1(request)) continue;
|
|
1546
|
+
if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
|
|
1547
|
+
if (request && isTailwindImportRequest$1(request)) {
|
|
1548
|
+
const key = normalizedTrimmed;
|
|
1549
|
+
if (seenImports.has(key)) continue;
|
|
1550
|
+
seenImports.add(key);
|
|
1551
|
+
}
|
|
1552
|
+
directives.push(normalized);
|
|
1553
|
+
}
|
|
1554
|
+
return directives;
|
|
1555
|
+
}
|
|
1556
|
+
function stripPreprocessorLineComment(line) {
|
|
1557
|
+
let quote;
|
|
1558
|
+
let escaped = false;
|
|
1559
|
+
for (let index = 0; index < line.length; index++) {
|
|
1560
|
+
const char = line[index];
|
|
1561
|
+
if (escaped) {
|
|
1562
|
+
escaped = false;
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
if (char === "\\") {
|
|
1566
|
+
escaped = true;
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1569
|
+
if (quote) {
|
|
1570
|
+
if (char === quote) quote = void 0;
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
if (char === "\"" || char === "'") {
|
|
1574
|
+
quote = char;
|
|
1575
|
+
continue;
|
|
1576
|
+
}
|
|
1577
|
+
if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
|
|
1578
|
+
}
|
|
1579
|
+
return line;
|
|
1580
|
+
}
|
|
1581
|
+
function countBlockBraceDelta(line) {
|
|
1582
|
+
let quote;
|
|
1583
|
+
let escaped = false;
|
|
1584
|
+
let delta = 0;
|
|
1585
|
+
for (let index = 0; index < line.length; index++) {
|
|
1586
|
+
const char = line[index];
|
|
1587
|
+
if (escaped) {
|
|
1588
|
+
escaped = false;
|
|
1589
|
+
continue;
|
|
1590
|
+
}
|
|
1591
|
+
if (char === "\\") {
|
|
1592
|
+
escaped = true;
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
if (quote) {
|
|
1596
|
+
if (char === quote) quote = void 0;
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
if (char === "\"" || char === "'") {
|
|
1600
|
+
quote = char;
|
|
1601
|
+
continue;
|
|
1602
|
+
}
|
|
1603
|
+
if (char === "{") delta++;
|
|
1604
|
+
else if (char === "}") delta--;
|
|
1605
|
+
}
|
|
1606
|
+
return delta;
|
|
1607
|
+
}
|
|
1608
|
+
function extractTailwindFallbackBlocks(rawSource) {
|
|
1609
|
+
const blocks = [];
|
|
1610
|
+
let current;
|
|
1611
|
+
let depth = 0;
|
|
1612
|
+
for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
1613
|
+
const line = stripPreprocessorLineComment(rawLine);
|
|
1614
|
+
if (!line.trim()) continue;
|
|
1615
|
+
if (!current) {
|
|
1616
|
+
if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
|
|
1617
|
+
current = [line];
|
|
1618
|
+
depth = countBlockBraceDelta(line);
|
|
1619
|
+
if (depth <= 0) {
|
|
1620
|
+
blocks.push(current.join("\n"));
|
|
1621
|
+
current = void 0;
|
|
1622
|
+
depth = 0;
|
|
1623
|
+
}
|
|
1624
|
+
continue;
|
|
1625
|
+
}
|
|
1626
|
+
current.push(line);
|
|
1627
|
+
depth += countBlockBraceDelta(line);
|
|
1628
|
+
if (depth <= 0) {
|
|
1629
|
+
blocks.push(current.join("\n"));
|
|
1630
|
+
current = void 0;
|
|
1631
|
+
depth = 0;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
return blocks;
|
|
1635
|
+
}
|
|
1636
|
+
function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
|
|
1637
|
+
const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
|
|
1638
|
+
return directives.length > 0 ? directives.join("\n") : void 0;
|
|
1639
|
+
}
|
|
1640
|
+
function extractConfigRequestFromSource(rawSource) {
|
|
1641
|
+
for (const line of rawSource.split(/\r?\n/)) {
|
|
1642
|
+
const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
|
|
1643
|
+
const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
|
|
1644
|
+
if (request) return request;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
//#endregion
|
|
1648
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
1649
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
1650
|
+
"config",
|
|
1651
|
+
"custom-variant",
|
|
1652
|
+
"layer",
|
|
1653
|
+
"plugin",
|
|
1654
|
+
"reference",
|
|
1655
|
+
"source",
|
|
1656
|
+
"tailwind",
|
|
1657
|
+
"theme",
|
|
1658
|
+
"utility",
|
|
1659
|
+
"variant"
|
|
1660
|
+
]);
|
|
1661
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
1662
|
+
"config",
|
|
1663
|
+
"custom-variant",
|
|
1664
|
+
"plugin",
|
|
1665
|
+
"source",
|
|
1666
|
+
"tailwind",
|
|
1667
|
+
"theme",
|
|
1668
|
+
"utility",
|
|
1669
|
+
"variant"
|
|
1670
|
+
]);
|
|
1671
|
+
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/;
|
|
1672
|
+
function parseImportRequest(params) {
|
|
1673
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
1674
|
+
}
|
|
1675
|
+
function hasLocalCssImport(rawSource) {
|
|
1676
|
+
let found = false;
|
|
1677
|
+
try {
|
|
1678
|
+
_weapp_tailwindcss_postcss.postcss.parse(rawSource).walkAtRules("import", (rule) => {
|
|
1679
|
+
const request = parseImportRequest(rule.params);
|
|
1680
|
+
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
1681
|
+
found = true;
|
|
1682
|
+
return false;
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
} catch {}
|
|
1686
|
+
return found;
|
|
1687
|
+
}
|
|
1688
|
+
function parseConfigRequest(params) {
|
|
1689
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
1690
|
+
}
|
|
1691
|
+
function isPackageJsonImportRequest(request) {
|
|
1692
|
+
return typeof request === "string" && request.startsWith("#");
|
|
1693
|
+
}
|
|
1694
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
1695
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
1696
|
+
}
|
|
1697
|
+
function normalizeTailwindImportRequest(request, options = {}) {
|
|
1698
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
1699
|
+
return request;
|
|
1700
|
+
}
|
|
1701
|
+
function replaceImportRequest(params, request, replacement) {
|
|
1702
|
+
const index = params.indexOf(request);
|
|
1703
|
+
if (index === -1) return params;
|
|
1704
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
1705
|
+
}
|
|
1706
|
+
function normalizeTailwindImportAtRules(root, options = {}) {
|
|
1707
|
+
if (!options.importFallback) return false;
|
|
1708
|
+
let changed = false;
|
|
1709
|
+
const seenCanonicalImports = /* @__PURE__ */ new Set();
|
|
1710
|
+
root.walkAtRules("import", (node) => {
|
|
1711
|
+
const request = parseImportRequest(node.params);
|
|
1712
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
1713
|
+
if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
|
|
1714
|
+
const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
|
|
1715
|
+
const normalizedKey = normalizedParams.trim();
|
|
1716
|
+
if (seenCanonicalImports.has(normalizedKey)) {
|
|
1717
|
+
node.remove();
|
|
1718
|
+
changed = true;
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
seenCanonicalImports.add(normalizedKey);
|
|
1722
|
+
if (normalizedParams !== node.params) {
|
|
1723
|
+
node.params = normalizedParams;
|
|
1724
|
+
changed = true;
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
return changed;
|
|
1728
|
+
}
|
|
1729
|
+
function resolveConfigPath(base, configPath) {
|
|
1730
|
+
if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
|
|
1731
|
+
return node_path.default.resolve(base, configPath);
|
|
1732
|
+
}
|
|
1733
|
+
function normalizeTailwindConfigDirectives(rawSource, base) {
|
|
1734
|
+
return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
|
|
1735
|
+
if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
|
|
1736
|
+
return `@config ${quote}${node_path.default.resolve(base, request).replace(/\\/g, "/")}${quote};`;
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
function hasPreprocessorOnlySyntax(rawSource) {
|
|
1740
|
+
return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
|
|
1741
|
+
}
|
|
1742
|
+
function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
|
|
1743
|
+
return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
|
|
1744
|
+
}
|
|
1745
|
+
function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
1746
|
+
if (!options.importFallback) return rawSource;
|
|
1747
|
+
try {
|
|
1748
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1749
|
+
return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
|
|
1750
|
+
} catch {
|
|
1751
|
+
return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
function isTailwindImportRequest(request) {
|
|
1755
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
1756
|
+
}
|
|
1757
|
+
function isTailwindImportAtRule(node, options = {}) {
|
|
1758
|
+
if (node.name === "tailwind") return true;
|
|
1759
|
+
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
1760
|
+
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
1761
|
+
}
|
|
1762
|
+
function isTailwindSourceDirective(node, options = {}) {
|
|
1763
|
+
if (node.type !== "atrule") return false;
|
|
1764
|
+
const atRule = node;
|
|
1765
|
+
if (isTailwindImportAtRule(atRule, options)) return true;
|
|
1766
|
+
if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
|
|
1767
|
+
if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
|
|
1768
|
+
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
|
|
1769
|
+
}
|
|
1770
|
+
function hasGeneratedCssArtifacts(rawSource) {
|
|
1771
|
+
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
1772
|
+
}
|
|
1773
|
+
function isTailwindGenerationDirective(node, options = {}) {
|
|
1774
|
+
if (node.type !== "atrule") return false;
|
|
1775
|
+
const atRule = node;
|
|
1776
|
+
const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
|
|
1777
|
+
return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
|
|
1778
|
+
}
|
|
1779
|
+
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
1780
|
+
try {
|
|
1781
|
+
const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
|
|
1782
|
+
if (!source) return "";
|
|
1783
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1784
|
+
let removed = false;
|
|
1785
|
+
root.walk((node) => {
|
|
1786
|
+
if (isTailwindSourceDirective(node, options)) {
|
|
1787
|
+
node.remove();
|
|
1788
|
+
removed = true;
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1791
|
+
return removed ? root.toString() : source;
|
|
1792
|
+
} catch {
|
|
1793
|
+
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
1797
|
+
try {
|
|
1798
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1799
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1800
|
+
let found = false;
|
|
1801
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1802
|
+
root.walk((node) => {
|
|
1803
|
+
if (isTailwindGenerationDirective(node, {
|
|
1804
|
+
...options,
|
|
1805
|
+
ignoreLayer
|
|
1806
|
+
})) {
|
|
1807
|
+
found = true;
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
return found;
|
|
1812
|
+
} catch {
|
|
1813
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
function hasTailwindNonRootGenerationDirectives(rawSource, options = {}) {
|
|
1817
|
+
try {
|
|
1818
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1819
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1820
|
+
let found = false;
|
|
1821
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1822
|
+
root.walk((node) => {
|
|
1823
|
+
if (isTailwindGenerationDirective(node, {
|
|
1824
|
+
...options,
|
|
1825
|
+
ignoreLayer
|
|
1826
|
+
}) && !(node.type === "atrule" && isTailwindImportAtRule(node, options))) {
|
|
1827
|
+
found = true;
|
|
1828
|
+
return false;
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
return found;
|
|
1832
|
+
} catch {
|
|
1833
|
+
return GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource) || /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
function hasTailwindRootImportDirectives(rawSource, options = {}) {
|
|
1837
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
1838
|
+
try {
|
|
1839
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1840
|
+
let found = false;
|
|
1841
|
+
root.walkAtRules((node) => {
|
|
1842
|
+
if (isTailwindImportAtRule(node, options)) {
|
|
1843
|
+
found = true;
|
|
1844
|
+
return false;
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1847
|
+
return found;
|
|
1848
|
+
} catch {
|
|
1849
|
+
return extractTailwindDirectiveLines(rawSource, options).some((line) => /@(?:import|use|forward)\b/.test(line));
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
1853
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
1854
|
+
try {
|
|
1855
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1856
|
+
let found = false;
|
|
1857
|
+
root.walkAtRules((node) => {
|
|
1858
|
+
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
1859
|
+
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
1860
|
+
found = true;
|
|
1861
|
+
return false;
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
return found;
|
|
1865
|
+
} catch {
|
|
1866
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
function hasTailwindApplyDirective(rawSource) {
|
|
1870
|
+
if (!rawSource.includes("@apply")) return false;
|
|
1871
|
+
try {
|
|
1872
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1873
|
+
let found = false;
|
|
1874
|
+
root.walkAtRules("apply", () => {
|
|
1875
|
+
found = true;
|
|
1876
|
+
return false;
|
|
1877
|
+
});
|
|
1878
|
+
return found;
|
|
1879
|
+
} catch {
|
|
1880
|
+
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
1881
|
+
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
1885
|
+
try {
|
|
1886
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1887
|
+
const normalizedImports = normalizeTailwindImportAtRules(root, options);
|
|
1888
|
+
let found = false;
|
|
1889
|
+
let config;
|
|
1890
|
+
let configRequest;
|
|
1891
|
+
let removedConfig = false;
|
|
1892
|
+
const removeConfig = options.removeConfig ?? true;
|
|
1893
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1894
|
+
root.walk((node) => {
|
|
1895
|
+
if (isTailwindGenerationDirective(node, {
|
|
1896
|
+
...options,
|
|
1897
|
+
ignoreLayer
|
|
1898
|
+
})) found = true;
|
|
1899
|
+
if (node.type === "atrule" && node.name === "config") {
|
|
1900
|
+
const configPath = parseConfigRequest(node.params);
|
|
1901
|
+
if (configPath && !config) {
|
|
1902
|
+
configRequest = configPath;
|
|
1903
|
+
config = resolveConfigPath(base, configPath);
|
|
1904
|
+
}
|
|
1905
|
+
if (removeConfig) {
|
|
1906
|
+
node.remove();
|
|
1907
|
+
removedConfig = true;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
if (!found) return;
|
|
1912
|
+
if (hasPreprocessorOnlySyntax(rawSource)) {
|
|
1913
|
+
const css = extractTailwindSourceForPostcssFallback(rawSource, {
|
|
1914
|
+
...options,
|
|
1915
|
+
removeConfig
|
|
1916
|
+
});
|
|
1917
|
+
if (css) return {
|
|
1918
|
+
css,
|
|
1919
|
+
config,
|
|
1920
|
+
configRequest,
|
|
1921
|
+
base
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
return {
|
|
1925
|
+
css: removedConfig || normalizedImports ? root.toString() : rawSource,
|
|
1926
|
+
config,
|
|
1927
|
+
configRequest,
|
|
1928
|
+
base
|
|
1929
|
+
};
|
|
1930
|
+
} catch {
|
|
1931
|
+
const css = extractTailwindSourceForPostcssFallback(rawSource, options);
|
|
1932
|
+
const configRequest = extractConfigRequestFromSource(rawSource);
|
|
1933
|
+
const config = configRequest ? resolveConfigPath(base, configRequest) : void 0;
|
|
1934
|
+
return css ? {
|
|
1935
|
+
css,
|
|
1936
|
+
config,
|
|
1937
|
+
configRequest,
|
|
1938
|
+
base
|
|
1939
|
+
} : void 0;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
//#endregion
|
|
1943
|
+
//#region src/utils/options.ts
|
|
1944
|
+
function resolveBooleanObjectOption(value, enabledValue) {
|
|
1945
|
+
if (!value) return false;
|
|
1946
|
+
if (value === true) return enabledValue;
|
|
1947
|
+
return value;
|
|
1948
|
+
}
|
|
1949
|
+
function normalizeStringListOption(value) {
|
|
1950
|
+
if (!value) return;
|
|
1951
|
+
const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : void 0;
|
|
1952
|
+
if (!values) return;
|
|
1953
|
+
const normalized = values.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
1954
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1955
|
+
}
|
|
1956
|
+
//#endregion
|
|
1957
|
+
//#region src/tailwindcss/runtime-options.ts
|
|
1958
|
+
function resolveTailwindcssOptions(options) {
|
|
1959
|
+
return options?.tailwindcss ?? options?.tailwind;
|
|
1960
|
+
}
|
|
1961
|
+
function normalizeExtendLengthUnits(value) {
|
|
1962
|
+
if (value === void 0) return;
|
|
1963
|
+
const resolved = resolveBooleanObjectOption(value, { enabled: true });
|
|
1964
|
+
return resolved && typeof resolved === "object" ? {
|
|
1965
|
+
enabled: true,
|
|
1966
|
+
...resolved
|
|
1967
|
+
} : resolved;
|
|
1968
|
+
}
|
|
1969
|
+
function normalizeTailwindcssRuntimeOptions(options) {
|
|
1970
|
+
return options;
|
|
1971
|
+
}
|
|
1972
|
+
//#endregion
|
|
1973
|
+
//#region src/context/workspace.ts
|
|
1974
|
+
const IGNORED_WORKSPACE_DIRS = new Set([
|
|
1975
|
+
"node_modules",
|
|
1976
|
+
".git",
|
|
1977
|
+
".hg",
|
|
1978
|
+
".svn",
|
|
1979
|
+
".turbo",
|
|
1980
|
+
".output",
|
|
1981
|
+
".next",
|
|
1982
|
+
"dist",
|
|
1983
|
+
"build"
|
|
1984
|
+
]);
|
|
1985
|
+
function findWorkspaceRoot(startDir) {
|
|
1986
|
+
if (!startDir) return;
|
|
1987
|
+
let current = node_path.default.resolve(startDir);
|
|
1988
|
+
while (true) {
|
|
1989
|
+
if ((0, node_fs.existsSync)(node_path.default.join(current, "pnpm-workspace.yaml"))) return current;
|
|
1990
|
+
const parent = node_path.default.dirname(current);
|
|
1991
|
+
if (parent === current) return;
|
|
1992
|
+
current = parent;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
function findNearestPackageRoot(startDir) {
|
|
1996
|
+
if (!startDir) return;
|
|
1997
|
+
let current = node_path.default.resolve(startDir);
|
|
1998
|
+
while (true) {
|
|
1999
|
+
if ((0, node_fs.existsSync)(node_path.default.join(current, "package.json"))) return current;
|
|
2000
|
+
const parent = node_path.default.dirname(current);
|
|
2001
|
+
if (parent === current) return;
|
|
2002
|
+
current = parent;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
function findWorkspacePackageDir(rootDir, packageName) {
|
|
2006
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2007
|
+
const queue = [node_path.default.resolve(rootDir)];
|
|
2008
|
+
while (queue.length > 0) {
|
|
2009
|
+
const current = queue.shift();
|
|
2010
|
+
const normalized = node_path.default.normalize(current);
|
|
2011
|
+
if (visited.has(normalized)) continue;
|
|
2012
|
+
visited.add(normalized);
|
|
2013
|
+
try {
|
|
2014
|
+
const pkgPath = node_path.default.join(normalized, "package.json");
|
|
2015
|
+
if ((0, node_fs.existsSync)(pkgPath)) {
|
|
2016
|
+
if (JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"))?.name === packageName) return normalized;
|
|
2017
|
+
}
|
|
2018
|
+
} catch {}
|
|
2019
|
+
let entries;
|
|
2020
|
+
try {
|
|
2021
|
+
entries = (0, node_fs.readdirSync)(normalized, { withFileTypes: true });
|
|
2022
|
+
} catch {
|
|
2023
|
+
continue;
|
|
2024
|
+
}
|
|
2025
|
+
for (const entry of entries) {
|
|
2026
|
+
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
|
|
2027
|
+
queue.push(node_path.default.join(normalized, entry.name));
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
//#endregion
|
|
2032
|
+
//#region src/tailwindcss/v4/css-entries.ts
|
|
2033
|
+
const TAILWIND_V4_CSS_ENTRY_RE = /\.css(?:[?#].*)?$/i;
|
|
2034
|
+
function isTailwindV4CssEntry(entry) {
|
|
2035
|
+
return typeof entry === "string" && TAILWIND_V4_CSS_ENTRY_RE.test(entry.trim());
|
|
2036
|
+
}
|
|
2037
|
+
function guessBasedirFromEntries(entries) {
|
|
2038
|
+
if (!entries) return;
|
|
2039
|
+
for (const entry of entries) {
|
|
2040
|
+
if (typeof entry !== "string") continue;
|
|
2041
|
+
const trimmed = entry.trim();
|
|
2042
|
+
if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
|
|
2043
|
+
if (!isTailwindV4CssEntry(trimmed)) continue;
|
|
2044
|
+
const entryDir = node_path.default.dirname(trimmed);
|
|
2045
|
+
const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
|
|
2046
|
+
if (resolved) return resolved;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
function normalizeCssEntries(entries, anchor) {
|
|
2050
|
+
if (!entries || entries.length === 0) return;
|
|
2051
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
2052
|
+
for (const entry of entries) {
|
|
2053
|
+
if (typeof entry !== "string") continue;
|
|
2054
|
+
const trimmed = entry.trim();
|
|
2055
|
+
if (trimmed.length === 0) continue;
|
|
2056
|
+
if (!isTailwindV4CssEntry(trimmed)) continue;
|
|
2057
|
+
const resolved = node_path.default.isAbsolute(trimmed) ? node_path.default.normalize(trimmed) : node_path.default.normalize(node_path.default.resolve(anchor, trimmed));
|
|
2058
|
+
normalized.add(resolved);
|
|
2059
|
+
}
|
|
2060
|
+
return normalized.size > 0 ? [...normalized] : void 0;
|
|
2061
|
+
}
|
|
2062
|
+
function isSubPath(parent, child) {
|
|
2063
|
+
if (!parent || !child) return false;
|
|
2064
|
+
const relative = node_path.default.relative(parent, child);
|
|
2065
|
+
return relative === "" || !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
2066
|
+
}
|
|
2067
|
+
function resolveCssEntryBase(entryDir, options) {
|
|
2068
|
+
const normalizedDir = node_path.default.normalize(entryDir);
|
|
2069
|
+
const { preferredBaseDir, workspaceRoot } = options;
|
|
2070
|
+
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
|
|
2071
|
+
if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
|
|
2072
|
+
const packageRoot = findNearestPackageRoot(normalizedDir);
|
|
2073
|
+
if (packageRoot) return node_path.default.normalize(packageRoot);
|
|
2074
|
+
return normalizedDir;
|
|
2075
|
+
}
|
|
2076
|
+
function groupCssEntriesByBase(entries, options = {}) {
|
|
2077
|
+
const normalizedOptions = {
|
|
2078
|
+
preferredBaseDir: options.preferredBaseDir ? node_path.default.normalize(options.preferredBaseDir) : void 0,
|
|
2079
|
+
workspaceRoot: options.workspaceRoot ? node_path.default.normalize(options.workspaceRoot) : void 0
|
|
2080
|
+
};
|
|
2081
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2082
|
+
for (const entry of entries) {
|
|
2083
|
+
const baseDir = resolveCssEntryBase(node_path.default.dirname(entry), normalizedOptions);
|
|
2084
|
+
const bucket = groups.get(baseDir);
|
|
2085
|
+
if (bucket) bucket.push(entry);
|
|
2086
|
+
else groups.set(baseDir, [entry]);
|
|
2087
|
+
}
|
|
2088
|
+
return groups;
|
|
2089
|
+
}
|
|
2090
|
+
//#endregion
|
|
2091
|
+
//#region src/tailwindcss/v4/css-sources.ts
|
|
2092
|
+
function hasCssEntriesValue(value) {
|
|
2093
|
+
if (typeof value === "string") return isTailwindV4CssEntry(value);
|
|
2094
|
+
return Array.isArray(value) && value.some(isTailwindV4CssEntry);
|
|
2095
|
+
}
|
|
2096
|
+
function hasCssSourcesValue(value) {
|
|
2097
|
+
return Array.isArray(value) && value.some((source) => {
|
|
2098
|
+
const file = source?.file;
|
|
2099
|
+
return typeof source === "object" && source !== null && typeof file === "string" && isTailwindV4CssEntry(file) && typeof source.css === "string" && source.css.trim().length > 0;
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
function isTailwindV4CssSourceRoot(source) {
|
|
2103
|
+
return typeof source === "object" && source !== null && typeof source.file === "string" && isTailwindV4CssEntry(source.file);
|
|
2104
|
+
}
|
|
2105
|
+
function filterTailwindV4CssSourceRoots(sources) {
|
|
2106
|
+
const filtered = sources?.filter(isTailwindV4CssSourceRoot);
|
|
2107
|
+
return filtered && filtered.length > 0 ? filtered : void 0;
|
|
2108
|
+
}
|
|
2109
|
+
function hasConfiguredTailwindV4CssRoots(options) {
|
|
2110
|
+
return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources);
|
|
2111
|
+
}
|
|
2112
|
+
function normalizeCssSourceFile(file) {
|
|
2113
|
+
if (!file) return;
|
|
2114
|
+
return node_path.default.isAbsolute(file) ? node_path.default.normalize(file) : file;
|
|
2115
|
+
}
|
|
2116
|
+
function normalizeCssSourceBase(base) {
|
|
2117
|
+
if (!base) return;
|
|
2118
|
+
return node_path.default.resolve(base);
|
|
2119
|
+
}
|
|
2120
|
+
function normalizeDependencies(dependencies) {
|
|
2121
|
+
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
2122
|
+
}
|
|
2123
|
+
function isSameCssSource(a, b) {
|
|
2124
|
+
return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
2125
|
+
}
|
|
2126
|
+
function upsertTailwindV4CssSource(opts, source) {
|
|
2127
|
+
if (!isTailwindV4CssEntry(source.file)) return false;
|
|
2128
|
+
const normalizedSource = omitUndefined({
|
|
2129
|
+
...source,
|
|
2130
|
+
...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
|
|
2131
|
+
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
2132
|
+
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
2133
|
+
});
|
|
2134
|
+
const tailwindcss = opts.tailwindcss ?? {};
|
|
2135
|
+
const v4 = tailwindcss.v4 ?? {};
|
|
2136
|
+
const cssSources = [...v4.cssSources ?? []];
|
|
2137
|
+
const sourceFile = normalizeCssSourceFile(normalizedSource.file);
|
|
2138
|
+
const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
|
|
2139
|
+
if (existingIndex >= 0) {
|
|
2140
|
+
const existing = cssSources[existingIndex];
|
|
2141
|
+
if (!existing) {
|
|
2142
|
+
cssSources[existingIndex] = normalizedSource;
|
|
2143
|
+
return true;
|
|
2144
|
+
}
|
|
2145
|
+
const nextSource = {
|
|
2146
|
+
...existing,
|
|
2147
|
+
...normalizedSource
|
|
2148
|
+
};
|
|
2149
|
+
if (isSameCssSource(existing, nextSource)) return false;
|
|
2150
|
+
cssSources[existingIndex] = nextSource;
|
|
2151
|
+
} else cssSources.push(normalizedSource);
|
|
2152
|
+
opts.tailwindcss = {
|
|
2153
|
+
...tailwindcss,
|
|
2154
|
+
v4: {
|
|
2155
|
+
...v4,
|
|
2156
|
+
cssSources
|
|
2157
|
+
}
|
|
2158
|
+
};
|
|
2159
|
+
return true;
|
|
2160
|
+
}
|
|
2161
|
+
//#endregion
|
|
2162
|
+
//#region src/tailwindcss/v4-engine/source.ts
|
|
2163
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
2164
|
+
function isCssEntryPoint(file) {
|
|
2165
|
+
return typeof file === "string" && node_path.default.basename(file) === "index.css" && (0, node_fs.existsSync)(file);
|
|
2166
|
+
}
|
|
2167
|
+
function resolvePackageCssEntryPoint(specifier) {
|
|
2168
|
+
try {
|
|
2169
|
+
const resolved = require$1.resolve(specifier);
|
|
2170
|
+
if (isCssEntryPoint(resolved)) return resolved;
|
|
2171
|
+
} catch {}
|
|
2172
|
+
const packageName = specifier.replace(/\/index\.css$/, "");
|
|
2173
|
+
if (packageName !== "tailwindcss") return;
|
|
2174
|
+
try {
|
|
2175
|
+
const packageJson = require$1.resolve(`${packageName}/package.json`);
|
|
2176
|
+
const cssEntry = node_path.default.resolve(node_path.default.dirname(packageJson), "index.css");
|
|
2177
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
2178
|
+
} catch {}
|
|
2179
|
+
try {
|
|
2180
|
+
let current = node_path.default.dirname(require$1.resolve("@tailwindcss-mangle/engine"));
|
|
2181
|
+
while (true) {
|
|
2182
|
+
const cssEntry = node_path.default.resolve(current, "..", "tailwindcss", "index.css");
|
|
2183
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
2184
|
+
const parent = node_path.default.dirname(current);
|
|
2185
|
+
if (parent === current) break;
|
|
2186
|
+
current = parent;
|
|
2187
|
+
}
|
|
2188
|
+
} catch {}
|
|
2189
|
+
}
|
|
2190
|
+
function isPostcssPluginImportTarget(value) {
|
|
2191
|
+
if (!value) return false;
|
|
2192
|
+
return value === "@tailwindcss/postcss" || value.includes("/postcss");
|
|
2193
|
+
}
|
|
2194
|
+
function uniqueDefined(values) {
|
|
2195
|
+
return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
|
|
2196
|
+
}
|
|
2197
|
+
function getProjectRoot(runtime) {
|
|
2198
|
+
return runtime.options?.projectRoot ?? node_process.default.cwd();
|
|
2199
|
+
}
|
|
2200
|
+
function resolveBase(value, fallback) {
|
|
2201
|
+
return value === void 0 ? fallback : node_path.default.isAbsolute(value) ? node_path.default.resolve(value) : node_path.default.resolve(fallback, value);
|
|
2202
|
+
}
|
|
2203
|
+
function resolveConfigDir(config, projectRoot) {
|
|
2204
|
+
if (!config) return;
|
|
2205
|
+
const configPath = node_path.default.isAbsolute(config) ? config : node_path.default.resolve(projectRoot, config);
|
|
2206
|
+
return node_path.default.dirname(configPath);
|
|
2207
|
+
}
|
|
2208
|
+
function isBarePackageSpecifier(specifier) {
|
|
2209
|
+
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
|
|
2210
|
+
}
|
|
2211
|
+
function isPackageJsonImportSpecifier(specifier) {
|
|
2212
|
+
return typeof specifier === "string" && specifier.startsWith("#");
|
|
2213
|
+
}
|
|
2214
|
+
function parseCssImportSpecifier(params) {
|
|
2215
|
+
const value = params.trim();
|
|
2216
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
2217
|
+
if (quoted) {
|
|
2218
|
+
const specifier = quoted[2];
|
|
2219
|
+
if (specifier === void 0) return;
|
|
2220
|
+
return {
|
|
2221
|
+
quote: quoted[1],
|
|
2222
|
+
raw: quoted[0],
|
|
2223
|
+
specifier
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
2227
|
+
if (!url) return;
|
|
2228
|
+
const specifier = url[2] ?? url[3];
|
|
2229
|
+
if (specifier === void 0) return;
|
|
2230
|
+
return {
|
|
2231
|
+
quote: url[1],
|
|
2232
|
+
raw: url[0],
|
|
2233
|
+
specifier
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
function quoteCssImportSpecifier(specifier, quote = "\"") {
|
|
2237
|
+
return `${quote}${specifier.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`)}${quote}`;
|
|
2238
|
+
}
|
|
2239
|
+
function createTailwindV4CssImportSpecifierSet(packageName) {
|
|
2240
|
+
const specifiers = new Set(["tailwindcss"]);
|
|
2241
|
+
if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
|
|
2242
|
+
return specifiers;
|
|
2243
|
+
}
|
|
2244
|
+
function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
2245
|
+
if (!css.includes("tailwindcss")) return css;
|
|
2246
|
+
let root;
|
|
2247
|
+
try {
|
|
2248
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2249
|
+
} catch {
|
|
2250
|
+
return css;
|
|
2251
|
+
}
|
|
2252
|
+
const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
|
|
2253
|
+
let changed = false;
|
|
2254
|
+
root.walkAtRules((rule) => {
|
|
2255
|
+
if (rule.name !== "import" && rule.name !== "reference") return;
|
|
2256
|
+
const parsed = parseCssImportSpecifier(rule.params);
|
|
2257
|
+
if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
|
|
2258
|
+
const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
|
|
2259
|
+
if (!cssEntryPoint) return;
|
|
2260
|
+
rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
|
|
2261
|
+
changed = true;
|
|
2262
|
+
});
|
|
2263
|
+
return changed ? root.toString() : css;
|
|
2264
|
+
}
|
|
2265
|
+
function normalizeTailwindV4CssSources(cssSources, packageName, projectRoot) {
|
|
2266
|
+
if (!cssSources?.length) return cssSources;
|
|
2267
|
+
let changed = false;
|
|
2268
|
+
const normalizedCssSources = cssSources.map((cssSource) => {
|
|
2269
|
+
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.isAbsolute(cssSource.file) ? node_path.default.resolve(cssSource.file) : node_path.default.resolve(projectRoot ?? node_process.default.cwd(), cssSource.file) : void 0;
|
|
2270
|
+
const base = typeof cssSource.base === "string" && cssSource.base.length > 0 ? node_path.default.isAbsolute(cssSource.base) ? node_path.default.resolve(cssSource.base) : node_path.default.resolve(projectRoot ?? node_process.default.cwd(), cssSource.base) : file ? node_path.default.dirname(file) : void 0;
|
|
2271
|
+
if (typeof cssSource.css !== "string") {
|
|
2272
|
+
if (file === cssSource.file && base === cssSource.base) return cssSource;
|
|
2273
|
+
changed = true;
|
|
2274
|
+
return {
|
|
2275
|
+
...cssSource,
|
|
2276
|
+
...base === void 0 ? {} : { base },
|
|
2277
|
+
...file === void 0 ? {} : { file }
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
const configBase = base ?? projectRoot ?? node_process.default.cwd();
|
|
2281
|
+
const css = normalizeTailwindV4CssPackageImports(normalizeTailwindConfigDirectives(cssSource.css, configBase), packageName);
|
|
2282
|
+
if (css === cssSource.css && file === cssSource.file && base === cssSource.base) return cssSource;
|
|
2283
|
+
changed = true;
|
|
2284
|
+
return {
|
|
2285
|
+
...cssSource,
|
|
2286
|
+
css,
|
|
2287
|
+
...base === void 0 ? {} : { base },
|
|
2288
|
+
...file === void 0 ? {} : { file }
|
|
2289
|
+
};
|
|
2290
|
+
});
|
|
2291
|
+
return changed ? normalizedCssSources : cssSources;
|
|
2292
|
+
}
|
|
2293
|
+
function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
|
|
2294
|
+
if (!cssEntries?.length) return;
|
|
2295
|
+
const remainingCssEntries = [];
|
|
2296
|
+
const cssSources = [];
|
|
2297
|
+
for (const cssEntry of cssEntries) {
|
|
2298
|
+
const file = node_path.default.resolve(cssEntry);
|
|
2299
|
+
if (!(0, node_fs.existsSync)(file)) {
|
|
2300
|
+
remainingCssEntries.push(cssEntry);
|
|
2301
|
+
continue;
|
|
2302
|
+
}
|
|
2303
|
+
const base = node_path.default.dirname(file);
|
|
2304
|
+
const rawCss = (0, node_fs.readFileSync)(file, "utf8");
|
|
2305
|
+
const entrySource = resolveCssEntrySource(rawCss, base, { removeConfig: false });
|
|
2306
|
+
const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, entrySource?.config && (0, node_fs.existsSync)(entrySource.config) ? entrySource.config : entrySource?.configRequest && !node_path.default.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? node_path.default.resolve(base, entrySource.configRequest) : entrySource?.config), packageName);
|
|
2307
|
+
cssSources.push({
|
|
2308
|
+
file,
|
|
2309
|
+
base,
|
|
2310
|
+
css,
|
|
2311
|
+
dependencies: [file]
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2314
|
+
return {
|
|
2315
|
+
cssEntries: remainingCssEntries,
|
|
2316
|
+
cssSources
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
function normalizeTailwindV4SourceOptions(options) {
|
|
2320
|
+
if (!options) return options;
|
|
2321
|
+
const cssBase = resolveBase(options.base, options.projectRoot ?? options.cwd ?? node_process.default.cwd());
|
|
2322
|
+
const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(normalizeTailwindConfigDirectives(options.css, cssBase), options.packageName);
|
|
2323
|
+
const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
|
|
2324
|
+
const configuredCssSources = filterTailwindV4CssSourceRoots(options.cssSources);
|
|
2325
|
+
const cssSources = normalizeTailwindV4CssSources(configuredCssSources || entrySources?.cssSources ? [...configuredCssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName, options.projectRoot);
|
|
2326
|
+
const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
|
|
2327
|
+
if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
|
|
2328
|
+
return {
|
|
2329
|
+
...options,
|
|
2330
|
+
css,
|
|
2331
|
+
...cssEntries === void 0 ? {} : { cssEntries },
|
|
2332
|
+
cssSources
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
function resolveTailwindCssImportTarget(runtime) {
|
|
2336
|
+
const configuredPackageName = resolveTailwindcssOptions(runtime.options)?.packageName;
|
|
2337
|
+
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
2338
|
+
const packageName = runtime.packageInfo?.name;
|
|
2339
|
+
if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
|
|
2340
|
+
return "tailwindcss";
|
|
2341
|
+
}
|
|
2342
|
+
function readTailwindV4Options(runtime) {
|
|
2343
|
+
return resolveTailwindcssOptions(runtime.options)?.v4 ?? runtime.options?.tailwind?.v4;
|
|
2344
|
+
}
|
|
2345
|
+
function isRawTailwindcssPatchOptions(options) {
|
|
2346
|
+
return Boolean(options && "tailwindcss" in options);
|
|
2347
|
+
}
|
|
2348
|
+
function resolveEngineTailwindV4SourceOptions(runtime) {
|
|
2349
|
+
if (runtime.options) {
|
|
2350
|
+
const projectRoot = getProjectRoot(runtime);
|
|
2351
|
+
const tailwindOptions = resolveTailwindcssOptions(runtime.options);
|
|
2352
|
+
const tailwindV4Options = readTailwindV4Options(runtime);
|
|
2353
|
+
const cwd = resolveBase(tailwindOptions?.cwd, projectRoot);
|
|
2354
|
+
const configuredBase = tailwindV4Options?.configuredBase ?? (isRawTailwindcssPatchOptions(runtime.options) ? tailwindV4Options?.base : void 0);
|
|
2355
|
+
const baseFallbacks = uniqueDefined([
|
|
2356
|
+
configuredBase,
|
|
2357
|
+
cwd,
|
|
2358
|
+
projectRoot,
|
|
2359
|
+
resolveConfigDir(tailwindOptions?.config, projectRoot)
|
|
2360
|
+
]);
|
|
2361
|
+
return {
|
|
2362
|
+
projectRoot,
|
|
2363
|
+
cwd,
|
|
2364
|
+
...configuredBase === void 0 ? {} : { base: configuredBase },
|
|
2365
|
+
baseFallbacks,
|
|
2366
|
+
...tailwindV4Options?.cssSources === void 0 ? {} : { cssSources: tailwindV4Options.cssSources },
|
|
2367
|
+
...tailwindV4Options?.cssEntries === void 0 ? {} : { cssEntries: tailwindV4Options.cssEntries },
|
|
2368
|
+
packageName: resolveTailwindCssImportTarget(runtime)
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
return {
|
|
2372
|
+
projectRoot: getProjectRoot(runtime),
|
|
2373
|
+
packageName: resolveTailwindCssImportTarget(runtime)
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
function resolveTailwindV4SourceOptionsFromRuntime(runtime) {
|
|
2377
|
+
const tailwindV4Options = readTailwindV4Options(runtime);
|
|
2378
|
+
return normalizeTailwindV4SourceOptions(omitUndefined({
|
|
2379
|
+
...resolveEngineTailwindV4SourceOptions(runtime),
|
|
2380
|
+
sources: tailwindV4Options?.sources
|
|
2381
|
+
}));
|
|
2382
|
+
}
|
|
2383
|
+
function resolveTailwindV4Source(options) {
|
|
2384
|
+
return (0, _tailwindcss_mangle_engine.resolveTailwindV4Source)(normalizeTailwindV4SourceOptions(options));
|
|
2385
|
+
}
|
|
2386
|
+
function resolveTailwindV4SourceFromRuntimeOptions(options) {
|
|
2387
|
+
const projectRoot = options?.projectRoot ?? node_process.default.cwd();
|
|
2388
|
+
const tailwindOptions = options?.tailwindcss;
|
|
2389
|
+
const v4Options = tailwindOptions?.v4;
|
|
2390
|
+
return resolveTailwindV4Source({
|
|
2391
|
+
projectRoot,
|
|
2392
|
+
cwd: resolveBase(tailwindOptions?.cwd, projectRoot),
|
|
2393
|
+
packageName: tailwindOptions?.packageName ?? "tailwindcss",
|
|
2394
|
+
...v4Options ?? {}
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
async function resolveTailwindV4SourceFromRuntime(runtime) {
|
|
2398
|
+
return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromRuntime(runtime));
|
|
2399
|
+
}
|
|
2400
|
+
//#endregion
|
|
2401
|
+
Object.defineProperty(exports, "FULL_SOURCE_SCAN_EXTENSION_RE", {
|
|
2402
|
+
enumerable: true,
|
|
2403
|
+
get: function() {
|
|
2404
|
+
return FULL_SOURCE_SCAN_EXTENSION_RE;
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
Object.defineProperty(exports, "FULL_SOURCE_SCAN_PATTERN", {
|
|
2408
|
+
enumerable: true,
|
|
2409
|
+
get: function() {
|
|
2410
|
+
return FULL_SOURCE_SCAN_PATTERN;
|
|
2411
|
+
}
|
|
2412
|
+
});
|
|
2413
|
+
Object.defineProperty(exports, "GENERATOR_PLACEHOLDER_MARKER_RE", {
|
|
2414
|
+
enumerable: true,
|
|
2415
|
+
get: function() {
|
|
2416
|
+
return GENERATOR_PLACEHOLDER_MARKER_RE;
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
Object.defineProperty(exports, "VITE_MARKER_RE", {
|
|
2420
|
+
enumerable: true,
|
|
2421
|
+
get: function() {
|
|
2422
|
+
return VITE_MARKER_RE;
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
|
|
2426
|
+
enumerable: true,
|
|
2427
|
+
get: function() {
|
|
2428
|
+
return collectCssInlineSourceCandidates;
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
Object.defineProperty(exports, "createCssAppend", {
|
|
2432
|
+
enumerable: true,
|
|
2433
|
+
get: function() {
|
|
2434
|
+
return createCssAppend;
|
|
2435
|
+
}
|
|
2436
|
+
});
|
|
2437
|
+
Object.defineProperty(exports, "createTailwindSourceEntryMatcher", {
|
|
2438
|
+
enumerable: true,
|
|
2439
|
+
get: function() {
|
|
2440
|
+
return createTailwindSourceEntryMatcher;
|
|
2441
|
+
}
|
|
2442
|
+
});
|
|
2443
|
+
Object.defineProperty(exports, "createTailwindV4Engine", {
|
|
2444
|
+
enumerable: true,
|
|
2445
|
+
get: function() {
|
|
2446
|
+
return createTailwindV4Engine;
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
Object.defineProperty(exports, "expandTailwindSourceEntries", {
|
|
2450
|
+
enumerable: true,
|
|
2451
|
+
get: function() {
|
|
2452
|
+
return expandTailwindSourceEntries;
|
|
2453
|
+
}
|
|
2454
|
+
});
|
|
2455
|
+
Object.defineProperty(exports, "filterTailwindV4CssSourceRoots", {
|
|
2456
|
+
enumerable: true,
|
|
2457
|
+
get: function() {
|
|
2458
|
+
return filterTailwindV4CssSourceRoots;
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
Object.defineProperty(exports, "filterUnsupportedMiniProgramTailwindV4Candidates", {
|
|
2462
|
+
enumerable: true,
|
|
2463
|
+
get: function() {
|
|
2464
|
+
return filterUnsupportedMiniProgramTailwindV4Candidates;
|
|
2465
|
+
}
|
|
2466
|
+
});
|
|
2467
|
+
Object.defineProperty(exports, "findNearestPackageRoot", {
|
|
2468
|
+
enumerable: true,
|
|
2469
|
+
get: function() {
|
|
2470
|
+
return findNearestPackageRoot;
|
|
2471
|
+
}
|
|
2472
|
+
});
|
|
2473
|
+
Object.defineProperty(exports, "findWorkspacePackageDir", {
|
|
2474
|
+
enumerable: true,
|
|
2475
|
+
get: function() {
|
|
2476
|
+
return findWorkspacePackageDir;
|
|
2477
|
+
}
|
|
2478
|
+
});
|
|
2479
|
+
Object.defineProperty(exports, "findWorkspaceRoot", {
|
|
2480
|
+
enumerable: true,
|
|
2481
|
+
get: function() {
|
|
2482
|
+
return findWorkspaceRoot;
|
|
2483
|
+
}
|
|
2484
|
+
});
|
|
2485
|
+
Object.defineProperty(exports, "getTailwindV4IncrementalGenerateCacheStats", {
|
|
2486
|
+
enumerable: true,
|
|
2487
|
+
get: function() {
|
|
2488
|
+
return getTailwindV4IncrementalGenerateCacheStats;
|
|
2489
|
+
}
|
|
2490
|
+
});
|
|
2491
|
+
Object.defineProperty(exports, "groupCssEntriesByBase", {
|
|
2492
|
+
enumerable: true,
|
|
2493
|
+
get: function() {
|
|
2494
|
+
return groupCssEntriesByBase;
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
Object.defineProperty(exports, "guessBasedirFromEntries", {
|
|
2498
|
+
enumerable: true,
|
|
2499
|
+
get: function() {
|
|
2500
|
+
return guessBasedirFromEntries;
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
Object.defineProperty(exports, "hasConfiguredTailwindV4CssRoots", {
|
|
2504
|
+
enumerable: true,
|
|
2505
|
+
get: function() {
|
|
2506
|
+
return hasConfiguredTailwindV4CssRoots;
|
|
2507
|
+
}
|
|
2508
|
+
});
|
|
2509
|
+
Object.defineProperty(exports, "hasLocalCssImport", {
|
|
2510
|
+
enumerable: true,
|
|
2511
|
+
get: function() {
|
|
2512
|
+
return hasLocalCssImport;
|
|
2513
|
+
}
|
|
2514
|
+
});
|
|
2515
|
+
Object.defineProperty(exports, "hasTailwindApplyDirective", {
|
|
2516
|
+
enumerable: true,
|
|
2517
|
+
get: function() {
|
|
2518
|
+
return hasTailwindApplyDirective;
|
|
2519
|
+
}
|
|
2520
|
+
});
|
|
2521
|
+
Object.defineProperty(exports, "hasTailwindGeneratedCss", {
|
|
2522
|
+
enumerable: true,
|
|
2523
|
+
get: function() {
|
|
2524
|
+
return hasTailwindGeneratedCss;
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
Object.defineProperty(exports, "hasTailwindGeneratedCssMarkers", {
|
|
2528
|
+
enumerable: true,
|
|
2529
|
+
get: function() {
|
|
2530
|
+
return hasTailwindGeneratedCssMarkers;
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
Object.defineProperty(exports, "hasTailwindNonRootGenerationDirectives", {
|
|
2534
|
+
enumerable: true,
|
|
2535
|
+
get: function() {
|
|
2536
|
+
return hasTailwindNonRootGenerationDirectives;
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
Object.defineProperty(exports, "hasTailwindRootDirectives", {
|
|
2540
|
+
enumerable: true,
|
|
2541
|
+
get: function() {
|
|
2542
|
+
return hasTailwindRootDirectives;
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
Object.defineProperty(exports, "hasTailwindRootImportDirectives", {
|
|
2546
|
+
enumerable: true,
|
|
2547
|
+
get: function() {
|
|
2548
|
+
return hasTailwindRootImportDirectives;
|
|
2549
|
+
}
|
|
2550
|
+
});
|
|
2551
|
+
Object.defineProperty(exports, "hasTailwindSourceDirectives", {
|
|
2552
|
+
enumerable: true,
|
|
2553
|
+
get: function() {
|
|
2554
|
+
return hasTailwindSourceDirectives;
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
Object.defineProperty(exports, "inferGeneratorTargetFromEnv", {
|
|
2558
|
+
enumerable: true,
|
|
2559
|
+
get: function() {
|
|
2560
|
+
return inferGeneratorTargetFromEnv;
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2563
|
+
Object.defineProperty(exports, "isFileMatchedByTailwindSourceEntries", {
|
|
2564
|
+
enumerable: true,
|
|
2565
|
+
get: function() {
|
|
2566
|
+
return isFileMatchedByTailwindSourceEntries;
|
|
2567
|
+
}
|
|
2568
|
+
});
|
|
2569
|
+
Object.defineProperty(exports, "isTailwindV4CssEntry", {
|
|
2570
|
+
enumerable: true,
|
|
2571
|
+
get: function() {
|
|
2572
|
+
return isTailwindV4CssEntry;
|
|
2573
|
+
}
|
|
2574
|
+
});
|
|
2575
|
+
Object.defineProperty(exports, "normalizeConfigDirective", {
|
|
2576
|
+
enumerable: true,
|
|
2577
|
+
get: function() {
|
|
2578
|
+
return normalizeConfigDirective;
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
Object.defineProperty(exports, "normalizeCssEntries", {
|
|
2582
|
+
enumerable: true,
|
|
2583
|
+
get: function() {
|
|
2584
|
+
return normalizeCssEntries;
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
Object.defineProperty(exports, "normalizeExtendLengthUnits", {
|
|
2588
|
+
enumerable: true,
|
|
2589
|
+
get: function() {
|
|
2590
|
+
return normalizeExtendLengthUnits;
|
|
2591
|
+
}
|
|
2592
|
+
});
|
|
2593
|
+
Object.defineProperty(exports, "normalizeLegacyContentEntries", {
|
|
2594
|
+
enumerable: true,
|
|
2595
|
+
get: function() {
|
|
2596
|
+
return normalizeLegacyContentEntries;
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2599
|
+
Object.defineProperty(exports, "normalizeStringListOption", {
|
|
2600
|
+
enumerable: true,
|
|
2601
|
+
get: function() {
|
|
2602
|
+
return normalizeStringListOption;
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
Object.defineProperty(exports, "normalizeTailwindConfigDirectives", {
|
|
2606
|
+
enumerable: true,
|
|
2607
|
+
get: function() {
|
|
2608
|
+
return normalizeTailwindConfigDirectives;
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2611
|
+
Object.defineProperty(exports, "normalizeTailwindSourceDirectives", {
|
|
2612
|
+
enumerable: true,
|
|
2613
|
+
get: function() {
|
|
2614
|
+
return normalizeTailwindSourceDirectives;
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
Object.defineProperty(exports, "normalizeTailwindSourceForGenerator", {
|
|
2618
|
+
enumerable: true,
|
|
2619
|
+
get: function() {
|
|
2620
|
+
return normalizeTailwindSourceForGenerator;
|
|
2621
|
+
}
|
|
2622
|
+
});
|
|
2623
|
+
Object.defineProperty(exports, "normalizeTailwindcssRuntimeOptions", {
|
|
2624
|
+
enumerable: true,
|
|
2625
|
+
get: function() {
|
|
2626
|
+
return normalizeTailwindcssRuntimeOptions;
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
Object.defineProperty(exports, "omitUndefined", {
|
|
2630
|
+
enumerable: true,
|
|
2631
|
+
get: function() {
|
|
2632
|
+
return omitUndefined;
|
|
2633
|
+
}
|
|
2634
|
+
});
|
|
2635
|
+
Object.defineProperty(exports, "parseConfigParam", {
|
|
2636
|
+
enumerable: true,
|
|
2637
|
+
get: function() {
|
|
2638
|
+
return parseConfigParam;
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
Object.defineProperty(exports, "parseImportRequest", {
|
|
2642
|
+
enumerable: true,
|
|
2643
|
+
get: function() {
|
|
2644
|
+
return parseImportRequest;
|
|
2645
|
+
}
|
|
2646
|
+
});
|
|
2647
|
+
Object.defineProperty(exports, "prependConfigDirective", {
|
|
2648
|
+
enumerable: true,
|
|
2649
|
+
get: function() {
|
|
2650
|
+
return prependConfigDirective;
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
Object.defineProperty(exports, "removeTailwindSourceDirectives", {
|
|
2654
|
+
enumerable: true,
|
|
2655
|
+
get: function() {
|
|
2656
|
+
return removeTailwindSourceDirectives;
|
|
2657
|
+
}
|
|
2658
|
+
});
|
|
2659
|
+
Object.defineProperty(exports, "resolveBooleanObjectOption", {
|
|
2660
|
+
enumerable: true,
|
|
2661
|
+
get: function() {
|
|
2662
|
+
return resolveBooleanObjectOption;
|
|
2663
|
+
}
|
|
2664
|
+
});
|
|
2665
|
+
Object.defineProperty(exports, "resolveCssEntrySource", {
|
|
2666
|
+
enumerable: true,
|
|
2667
|
+
get: function() {
|
|
2668
|
+
return resolveCssEntrySource;
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
Object.defineProperty(exports, "resolveCssSourceEntries", {
|
|
2672
|
+
enumerable: true,
|
|
2673
|
+
get: function() {
|
|
2674
|
+
return resolveCssSourceEntries;
|
|
2675
|
+
}
|
|
2676
|
+
});
|
|
2677
|
+
Object.defineProperty(exports, "resolveSourceScanPath", {
|
|
2678
|
+
enumerable: true,
|
|
2679
|
+
get: function() {
|
|
2680
|
+
return resolveSourceScanPath;
|
|
2681
|
+
}
|
|
2682
|
+
});
|
|
2683
|
+
Object.defineProperty(exports, "resolveTailwindV4CssSourceBase", {
|
|
2684
|
+
enumerable: true,
|
|
2685
|
+
get: function() {
|
|
2686
|
+
return resolveTailwindV4CssSourceBase;
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
2689
|
+
Object.defineProperty(exports, "resolveTailwindV4Source", {
|
|
2690
|
+
enumerable: true,
|
|
2691
|
+
get: function() {
|
|
2692
|
+
return resolveTailwindV4Source;
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2695
|
+
Object.defineProperty(exports, "resolveTailwindV4SourceFromRuntime", {
|
|
2696
|
+
enumerable: true,
|
|
2697
|
+
get: function() {
|
|
2698
|
+
return resolveTailwindV4SourceFromRuntime;
|
|
2699
|
+
}
|
|
2700
|
+
});
|
|
2701
|
+
Object.defineProperty(exports, "resolveTailwindV4SourceFromRuntimeOptions", {
|
|
2702
|
+
enumerable: true,
|
|
2703
|
+
get: function() {
|
|
2704
|
+
return resolveTailwindV4SourceFromRuntimeOptions;
|
|
2705
|
+
}
|
|
2706
|
+
});
|
|
2707
|
+
Object.defineProperty(exports, "resolveTailwindV4SourceOptionsFromRuntime", {
|
|
2708
|
+
enumerable: true,
|
|
2709
|
+
get: function() {
|
|
2710
|
+
return resolveTailwindV4SourceOptionsFromRuntime;
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2713
|
+
Object.defineProperty(exports, "resolveTailwindcssOptions", {
|
|
2714
|
+
enumerable: true,
|
|
2715
|
+
get: function() {
|
|
2716
|
+
return resolveTailwindcssOptions;
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
Object.defineProperty(exports, "splitGeneratorPlaceholderCssBySourceOrder", {
|
|
2720
|
+
enumerable: true,
|
|
2721
|
+
get: function() {
|
|
2722
|
+
return splitGeneratorPlaceholderCssBySourceOrder;
|
|
2723
|
+
}
|
|
2724
|
+
});
|
|
2725
|
+
Object.defineProperty(exports, "splitTailwindGeneratedCssByBanner", {
|
|
2726
|
+
enumerable: true,
|
|
2727
|
+
get: function() {
|
|
2728
|
+
return splitTailwindGeneratedCssByBanner;
|
|
2729
|
+
}
|
|
2730
|
+
});
|
|
2731
|
+
Object.defineProperty(exports, "splitTailwindV4GeneratedCssBySourceOrder", {
|
|
2732
|
+
enumerable: true,
|
|
2733
|
+
get: function() {
|
|
2734
|
+
return splitTailwindV4GeneratedCssBySourceOrder;
|
|
2735
|
+
}
|
|
2736
|
+
});
|
|
2737
|
+
Object.defineProperty(exports, "stripGeneratorPlaceholderMarkers", {
|
|
2738
|
+
enumerable: true,
|
|
2739
|
+
get: function() {
|
|
2740
|
+
return stripGeneratorPlaceholderMarkers;
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
Object.defineProperty(exports, "stripTailwindBanner", {
|
|
2744
|
+
enumerable: true,
|
|
2745
|
+
get: function() {
|
|
2746
|
+
return stripTailwindBanner;
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
Object.defineProperty(exports, "stripTailwindBanners", {
|
|
2750
|
+
enumerable: true,
|
|
2751
|
+
get: function() {
|
|
2752
|
+
return stripTailwindBanners;
|
|
2753
|
+
}
|
|
2754
|
+
});
|
|
2755
|
+
Object.defineProperty(exports, "toPosixPath", {
|
|
2756
|
+
enumerable: true,
|
|
2757
|
+
get: function() {
|
|
2758
|
+
return toPosixPath;
|
|
2759
|
+
}
|
|
2760
|
+
});
|
|
2761
|
+
Object.defineProperty(exports, "transformTailwindV4CssByTarget", {
|
|
2762
|
+
enumerable: true,
|
|
2763
|
+
get: function() {
|
|
2764
|
+
return transformTailwindV4CssByTarget;
|
|
2765
|
+
}
|
|
2766
|
+
});
|
|
2767
|
+
Object.defineProperty(exports, "transformTailwindV4CssToWeapp", {
|
|
2768
|
+
enumerable: true,
|
|
2769
|
+
get: function() {
|
|
2770
|
+
return transformTailwindV4CssToWeapp;
|
|
2771
|
+
}
|
|
2772
|
+
});
|
|
2773
|
+
Object.defineProperty(exports, "upsertTailwindV4CssSource", {
|
|
2774
|
+
enumerable: true,
|
|
2775
|
+
get: function() {
|
|
2776
|
+
return upsertTailwindV4CssSource;
|
|
2777
|
+
}
|
|
2778
|
+
});
|