weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.7
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 +4 -5
- package/bin/weapp-tailwindcss.js +1 -21
- 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 +4 -0
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +11 -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 +16 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +12 -22
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -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 +2 -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/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +0 -1
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
- package/dist/cache-DPN5yKSX.js +497 -0
- package/dist/cache-nq0_XJoS.mjs +429 -0
- package/dist/cli/context.d.ts +0 -3
- 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.js +108 -598
- package/dist/cli.mjs +119 -608
- package/dist/constants.d.ts +1 -2
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- 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.d.ts +15 -1
- package/dist/defaults.js +33 -14
- package/dist/defaults.mjs +30 -15
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +3 -4
- package/dist/{generator-Y-Ikv4Fu.mjs → generator-CzfdCZyd.mjs} +277 -23
- package/dist/{generator-mmhXzZnv.js → generator-TOp4uz7c.js} +281 -27
- package/dist/{generator-css-Bwy_Uz89.mjs → generator-css-B938WI9a.mjs} +694 -506
- package/dist/{generator-css-CRLrHW4F.js → generator-css-Dnpl-IY2.js} +699 -505
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +29 -28
- package/dist/gulp.mjs +25 -24
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/logger-BRy6XPQ2.js +1 -0
- package/dist/logger-Bub1jggA.mjs +2 -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-BtAP6sQO.mjs +288 -0
- package/dist/postcss-WsXlC7A-.js +298 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/{recorder-GdTJ3QqX.js → precheck-Dka94ArV.js} +141 -283
- package/dist/{recorder-XdFvVASS.mjs → precheck-DlrmwCc-.mjs} +106 -247
- package/dist/presets.js +6 -4
- package/dist/presets.mjs +4 -2
- package/dist/reset.d.ts +1 -0
- package/dist/{css-imports-BbrbluP9.js → run-tasks-B50A3pxt.js} +6 -55
- package/dist/{css-imports-CSdPq_Sc.mjs → run-tasks-DdNi-hkk.mjs} +5 -42
- package/dist/runtime-patch-pGdCqAEu.mjs +71 -0
- package/dist/runtime-patch-qwuisukL.js +85 -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-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +2 -3
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +2 -1
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/{logger-BoVx1Dbt.mjs → tailwindcss-BIJ185GB.mjs} +25 -434
- package/dist/{logger-BZ45DZJT.js → tailwindcss-T1U5T-iF.js} +30 -468
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +2 -9
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +0 -2
- package/dist/types/user-defined-options/important.d.ts +3 -3
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/{vite-BDywuCjn.mjs → vite-BXChkciE.mjs} +669 -481
- package/dist/{vite-DgRh_GXn.js → vite-D0CoRblu.js} +707 -519
- 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 +1 -1
- package/dist/{webpack-CiHqVZTg.mjs → webpack-BNdGm9KL.mjs} +224 -38
- package/dist/{webpack-CAJR4hhP.js → webpack-D-sUCY0u.js} +250 -69
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +23 -35
- 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/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/js/syntax.d.ts +0 -10
- package/dist/loader-anchors-1MumTAtA.mjs +0 -205
- package/dist/loader-anchors-TrFvT6g1.js +0 -273
- 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/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-p1dyh1x1.js → constants-BoB_6lFw.js} +0 -0
- /package/dist/{constants-B-_T5UnW.mjs → constants-E_loJC49.mjs} +0 -0
- /package/dist/{utils-7DUGTFED.mjs → utils-BJjKRQgf.mjs} +0 -0
- /package/dist/{utils-DmC9_In3.js → utils-VZvGusYs.js} +0 -0
|
@@ -1,185 +1,15 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const
|
|
3
|
-
require("./utils-
|
|
2
|
+
const require_cache = require("./cache-DPN5yKSX.js");
|
|
3
|
+
require("./utils-VZvGusYs.js");
|
|
4
4
|
let node_module = require("node:module");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
7
7
|
let node_process = require("node:process");
|
|
8
8
|
node_process = require_chunk.__toESM(node_process);
|
|
9
|
-
let tailwindcss_patch = require("tailwindcss-patch");
|
|
10
|
-
let node_fs = require("node:fs");
|
|
11
9
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
12
|
-
let
|
|
10
|
+
let node_fs = require("node:fs");
|
|
13
11
|
let node_url = require("node:url");
|
|
14
|
-
|
|
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
|
|
12
|
+
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
183
13
|
//#region src/tailwindcss/v4/config.ts
|
|
184
14
|
const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
185
15
|
function includesToken(list, token) {
|
|
@@ -234,8 +64,6 @@ function hasConfiguredCssEntries(ctx) {
|
|
|
234
64
|
const patcherOptions = ctx.tailwindcssPatcherOptions;
|
|
235
65
|
if (patcherOptions) {
|
|
236
66
|
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
67
|
}
|
|
240
68
|
return false;
|
|
241
69
|
}
|
|
@@ -253,226 +81,17 @@ function applyV4CssCalcDefaults(cssCalc, patcher) {
|
|
|
253
81
|
return cssCalcOptions;
|
|
254
82
|
}
|
|
255
83
|
//#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
84
|
//#region src/tailwindcss/v4/multi-patcher.ts
|
|
455
85
|
function createMultiTailwindcssPatcher(patchers) {
|
|
456
86
|
if (patchers.length <= 1) return patchers[0];
|
|
457
|
-
const
|
|
87
|
+
const first = patchers[0];
|
|
88
|
+
const firstWithoutPatch = { ...first };
|
|
89
|
+
delete firstWithoutPatch.patch;
|
|
458
90
|
const multiPatcher = {
|
|
459
|
-
...
|
|
91
|
+
...firstWithoutPatch,
|
|
460
92
|
packageInfo: first?.packageInfo,
|
|
461
93
|
majorVersion: first?.majorVersion,
|
|
462
94
|
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
95
|
async getClassSet() {
|
|
477
96
|
const aggregated = /* @__PURE__ */ new Set();
|
|
478
97
|
for (const patcher of patchers) {
|
|
@@ -511,7 +130,7 @@ function createMultiTailwindcssPatcher(patchers) {
|
|
|
511
130
|
}
|
|
512
131
|
return aggregated;
|
|
513
132
|
};
|
|
514
|
-
Object.defineProperty(multiPatcher, runtimeSignaturePatchersSymbol, {
|
|
133
|
+
Object.defineProperty(multiPatcher, require_cache.runtimeSignaturePatchersSymbol, {
|
|
515
134
|
value: [...patchers],
|
|
516
135
|
configurable: true
|
|
517
136
|
});
|
|
@@ -519,46 +138,13 @@ function createMultiTailwindcssPatcher(patchers) {
|
|
|
519
138
|
}
|
|
520
139
|
//#endregion
|
|
521
140
|
//#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
141
|
function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries) {
|
|
529
142
|
const hasCssEntries = cssEntries.length > 0;
|
|
530
143
|
if (!options) return options;
|
|
531
|
-
|
|
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;
|
|
144
|
+
const modernTailwind = options.tailwindcss;
|
|
558
145
|
if (!modernTailwind) return options;
|
|
559
|
-
const { tailwind: _legacyTailwind, ...rest } = options;
|
|
560
146
|
return {
|
|
561
|
-
...
|
|
147
|
+
...options,
|
|
562
148
|
tailwindcss: {
|
|
563
149
|
...modernTailwind,
|
|
564
150
|
v4: {
|
|
@@ -578,7 +164,7 @@ function guessBasedirFromEntries(entries) {
|
|
|
578
164
|
const trimmed = entry.trim();
|
|
579
165
|
if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
|
|
580
166
|
const entryDir = node_path.default.dirname(trimmed);
|
|
581
|
-
const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
|
|
167
|
+
const resolved = require_cache.findNearestPackageRoot(entryDir) ?? entryDir;
|
|
582
168
|
if (resolved) return resolved;
|
|
583
169
|
}
|
|
584
170
|
}
|
|
@@ -604,7 +190,7 @@ function resolveCssEntryBase(entryDir, options) {
|
|
|
604
190
|
const { preferredBaseDir, workspaceRoot } = options;
|
|
605
191
|
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
|
|
606
192
|
if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
|
|
607
|
-
const packageRoot = findNearestPackageRoot(normalizedDir);
|
|
193
|
+
const packageRoot = require_cache.findNearestPackageRoot(normalizedDir);
|
|
608
194
|
if (packageRoot) return node_path.default.normalize(packageRoot);
|
|
609
195
|
return normalizedDir;
|
|
610
196
|
}
|
|
@@ -641,7 +227,7 @@ function isTailwindVersionMismatchError(error) {
|
|
|
641
227
|
return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
|
|
642
228
|
}
|
|
643
229
|
function createPatcherForBase(baseDir, cssEntries, options) {
|
|
644
|
-
const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch } = options;
|
|
230
|
+
const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch, bareArbitraryValues } = options;
|
|
645
231
|
const hasCssEntries = Boolean(cssEntries?.length);
|
|
646
232
|
const mergedTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, {
|
|
647
233
|
cwd: baseDir,
|
|
@@ -663,11 +249,15 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
663
249
|
else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = [];
|
|
664
250
|
} else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = cssEntries ?? [];
|
|
665
251
|
}
|
|
252
|
+
if (bareArbitraryValues !== void 0 && bareArbitraryValues !== false) mergedTailwindOptions.v4.bareArbitraryValues = bareArbitraryValues;
|
|
666
253
|
const patchedOptions = overrideTailwindcssPatcherOptionsForBase(tailwindcssPatcherOptions, baseDir, cssEntries ?? []);
|
|
667
|
-
const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName
|
|
668
|
-
const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version ||
|
|
669
|
-
const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss)
|
|
670
|
-
const
|
|
254
|
+
const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName;
|
|
255
|
+
const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
|
|
256
|
+
const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss);
|
|
257
|
+
const packageNameForVersionDetection = configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss";
|
|
258
|
+
const installedTailwindVersion = require_cache.readInstalledPackageMajorVersion(packageNameForVersionDetection, baseDir);
|
|
259
|
+
const resolvedTailwindVersion = installedTailwindVersion ?? explicitTailwindVersion;
|
|
260
|
+
const shouldPatchV4PostcssPackage = (resolvedTailwindVersion === 4 && (installedTailwindVersion === 4 || explicitTailwindVersion === 4 || hasExplicitV4Signals && isTailwindcss4Package(packageNameForVersionDetection)) || resolvedTailwindVersion === void 0 && (hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss))) && !Boolean(configuredPackageName);
|
|
671
261
|
const packageCandidates = /* @__PURE__ */ new Set();
|
|
672
262
|
if (shouldPatchV4PostcssPackage) packageCandidates.add("@tailwindcss/postcss");
|
|
673
263
|
packageCandidates.add(mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss");
|
|
@@ -679,8 +269,9 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
679
269
|
...mergedTailwindOptions,
|
|
680
270
|
packageName
|
|
681
271
|
};
|
|
272
|
+
if (resolvedTailwindVersion) tailwindOptionsForPackage.version = resolvedTailwindVersion;
|
|
682
273
|
try {
|
|
683
|
-
patchers.push(createTailwindcssPatcher({
|
|
274
|
+
patchers.push(require_cache.createTailwindcssPatcher({
|
|
684
275
|
basedir: baseDir,
|
|
685
276
|
supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
|
|
686
277
|
tailwindcss: tailwindOptionsForPackage,
|
|
@@ -843,9 +434,9 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
843
434
|
return node_path.default.normalize(node_path.default.dirname(packageJsonPath));
|
|
844
435
|
} catch {
|
|
845
436
|
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);
|
|
437
|
+
const workspaceRoot = require_cache.findWorkspaceRoot(anchor);
|
|
847
438
|
if (workspaceRoot) {
|
|
848
|
-
const packageDir = findWorkspacePackageDir(workspaceRoot, packageName);
|
|
439
|
+
const packageDir = require_cache.findWorkspacePackageDir(workspaceRoot, packageName);
|
|
849
440
|
if (packageDir) return packageDir;
|
|
850
441
|
}
|
|
851
442
|
}
|
|
@@ -904,7 +495,7 @@ function detectImplicitCssEntries(appType, baseDir) {
|
|
|
904
495
|
//#endregion
|
|
905
496
|
//#region src/context/tailwindcss.ts
|
|
906
497
|
function createTailwindcssPatcherFromContext(ctx) {
|
|
907
|
-
const { tailwindcssBasedir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions, cssEntries: rawCssEntries, appType } = ctx;
|
|
498
|
+
const { tailwindcssBasedir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions, cssEntries: rawCssEntries, appType, arbitraryValues } = ctx;
|
|
908
499
|
const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
|
|
909
500
|
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
|
|
910
501
|
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
@@ -916,9 +507,10 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
916
507
|
tailwindcss,
|
|
917
508
|
tailwindcssPatcherOptions,
|
|
918
509
|
supportCustomLengthUnitsPatch,
|
|
919
|
-
appType
|
|
510
|
+
appType,
|
|
511
|
+
bareArbitraryValues: arbitraryValues?.bareArbitraryValues
|
|
920
512
|
};
|
|
921
|
-
const workspaceRoot = findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
|
|
513
|
+
const workspaceRoot = require_cache.findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? require_cache.findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
|
|
922
514
|
const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, {
|
|
923
515
|
preferredBaseDir: resolvedTailwindcssBasedir,
|
|
924
516
|
workspaceRoot
|
|
@@ -947,36 +539,6 @@ Object.defineProperty(exports, "createTailwindcssPatcherFromContext", {
|
|
|
947
539
|
return createTailwindcssPatcherFromContext;
|
|
948
540
|
}
|
|
949
541
|
});
|
|
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
542
|
Object.defineProperty(exports, "isUniAppXEnabled", {
|
|
981
543
|
enumerable: true,
|
|
982
544
|
get: function() {
|
package/dist/typedoc.export.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export type { WeappTailwindcssGenerateOptions, WeappTailwindcssGenerateResult, WeappTailwindcssGenerator, WeappTailwindcssGeneratorTarget, WeappTailwindcssPostcssPluginOptions, } from './index';
|
|
2
|
-
export type { DisabledOptions } from './types/disabled-options';
|
|
3
2
|
export type { UserDefinedOptions } from './types/user-defined-options';
|
|
4
3
|
export type { ApplyOptions, CacheOptions, ExtractOptions, TailwindCssOptions, TailwindCssPatchOptions, TailwindV2Options, TailwindV3Options, TailwindV4Options, } from 'tailwindcss-patch';
|
|
5
|
-
export type TailwindcssPatchOptions = import('tailwindcss-patch').TailwindCssPatchOptions;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,11 +5,10 @@ import type { Document, Result as PostcssResult, Root } from 'postcss';
|
|
|
5
5
|
import type { ILengthUnitsPatchOptions, TailwindcssPatcher } from 'tailwindcss-patch';
|
|
6
6
|
import type { ICreateCacheReturnType } from '../cache';
|
|
7
7
|
import type { ItemOrItemArray } from './base';
|
|
8
|
-
import type { DisabledOptions } from './disabled-options';
|
|
9
8
|
import type { AppType, IArbitraryValues, ICustomAttributesEntities } from './shared';
|
|
10
9
|
import type { UniAppXComponentLocalStylesOptions, UniAppXOptions as UniAppXUserDefinedOptions, UserDefinedOptions } from './user-defined-options';
|
|
11
10
|
type AsyncableMethod<T> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> | Awaited<R> : never;
|
|
12
|
-
export type {
|
|
11
|
+
export type { UniAppXComponentLocalStylesOptions, UniAppXUserDefinedOptions, UserDefinedOptions, };
|
|
13
12
|
export type { CssPreflightOptions, IStyleHandlerOptions, ItemOrItemArray };
|
|
14
13
|
export type { AppType, IArbitraryValues, ICustomAttributes, ICustomAttributesEntities } from './shared';
|
|
15
14
|
export interface LinkedJsModuleResult {
|
|
@@ -24,7 +23,7 @@ export interface JsHandlerResult {
|
|
|
24
23
|
export interface TailwindcssPatcherLike {
|
|
25
24
|
packageInfo: TailwindcssPatcher['packageInfo'];
|
|
26
25
|
majorVersion?: TailwindcssPatcher['majorVersion'];
|
|
27
|
-
patch
|
|
26
|
+
patch?: TailwindcssPatcher['patch'];
|
|
28
27
|
getClassSet: AsyncableMethod<TailwindcssPatcher['getClassSet']>;
|
|
29
28
|
getClassSetSync?: TailwindcssPatcher['getClassSetSync'];
|
|
30
29
|
extract: TailwindcssPatcher['extract'];
|
|
@@ -37,7 +36,6 @@ export interface RefreshTailwindcssPatcherOptions {
|
|
|
37
36
|
export interface IJsHandlerOptions {
|
|
38
37
|
escapeMap?: Record<string, string>;
|
|
39
38
|
classNameSet?: Set<string>;
|
|
40
|
-
staleClassNameFallback?: boolean;
|
|
41
39
|
jsArbitraryValueFallback?: boolean | 'auto';
|
|
42
40
|
tailwindcssMajorVersion?: number;
|
|
43
41
|
arbitraryValues?: IArbitraryValues;
|
|
@@ -90,11 +88,6 @@ export interface IBaseWebpackPlugin {
|
|
|
90
88
|
appType?: AppType;
|
|
91
89
|
apply: (compiler: any) => void;
|
|
92
90
|
}
|
|
93
|
-
export interface InternalPatchResult {
|
|
94
|
-
dataTypes?: string;
|
|
95
|
-
processTailwindFeatures?: string;
|
|
96
|
-
plugin?: string;
|
|
97
|
-
}
|
|
98
91
|
export type CreateJsHandlerOptions = Omit<IJsHandlerOptions, 'classNameSet'>;
|
|
99
92
|
export interface JsModuleGraphOptions {
|
|
100
93
|
resolve: (specifier: string, importer: string) => string | undefined;
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -4,4 +4,7 @@ export type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>>
|
|
|
4
4
|
export type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
|
|
5
5
|
export interface IArbitraryValues {
|
|
6
6
|
allowDoubleQuotes?: boolean;
|
|
7
|
+
bareArbitraryValues?: boolean | {
|
|
8
|
+
units?: string[];
|
|
9
|
+
};
|
|
7
10
|
}
|