weapp-tailwindcss 4.12.0 → 5.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel/index.d.ts +3 -0
- package/dist/bundlers/gulp/index.d.ts +7 -0
- package/dist/bundlers/shared/cache.d.ts +16 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/css-imports.d.ts +8 -0
- package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +43 -0
- package/dist/bundlers/shared/module-graph.d.ts +5 -0
- package/dist/bundlers/shared/run-tasks.d.ts +2 -0
- package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
- package/dist/bundlers/vite/bundle-state.d.ts +43 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +22 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +33 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
- package/dist/bundlers/vite/index.d.ts +3 -0
- package/dist/bundlers/vite/js-precheck.d.ts +1 -0
- package/dist/bundlers/vite/query.d.ts +15 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +11 -0
- package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates.d.ts +15 -0
- package/dist/bundlers/vite/utils.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
- package/dist/bundlers/webpack/index.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
- package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
- package/dist/cache/index.d.ts +38 -0
- package/dist/cache/md5.d.ts +1 -0
- package/dist/chunk-8l464Juk.js +28 -0
- package/dist/cli/config.d.ts +5 -0
- package/dist/cli/context.d.ts +16 -0
- package/dist/cli/doctor/constants.d.ts +7 -0
- package/dist/cli/doctor/types.d.ts +31 -0
- package/dist/cli/doctor.d.ts +4 -0
- package/dist/cli/helpers/options/format.d.ts +2 -0
- package/dist/cli/helpers/options/parse.d.ts +3 -0
- package/dist/cli/helpers/options/resolve.d.ts +1 -0
- package/dist/cli/helpers/options.d.ts +3 -0
- package/dist/cli/helpers/patch-cwd.d.ts +1 -0
- package/dist/cli/helpers.d.ts +5 -0
- package/dist/cli/mount-options/patch-status.d.ts +2 -0
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/patch-options.d.ts +6 -0
- package/dist/cli/tokens.d.ts +4 -0
- package/dist/cli/types.d.ts +17 -0
- package/dist/cli/vscode-entry.d.ts +14 -0
- package/dist/cli/workspace/package-dirs.d.ts +3 -0
- package/dist/cli/workspace/patch-package.d.ts +3 -0
- package/dist/cli/workspace/patch-utils.d.ts +3 -0
- package/dist/cli/workspace/types.d.ts +11 -0
- package/dist/cli/workspace/workspace-globs.d.ts +2 -0
- package/dist/cli/workspace/workspace-io.d.ts +1 -0
- package/dist/cli/workspace/workspace-lock.d.ts +1 -0
- package/dist/cli/workspace.d.ts +2 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +2425 -3524
- package/dist/cli.mjs +2402 -3505
- package/dist/constants-B-_T5UnW.mjs +44 -0
- package/dist/constants-p1dyh1x1.js +73 -0
- package/dist/constants.d.ts +13 -0
- package/dist/context/compiler-context-cache.d.ts +3 -0
- package/dist/context/custom-attributes.d.ts +2 -0
- package/dist/context/handlers.d.ts +6 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/logger.d.ts +4 -0
- package/dist/context/tailwindcss/basedir.d.ts +1 -0
- package/dist/context/tailwindcss/rax.d.ts +2 -0
- package/dist/context/tailwindcss.d.ts +4 -0
- package/dist/context/workspace.d.ts +3 -0
- package/dist/core.d.ts +5 -21
- package/dist/core.js +138 -180
- package/dist/core.mjs +135 -180
- package/dist/css-imports-BbrbluP9.js +177 -0
- package/dist/css-imports-CSdPq_Sc.mjs +128 -0
- package/dist/css-macro/constants.d.ts +14 -0
- package/dist/css-macro/index.d.ts +15 -0
- package/dist/css-macro/postcss.d.ts +3 -7
- package/dist/css-macro/postcss.js +44 -58
- package/dist/css-macro/postcss.mjs +44 -56
- package/dist/css-macro.d.ts +1 -20
- package/dist/css-macro.js +37 -50
- package/dist/css-macro.mjs +33 -47
- package/dist/debug/index.d.ts +5 -0
- package/dist/defaults.d.ts +2 -11
- package/dist/defaults.js +132 -8
- package/dist/defaults.mjs +128 -7
- package/dist/escape.js +31 -54
- package/dist/escape.mjs +18 -25
- package/dist/experimental/index.d.ts +2 -0
- package/dist/experimental/oxc/ast-utils.d.ts +30 -0
- package/dist/experimental/oxc/index.d.ts +2 -0
- package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
- package/dist/experimental/shared/cache.d.ts +3 -0
- package/dist/experimental/shared/transform.d.ts +3 -0
- package/dist/experimental/shared.d.ts +8 -0
- package/dist/experimental/swc/ast-utils.d.ts +30 -0
- package/dist/experimental/swc/index.d.ts +2 -0
- package/dist/experimental/swc/module-specifiers.d.ts +2 -0
- package/dist/generator/index.d.ts +11 -0
- package/dist/generator/options.d.ts +17 -0
- package/dist/generator/types.d.ts +20 -0
- package/dist/generator-Y-Ikv4Fu.mjs +1177 -0
- package/dist/generator-css-B5ejWUMv.mjs +1098 -0
- package/dist/generator-css-D3OdPRiS.js +1125 -0
- package/dist/generator-mmhXzZnv.js +1276 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +19 -0
- package/dist/generator.mjs +2 -0
- package/dist/gulp.d.ts +4 -24
- package/dist/gulp.js +271 -13
- package/dist/gulp.mjs +263 -13
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/index.mjs +6 -24
- package/dist/js/JsTokenUpdater.d.ts +14 -0
- package/dist/js/ModuleGraph.d.ts +18 -0
- package/dist/js/NodePathWalker.d.ts +33 -0
- package/dist/js/babel/parse.d.ts +9 -0
- package/dist/js/babel/process.d.ts +4 -0
- package/dist/js/babel.d.ts +13 -0
- package/dist/js/class-context.d.ts +3 -0
- package/dist/js/evalTransforms.d.ts +7 -0
- package/dist/js/handlers.d.ts +5 -0
- package/dist/js/index.d.ts +4 -0
- package/dist/js/module-graph/ignored-exports.d.ts +18 -0
- package/dist/js/module-graph/types.d.ts +17 -0
- package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
- package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
- package/dist/js/precheck.d.ts +2 -0
- package/dist/js/sourceAnalysis.d.ts +17 -0
- package/dist/js/syntax.d.ts +10 -0
- package/dist/js/taggedTemplateIgnore.d.ts +13 -0
- package/dist/js/types.d.ts +11 -0
- package/dist/lightningcss/index.d.ts +8 -0
- package/dist/lightningcss/style-handler/options.d.ts +3 -0
- package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
- package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
- package/dist/lightningcss/style-handler.d.ts +17 -0
- package/dist/loader-anchors-CNkWT8hx.js +273 -0
- package/dist/loader-anchors-TrU7EUr7.mjs +205 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger-BZ45DZJT.js +1003 -0
- package/dist/logger-BoVx1Dbt.mjs +935 -0
- package/dist/patcher-options-6gJN2EXy.js +115 -0
- package/dist/patcher-options-DQfR5xxT.mjs +92 -0
- package/dist/postcss-html-transform.d.ts +3 -3
- package/dist/postcss-html-transform.js +7 -10
- package/dist/postcss-html-transform.mjs +3 -6
- package/dist/postcss.d.ts +15 -0
- package/dist/postcss.js +280 -0
- package/dist/postcss.mjs +270 -0
- package/dist/presets/hbuilderx.d.ts +4 -0
- package/dist/presets/index.d.ts +3 -0
- package/dist/presets/shared.d.ts +10 -0
- package/dist/presets/taro.d.ts +4 -0
- package/dist/presets/uni-app-x.d.ts +16 -0
- package/dist/presets/uni-app.d.ts +4 -0
- package/dist/presets.d.ts +1 -76
- package/dist/presets.js +115 -163
- package/dist/presets.mjs +107 -163
- package/dist/recorder-gYSNLfOP.js +2878 -0
- package/dist/recorder-zsgatmkB.mjs +2763 -0
- package/dist/reset/index.d.ts +2 -0
- package/dist/reset.d.ts +1 -4
- package/dist/reset.js +19 -8
- package/dist/reset.mjs +2 -8
- package/dist/shared/classname-transform.d.ts +14 -0
- package/dist/shared/mpx.d.ts +7 -0
- package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
- package/dist/tailwindcss/index.d.ts +11 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -0
- package/dist/tailwindcss/patcher-options.d.ts +56 -0
- package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
- package/dist/tailwindcss/patcher.d.ts +13 -0
- package/dist/tailwindcss/recorder.d.ts +13 -0
- package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
- package/dist/tailwindcss/runtime/cache.d.ts +11 -0
- package/dist/tailwindcss/runtime-logs.d.ts +3 -0
- package/dist/tailwindcss/runtime.d.ts +29 -0
- package/dist/tailwindcss/targets/paths.d.ts +13 -0
- package/dist/tailwindcss/targets/record-io.d.ts +5 -0
- package/dist/tailwindcss/targets/recorder.d.ts +3 -0
- package/dist/tailwindcss/targets/types.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +6 -0
- package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
- package/dist/tailwindcss/v4/config.d.ts +5 -0
- package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
- package/dist/tailwindcss/v4/index.d.ts +2 -0
- package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
- package/dist/tailwindcss/v4/patcher.d.ts +14 -0
- package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +5 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +19 -0
- package/dist/typedoc.export.d.ts +5 -0
- package/dist/types/base.d.ts +1 -0
- package/dist/types/disabled-options.d.ts +4 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/shared.d.ts +7 -0
- package/dist/types/user-defined-options/general.d.ts +31 -0
- package/dist/types/user-defined-options/important.d.ts +37 -0
- package/dist/types/user-defined-options/index.d.ts +11 -0
- package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
- package/dist/types/user-defined-options/matcher.d.ts +9 -0
- package/dist/types.d.ts +1 -150
- package/dist/types.js +0 -1
- package/dist/types.mjs +1 -1
- package/dist/uni-app-x/component-local-style.d.ts +19 -0
- package/dist/uni-app-x/index.d.ts +2 -0
- package/dist/uni-app-x/options.d.ts +12 -0
- package/dist/uni-app-x/style-isolation.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +9 -0
- package/dist/uni-app-x/vite.d.ts +36 -0
- package/dist/utils/decode.d.ts +2 -0
- package/dist/utils/disabled.d.ts +6 -0
- package/dist/utils/hbuilderx.d.ts +5 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/nameMatcher.d.ts +4 -0
- package/dist/utils/resolve-package.d.ts +1 -0
- package/dist/utils/uni-platform.d.ts +11 -0
- package/dist/utils-7DUGTFED.mjs +48 -0
- package/dist/utils-DmC9_In3.js +61 -0
- package/dist/vite-BC9U7ahn.js +2199 -0
- package/dist/vite-CrlzCNqz.mjs +2186 -0
- package/dist/vite.d.ts +4 -17
- package/dist/vite.js +5 -14
- package/dist/vite.mjs +2 -14
- package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
- package/dist/weapp-tw-runtime-classset-loader.js +31 -50
- package/dist/webpack-Bu6M-Hbw.mjs +441 -0
- package/dist/webpack-DD7A6V0u.js +456 -0
- package/dist/webpack.d.ts +4 -25
- package/dist/webpack.js +6 -17
- package/dist/webpack.mjs +2 -17
- package/dist/webpack4.d.ts +4 -26
- package/dist/webpack4.js +375 -481
- package/dist/webpack4.mjs +366 -482
- package/dist/wxml/Tokenizer.d.ts +15 -0
- package/dist/wxml/custom-attributes.d.ts +4 -0
- package/dist/wxml/index.d.ts +2 -0
- package/dist/wxml/shared.d.ts +2 -0
- package/dist/wxml/tokenizer/types.d.ts +18 -0
- package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
- package/dist/wxml/utils/codegen.d.ts +2 -0
- package/dist/wxml/utils/custom-template.d.ts +3 -0
- package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
- package/dist/wxml/utils/fragment-updater.d.ts +4 -0
- package/dist/wxml/utils/template-fragments.d.ts +3 -0
- package/dist/wxml/utils.d.ts +8 -0
- package/dist/wxml/whitespace.d.ts +2 -0
- package/generator-placeholder.css +1 -0
- package/package.json +19 -8
- package/dist/chunk-24AGZQVR.js +0 -183
- package/dist/chunk-3VQKDHGP.mjs +0 -179
- package/dist/chunk-4AFQP74Z.js +0 -24
- package/dist/chunk-57SOQCAU.mjs +0 -582
- package/dist/chunk-5ZYHNDEK.mjs +0 -2439
- package/dist/chunk-76S2EME4.mjs +0 -34
- package/dist/chunk-A5PB4KZT.js +0 -138
- package/dist/chunk-DUHYLR2R.js +0 -276
- package/dist/chunk-DYLQ6UOI.js +0 -71
- package/dist/chunk-E7I5TW5K.js +0 -52
- package/dist/chunk-FS2NOOEB.js +0 -292
- package/dist/chunk-HVNGIKLS.js +0 -3930
- package/dist/chunk-JZQBZHN5.js +0 -579
- package/dist/chunk-KGTVD4EP.mjs +0 -3930
- package/dist/chunk-NNOQDMUP.mjs +0 -10
- package/dist/chunk-OF6MFURR.js +0 -34
- package/dist/chunk-OFB2KBRP.js +0 -2442
- package/dist/chunk-OOHJLO5M.mjs +0 -71
- package/dist/chunk-PCDYXXSK.mjs +0 -1515
- package/dist/chunk-RKISS72P.js +0 -7
- package/dist/chunk-RRQZL7FQ.mjs +0 -292
- package/dist/chunk-XAKAD2CR.mjs +0 -138
- package/dist/chunk-XZP3MREK.mjs +0 -276
- package/dist/chunk-ZAA5ZG3D.js +0 -1518
- package/dist/chunk-ZCH4YINE.mjs +0 -52
- package/dist/cli.d.mts +0 -2
- package/dist/core.d.mts +0 -26
- package/dist/css-macro/postcss.d.mts +0 -7
- package/dist/css-macro.d.mts +0 -18
- package/dist/defaults.d.mts +0 -11
- package/dist/gulp.d.mts +0 -24
- package/dist/index-BXrmQelt.d.mts +0 -672
- package/dist/index-BXrmQelt.d.ts +0 -672
- package/dist/index.d.mts +0 -15
- package/dist/postcss-html-transform.d.mts +0 -2
- package/dist/presets.d.mts +0 -76
- package/dist/reset.d.mts +0 -1
- package/dist/types.d.mts +0 -150
- package/dist/vite.d.mts +0 -17
- package/dist/webpack.d.mts +0 -25
- package/dist/webpack4.d.mts +0 -26
|
@@ -0,0 +1,1003 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
+
const require_patcher_options = require("./patcher-options-6gJN2EXy.js");
|
|
3
|
+
require("./utils-DmC9_In3.js");
|
|
4
|
+
let node_module = require("node:module");
|
|
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_patch = require("tailwindcss-patch");
|
|
10
|
+
let node_fs = require("node:fs");
|
|
11
|
+
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
12
|
+
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
13
|
+
let node_url = require("node:url");
|
|
14
|
+
//#region src/tailwindcss/runtime/cache.ts
|
|
15
|
+
const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
|
|
17
|
+
let runtimeFileSignatureCacheClearTimer;
|
|
18
|
+
const runtimeSignaturePatchersSymbol = Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
|
|
19
|
+
function getCacheEntry(twPatcher) {
|
|
20
|
+
let entry = runtimeClassSetCache.get(twPatcher);
|
|
21
|
+
if (!entry) {
|
|
22
|
+
entry = {};
|
|
23
|
+
runtimeClassSetCache.set(twPatcher, entry);
|
|
24
|
+
}
|
|
25
|
+
return entry;
|
|
26
|
+
}
|
|
27
|
+
function scheduleRuntimeConfigSignatureCacheClear() {
|
|
28
|
+
if (runtimeFileSignatureCacheClearTimer) return;
|
|
29
|
+
runtimeFileSignatureCacheClearTimer = setTimeout(() => {
|
|
30
|
+
runtimeFileSignatureCache.clear();
|
|
31
|
+
runtimeFileSignatureCacheClearTimer = void 0;
|
|
32
|
+
}, 0);
|
|
33
|
+
runtimeFileSignatureCacheClearTimer.unref?.();
|
|
34
|
+
}
|
|
35
|
+
function getFileSignature(filePath) {
|
|
36
|
+
const cached = runtimeFileSignatureCache.get(filePath);
|
|
37
|
+
if (cached !== void 0) return cached;
|
|
38
|
+
let signature;
|
|
39
|
+
try {
|
|
40
|
+
const stats = (0, node_fs.statSync)(filePath);
|
|
41
|
+
signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
|
|
42
|
+
} catch {
|
|
43
|
+
signature = `${filePath}:missing`;
|
|
44
|
+
}
|
|
45
|
+
runtimeFileSignatureCache.set(filePath, signature);
|
|
46
|
+
scheduleRuntimeConfigSignatureCacheClear();
|
|
47
|
+
return signature;
|
|
48
|
+
}
|
|
49
|
+
function getTailwindTrackedFiles(twPatcher) {
|
|
50
|
+
const tailwindOptions = require_patcher_options.resolveTailwindcssOptions(twPatcher.options);
|
|
51
|
+
const tracked = /* @__PURE__ */ new Set();
|
|
52
|
+
const configPath = tailwindOptions?.config;
|
|
53
|
+
if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
|
|
54
|
+
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
|
|
55
|
+
return tracked;
|
|
56
|
+
}
|
|
57
|
+
function normalizeSignatureValue(value) {
|
|
58
|
+
if (value == null) return "null";
|
|
59
|
+
if (typeof value === "string") return value;
|
|
60
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
61
|
+
if (Array.isArray(value)) return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
|
|
62
|
+
if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
|
|
63
|
+
return String(value);
|
|
64
|
+
}
|
|
65
|
+
function readOptionalProperty(value, key) {
|
|
66
|
+
if (typeof value !== "object" || value === null || !(key in value)) return;
|
|
67
|
+
return value[key];
|
|
68
|
+
}
|
|
69
|
+
function getTailwindOptionsSignature(twPatcher) {
|
|
70
|
+
const options = twPatcher.options;
|
|
71
|
+
const tailwindOptions = require_patcher_options.resolveTailwindcssOptions(options);
|
|
72
|
+
return normalizeSignatureValue({
|
|
73
|
+
projectRoot: options?.projectRoot,
|
|
74
|
+
packageName: tailwindOptions?.packageName,
|
|
75
|
+
versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
|
|
76
|
+
cwd: tailwindOptions?.cwd,
|
|
77
|
+
config: tailwindOptions?.config,
|
|
78
|
+
v2: tailwindOptions?.v2,
|
|
79
|
+
v3: tailwindOptions?.v3,
|
|
80
|
+
v4: {
|
|
81
|
+
base: tailwindOptions?.v4?.base,
|
|
82
|
+
configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
|
|
83
|
+
css: tailwindOptions?.v4?.css,
|
|
84
|
+
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
85
|
+
hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
|
|
86
|
+
sources: tailwindOptions?.v4?.sources
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function getPatchTargetSignature(twPatcher) {
|
|
91
|
+
const packageInfo = twPatcher.packageInfo;
|
|
92
|
+
return [
|
|
93
|
+
packageInfo?.name ?? "missing",
|
|
94
|
+
packageInfo?.rootPath ?? "missing",
|
|
95
|
+
packageInfo?.version ?? "unknown",
|
|
96
|
+
twPatcher.majorVersion ?? "unknown",
|
|
97
|
+
getTailwindOptionsSignature(twPatcher)
|
|
98
|
+
].join(":");
|
|
99
|
+
}
|
|
100
|
+
function getNestedPatchers(twPatcher) {
|
|
101
|
+
const nested = twPatcher[runtimeSignaturePatchersSymbol];
|
|
102
|
+
return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
|
|
103
|
+
}
|
|
104
|
+
function getOwnRuntimeClassSetSignature(twPatcher) {
|
|
105
|
+
const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
|
|
106
|
+
return `${trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing"}|patch:${getPatchTargetSignature(twPatcher)}`;
|
|
107
|
+
}
|
|
108
|
+
function invalidateRuntimeClassSet(twPatcher) {
|
|
109
|
+
if (!twPatcher) return;
|
|
110
|
+
const nestedPatchers = getNestedPatchers(twPatcher);
|
|
111
|
+
if (nestedPatchers) for (const patcher of nestedPatchers) invalidateRuntimeClassSet(patcher);
|
|
112
|
+
for (const trackedFile of getTailwindTrackedFiles(twPatcher)) runtimeFileSignatureCache.delete(trackedFile);
|
|
113
|
+
runtimeClassSetCache.delete(twPatcher);
|
|
114
|
+
}
|
|
115
|
+
function getRuntimeClassSetCacheEntry(twPatcher) {
|
|
116
|
+
return getCacheEntry(twPatcher);
|
|
117
|
+
}
|
|
118
|
+
function getRuntimeClassSetSignature(twPatcher) {
|
|
119
|
+
const nestedPatchers = getNestedPatchers(twPatcher);
|
|
120
|
+
if (nestedPatchers) return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
|
|
121
|
+
return getOwnRuntimeClassSetSignature(twPatcher);
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/context/workspace.ts
|
|
125
|
+
const IGNORED_WORKSPACE_DIRS = new Set([
|
|
126
|
+
"node_modules",
|
|
127
|
+
".git",
|
|
128
|
+
".hg",
|
|
129
|
+
".svn",
|
|
130
|
+
".turbo",
|
|
131
|
+
".output",
|
|
132
|
+
".next",
|
|
133
|
+
"dist",
|
|
134
|
+
"build"
|
|
135
|
+
]);
|
|
136
|
+
function findWorkspaceRoot(startDir) {
|
|
137
|
+
if (!startDir) return;
|
|
138
|
+
let current = node_path.default.resolve(startDir);
|
|
139
|
+
while (true) {
|
|
140
|
+
if ((0, node_fs.existsSync)(node_path.default.join(current, "pnpm-workspace.yaml"))) return current;
|
|
141
|
+
const parent = node_path.default.dirname(current);
|
|
142
|
+
if (parent === current) return;
|
|
143
|
+
current = parent;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function findNearestPackageRoot(startDir) {
|
|
147
|
+
if (!startDir) return;
|
|
148
|
+
let current = node_path.default.resolve(startDir);
|
|
149
|
+
while (true) {
|
|
150
|
+
if ((0, node_fs.existsSync)(node_path.default.join(current, "package.json"))) return current;
|
|
151
|
+
const parent = node_path.default.dirname(current);
|
|
152
|
+
if (parent === current) return;
|
|
153
|
+
current = parent;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function findWorkspacePackageDir(rootDir, packageName) {
|
|
157
|
+
const visited = /* @__PURE__ */ new Set();
|
|
158
|
+
const queue = [node_path.default.resolve(rootDir)];
|
|
159
|
+
while (queue.length > 0) {
|
|
160
|
+
const current = queue.shift();
|
|
161
|
+
const normalized = node_path.default.normalize(current);
|
|
162
|
+
if (visited.has(normalized)) continue;
|
|
163
|
+
visited.add(normalized);
|
|
164
|
+
try {
|
|
165
|
+
const pkgPath = node_path.default.join(normalized, "package.json");
|
|
166
|
+
if ((0, node_fs.existsSync)(pkgPath)) {
|
|
167
|
+
if (JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"))?.name === packageName) return normalized;
|
|
168
|
+
}
|
|
169
|
+
} catch {}
|
|
170
|
+
let entries;
|
|
171
|
+
try {
|
|
172
|
+
entries = (0, node_fs.readdirSync)(normalized, { withFileTypes: true });
|
|
173
|
+
} catch {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
for (const entry of entries) {
|
|
177
|
+
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
|
|
178
|
+
queue.push(node_path.default.join(normalized, entry.name));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/tailwindcss/v4/config.ts
|
|
184
|
+
const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
185
|
+
function includesToken(list, token) {
|
|
186
|
+
return list.some((candidate) => {
|
|
187
|
+
if (typeof token === "string") {
|
|
188
|
+
if (typeof candidate === "string") return candidate === token;
|
|
189
|
+
candidate.lastIndex = 0;
|
|
190
|
+
return candidate.test(token);
|
|
191
|
+
}
|
|
192
|
+
if (typeof candidate === "string") {
|
|
193
|
+
token.lastIndex = 0;
|
|
194
|
+
return token.test(candidate);
|
|
195
|
+
}
|
|
196
|
+
return candidate.source === token.source && candidate.flags === token.flags;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function ensureDefaultsIncluded(value) {
|
|
200
|
+
if (value === true) return { includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES] };
|
|
201
|
+
if (Array.isArray(value)) {
|
|
202
|
+
if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
|
|
203
|
+
const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
|
|
204
|
+
return missing.length > 0 ? [...value, ...missing] : value;
|
|
205
|
+
}
|
|
206
|
+
if (value && typeof value === "object") {
|
|
207
|
+
const include = value.includeCustomProperties;
|
|
208
|
+
if (!Array.isArray(include)) return {
|
|
209
|
+
...value,
|
|
210
|
+
includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
|
|
211
|
+
};
|
|
212
|
+
if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
|
|
213
|
+
const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
|
|
214
|
+
return missing.length > 0 ? {
|
|
215
|
+
...value,
|
|
216
|
+
includeCustomProperties: [...include, ...missing]
|
|
217
|
+
} : value;
|
|
218
|
+
}
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
function normalizeCssEntriesConfig(entries) {
|
|
222
|
+
if (!entries) return;
|
|
223
|
+
if (typeof entries === "string") {
|
|
224
|
+
const trimmed = entries.trim();
|
|
225
|
+
return trimmed ? [trimmed] : void 0;
|
|
226
|
+
}
|
|
227
|
+
if (!Array.isArray(entries)) return;
|
|
228
|
+
const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
229
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
230
|
+
}
|
|
231
|
+
function hasConfiguredCssEntries(ctx) {
|
|
232
|
+
if (normalizeCssEntriesConfig(ctx.cssEntries)) return true;
|
|
233
|
+
if (normalizeCssEntriesConfig(ctx.tailwindcss?.v4?.cssEntries)) return true;
|
|
234
|
+
const patcherOptions = ctx.tailwindcssPatcherOptions;
|
|
235
|
+
if (patcherOptions) {
|
|
236
|
+
if (normalizeCssEntriesConfig(patcherOptions.tailwindcss?.v4?.cssEntries)) return true;
|
|
237
|
+
if (normalizeCssEntriesConfig(patcherOptions.tailwind?.v4?.cssEntries)) return true;
|
|
238
|
+
if (normalizeCssEntriesConfig(patcherOptions.patch?.tailwindcss?.v4?.cssEntries)) return true;
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
let hasWarnedMissingCssEntries = false;
|
|
243
|
+
function warnMissingCssEntries(ctx, patcher) {
|
|
244
|
+
if (hasWarnedMissingCssEntries) return;
|
|
245
|
+
if (patcher?.majorVersion !== 4) return;
|
|
246
|
+
if (hasConfiguredCssEntries(ctx)) return;
|
|
247
|
+
hasWarnedMissingCssEntries = true;
|
|
248
|
+
_weapp_tailwindcss_logger.logger.warn("[tailwindcss@4] 未检测到 cssEntries 配置。请传入包含 tailwindcss 引用的 CSS 绝对路径,例如 cssEntries: [\"/absolute/path/to/src/app.css\"],否则 tailwindcss 生成的类名不会参与转译。");
|
|
249
|
+
}
|
|
250
|
+
function applyV4CssCalcDefaults(cssCalc, patcher) {
|
|
251
|
+
const cssCalcOptions = cssCalc ?? patcher?.majorVersion === 4;
|
|
252
|
+
if (patcher?.majorVersion === 4 && cssCalcOptions) return ensureDefaultsIncluded(cssCalcOptions);
|
|
253
|
+
return cssCalcOptions;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/tailwindcss/patcher-resolve.ts
|
|
257
|
+
const GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
|
|
258
|
+
const DEFAULT_TAILWIND_CONFIG_SPECIFIERS = ["stubs/config.full.js", "defaultConfig.js"];
|
|
259
|
+
const TAILWIND_CONFIG_FILES = [
|
|
260
|
+
"tailwind.config.js",
|
|
261
|
+
"tailwind.config.cjs",
|
|
262
|
+
"tailwind.config.mjs",
|
|
263
|
+
"tailwind.config.ts",
|
|
264
|
+
"tailwind.config.cts",
|
|
265
|
+
"tailwind.config.mts"
|
|
266
|
+
];
|
|
267
|
+
function isPathSpecifier(specifier) {
|
|
268
|
+
if (!specifier) return false;
|
|
269
|
+
if (specifier.startsWith("file://")) return true;
|
|
270
|
+
if (node_path.default.isAbsolute(specifier)) return true;
|
|
271
|
+
return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
|
|
272
|
+
}
|
|
273
|
+
function resolveModuleFromPaths(specifier, paths) {
|
|
274
|
+
if (!specifier || isPathSpecifier(specifier) || paths.length === 0) return;
|
|
275
|
+
try {
|
|
276
|
+
return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve(specifier, { paths });
|
|
277
|
+
} catch {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function resolveTailwindConfigFallback(packageName, paths) {
|
|
282
|
+
if (!packageName) return;
|
|
283
|
+
for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
|
|
284
|
+
const resolved = resolveModuleFromPaths(`${packageName}/${suffix}`, paths);
|
|
285
|
+
if (resolved) return resolved;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function appendNodeModules(paths, dir) {
|
|
289
|
+
if (!dir) return;
|
|
290
|
+
const nodeModulesDir = node_path.default.join(dir, "node_modules");
|
|
291
|
+
if ((0, node_fs.existsSync)(nodeModulesDir)) paths.add(nodeModulesDir);
|
|
292
|
+
}
|
|
293
|
+
function findTailwindConfig(searchRoots) {
|
|
294
|
+
for (const root of searchRoots) for (const file of TAILWIND_CONFIG_FILES) {
|
|
295
|
+
const candidate = node_path.default.resolve(root, file);
|
|
296
|
+
if ((0, node_fs.existsSync)(candidate)) return candidate;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function createDefaultResolvePaths(basedir) {
|
|
300
|
+
const paths = /* @__PURE__ */ new Set();
|
|
301
|
+
let fallbackCandidates = [];
|
|
302
|
+
if (basedir) {
|
|
303
|
+
const resolvedBase = node_path.default.resolve(basedir);
|
|
304
|
+
appendNodeModules(paths, resolvedBase);
|
|
305
|
+
fallbackCandidates.push(resolvedBase);
|
|
306
|
+
const packageRoot = findNearestPackageRoot(resolvedBase);
|
|
307
|
+
if (packageRoot) {
|
|
308
|
+
appendNodeModules(paths, packageRoot);
|
|
309
|
+
fallbackCandidates.push(packageRoot);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const cwd = node_process.default.cwd();
|
|
313
|
+
appendNodeModules(paths, cwd);
|
|
314
|
+
try {
|
|
315
|
+
const modulePath = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
316
|
+
const candidate = (0, node_fs.existsSync)(modulePath) && !node_path.default.extname(modulePath) ? modulePath : node_path.default.dirname(modulePath);
|
|
317
|
+
paths.add(candidate);
|
|
318
|
+
} catch {
|
|
319
|
+
paths.add(require("url").pathToFileURL(__filename).href);
|
|
320
|
+
}
|
|
321
|
+
if (paths.size === 0) {
|
|
322
|
+
fallbackCandidates = fallbackCandidates.filter(Boolean);
|
|
323
|
+
if (fallbackCandidates.length === 0) fallbackCandidates.push(cwd);
|
|
324
|
+
for (const candidate of fallbackCandidates) paths.add(candidate);
|
|
325
|
+
}
|
|
326
|
+
return [...paths];
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/tailwindcss/patcher.ts
|
|
330
|
+
function createFallbackTailwindcssPatcher() {
|
|
331
|
+
return {
|
|
332
|
+
packageInfo: {
|
|
333
|
+
name: "tailwindcss",
|
|
334
|
+
version: void 0,
|
|
335
|
+
rootPath: "",
|
|
336
|
+
packageJsonPath: "",
|
|
337
|
+
packageJson: {}
|
|
338
|
+
},
|
|
339
|
+
async patch() {
|
|
340
|
+
return {
|
|
341
|
+
exposeContext: void 0,
|
|
342
|
+
extendLengthUnits: void 0
|
|
343
|
+
};
|
|
344
|
+
},
|
|
345
|
+
async getClassSet() {
|
|
346
|
+
return /* @__PURE__ */ new Set();
|
|
347
|
+
},
|
|
348
|
+
async extract(_options) {
|
|
349
|
+
return {
|
|
350
|
+
classList: [],
|
|
351
|
+
classSet: /* @__PURE__ */ new Set()
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
async collectContentTokens() {
|
|
355
|
+
return {
|
|
356
|
+
entries: [],
|
|
357
|
+
filesScanned: 0,
|
|
358
|
+
sources: [],
|
|
359
|
+
skippedFiles: []
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
let hasLoggedMissingTailwind = false;
|
|
365
|
+
const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
|
|
366
|
+
const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
|
|
367
|
+
function isTailwindcssV4PackageName(packageName) {
|
|
368
|
+
return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
|
|
369
|
+
}
|
|
370
|
+
function createTailwindcssPatcher(options) {
|
|
371
|
+
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
372
|
+
const cache = { driver: "memory" };
|
|
373
|
+
const normalizedBasedir = basedir ? node_path.default.resolve(basedir) : void 0;
|
|
374
|
+
const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? node_process.default.cwd();
|
|
375
|
+
if (cacheDir) if (node_path.default.isAbsolute(cacheDir)) cache.dir = cacheDir;
|
|
376
|
+
else if (normalizedBasedir) cache.dir = node_path.default.resolve(normalizedBasedir, cacheDir);
|
|
377
|
+
else cache.dir = node_path.default.resolve(node_process.default.cwd(), cacheDir);
|
|
378
|
+
else cache.dir = node_path.default.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
|
|
379
|
+
if (normalizedBasedir) cache.cwd = normalizedBasedir;
|
|
380
|
+
const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? node_process.default.cwd());
|
|
381
|
+
const normalizedUserOptions = require_patcher_options.normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
|
|
382
|
+
const extendLengthUnits = require_patcher_options.normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
|
|
383
|
+
const baseTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, {
|
|
384
|
+
cwd: normalizedBasedir,
|
|
385
|
+
resolve: { paths: resolvePaths }
|
|
386
|
+
});
|
|
387
|
+
if (baseTailwindOptions.version === 2) {
|
|
388
|
+
if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "@tailwindcss/postcss7-compat";
|
|
389
|
+
if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
|
|
390
|
+
} else if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
|
|
391
|
+
if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
|
|
392
|
+
if (typeof baseTailwindOptions.postcssPlugin === "string") {
|
|
393
|
+
const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
|
|
394
|
+
if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
|
|
395
|
+
}
|
|
396
|
+
const resolvedOptions = require_patcher_options.toModernTailwindcssPatchOptions((0, _weapp_tailwindcss_shared.defuOverrideArray)(normalizedUserOptions ?? {}, {
|
|
397
|
+
projectRoot: normalizedBasedir,
|
|
398
|
+
cache,
|
|
399
|
+
tailwindcss: baseTailwindOptions,
|
|
400
|
+
apply: {
|
|
401
|
+
exposeContext: true,
|
|
402
|
+
extendLengthUnits
|
|
403
|
+
}
|
|
404
|
+
})) ?? {};
|
|
405
|
+
const resolvedTailwindOptions = resolvedOptions.tailwindcss;
|
|
406
|
+
if (resolvedTailwindOptions) {
|
|
407
|
+
const existingResolve = resolvedTailwindOptions.resolve ?? {};
|
|
408
|
+
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? existingResolve.paths : resolvePaths;
|
|
409
|
+
resolvedTailwindOptions.resolve = {
|
|
410
|
+
...existingResolve,
|
|
411
|
+
paths: [...new Set(sourcePaths)]
|
|
412
|
+
};
|
|
413
|
+
_weapp_tailwindcss_logger.logger.debug("Tailwind resolve config %O", {
|
|
414
|
+
packageName: resolvedTailwindOptions.packageName,
|
|
415
|
+
version: resolvedTailwindOptions.version,
|
|
416
|
+
resolve: resolvedTailwindOptions.resolve,
|
|
417
|
+
cwd: resolvedTailwindOptions.cwd
|
|
418
|
+
});
|
|
419
|
+
if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
|
|
420
|
+
const resolvedPlugin = resolveModuleFromPaths(resolvedTailwindOptions.postcssPlugin, resolvedTailwindOptions.resolve?.paths ?? resolvePaths);
|
|
421
|
+
if (resolvedPlugin) resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
|
|
422
|
+
}
|
|
423
|
+
const searchRoots = /* @__PURE__ */ new Set();
|
|
424
|
+
if (resolvedTailwindOptions.cwd) searchRoots.add(resolvedTailwindOptions.cwd);
|
|
425
|
+
for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
|
|
426
|
+
const parentDir = node_path.default.dirname(resolvePath);
|
|
427
|
+
searchRoots.add(parentDir);
|
|
428
|
+
}
|
|
429
|
+
const configPath = findTailwindConfig(searchRoots);
|
|
430
|
+
if (!resolvedTailwindOptions.config) if (configPath) resolvedTailwindOptions.config = configPath;
|
|
431
|
+
else {
|
|
432
|
+
const fallbackConfig = resolveTailwindConfigFallback(resolvedTailwindOptions.packageName, resolvedTailwindOptions.resolve.paths ?? resolvePaths);
|
|
433
|
+
if (fallbackConfig) resolvedTailwindOptions.config = fallbackConfig;
|
|
434
|
+
}
|
|
435
|
+
if (!resolvedTailwindOptions.cwd && configPath) resolvedTailwindOptions.cwd = node_path.default.dirname(configPath);
|
|
436
|
+
resolvedOptions.tailwindcss = resolvedTailwindOptions;
|
|
437
|
+
}
|
|
438
|
+
try {
|
|
439
|
+
return new tailwindcss_patch.TailwindcssPatcher(resolvedOptions);
|
|
440
|
+
} catch (error) {
|
|
441
|
+
const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
|
|
442
|
+
if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
|
|
443
|
+
if (!hasLoggedMissingTailwind) {
|
|
444
|
+
_weapp_tailwindcss_logger.logger.warn("Tailwind CSS 未安装,已跳过 Tailwind 相关补丁。若需使用 Tailwind 能力,请安装 tailwindcss。");
|
|
445
|
+
hasLoggedMissingTailwind = true;
|
|
446
|
+
}
|
|
447
|
+
return createFallbackTailwindcssPatcher();
|
|
448
|
+
}
|
|
449
|
+
if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) _weapp_tailwindcss_logger.logger.error("无法定位 Tailwind CSS 包 \"%s\",已尝试路径: %O", resolvedOptions.tailwindcss?.packageName, searchPaths);
|
|
450
|
+
throw error;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/tailwindcss/v4/multi-patcher.ts
|
|
455
|
+
function createMultiTailwindcssPatcher(patchers) {
|
|
456
|
+
if (patchers.length <= 1) return patchers[0];
|
|
457
|
+
const [first] = patchers;
|
|
458
|
+
const multiPatcher = {
|
|
459
|
+
...first,
|
|
460
|
+
packageInfo: first?.packageInfo,
|
|
461
|
+
majorVersion: first?.majorVersion,
|
|
462
|
+
options: first?.options,
|
|
463
|
+
async patch() {
|
|
464
|
+
let exposeContext;
|
|
465
|
+
let extendLengthUnits;
|
|
466
|
+
for (const patcher of patchers) {
|
|
467
|
+
const result = await patcher.patch();
|
|
468
|
+
if (result?.exposeContext && exposeContext == null) exposeContext = result.exposeContext;
|
|
469
|
+
if (result?.extendLengthUnits && extendLengthUnits == null) extendLengthUnits = result.extendLengthUnits;
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
exposeContext,
|
|
473
|
+
extendLengthUnits
|
|
474
|
+
};
|
|
475
|
+
},
|
|
476
|
+
async getClassSet() {
|
|
477
|
+
const aggregated = /* @__PURE__ */ new Set();
|
|
478
|
+
for (const patcher of patchers) {
|
|
479
|
+
const current = await patcher.getClassSet();
|
|
480
|
+
for (const className of current) aggregated.add(className);
|
|
481
|
+
}
|
|
482
|
+
return aggregated;
|
|
483
|
+
},
|
|
484
|
+
async extract(options) {
|
|
485
|
+
const aggregatedSet = /* @__PURE__ */ new Set();
|
|
486
|
+
const aggregatedList = [];
|
|
487
|
+
let filename;
|
|
488
|
+
for (const patcher of patchers) {
|
|
489
|
+
const result = await patcher.extract(options);
|
|
490
|
+
if (!result) continue;
|
|
491
|
+
if (filename === void 0 && result.filename) filename = result.filename;
|
|
492
|
+
if (result.classList) for (const className of result.classList) {
|
|
493
|
+
if (!aggregatedSet.has(className)) aggregatedList.push(className);
|
|
494
|
+
aggregatedSet.add(className);
|
|
495
|
+
}
|
|
496
|
+
if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
classList: aggregatedList,
|
|
500
|
+
classSet: aggregatedSet,
|
|
501
|
+
filename
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) multiPatcher.getClassSetSync = () => {
|
|
506
|
+
const aggregated = /* @__PURE__ */ new Set();
|
|
507
|
+
for (const patcher of patchers) {
|
|
508
|
+
const current = patcher.getClassSetSync?.();
|
|
509
|
+
if (!current) continue;
|
|
510
|
+
for (const className of current) aggregated.add(className);
|
|
511
|
+
}
|
|
512
|
+
return aggregated;
|
|
513
|
+
};
|
|
514
|
+
Object.defineProperty(multiPatcher, runtimeSignaturePatchersSymbol, {
|
|
515
|
+
value: [...patchers],
|
|
516
|
+
configurable: true
|
|
517
|
+
});
|
|
518
|
+
return multiPatcher;
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/tailwindcss/v4/patcher-options.ts
|
|
522
|
+
function isLegacyTailwindcssPatcherOptions(options) {
|
|
523
|
+
return typeof options === "object" && options !== null && "patch" in options;
|
|
524
|
+
}
|
|
525
|
+
function isModernTailwindcssPatchOptions(options) {
|
|
526
|
+
return typeof options === "object" && options !== null && !("patch" in options);
|
|
527
|
+
}
|
|
528
|
+
function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries) {
|
|
529
|
+
const hasCssEntries = cssEntries.length > 0;
|
|
530
|
+
if (!options) return options;
|
|
531
|
+
if (isLegacyTailwindcssPatcherOptions(options)) {
|
|
532
|
+
const patchOptions = options.patch;
|
|
533
|
+
if (!patchOptions) return options;
|
|
534
|
+
const nextPatch = {
|
|
535
|
+
...patchOptions,
|
|
536
|
+
basedir: baseDir,
|
|
537
|
+
cwd: patchOptions.cwd ?? baseDir
|
|
538
|
+
};
|
|
539
|
+
if (patchOptions.tailwindcss) {
|
|
540
|
+
const nextV4 = { ...patchOptions.tailwindcss.v4 ?? {} };
|
|
541
|
+
if (hasCssEntries) nextV4.cssEntries = cssEntries;
|
|
542
|
+
else {
|
|
543
|
+
nextV4.cssEntries = nextV4.cssEntries ?? cssEntries;
|
|
544
|
+
if (nextV4.base === void 0) nextV4.base = baseDir;
|
|
545
|
+
}
|
|
546
|
+
nextPatch.tailwindcss = {
|
|
547
|
+
...patchOptions.tailwindcss,
|
|
548
|
+
v4: nextV4
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
...options,
|
|
553
|
+
patch: nextPatch
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
if (!isModernTailwindcssPatchOptions(options)) return options;
|
|
557
|
+
const modernTailwind = options.tailwindcss ?? options.tailwind;
|
|
558
|
+
if (!modernTailwind) return options;
|
|
559
|
+
const { tailwind: _legacyTailwind, ...rest } = options;
|
|
560
|
+
return {
|
|
561
|
+
...rest,
|
|
562
|
+
tailwindcss: {
|
|
563
|
+
...modernTailwind,
|
|
564
|
+
v4: {
|
|
565
|
+
...modernTailwind.v4 ?? {},
|
|
566
|
+
...hasCssEntries ? {} : { base: modernTailwind.v4?.base ?? baseDir },
|
|
567
|
+
cssEntries: hasCssEntries ? cssEntries : modernTailwind.v4?.cssEntries ?? cssEntries
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/tailwindcss/v4/css-entries.ts
|
|
574
|
+
function guessBasedirFromEntries(entries) {
|
|
575
|
+
if (!entries) return;
|
|
576
|
+
for (const entry of entries) {
|
|
577
|
+
if (typeof entry !== "string") continue;
|
|
578
|
+
const trimmed = entry.trim();
|
|
579
|
+
if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
|
|
580
|
+
const entryDir = node_path.default.dirname(trimmed);
|
|
581
|
+
const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
|
|
582
|
+
if (resolved) return resolved;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
function normalizeCssEntries(entries, anchor) {
|
|
586
|
+
if (!entries || entries.length === 0) return;
|
|
587
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
588
|
+
for (const entry of entries) {
|
|
589
|
+
if (typeof entry !== "string") continue;
|
|
590
|
+
const trimmed = entry.trim();
|
|
591
|
+
if (trimmed.length === 0) continue;
|
|
592
|
+
const resolved = node_path.default.isAbsolute(trimmed) ? node_path.default.normalize(trimmed) : node_path.default.normalize(node_path.default.resolve(anchor, trimmed));
|
|
593
|
+
normalized.add(resolved);
|
|
594
|
+
}
|
|
595
|
+
return normalized.size > 0 ? [...normalized] : void 0;
|
|
596
|
+
}
|
|
597
|
+
function isSubPath(parent, child) {
|
|
598
|
+
if (!parent || !child) return false;
|
|
599
|
+
const relative = node_path.default.relative(parent, child);
|
|
600
|
+
return relative === "" || !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
601
|
+
}
|
|
602
|
+
function resolveCssEntryBase(entryDir, options) {
|
|
603
|
+
const normalizedDir = node_path.default.normalize(entryDir);
|
|
604
|
+
const { preferredBaseDir, workspaceRoot } = options;
|
|
605
|
+
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
|
|
606
|
+
if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
|
|
607
|
+
const packageRoot = findNearestPackageRoot(normalizedDir);
|
|
608
|
+
if (packageRoot) return node_path.default.normalize(packageRoot);
|
|
609
|
+
return normalizedDir;
|
|
610
|
+
}
|
|
611
|
+
function groupCssEntriesByBase(entries, options = {}) {
|
|
612
|
+
const normalizedOptions = {
|
|
613
|
+
preferredBaseDir: options.preferredBaseDir ? node_path.default.normalize(options.preferredBaseDir) : void 0,
|
|
614
|
+
workspaceRoot: options.workspaceRoot ? node_path.default.normalize(options.workspaceRoot) : void 0
|
|
615
|
+
};
|
|
616
|
+
const groups = /* @__PURE__ */ new Map();
|
|
617
|
+
for (const entry of entries) {
|
|
618
|
+
const baseDir = resolveCssEntryBase(node_path.default.dirname(entry), normalizedOptions);
|
|
619
|
+
const bucket = groups.get(baseDir);
|
|
620
|
+
if (bucket) bucket.push(entry);
|
|
621
|
+
else groups.set(baseDir, [entry]);
|
|
622
|
+
}
|
|
623
|
+
return groups;
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/tailwindcss/v4/patcher.ts
|
|
627
|
+
const CONFIGURED_TAILWIND_VERSION_RE = /Configured tailwindcss\.version=\d+/u;
|
|
628
|
+
const RESOLVED_TAILWIND_VERSION_RE = /resolved package ".+" is version /u;
|
|
629
|
+
function isTailwindcss4Package(packageName) {
|
|
630
|
+
return Boolean(packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")));
|
|
631
|
+
}
|
|
632
|
+
function resolveExplicitTailwindVersion(configuredVersion, configuredPackageName) {
|
|
633
|
+
if (typeof configuredVersion === "number") return configuredVersion;
|
|
634
|
+
if (configuredPackageName === "tailwindcss") return 3;
|
|
635
|
+
if (isTailwindcss4Package(configuredPackageName)) return 4;
|
|
636
|
+
}
|
|
637
|
+
function hasOwnV4Signal(value) {
|
|
638
|
+
return typeof value === "object" && value !== null && "v4" in value;
|
|
639
|
+
}
|
|
640
|
+
function isTailwindVersionMismatchError(error) {
|
|
641
|
+
return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
|
|
642
|
+
}
|
|
643
|
+
function createPatcherForBase(baseDir, cssEntries, options) {
|
|
644
|
+
const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch } = options;
|
|
645
|
+
const hasCssEntries = Boolean(cssEntries?.length);
|
|
646
|
+
const mergedTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, {
|
|
647
|
+
cwd: baseDir,
|
|
648
|
+
v2: { cwd: baseDir },
|
|
649
|
+
v3: { cwd: baseDir },
|
|
650
|
+
v4: hasCssEntries ? { cssEntries } : {
|
|
651
|
+
base: baseDir,
|
|
652
|
+
cssEntries
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
if (!mergedTailwindOptions.v4) mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
|
|
656
|
+
base: baseDir,
|
|
657
|
+
cssEntries: cssEntries ?? []
|
|
658
|
+
};
|
|
659
|
+
else {
|
|
660
|
+
if (!hasCssEntries && !mergedTailwindOptions.v4.base) mergedTailwindOptions.v4.base = baseDir;
|
|
661
|
+
if (hasCssEntries) {
|
|
662
|
+
if (cssEntries?.length) mergedTailwindOptions.v4.cssEntries = cssEntries;
|
|
663
|
+
else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = [];
|
|
664
|
+
} else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = cssEntries ?? [];
|
|
665
|
+
}
|
|
666
|
+
const patchedOptions = overrideTailwindcssPatcherOptionsForBase(tailwindcssPatcherOptions, baseDir, cssEntries ?? []);
|
|
667
|
+
const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwind?.packageName || tailwindcssPatcherOptions?.patch?.tailwindcss?.packageName;
|
|
668
|
+
const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || tailwindcssPatcherOptions?.tailwind?.version || tailwindcssPatcherOptions?.patch?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
|
|
669
|
+
const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwind) || hasOwnV4Signal(tailwindcssPatcherOptions?.patch?.tailwindcss);
|
|
670
|
+
const shouldPatchV4PostcssPackage = (explicitTailwindVersion === 3 ? false : explicitTailwindVersion === 4 || explicitTailwindVersion === void 0 && (mergedTailwindOptions.version === 4 || isTailwindcss4Package(configuredPackageName ?? mergedTailwindOptions.packageName) || hasExplicitV4Signals)) && !Boolean(configuredPackageName);
|
|
671
|
+
const packageCandidates = /* @__PURE__ */ new Set();
|
|
672
|
+
if (shouldPatchV4PostcssPackage) packageCandidates.add("@tailwindcss/postcss");
|
|
673
|
+
packageCandidates.add(mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss");
|
|
674
|
+
const patchers = [];
|
|
675
|
+
const packageCandidateList = [...packageCandidates];
|
|
676
|
+
let firstVersionMismatchError;
|
|
677
|
+
for (const packageName of packageCandidateList) {
|
|
678
|
+
const tailwindOptionsForPackage = {
|
|
679
|
+
...mergedTailwindOptions,
|
|
680
|
+
packageName
|
|
681
|
+
};
|
|
682
|
+
try {
|
|
683
|
+
patchers.push(createTailwindcssPatcher({
|
|
684
|
+
basedir: baseDir,
|
|
685
|
+
supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
|
|
686
|
+
tailwindcss: tailwindOptionsForPackage,
|
|
687
|
+
tailwindcssPatcherOptions: patchedOptions
|
|
688
|
+
}));
|
|
689
|
+
} catch (error) {
|
|
690
|
+
if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
|
|
691
|
+
firstVersionMismatchError ?? (firstVersionMismatchError = error);
|
|
692
|
+
_weapp_tailwindcss_logger.logger.warn("skip incompatible Tailwind package candidate \"%s\" for v4 patcher: %s", packageName, error.message);
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
throw error;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (patchers.length === 0 && firstVersionMismatchError) throw firstVersionMismatchError;
|
|
699
|
+
return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
|
|
700
|
+
}
|
|
701
|
+
function tryCreateMultiTailwindcssPatcher(groups, options) {
|
|
702
|
+
if (groups.size <= 1) return;
|
|
703
|
+
_weapp_tailwindcss_logger.logger.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
|
|
704
|
+
const patchers = [];
|
|
705
|
+
for (const [baseDir, entries] of groups) patchers.push(createPatcherForBase(baseDir, entries, options));
|
|
706
|
+
return createMultiTailwindcssPatcher(patchers);
|
|
707
|
+
}
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/uni-app-x/options.ts
|
|
710
|
+
function resolveComponentLocalStyles(option) {
|
|
711
|
+
if (option === false) return {
|
|
712
|
+
enabled: false,
|
|
713
|
+
onlyWhenStyleIsolationVersion2: true
|
|
714
|
+
};
|
|
715
|
+
if (option === true || option === void 0) return {
|
|
716
|
+
enabled: false,
|
|
717
|
+
onlyWhenStyleIsolationVersion2: true
|
|
718
|
+
};
|
|
719
|
+
const componentLocalStyles = option.componentLocalStyles;
|
|
720
|
+
if (componentLocalStyles === false) return {
|
|
721
|
+
enabled: false,
|
|
722
|
+
onlyWhenStyleIsolationVersion2: true
|
|
723
|
+
};
|
|
724
|
+
if (componentLocalStyles === true || componentLocalStyles === void 0) return {
|
|
725
|
+
enabled: true,
|
|
726
|
+
onlyWhenStyleIsolationVersion2: true
|
|
727
|
+
};
|
|
728
|
+
return {
|
|
729
|
+
enabled: componentLocalStyles.enabled !== false,
|
|
730
|
+
onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
function resolveUniAppXOptions(option) {
|
|
734
|
+
if (typeof option === "object" && option) return {
|
|
735
|
+
enabled: option.enabled !== false,
|
|
736
|
+
componentLocalStyles: resolveComponentLocalStyles(option),
|
|
737
|
+
uvueUnsupported: option.uvueUnsupported ?? "warn"
|
|
738
|
+
};
|
|
739
|
+
return {
|
|
740
|
+
enabled: Boolean(option),
|
|
741
|
+
componentLocalStyles: resolveComponentLocalStyles(option),
|
|
742
|
+
uvueUnsupported: "warn"
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function isUniAppXEnabled(option) {
|
|
746
|
+
return resolveUniAppXOptions(option).enabled;
|
|
747
|
+
}
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/context/tailwindcss/basedir.ts
|
|
750
|
+
const ENV_BASEDIR_KEYS = [
|
|
751
|
+
"WEAPP_TAILWINDCSS_BASEDIR",
|
|
752
|
+
"WEAPP_TAILWINDCSS_BASE_DIR",
|
|
753
|
+
"TAILWINDCSS_BASEDIR",
|
|
754
|
+
"TAILWINDCSS_BASE_DIR",
|
|
755
|
+
"UNI_INPUT_DIR",
|
|
756
|
+
"UNI_INPUT_ROOT",
|
|
757
|
+
"UNI_CLI_ROOT",
|
|
758
|
+
"UNI_APP_INPUT_DIR",
|
|
759
|
+
"INIT_CWD",
|
|
760
|
+
"PWD"
|
|
761
|
+
];
|
|
762
|
+
const GENERIC_ENV_BASEDIR_KEYS = new Set(["INIT_CWD", "PWD"]);
|
|
763
|
+
function pickEnvBasedir() {
|
|
764
|
+
for (const key of ENV_BASEDIR_KEYS) {
|
|
765
|
+
const value = node_process.default.env[key];
|
|
766
|
+
if (value && node_path.default.isAbsolute(value)) return {
|
|
767
|
+
key,
|
|
768
|
+
value
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function pickPackageEnvBasedir() {
|
|
773
|
+
const packageJsonPath = node_process.default.env.npm_package_json;
|
|
774
|
+
if (packageJsonPath) {
|
|
775
|
+
const packageDir = node_path.default.dirname(packageJsonPath);
|
|
776
|
+
if (packageDir && node_path.default.isAbsolute(packageDir)) return packageDir;
|
|
777
|
+
}
|
|
778
|
+
const localPrefix = node_process.default.env.npm_config_local_prefix;
|
|
779
|
+
if (localPrefix && node_path.default.isAbsolute(localPrefix)) return localPrefix;
|
|
780
|
+
}
|
|
781
|
+
const STACK_PAREN_RE = /\(([^)]+)\)/u;
|
|
782
|
+
const STACK_AT_RE = /at\s+(\S.*)$/u;
|
|
783
|
+
function detectCallerBasedir() {
|
|
784
|
+
const stack = (/* @__PURE__ */ new Error("resolveTailwindcssBasedir stack probe")).stack;
|
|
785
|
+
if (!stack) return;
|
|
786
|
+
if (node_process.default.env.WEAPP_TW_DEBUG_STACK === "1") _weapp_tailwindcss_logger.logger.debug("caller stack: %s", stack);
|
|
787
|
+
const lines = stack.split("\n");
|
|
788
|
+
for (const line of lines) {
|
|
789
|
+
const location = (line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE))?.[1];
|
|
790
|
+
if (!location) continue;
|
|
791
|
+
let filePath = location;
|
|
792
|
+
if (filePath.startsWith("file://")) try {
|
|
793
|
+
filePath = (0, node_url.fileURLToPath)(filePath);
|
|
794
|
+
} catch {
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
const [candidate] = filePath.split(":");
|
|
798
|
+
const resolvedPath = node_path.default.isAbsolute(filePath) ? filePath : candidate;
|
|
799
|
+
if (!node_path.default.isAbsolute(resolvedPath)) continue;
|
|
800
|
+
if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) continue;
|
|
801
|
+
try {
|
|
802
|
+
return node_path.default.dirname(resolvedPath);
|
|
803
|
+
} catch {
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function resolveTailwindcssBasedir(basedir, fallback) {
|
|
809
|
+
const envBasedirResult = pickEnvBasedir();
|
|
810
|
+
const envBasedir = envBasedirResult?.value;
|
|
811
|
+
const envBasedirKey = envBasedirResult?.key;
|
|
812
|
+
const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
|
|
813
|
+
const packageEnvBasedir = pickPackageEnvBasedir();
|
|
814
|
+
const callerBasedir = !envBasedir || envBasedirIsGeneric ? detectCallerBasedir() : void 0;
|
|
815
|
+
const cwd = node_process.default.cwd();
|
|
816
|
+
const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
|
|
817
|
+
const resolveRelative = (value) => node_path.default.isAbsolute(value) ? node_path.default.normalize(value) : node_path.default.normalize(node_path.default.resolve(anchor, value));
|
|
818
|
+
if (node_process.default.env.WEAPP_TW_DEBUG_STACK === "1") _weapp_tailwindcss_logger.logger.debug("resolveTailwindcssBasedir anchor %O", {
|
|
819
|
+
basedir,
|
|
820
|
+
envBasedir,
|
|
821
|
+
envBasedirKey,
|
|
822
|
+
envBasedirIsGeneric,
|
|
823
|
+
packageEnvBasedir,
|
|
824
|
+
fallback,
|
|
825
|
+
callerBasedir,
|
|
826
|
+
npm_package_json: node_process.default.env.npm_package_json,
|
|
827
|
+
cwd,
|
|
828
|
+
anchor
|
|
829
|
+
});
|
|
830
|
+
if (basedir && basedir.trim().length > 0) return resolveRelative(basedir);
|
|
831
|
+
if (envBasedir && !envBasedirIsGeneric) return node_path.default.normalize(envBasedir);
|
|
832
|
+
if (fallback && fallback.trim().length > 0) return resolveRelative(fallback);
|
|
833
|
+
if (packageEnvBasedir) return node_path.default.normalize(packageEnvBasedir);
|
|
834
|
+
if (callerBasedir) {
|
|
835
|
+
const normalizedCaller = node_path.default.normalize(callerBasedir);
|
|
836
|
+
const librarySegment = `${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}`;
|
|
837
|
+
if (!normalizedCaller.includes(librarySegment)) return normalizedCaller;
|
|
838
|
+
}
|
|
839
|
+
const packageName = node_process.default.env.PNPM_PACKAGE_NAME;
|
|
840
|
+
if (packageName) try {
|
|
841
|
+
const packageJsonPath = (0, node_module.createRequire)(node_path.default.join(anchor, "__resolve_tailwindcss_basedir__.cjs")).resolve(`${packageName}/package.json`);
|
|
842
|
+
if (node_process.default.env.WEAPP_TW_DEBUG_STACK === "1") _weapp_tailwindcss_logger.logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
|
|
843
|
+
return node_path.default.normalize(node_path.default.dirname(packageJsonPath));
|
|
844
|
+
} catch {
|
|
845
|
+
if (node_process.default.env.WEAPP_TW_DEBUG_STACK === "1") _weapp_tailwindcss_logger.logger.debug("failed to resolve package json for %s", packageName);
|
|
846
|
+
const workspaceRoot = findWorkspaceRoot(anchor);
|
|
847
|
+
if (workspaceRoot) {
|
|
848
|
+
const packageDir = findWorkspacePackageDir(workspaceRoot, packageName);
|
|
849
|
+
if (packageDir) return packageDir;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (envBasedir) return node_path.default.normalize(envBasedir);
|
|
853
|
+
return node_path.default.normalize(cwd);
|
|
854
|
+
}
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region src/context/tailwindcss/rax.ts
|
|
857
|
+
function isRaxWorkspace(appType, baseDir) {
|
|
858
|
+
if (appType === "rax") return true;
|
|
859
|
+
try {
|
|
860
|
+
const pkgPath = node_path.default.join(baseDir, "package.json");
|
|
861
|
+
if (!(0, node_fs.existsSync)(pkgPath)) return false;
|
|
862
|
+
const pkg = JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"));
|
|
863
|
+
const deps = {
|
|
864
|
+
...pkg.dependencies ?? {},
|
|
865
|
+
...pkg.devDependencies ?? {}
|
|
866
|
+
};
|
|
867
|
+
if (deps["rax-app"] || deps.rax) return true;
|
|
868
|
+
} catch {
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
function collectRaxStyleEntries(baseDir) {
|
|
874
|
+
const STYLE_CANDIDATES = [
|
|
875
|
+
"src/global.css",
|
|
876
|
+
"src/global.scss",
|
|
877
|
+
"src/global.less",
|
|
878
|
+
"src/global.sass",
|
|
879
|
+
"src/global.styl",
|
|
880
|
+
"src/global.stylus"
|
|
881
|
+
];
|
|
882
|
+
const discovered = [];
|
|
883
|
+
for (const relative of STYLE_CANDIDATES) {
|
|
884
|
+
const candidate = node_path.default.resolve(baseDir, relative);
|
|
885
|
+
if ((0, node_fs.existsSync)(candidate)) discovered.push(node_path.default.normalize(candidate));
|
|
886
|
+
}
|
|
887
|
+
return discovered;
|
|
888
|
+
}
|
|
889
|
+
function detectImplicitCssEntries(appType, baseDir) {
|
|
890
|
+
const baseCandidates = /* @__PURE__ */ new Set();
|
|
891
|
+
baseCandidates.add(node_path.default.normalize(baseDir));
|
|
892
|
+
const envCandidates = [
|
|
893
|
+
node_process.default.cwd(),
|
|
894
|
+
node_process.default.env.INIT_CWD,
|
|
895
|
+
node_process.default.env.PWD
|
|
896
|
+
];
|
|
897
|
+
for (const candidate of envCandidates) if (candidate) baseCandidates.add(node_path.default.normalize(candidate));
|
|
898
|
+
for (const candidateBase of baseCandidates) {
|
|
899
|
+
if (!isRaxWorkspace(appType, candidateBase)) continue;
|
|
900
|
+
const entries = collectRaxStyleEntries(candidateBase);
|
|
901
|
+
if (entries.length) return entries;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region src/context/tailwindcss.ts
|
|
906
|
+
function createTailwindcssPatcherFromContext(ctx) {
|
|
907
|
+
const { tailwindcssBasedir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions, cssEntries: rawCssEntries, appType } = ctx;
|
|
908
|
+
const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
|
|
909
|
+
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
|
|
910
|
+
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
911
|
+
_weapp_tailwindcss_logger.logger.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
|
|
912
|
+
let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
|
|
913
|
+
if (!normalizedCssEntries) normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
|
|
914
|
+
if (normalizedCssEntries) ctx.cssEntries = normalizedCssEntries;
|
|
915
|
+
const patcherOptions = {
|
|
916
|
+
tailwindcss,
|
|
917
|
+
tailwindcssPatcherOptions,
|
|
918
|
+
supportCustomLengthUnitsPatch,
|
|
919
|
+
appType
|
|
920
|
+
};
|
|
921
|
+
const workspaceRoot = findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
|
|
922
|
+
const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, {
|
|
923
|
+
preferredBaseDir: resolvedTailwindcssBasedir,
|
|
924
|
+
workspaceRoot
|
|
925
|
+
}) : void 0;
|
|
926
|
+
const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
|
|
927
|
+
if (multiPatcher) return multiPatcher;
|
|
928
|
+
if (groupedCssEntries?.size === 1) {
|
|
929
|
+
const firstGroup = groupedCssEntries.entries().next().value;
|
|
930
|
+
if (firstGroup) {
|
|
931
|
+
const [baseDir, entries] = firstGroup;
|
|
932
|
+
return createPatcherForBase(baseDir, entries, patcherOptions);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return createPatcherForBase(resolvedTailwindcssBasedir, normalizedCssEntries ?? rawCssEntries, patcherOptions);
|
|
936
|
+
}
|
|
937
|
+
//#endregion
|
|
938
|
+
Object.defineProperty(exports, "applyV4CssCalcDefaults", {
|
|
939
|
+
enumerable: true,
|
|
940
|
+
get: function() {
|
|
941
|
+
return applyV4CssCalcDefaults;
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
Object.defineProperty(exports, "createTailwindcssPatcherFromContext", {
|
|
945
|
+
enumerable: true,
|
|
946
|
+
get: function() {
|
|
947
|
+
return createTailwindcssPatcherFromContext;
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
Object.defineProperty(exports, "findNearestPackageRoot", {
|
|
951
|
+
enumerable: true,
|
|
952
|
+
get: function() {
|
|
953
|
+
return findNearestPackageRoot;
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
Object.defineProperty(exports, "findTailwindConfig", {
|
|
957
|
+
enumerable: true,
|
|
958
|
+
get: function() {
|
|
959
|
+
return findTailwindConfig;
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
Object.defineProperty(exports, "getRuntimeClassSetCacheEntry", {
|
|
963
|
+
enumerable: true,
|
|
964
|
+
get: function() {
|
|
965
|
+
return getRuntimeClassSetCacheEntry;
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
Object.defineProperty(exports, "getRuntimeClassSetSignature", {
|
|
969
|
+
enumerable: true,
|
|
970
|
+
get: function() {
|
|
971
|
+
return getRuntimeClassSetSignature;
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
Object.defineProperty(exports, "invalidateRuntimeClassSet", {
|
|
975
|
+
enumerable: true,
|
|
976
|
+
get: function() {
|
|
977
|
+
return invalidateRuntimeClassSet;
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
Object.defineProperty(exports, "isUniAppXEnabled", {
|
|
981
|
+
enumerable: true,
|
|
982
|
+
get: function() {
|
|
983
|
+
return isUniAppXEnabled;
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
Object.defineProperty(exports, "resolveTailwindcssBasedir", {
|
|
987
|
+
enumerable: true,
|
|
988
|
+
get: function() {
|
|
989
|
+
return resolveTailwindcssBasedir;
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
Object.defineProperty(exports, "resolveUniAppXOptions", {
|
|
993
|
+
enumerable: true,
|
|
994
|
+
get: function() {
|
|
995
|
+
return resolveUniAppXOptions;
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
Object.defineProperty(exports, "warnMissingCssEntries", {
|
|
999
|
+
enumerable: true,
|
|
1000
|
+
get: function() {
|
|
1001
|
+
return warnMissingCssEntries;
|
|
1002
|
+
}
|
|
1003
|
+
});
|