weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.20
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.md +6 -7
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/bundle-state-BlXvU4jl.js +530 -0
- package/dist/bundle-state-PO6MysTJ.mjs +414 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +5 -0
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +7 -3
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
- package/dist/bundlers/shared/generator-css.d.ts +16 -22
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
- package/dist/bundlers/vite/source-candidates.d.ts +16 -1
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +605 -611
- package/dist/cli.mjs +614 -620
- package/dist/constants.d.ts +1 -2
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +3 -2
- package/dist/css-macro/postcss.mjs +3 -2
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults-B1igPF_e.mjs +150 -0
- package/dist/defaults-IHhYxNeU.js +193 -0
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +6 -131
- package/dist/defaults.mjs +2 -129
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +9 -8
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-DIuglJub.mjs +32 -0
- package/dist/generator-N4jy1HCk.js +55 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +185 -47
- package/dist/gulp.mjs +179 -41
- package/dist/incremental-runtime-class-set-CJ0Pnsw2.js +2348 -0
- package/dist/incremental-runtime-class-set-hF-uiw6W.mjs +2285 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
- package/dist/lightningcss/style-handler.d.ts +3 -3
- package/dist/logger-CZUxvJJD.mjs +2 -0
- package/dist/logger-EVNB9z7i.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-D4UdbBQ6.mjs +228 -0
- package/dist/postcss-DlY-YRvA.js +237 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/{recorder-gYSNLfOP.js → precheck-BjEbVEpX.js} +218 -314
- package/dist/{recorder-zsgatmkB.mjs → precheck-tbk626YL.mjs} +186 -281
- package/dist/presets.js +13 -11
- package/dist/presets.mjs +11 -9
- package/dist/reset.d.ts +1 -0
- package/dist/runtime-registry-D5qnaSpo.js +5516 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-BrvneDDd.mjs +209 -0
- package/dist/source-candidates-gxijpPI3.js +222 -0
- package/dist/tailwindcss/miniprogram.d.ts +5 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-BhG7BtB-.js +651 -0
- package/dist/tailwindcss-c6ROlNNW.mjs +600 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +51 -48
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +23 -23
- package/dist/types/user-defined-options/important.d.ts +31 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
- package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
- package/dist/v3-engine-5LoZUH-4.js +3695 -0
- package/dist/v3-engine-DIXDEDmL.mjs +3406 -0
- package/dist/{vite-CrlzCNqz.mjs → vite-B5faZcbE.mjs} +1256 -1088
- package/dist/vite-MyXBNux0.js +2368 -0
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +5157 -16
- package/dist/weapp-tw-runtime-classset-loader.js +32 -7
- package/dist/webpack-BnVyDmsD.mjs +836 -0
- package/dist/webpack-Mz1V0A9p.js +846 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +27 -37
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
- package/dist/generator-css-B5ejWUMv.mjs +0 -1098
- package/dist/generator-css-D3OdPRiS.js +0 -1125
- package/dist/generator-mmhXzZnv.js +0 -1276
- package/dist/js/syntax.d.ts +0 -10
- package/dist/loader-anchors-CNkWT8hx.js +0 -273
- package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/vite-BC9U7ahn.js +0 -2199
- package/dist/webpack-Bu6M-Hbw.mjs +0 -441
- package/dist/webpack-DD7A6V0u.js +0 -456
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
- /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
- /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
+
const require_v3_engine = require("./v3-engine-5LoZUH-4.js");
|
|
3
|
+
require("./utils-4ODFyoqD.js");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_module = require("node:module");
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_chunk.__toESM(node_path);
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_chunk.__toESM(node_process);
|
|
10
|
+
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
11
|
+
let node_url = require("node:url");
|
|
12
|
+
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
13
|
+
//#region src/tailwindcss/v4/css-sources.ts
|
|
14
|
+
function hasCssEntriesValue(value) {
|
|
15
|
+
if (typeof value === "string") return value.trim().length > 0;
|
|
16
|
+
return Array.isArray(value) && value.some((entry) => typeof entry === "string" && entry.trim().length > 0);
|
|
17
|
+
}
|
|
18
|
+
function hasCssSourcesValue(value) {
|
|
19
|
+
return Array.isArray(value) && value.some((source) => {
|
|
20
|
+
return typeof source === "object" && source !== null && typeof source.css === "string" && source.css.trim().length > 0;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function hasConfiguredTailwindV4CssRoots(options) {
|
|
24
|
+
return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources);
|
|
25
|
+
}
|
|
26
|
+
function normalizeCssSourceFile(file) {
|
|
27
|
+
if (!file) return;
|
|
28
|
+
return node_path.default.isAbsolute(file) ? node_path.default.normalize(file) : file;
|
|
29
|
+
}
|
|
30
|
+
function normalizeCssSourceBase(base) {
|
|
31
|
+
if (!base) return;
|
|
32
|
+
return node_path.default.resolve(base);
|
|
33
|
+
}
|
|
34
|
+
function normalizeDependencies(dependencies) {
|
|
35
|
+
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
36
|
+
}
|
|
37
|
+
function isSameCssSource(a, b) {
|
|
38
|
+
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));
|
|
39
|
+
}
|
|
40
|
+
function upsertTailwindV4CssSource(opts, source) {
|
|
41
|
+
const normalizedSource = require_v3_engine.omitUndefined({
|
|
42
|
+
...source,
|
|
43
|
+
...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
|
|
44
|
+
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
45
|
+
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
46
|
+
});
|
|
47
|
+
const tailwindcss = opts.tailwindcss ?? {};
|
|
48
|
+
const v4 = tailwindcss.v4 ?? {};
|
|
49
|
+
const cssSources = [...v4.cssSources ?? []];
|
|
50
|
+
const sourceFile = normalizeCssSourceFile(normalizedSource.file);
|
|
51
|
+
const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
|
|
52
|
+
if (existingIndex >= 0) {
|
|
53
|
+
const existing = cssSources[existingIndex];
|
|
54
|
+
if (!existing) {
|
|
55
|
+
cssSources[existingIndex] = normalizedSource;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const nextSource = {
|
|
59
|
+
...existing,
|
|
60
|
+
...normalizedSource
|
|
61
|
+
};
|
|
62
|
+
if (isSameCssSource(existing, nextSource)) return false;
|
|
63
|
+
cssSources[existingIndex] = nextSource;
|
|
64
|
+
} else cssSources.push(normalizedSource);
|
|
65
|
+
opts.tailwindcss = {
|
|
66
|
+
...tailwindcss,
|
|
67
|
+
v4: {
|
|
68
|
+
...v4,
|
|
69
|
+
cssSources
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/tailwindcss/v4/config.ts
|
|
76
|
+
const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
77
|
+
function includesToken(list, token) {
|
|
78
|
+
return list.some((candidate) => {
|
|
79
|
+
if (typeof token === "string") {
|
|
80
|
+
if (typeof candidate === "string") return candidate === token;
|
|
81
|
+
candidate.lastIndex = 0;
|
|
82
|
+
return candidate.test(token);
|
|
83
|
+
}
|
|
84
|
+
if (typeof candidate === "string") {
|
|
85
|
+
token.lastIndex = 0;
|
|
86
|
+
return token.test(candidate);
|
|
87
|
+
}
|
|
88
|
+
return candidate.source === token.source && candidate.flags === token.flags;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function ensureDefaultsIncluded(value) {
|
|
92
|
+
if (value === true) return { includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES] };
|
|
93
|
+
if (Array.isArray(value)) {
|
|
94
|
+
if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
|
|
95
|
+
const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
|
|
96
|
+
return missing.length > 0 ? [...value, ...missing] : value;
|
|
97
|
+
}
|
|
98
|
+
if (value && typeof value === "object") {
|
|
99
|
+
const include = value.includeCustomProperties;
|
|
100
|
+
if (!Array.isArray(include)) return {
|
|
101
|
+
...value,
|
|
102
|
+
includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
|
|
103
|
+
};
|
|
104
|
+
if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
|
|
105
|
+
const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
|
|
106
|
+
return missing.length > 0 ? {
|
|
107
|
+
...value,
|
|
108
|
+
includeCustomProperties: [...include, ...missing]
|
|
109
|
+
} : value;
|
|
110
|
+
}
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function normalizeCssEntriesConfig(entries) {
|
|
114
|
+
if (!entries) return;
|
|
115
|
+
if (typeof entries === "string") {
|
|
116
|
+
const trimmed = entries.trim();
|
|
117
|
+
return trimmed ? [trimmed] : void 0;
|
|
118
|
+
}
|
|
119
|
+
if (!Array.isArray(entries)) return;
|
|
120
|
+
const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
121
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
122
|
+
}
|
|
123
|
+
function hasConfiguredCssEntries(ctx) {
|
|
124
|
+
if (normalizeCssEntriesConfig(ctx.cssEntries)) return true;
|
|
125
|
+
if (normalizeCssEntriesConfig(ctx.tailwindcss?.v4?.cssEntries)) return true;
|
|
126
|
+
const patcherOptions = ctx.tailwindcssPatcherOptions;
|
|
127
|
+
if (patcherOptions) {
|
|
128
|
+
if (normalizeCssEntriesConfig(patcherOptions.tailwindcss?.v4?.cssEntries)) return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
let hasWarnedMissingCssEntries = false;
|
|
133
|
+
function warnMissingCssEntries(ctx, patcher) {
|
|
134
|
+
if (hasWarnedMissingCssEntries) return;
|
|
135
|
+
if (patcher?.majorVersion !== 4) return;
|
|
136
|
+
if (hasConfiguredCssEntries(ctx) || hasConfiguredTailwindV4CssRoots(ctx)) return;
|
|
137
|
+
hasWarnedMissingCssEntries = true;
|
|
138
|
+
_weapp_tailwindcss_logger.logger.warn("[tailwindcss@4] 未检测到 cssEntries 配置。请传入包含 tailwindcss 引用的 CSS 绝对路径,例如 cssEntries: [\"/absolute/path/to/src/app.css\"],否则 tailwindcss 生成的类名不会参与转译。");
|
|
139
|
+
}
|
|
140
|
+
function applyV4CssCalcDefaults(cssCalc, patcher) {
|
|
141
|
+
const cssCalcOptions = cssCalc ?? patcher?.majorVersion === 4;
|
|
142
|
+
if (patcher?.majorVersion === 4 && cssCalcOptions) return ensureDefaultsIncluded(cssCalcOptions);
|
|
143
|
+
return cssCalcOptions;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/tailwindcss/v4/multi-patcher.ts
|
|
147
|
+
function createMultiTailwindcssPatcher(patchers) {
|
|
148
|
+
if (patchers.length <= 1) {
|
|
149
|
+
const [patcher] = patchers;
|
|
150
|
+
if (!patcher) throw new Error("createMultiTailwindcssPatcher requires at least one patcher.");
|
|
151
|
+
return patcher;
|
|
152
|
+
}
|
|
153
|
+
const first = patchers[0];
|
|
154
|
+
const firstWithoutPatch = { ...first };
|
|
155
|
+
delete firstWithoutPatch.patch;
|
|
156
|
+
const multiPatcher = {
|
|
157
|
+
...firstWithoutPatch,
|
|
158
|
+
packageInfo: first?.packageInfo,
|
|
159
|
+
majorVersion: first?.majorVersion,
|
|
160
|
+
options: first?.options,
|
|
161
|
+
async getClassSet() {
|
|
162
|
+
const aggregated = /* @__PURE__ */ new Set();
|
|
163
|
+
for (const patcher of patchers) {
|
|
164
|
+
const current = await patcher.getClassSet();
|
|
165
|
+
for (const className of current) aggregated.add(className);
|
|
166
|
+
}
|
|
167
|
+
return aggregated;
|
|
168
|
+
},
|
|
169
|
+
async extract(options) {
|
|
170
|
+
const aggregatedSet = /* @__PURE__ */ new Set();
|
|
171
|
+
const aggregatedList = [];
|
|
172
|
+
let filename;
|
|
173
|
+
for (const patcher of patchers) {
|
|
174
|
+
const result = await patcher.extract(options);
|
|
175
|
+
if (!result) continue;
|
|
176
|
+
if (filename === void 0 && result.filename) filename = result.filename;
|
|
177
|
+
if (result.classList) for (const className of result.classList) {
|
|
178
|
+
if (!aggregatedSet.has(className)) aggregatedList.push(className);
|
|
179
|
+
aggregatedSet.add(className);
|
|
180
|
+
}
|
|
181
|
+
if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
|
|
182
|
+
}
|
|
183
|
+
return require_v3_engine.omitUndefined({
|
|
184
|
+
classList: aggregatedList,
|
|
185
|
+
classSet: aggregatedSet,
|
|
186
|
+
filename
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) multiPatcher.getClassSetSync = () => {
|
|
191
|
+
const aggregated = /* @__PURE__ */ new Set();
|
|
192
|
+
for (const patcher of patchers) {
|
|
193
|
+
const current = patcher.getClassSetSync?.();
|
|
194
|
+
if (!current) continue;
|
|
195
|
+
for (const className of current) aggregated.add(className);
|
|
196
|
+
}
|
|
197
|
+
return aggregated;
|
|
198
|
+
};
|
|
199
|
+
Object.defineProperty(multiPatcher, require_v3_engine.runtimeSignaturePatchersSymbol, {
|
|
200
|
+
value: [...patchers],
|
|
201
|
+
configurable: true
|
|
202
|
+
});
|
|
203
|
+
return multiPatcher;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/tailwindcss/v4/patcher-options.ts
|
|
207
|
+
function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries) {
|
|
208
|
+
const hasCssEntries = cssEntries.length > 0;
|
|
209
|
+
if (!options) return options;
|
|
210
|
+
const modernTailwind = options.tailwindcss;
|
|
211
|
+
if (!modernTailwind) return options;
|
|
212
|
+
return {
|
|
213
|
+
...options,
|
|
214
|
+
tailwindcss: {
|
|
215
|
+
...modernTailwind,
|
|
216
|
+
v4: {
|
|
217
|
+
...modernTailwind.v4 ?? {},
|
|
218
|
+
...hasCssEntries ? {} : { base: modernTailwind.v4?.base ?? baseDir },
|
|
219
|
+
cssEntries: hasCssEntries ? cssEntries : modernTailwind.v4?.cssEntries ?? cssEntries
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/tailwindcss/v4/css-entries.ts
|
|
226
|
+
function guessBasedirFromEntries(entries) {
|
|
227
|
+
if (!entries) return;
|
|
228
|
+
for (const entry of entries) {
|
|
229
|
+
if (typeof entry !== "string") continue;
|
|
230
|
+
const trimmed = entry.trim();
|
|
231
|
+
if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
|
|
232
|
+
const entryDir = node_path.default.dirname(trimmed);
|
|
233
|
+
const resolved = require_v3_engine.findNearestPackageRoot(entryDir) ?? entryDir;
|
|
234
|
+
if (resolved) return resolved;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function normalizeCssEntries(entries, anchor) {
|
|
238
|
+
if (!entries || entries.length === 0) return;
|
|
239
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
240
|
+
for (const entry of entries) {
|
|
241
|
+
if (typeof entry !== "string") continue;
|
|
242
|
+
const trimmed = entry.trim();
|
|
243
|
+
if (trimmed.length === 0) continue;
|
|
244
|
+
const resolved = node_path.default.isAbsolute(trimmed) ? node_path.default.normalize(trimmed) : node_path.default.normalize(node_path.default.resolve(anchor, trimmed));
|
|
245
|
+
normalized.add(resolved);
|
|
246
|
+
}
|
|
247
|
+
return normalized.size > 0 ? [...normalized] : void 0;
|
|
248
|
+
}
|
|
249
|
+
function isSubPath(parent, child) {
|
|
250
|
+
if (!parent || !child) return false;
|
|
251
|
+
const relative = node_path.default.relative(parent, child);
|
|
252
|
+
return relative === "" || !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
253
|
+
}
|
|
254
|
+
function resolveCssEntryBase(entryDir, options) {
|
|
255
|
+
const normalizedDir = node_path.default.normalize(entryDir);
|
|
256
|
+
const { preferredBaseDir, workspaceRoot } = options;
|
|
257
|
+
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
|
|
258
|
+
if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
|
|
259
|
+
const packageRoot = require_v3_engine.findNearestPackageRoot(normalizedDir);
|
|
260
|
+
if (packageRoot) return node_path.default.normalize(packageRoot);
|
|
261
|
+
return normalizedDir;
|
|
262
|
+
}
|
|
263
|
+
function groupCssEntriesByBase(entries, options = {}) {
|
|
264
|
+
const normalizedOptions = {
|
|
265
|
+
preferredBaseDir: options.preferredBaseDir ? node_path.default.normalize(options.preferredBaseDir) : void 0,
|
|
266
|
+
workspaceRoot: options.workspaceRoot ? node_path.default.normalize(options.workspaceRoot) : void 0
|
|
267
|
+
};
|
|
268
|
+
const groups = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const entry of entries) {
|
|
270
|
+
const baseDir = resolveCssEntryBase(node_path.default.dirname(entry), normalizedOptions);
|
|
271
|
+
const bucket = groups.get(baseDir);
|
|
272
|
+
if (bucket) bucket.push(entry);
|
|
273
|
+
else groups.set(baseDir, [entry]);
|
|
274
|
+
}
|
|
275
|
+
return groups;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/tailwindcss/v4/patcher.ts
|
|
279
|
+
const CONFIGURED_TAILWIND_VERSION_RE = /Configured tailwindcss\.version=\d+/u;
|
|
280
|
+
const RESOLVED_TAILWIND_VERSION_RE = /resolved package ".+" is version /u;
|
|
281
|
+
function isTailwindcss4Package(packageName) {
|
|
282
|
+
return Boolean(packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")));
|
|
283
|
+
}
|
|
284
|
+
function resolveExplicitTailwindVersion(configuredVersion, configuredPackageName) {
|
|
285
|
+
if (typeof configuredVersion === "number") return configuredVersion;
|
|
286
|
+
if (configuredPackageName === "tailwindcss") return 3;
|
|
287
|
+
if (isTailwindcss4Package(configuredPackageName)) return 4;
|
|
288
|
+
}
|
|
289
|
+
function hasOwnV4Signal(value) {
|
|
290
|
+
return typeof value === "object" && value !== null && "v4" in value;
|
|
291
|
+
}
|
|
292
|
+
function isTailwindVersionMismatchError(error) {
|
|
293
|
+
return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
|
|
294
|
+
}
|
|
295
|
+
function createPatcherForBase(baseDir, cssEntries, options) {
|
|
296
|
+
const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch, bareArbitraryValues } = options;
|
|
297
|
+
const hasCssEntries = Boolean(cssEntries?.length);
|
|
298
|
+
const configuredV4Options = tailwindcss?.v4 ?? tailwindcssPatcherOptions?.tailwindcss?.v4;
|
|
299
|
+
const hasCssSources = Boolean(configuredV4Options?.cssSources?.length);
|
|
300
|
+
const defaultTailwindcssConfig = {
|
|
301
|
+
cwd: baseDir,
|
|
302
|
+
v2: { cwd: baseDir },
|
|
303
|
+
v3: { cwd: baseDir },
|
|
304
|
+
v4: hasCssEntries ? require_v3_engine.omitUndefined({ cssEntries }) : require_v3_engine.omitUndefined({
|
|
305
|
+
base: baseDir,
|
|
306
|
+
cssEntries
|
|
307
|
+
})
|
|
308
|
+
};
|
|
309
|
+
const mergedTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, defaultTailwindcssConfig);
|
|
310
|
+
if (!mergedTailwindOptions.v4) mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
|
|
311
|
+
base: baseDir,
|
|
312
|
+
cssEntries: cssEntries ?? []
|
|
313
|
+
};
|
|
314
|
+
else {
|
|
315
|
+
if (!hasCssEntries && !mergedTailwindOptions.v4.base) mergedTailwindOptions.v4.base = baseDir;
|
|
316
|
+
if (hasCssEntries) {
|
|
317
|
+
if (cssEntries?.length) mergedTailwindOptions.v4.cssEntries = cssEntries;
|
|
318
|
+
else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = [];
|
|
319
|
+
} else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = cssEntries ?? [];
|
|
320
|
+
}
|
|
321
|
+
if (bareArbitraryValues !== void 0 && bareArbitraryValues !== false) mergedTailwindOptions.v4.bareArbitraryValues = bareArbitraryValues;
|
|
322
|
+
const patchedOptions = overrideTailwindcssPatcherOptionsForBase(tailwindcssPatcherOptions, baseDir, cssEntries ?? []);
|
|
323
|
+
const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName;
|
|
324
|
+
const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
|
|
325
|
+
const hasExplicitV4Signals = hasCssEntries || hasCssSources || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss);
|
|
326
|
+
const packageNameForVersionDetection = configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss";
|
|
327
|
+
const installedTailwindVersion = require_v3_engine.readInstalledPackageMajorVersion(packageNameForVersionDetection, baseDir);
|
|
328
|
+
const resolvedTailwindVersion = installedTailwindVersion ?? explicitTailwindVersion;
|
|
329
|
+
const supportedResolvedTailwindVersion = resolvedTailwindVersion === 2 || resolvedTailwindVersion === 3 || resolvedTailwindVersion === 4 ? resolvedTailwindVersion : void 0;
|
|
330
|
+
const shouldPatchV4PostcssPackage = (resolvedTailwindVersion === 4 && (installedTailwindVersion === 4 || explicitTailwindVersion === 4 || hasExplicitV4Signals && isTailwindcss4Package(packageNameForVersionDetection)) || resolvedTailwindVersion === void 0 && (hasCssEntries || hasCssSources || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss))) && !Boolean(configuredPackageName);
|
|
331
|
+
const packageCandidates = /* @__PURE__ */ new Set();
|
|
332
|
+
if (shouldPatchV4PostcssPackage) packageCandidates.add("@tailwindcss/postcss");
|
|
333
|
+
packageCandidates.add(mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss");
|
|
334
|
+
const patchers = [];
|
|
335
|
+
const packageCandidateList = [...packageCandidates];
|
|
336
|
+
let firstVersionMismatchError;
|
|
337
|
+
for (const packageName of packageCandidateList) {
|
|
338
|
+
const tailwindOptionsForPackage = {
|
|
339
|
+
...mergedTailwindOptions,
|
|
340
|
+
packageName
|
|
341
|
+
};
|
|
342
|
+
if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
|
|
343
|
+
try {
|
|
344
|
+
patchers.push(require_v3_engine.createTailwindcssPatcher(require_v3_engine.omitUndefined({
|
|
345
|
+
basedir: baseDir,
|
|
346
|
+
supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
|
|
347
|
+
tailwindcss: tailwindOptionsForPackage,
|
|
348
|
+
tailwindcssPatcherOptions: patchedOptions
|
|
349
|
+
})));
|
|
350
|
+
} catch (error) {
|
|
351
|
+
if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
|
|
352
|
+
firstVersionMismatchError ?? (firstVersionMismatchError = error);
|
|
353
|
+
_weapp_tailwindcss_logger.logger.warn("skip incompatible Tailwind package candidate \"%s\" for v4 patcher: %s", packageName, error.message);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (patchers.length === 0 && firstVersionMismatchError) throw firstVersionMismatchError;
|
|
360
|
+
const [singlePatcher] = patchers;
|
|
361
|
+
return patchers.length === 1 && singlePatcher ? singlePatcher : createMultiTailwindcssPatcher(patchers);
|
|
362
|
+
}
|
|
363
|
+
function tryCreateMultiTailwindcssPatcher(groups, options) {
|
|
364
|
+
if (groups.size <= 1) return;
|
|
365
|
+
_weapp_tailwindcss_logger.logger.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
|
|
366
|
+
const patchers = [];
|
|
367
|
+
for (const [baseDir, entries] of groups) {
|
|
368
|
+
const patcher = createPatcherForBase(baseDir, entries, options);
|
|
369
|
+
if (patcher) patchers.push(patcher);
|
|
370
|
+
}
|
|
371
|
+
return createMultiTailwindcssPatcher(patchers);
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/uni-app-x/options.ts
|
|
375
|
+
function resolveComponentLocalStyles(option) {
|
|
376
|
+
if (option === false) return {
|
|
377
|
+
enabled: false,
|
|
378
|
+
onlyWhenStyleIsolationVersion2: true
|
|
379
|
+
};
|
|
380
|
+
if (option === true || option === void 0) return {
|
|
381
|
+
enabled: false,
|
|
382
|
+
onlyWhenStyleIsolationVersion2: true
|
|
383
|
+
};
|
|
384
|
+
const componentLocalStyles = option.componentLocalStyles;
|
|
385
|
+
if (componentLocalStyles === false) return {
|
|
386
|
+
enabled: false,
|
|
387
|
+
onlyWhenStyleIsolationVersion2: true
|
|
388
|
+
};
|
|
389
|
+
if (componentLocalStyles === true || componentLocalStyles === void 0) return {
|
|
390
|
+
enabled: true,
|
|
391
|
+
onlyWhenStyleIsolationVersion2: true
|
|
392
|
+
};
|
|
393
|
+
return {
|
|
394
|
+
enabled: componentLocalStyles.enabled !== false,
|
|
395
|
+
onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function resolveUniAppXOptions(option) {
|
|
399
|
+
if (typeof option === "object" && option) return {
|
|
400
|
+
enabled: option.enabled !== false,
|
|
401
|
+
componentLocalStyles: resolveComponentLocalStyles(option),
|
|
402
|
+
uvueUnsupported: option.uvueUnsupported ?? "warn"
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
enabled: Boolean(option),
|
|
406
|
+
componentLocalStyles: resolveComponentLocalStyles(option),
|
|
407
|
+
uvueUnsupported: "warn"
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function isUniAppXEnabled(option) {
|
|
411
|
+
return resolveUniAppXOptions(option).enabled;
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/context/tailwindcss/basedir.ts
|
|
415
|
+
const ENV_BASEDIR_KEYS = [
|
|
416
|
+
"WEAPP_TAILWINDCSS_BASEDIR",
|
|
417
|
+
"WEAPP_TAILWINDCSS_BASE_DIR",
|
|
418
|
+
"TAILWINDCSS_BASEDIR",
|
|
419
|
+
"TAILWINDCSS_BASE_DIR",
|
|
420
|
+
"UNI_INPUT_DIR",
|
|
421
|
+
"UNI_INPUT_ROOT",
|
|
422
|
+
"UNI_CLI_ROOT",
|
|
423
|
+
"UNI_APP_INPUT_DIR",
|
|
424
|
+
"INIT_CWD",
|
|
425
|
+
"PWD"
|
|
426
|
+
];
|
|
427
|
+
const GENERIC_ENV_BASEDIR_KEYS = new Set(["INIT_CWD", "PWD"]);
|
|
428
|
+
function pickEnvBasedir() {
|
|
429
|
+
for (const key of ENV_BASEDIR_KEYS) {
|
|
430
|
+
const value = node_process.default.env[key];
|
|
431
|
+
if (value && node_path.default.isAbsolute(value)) return {
|
|
432
|
+
key,
|
|
433
|
+
value
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function pickPackageEnvBasedir() {
|
|
438
|
+
const packageJsonPath = node_process.default.env["npm_package_json"];
|
|
439
|
+
if (packageJsonPath) {
|
|
440
|
+
const packageDir = node_path.default.dirname(packageJsonPath);
|
|
441
|
+
if (packageDir && node_path.default.isAbsolute(packageDir)) return packageDir;
|
|
442
|
+
}
|
|
443
|
+
const localPrefix = node_process.default.env["npm_config_local_prefix"];
|
|
444
|
+
if (localPrefix && node_path.default.isAbsolute(localPrefix)) return localPrefix;
|
|
445
|
+
}
|
|
446
|
+
const STACK_PAREN_RE = /\(([^)]+)\)/u;
|
|
447
|
+
const STACK_AT_RE = /at\s+(\S.*)$/u;
|
|
448
|
+
function detectCallerBasedir() {
|
|
449
|
+
const stack = (/* @__PURE__ */ new Error("resolveTailwindcssBasedir stack probe")).stack;
|
|
450
|
+
if (!stack) return;
|
|
451
|
+
if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("caller stack: %s", stack);
|
|
452
|
+
const lines = stack.split("\n");
|
|
453
|
+
for (const line of lines) {
|
|
454
|
+
const location = (line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE))?.[1];
|
|
455
|
+
if (!location) continue;
|
|
456
|
+
let filePath = location;
|
|
457
|
+
if (filePath.startsWith("file://")) try {
|
|
458
|
+
filePath = (0, node_url.fileURLToPath)(filePath);
|
|
459
|
+
} catch {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
const [candidate = ""] = filePath.split(":");
|
|
463
|
+
const resolvedPath = node_path.default.isAbsolute(filePath) ? filePath : candidate;
|
|
464
|
+
if (!node_path.default.isAbsolute(resolvedPath)) continue;
|
|
465
|
+
if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) continue;
|
|
466
|
+
try {
|
|
467
|
+
return node_path.default.dirname(resolvedPath);
|
|
468
|
+
} catch {
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function resolveTailwindcssBasedir(basedir, fallback) {
|
|
474
|
+
const envBasedirResult = pickEnvBasedir();
|
|
475
|
+
const envBasedir = envBasedirResult?.value;
|
|
476
|
+
const envBasedirKey = envBasedirResult?.key;
|
|
477
|
+
const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
|
|
478
|
+
const packageEnvBasedir = pickPackageEnvBasedir();
|
|
479
|
+
const callerBasedir = !envBasedir || envBasedirIsGeneric ? detectCallerBasedir() : void 0;
|
|
480
|
+
const cwd = node_process.default.cwd();
|
|
481
|
+
const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
|
|
482
|
+
const resolveRelative = (value) => node_path.default.isAbsolute(value) ? node_path.default.normalize(value) : node_path.default.normalize(node_path.default.resolve(anchor, value));
|
|
483
|
+
if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("resolveTailwindcssBasedir anchor %O", {
|
|
484
|
+
basedir,
|
|
485
|
+
envBasedir,
|
|
486
|
+
envBasedirKey,
|
|
487
|
+
envBasedirIsGeneric,
|
|
488
|
+
packageEnvBasedir,
|
|
489
|
+
fallback,
|
|
490
|
+
callerBasedir,
|
|
491
|
+
npm_package_json: node_process.default.env["npm_package_json"],
|
|
492
|
+
cwd,
|
|
493
|
+
anchor
|
|
494
|
+
});
|
|
495
|
+
if (basedir && basedir.trim().length > 0) return resolveRelative(basedir);
|
|
496
|
+
if (envBasedir && !envBasedirIsGeneric) return node_path.default.normalize(envBasedir);
|
|
497
|
+
if (fallback && fallback.trim().length > 0) return resolveRelative(fallback);
|
|
498
|
+
if (packageEnvBasedir) return node_path.default.normalize(packageEnvBasedir);
|
|
499
|
+
if (callerBasedir) {
|
|
500
|
+
const normalizedCaller = node_path.default.normalize(callerBasedir);
|
|
501
|
+
const librarySegment = `${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}`;
|
|
502
|
+
if (!normalizedCaller.includes(librarySegment)) return normalizedCaller;
|
|
503
|
+
}
|
|
504
|
+
const packageName = node_process.default.env["PNPM_PACKAGE_NAME"];
|
|
505
|
+
if (packageName) try {
|
|
506
|
+
const packageJsonPath = (0, node_module.createRequire)(node_path.default.join(anchor, "__resolve_tailwindcss_basedir__.cjs")).resolve(`${packageName}/package.json`);
|
|
507
|
+
if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
|
|
508
|
+
return node_path.default.normalize(node_path.default.dirname(packageJsonPath));
|
|
509
|
+
} catch {
|
|
510
|
+
if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("failed to resolve package json for %s", packageName);
|
|
511
|
+
const workspaceRoot = require_v3_engine.findWorkspaceRoot(anchor);
|
|
512
|
+
if (workspaceRoot) {
|
|
513
|
+
const packageDir = require_v3_engine.findWorkspacePackageDir(workspaceRoot, packageName);
|
|
514
|
+
if (packageDir) return packageDir;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (envBasedir) return node_path.default.normalize(envBasedir);
|
|
518
|
+
return node_path.default.normalize(cwd);
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/context/tailwindcss/rax.ts
|
|
522
|
+
function isRaxWorkspace(appType, baseDir) {
|
|
523
|
+
if (appType === "rax") return true;
|
|
524
|
+
try {
|
|
525
|
+
const pkgPath = node_path.default.join(baseDir, "package.json");
|
|
526
|
+
if (!(0, node_fs.existsSync)(pkgPath)) return false;
|
|
527
|
+
const pkg = JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"));
|
|
528
|
+
const deps = {
|
|
529
|
+
...pkg["dependencies"] ?? {},
|
|
530
|
+
...pkg["devDependencies"] ?? {}
|
|
531
|
+
};
|
|
532
|
+
if (deps["rax-app"] || deps.rax) return true;
|
|
533
|
+
} catch {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
function collectRaxStyleEntries(baseDir) {
|
|
539
|
+
const STYLE_CANDIDATES = [
|
|
540
|
+
"src/global.css",
|
|
541
|
+
"src/global.scss",
|
|
542
|
+
"src/global.less",
|
|
543
|
+
"src/global.sass",
|
|
544
|
+
"src/global.styl",
|
|
545
|
+
"src/global.stylus"
|
|
546
|
+
];
|
|
547
|
+
const discovered = [];
|
|
548
|
+
for (const relative of STYLE_CANDIDATES) {
|
|
549
|
+
const candidate = node_path.default.resolve(baseDir, relative);
|
|
550
|
+
if ((0, node_fs.existsSync)(candidate)) discovered.push(node_path.default.normalize(candidate));
|
|
551
|
+
}
|
|
552
|
+
return discovered;
|
|
553
|
+
}
|
|
554
|
+
function detectImplicitCssEntries(appType, baseDir) {
|
|
555
|
+
const baseCandidates = /* @__PURE__ */ new Set();
|
|
556
|
+
baseCandidates.add(node_path.default.normalize(baseDir));
|
|
557
|
+
const envCandidates = [
|
|
558
|
+
node_process.default.cwd(),
|
|
559
|
+
node_process.default.env["INIT_CWD"],
|
|
560
|
+
node_process.default.env["PWD"]
|
|
561
|
+
];
|
|
562
|
+
for (const candidate of envCandidates) if (candidate) baseCandidates.add(node_path.default.normalize(candidate));
|
|
563
|
+
for (const candidateBase of baseCandidates) {
|
|
564
|
+
if (!isRaxWorkspace(appType, candidateBase)) continue;
|
|
565
|
+
const entries = collectRaxStyleEntries(candidateBase);
|
|
566
|
+
if (entries.length) return entries;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
//#endregion
|
|
570
|
+
//#region src/context/tailwindcss.ts
|
|
571
|
+
function createTailwindcssPatcherFromContext(ctx) {
|
|
572
|
+
const { tailwindcssBasedir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions, cssEntries: rawCssEntries, appType, arbitraryValues } = ctx;
|
|
573
|
+
const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
|
|
574
|
+
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
|
|
575
|
+
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
576
|
+
_weapp_tailwindcss_logger.logger.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
|
|
577
|
+
let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
|
|
578
|
+
if (!normalizedCssEntries) normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
|
|
579
|
+
if (normalizedCssEntries) ctx.cssEntries = normalizedCssEntries;
|
|
580
|
+
const patcherOptions = {
|
|
581
|
+
tailwindcss,
|
|
582
|
+
tailwindcssPatcherOptions,
|
|
583
|
+
supportCustomLengthUnitsPatch,
|
|
584
|
+
appType,
|
|
585
|
+
bareArbitraryValues: arbitraryValues?.bareArbitraryValues
|
|
586
|
+
};
|
|
587
|
+
const workspaceRoot = require_v3_engine.findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? require_v3_engine.findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
|
|
588
|
+
const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, require_v3_engine.omitUndefined({
|
|
589
|
+
preferredBaseDir: resolvedTailwindcssBasedir,
|
|
590
|
+
workspaceRoot
|
|
591
|
+
})) : void 0;
|
|
592
|
+
const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
|
|
593
|
+
if (multiPatcher) return multiPatcher;
|
|
594
|
+
if (groupedCssEntries?.size === 1) {
|
|
595
|
+
const firstGroup = groupedCssEntries.entries().next().value;
|
|
596
|
+
if (firstGroup) {
|
|
597
|
+
const [baseDir, entries] = firstGroup;
|
|
598
|
+
return createPatcherForBase(baseDir, entries, patcherOptions);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return createPatcherForBase(resolvedTailwindcssBasedir, normalizedCssEntries ?? rawCssEntries, patcherOptions);
|
|
602
|
+
}
|
|
603
|
+
//#endregion
|
|
604
|
+
Object.defineProperty(exports, "applyV4CssCalcDefaults", {
|
|
605
|
+
enumerable: true,
|
|
606
|
+
get: function() {
|
|
607
|
+
return applyV4CssCalcDefaults;
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
Object.defineProperty(exports, "createTailwindcssPatcherFromContext", {
|
|
611
|
+
enumerable: true,
|
|
612
|
+
get: function() {
|
|
613
|
+
return createTailwindcssPatcherFromContext;
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
Object.defineProperty(exports, "hasConfiguredTailwindV4CssRoots", {
|
|
617
|
+
enumerable: true,
|
|
618
|
+
get: function() {
|
|
619
|
+
return hasConfiguredTailwindV4CssRoots;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
Object.defineProperty(exports, "isUniAppXEnabled", {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
get: function() {
|
|
625
|
+
return isUniAppXEnabled;
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
Object.defineProperty(exports, "resolveTailwindcssBasedir", {
|
|
629
|
+
enumerable: true,
|
|
630
|
+
get: function() {
|
|
631
|
+
return resolveTailwindcssBasedir;
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
Object.defineProperty(exports, "resolveUniAppXOptions", {
|
|
635
|
+
enumerable: true,
|
|
636
|
+
get: function() {
|
|
637
|
+
return resolveUniAppXOptions;
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
Object.defineProperty(exports, "upsertTailwindV4CssSource", {
|
|
641
|
+
enumerable: true,
|
|
642
|
+
get: function() {
|
|
643
|
+
return upsertTailwindV4CssSource;
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
Object.defineProperty(exports, "warnMissingCssEntries", {
|
|
647
|
+
enumerable: true,
|
|
648
|
+
get: function() {
|
|
649
|
+
return warnMissingCssEntries;
|
|
650
|
+
}
|
|
651
|
+
});
|