weapp-tailwindcss 5.0.0-next.1 → 5.0.0-next.11
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/bundle-state-BRkhpjio.js +448 -0
- package/dist/bundle-state-BrtFgX-A.mjs +369 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +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/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +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 -20
- package/dist/bundlers/shared/hmr-timing.d.ts +5 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +4 -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 +16 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +4 -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 +5 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
- package/dist/bundlers/vite/source-candidates.d.ts +18 -0
- package/dist/bundlers/vite/source-scan.d.ts +9 -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 +5 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -1
- package/dist/cache/index.d.ts +6 -6
- package/dist/cache-B_9E7FxF.js +517 -0
- package/dist/cache-DEDxBMIw.mjs +443 -0
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +126 -602
- package/dist/cli.mjs +135 -610
- package/dist/constants.d.ts +1 -2
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +3 -2
- package/dist/css-macro/postcss.mjs +3 -2
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +33 -14
- package/dist/defaults.mjs +30 -15
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +10 -7
- package/dist/generator/types.d.ts +3 -2
- package/dist/generator-CahkD2vq.mjs +1469 -0
- package/dist/generator-Ck1Dd1V0.js +1568 -0
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +149 -47
- package/dist/gulp.mjs +144 -42
- package/dist/incremental-runtime-class-set-CBMefNHQ.js +1744 -0
- package/dist/incremental-runtime-class-set-DaS2yw5c.mjs +1687 -0
- 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/js/precheck.d.ts +2 -2
- package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
- package/dist/lightningcss/style-handler.d.ts +3 -3
- package/dist/logger-CZUxvJJD.mjs +2 -0
- package/dist/logger-EVNB9z7i.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-BdcRlSpp.js +243 -0
- package/dist/postcss-Bs-RbNzK.js +5477 -0
- package/dist/postcss-xZDiTRII.mjs +234 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -274
- package/dist/postcss.mjs +1 -267
- package/dist/{recorder-rn_2v_nd.js → precheck-D5eEdqeH.js} +168 -304
- package/dist/{recorder-B_XyZ576.mjs → precheck-DtBGFS-n.mjs} +134 -269
- package/dist/presets.js +13 -11
- package/dist/presets.mjs +11 -9
- package/dist/reset.d.ts +1 -0
- package/dist/runtime-patch-CqB-A4zA.js +85 -0
- package/dist/runtime-patch-DGKsVkiG.mjs +71 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-scan-CIVTa3Cj.js +297 -0
- package/dist/source-scan-CJ0y0XBj.mjs +258 -0
- package/dist/tailwindcss/miniprogram.d.ts +5 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +3 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +25 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +14 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +1 -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 +6 -3
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-B78nj6n7.js +644 -0
- package/dist/tailwindcss-DGM8lHUj.mjs +593 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +45 -48
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +21 -23
- package/dist/types/user-defined-options/important.d.ts +31 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
- package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
- package/dist/{vite-BHpAqldo.js → vite-BEj9JOOA.js} +1245 -876
- package/dist/{vite-C8JlHiyR.mjs → vite-C8S1wfyQ.mjs} +1208 -842
- 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 +129 -15
- package/dist/weapp-tw-runtime-classset-loader.js +44 -6
- package/dist/webpack-Dm1IXTIh.js +778 -0
- package/dist/webpack-ZGIKKpFf.mjs +768 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +26 -39
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-CZ-JXw6T.js +0 -492
- package/dist/generator-Dwxgra97.mjs +0 -399
- package/dist/generator-css-CnYjiMrD.js +0 -1084
- package/dist/generator-css-DhPFjSzK.mjs +0 -1057
- package/dist/js/syntax.d.ts +0 -10
- package/dist/loader-anchors-DvwgIYdA.mjs +0 -205
- package/dist/loader-anchors-cprm4Klq.js +0 -273
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/webpack-CABjKGGQ.mjs +0 -441
- package/dist/webpack-DNIJ0ysE.js +0 -456
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
- /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
- /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { l as omitUndefined, n as getRuntimeClassSetSignature, r as invalidateRuntimeClassSet, t as getRuntimeClassSetCacheEntry } from "./cache-DEDxBMIw.mjs";
|
|
2
|
+
import { n as createDebug, t as ensureTailwindcssRuntimePatch } from "./runtime-patch-DGKsVkiG.mjs";
|
|
3
|
+
import { i as isMap, n as defuOverrideArray } from "./utils-CGBVVNm6.mjs";
|
|
4
|
+
import { getDefaultOptions, resolveDefaultCssPreflight } from "./defaults.mjs";
|
|
5
|
+
import { a as applyV4CssCalcDefaults, i as resolveUniAppXOptions, o as warnMissingCssEntries, r as isUniAppXEnabled, t as createTailwindcssPatcherFromContext } from "./tailwindcss-DGM8lHUj.mjs";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import process from "node:process";
|
|
7
|
-
import { Buffer } from "node:buffer";
|
|
8
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
-
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
10
8
|
import { logger, pc } from "@weapp-tailwindcss/logger";
|
|
9
|
+
import { createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
10
|
+
import { Buffer } from "node:buffer";
|
|
11
|
+
import { rm } from "node:fs/promises";
|
|
11
12
|
import { LRUCache } from "lru-cache";
|
|
12
13
|
import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
|
|
13
14
|
import { MappingChars2String, escape } from "@weapp-core/escape";
|
|
14
|
-
import _createDebug from "debug";
|
|
15
15
|
import _babelTraverse from "@babel/traverse";
|
|
16
16
|
import { parse, parseExpression } from "@babel/parser";
|
|
17
17
|
import { escapeStringRegexp } from "@weapp-core/regex";
|
|
@@ -102,33 +102,13 @@ function initializeCache(cacheConfig) {
|
|
|
102
102
|
return cacheConfig;
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
|
-
//#region src/debug/index.ts
|
|
106
|
-
const _debug = _createDebug("weapp-tw");
|
|
107
|
-
function createDebug(prefix) {
|
|
108
|
-
const debug = ((formatter, ...args) => {
|
|
109
|
-
return _debug((prefix ?? "") + formatter, ...args);
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(debug, "enabled", {
|
|
112
|
-
enumerable: false,
|
|
113
|
-
configurable: false,
|
|
114
|
-
get() {
|
|
115
|
-
return _debug.enabled;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return debug;
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
105
|
//#region src/tailwindcss/runtime.ts
|
|
122
106
|
const debug$1 = createDebug("[tailwindcss:runtime] ");
|
|
123
107
|
const refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
|
|
124
|
-
function
|
|
125
|
-
return Promise.resolve(
|
|
108
|
+
function createTailwindRuntimeReadyPromise(twPatcher) {
|
|
109
|
+
return Promise.resolve().then(async () => {
|
|
110
|
+
await ensureTailwindcssRuntimePatch(twPatcher);
|
|
126
111
|
invalidateRuntimeClassSet(twPatcher);
|
|
127
|
-
if (onPatched) try {
|
|
128
|
-
await onPatched();
|
|
129
|
-
} catch (error) {
|
|
130
|
-
debug$1("failed to persist patch target after patch(): %O", error);
|
|
131
|
-
}
|
|
132
112
|
});
|
|
133
113
|
}
|
|
134
114
|
const runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -146,14 +126,14 @@ async function refreshTailwindRuntimeState(state, forceOrOptions) {
|
|
|
146
126
|
const clearCache = normalizedOptions.clearCache === true;
|
|
147
127
|
if (!force) return false;
|
|
148
128
|
debug$1("refresh runtime state start, clearCache=%s major=%s", clearCache, state.twPatcher.majorVersion ?? "unknown");
|
|
149
|
-
await state.
|
|
129
|
+
await state.readyPromise;
|
|
150
130
|
let refreshed = false;
|
|
151
131
|
if (typeof state.refreshTailwindcssPatcher === "function") {
|
|
152
132
|
const next = await state.refreshTailwindcssPatcher({ clearCache });
|
|
153
133
|
if (next !== state.twPatcher) state.twPatcher = next;
|
|
154
134
|
refreshed = true;
|
|
155
135
|
}
|
|
156
|
-
if (refreshed) state.
|
|
136
|
+
if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(state.twPatcher);
|
|
157
137
|
debug$1("refresh runtime state end, refreshed=%s major=%s", refreshed, state.twPatcher.majorVersion ?? "unknown");
|
|
158
138
|
return refreshed;
|
|
159
139
|
}
|
|
@@ -166,7 +146,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
166
146
|
force: true,
|
|
167
147
|
clearCache
|
|
168
148
|
});
|
|
169
|
-
await state.
|
|
149
|
+
await state.readyPromise;
|
|
170
150
|
const entry = getRuntimeClassSetStateEntry(state);
|
|
171
151
|
const signature = getRuntimeClassSetSignature(state.twPatcher);
|
|
172
152
|
const signatureChanged = entry.signature !== signature;
|
|
@@ -186,7 +166,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
186
166
|
force: true,
|
|
187
167
|
clearCache: true
|
|
188
168
|
});
|
|
189
|
-
await state.
|
|
169
|
+
await state.readyPromise;
|
|
190
170
|
return collectRuntimeClassSet(state.twPatcher, {
|
|
191
171
|
force: true,
|
|
192
172
|
skipRefresh: true,
|
|
@@ -240,6 +220,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
240
220
|
if (entry.promise) return entry.promise;
|
|
241
221
|
} else entry.value = void 0;
|
|
242
222
|
const task = (async () => {
|
|
223
|
+
await ensureTailwindcssRuntimePatch(activePatcher);
|
|
243
224
|
const preExtractSyncSet = options.force ? tryGetRuntimeClassSetSync(activePatcher) : void 0;
|
|
244
225
|
if (preExtractSyncSet) debug$1("runtime class set snapshot via getClassSetSync() before extract(), size=%d", preExtractSyncSet.size);
|
|
245
226
|
const preferExtract = options.force === true;
|
|
@@ -319,197 +300,29 @@ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
|
|
|
319
300
|
return;
|
|
320
301
|
}
|
|
321
302
|
if (!markRuntimeLog("missing", baseDir, rootPath, version)) return;
|
|
322
|
-
logger.warn(`${pc.cyanBright("Tailwind CSS")}
|
|
303
|
+
logger.warn(`${pc.cyanBright("Tailwind CSS")} 未安装,已跳过版本检测与运行时初始化。`);
|
|
323
304
|
}
|
|
324
305
|
//#endregion
|
|
325
|
-
//#region src/tailwindcss/targets
|
|
326
|
-
const PATCH_INFO_FILENAME = "tailwindcss-target.json";
|
|
327
|
-
const PATCH_INFO_CACHE_RELATIVE_PATH = path.join("node_modules", ".cache", "weapp-tailwindcss", PATCH_INFO_FILENAME);
|
|
328
|
-
const PATCH_INFO_LEGACY_RELATIVE_PATH = path.join(".tw-patch", PATCH_INFO_FILENAME);
|
|
329
|
-
function toDisplayPath(value) {
|
|
330
|
-
return path.normalize(value).replace(/\\/g, "/");
|
|
331
|
-
}
|
|
306
|
+
//#region src/tailwindcss/targets.ts
|
|
332
307
|
function formatRelativeToBase(targetPath, baseDir) {
|
|
333
|
-
|
|
334
|
-
|
|
308
|
+
const normalized = path.normalize(targetPath);
|
|
309
|
+
if (!baseDir) return normalized.replace(/\\/g, "/");
|
|
310
|
+
const relative = path.relative(baseDir, normalized);
|
|
335
311
|
if (!relative || relative === ".") return ".";
|
|
336
|
-
if (relative.startsWith("..")) return
|
|
337
|
-
return
|
|
338
|
-
}
|
|
339
|
-
function resolveRecordLocation(baseDir) {
|
|
340
|
-
const normalizedBase = path.normalize(baseDir);
|
|
341
|
-
const packageRoot = findNearestPackageRoot(normalizedBase) ?? normalizedBase;
|
|
342
|
-
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
343
|
-
const hasPackageJson = existsSync(packageJsonPath);
|
|
344
|
-
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
345
|
-
const recordKey = md5Hash(path.normalize(recordKeySource));
|
|
346
|
-
const recordDir = path.join(packageRoot, "node_modules", ".cache", "weapp-tailwindcss", recordKey);
|
|
347
|
-
return {
|
|
348
|
-
normalizedBase,
|
|
349
|
-
packageRoot,
|
|
350
|
-
recordDir,
|
|
351
|
-
recordKey,
|
|
352
|
-
recordPath: path.join(recordDir, PATCH_INFO_FILENAME),
|
|
353
|
-
packageJsonPath: hasPackageJson ? packageJsonPath : void 0
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
function getRecordFileCandidates(baseDir) {
|
|
357
|
-
const { normalizedBase, packageRoot, recordPath } = resolveRecordLocation(baseDir);
|
|
358
|
-
return [...new Set([
|
|
359
|
-
recordPath,
|
|
360
|
-
path.join(packageRoot, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
361
|
-
path.join(normalizedBase, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
362
|
-
path.join(normalizedBase, PATCH_INFO_LEGACY_RELATIVE_PATH)
|
|
363
|
-
])];
|
|
364
|
-
}
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region package.json
|
|
367
|
-
var version = "5.0.0-next.1";
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/constants.ts
|
|
370
|
-
const pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
371
|
-
const vitePluginName = "weapp-tailwindcss:adaptor";
|
|
372
|
-
const WEAPP_TW_VERSION = version;
|
|
373
|
-
const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
374
|
-
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
375
|
-
"class-variance-authority": "@weapp-tailwindcss/cva",
|
|
376
|
-
"tailwind-variants": "@weapp-tailwindcss/variants"
|
|
377
|
-
};
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/tailwindcss/targets/record-io.ts
|
|
380
|
-
const loggedInvalidPatchRecords = /* @__PURE__ */ new Set();
|
|
381
|
-
function warnInvalidPatchTargetRecord(baseDir, recordPath, reason) {
|
|
382
|
-
const normalizedPath = path.normalize(recordPath);
|
|
383
|
-
if (loggedInvalidPatchRecords.has(normalizedPath)) return;
|
|
384
|
-
loggedInvalidPatchRecords.add(normalizedPath);
|
|
385
|
-
const fileDisplay = formatRelativeToBase(normalizedPath, baseDir);
|
|
386
|
-
const baseDisplay = formatRelativeToBase(path.normalize(baseDir), process.cwd());
|
|
387
|
-
const reasonMessage = reason ? `:${reason}` : "";
|
|
388
|
-
logger.warn(`检测到损坏的 Tailwind CSS 目标记录 ${fileDisplay}${reasonMessage}。请在 ${baseDisplay} 重新执行 "weapp-tw patch --record-target" 或删除该文件后再运行。`);
|
|
389
|
-
}
|
|
390
|
-
function readPatchTargetRecord(baseDir) {
|
|
391
|
-
if (!baseDir) return;
|
|
392
|
-
const normalizedBase = path.normalize(baseDir);
|
|
393
|
-
for (const recordPath of getRecordFileCandidates(normalizedBase)) {
|
|
394
|
-
if (!existsSync(recordPath)) continue;
|
|
395
|
-
try {
|
|
396
|
-
const content = readFileSync(recordPath, "utf8");
|
|
397
|
-
const parsed = JSON.parse(content);
|
|
398
|
-
if (!parsed || typeof parsed.tailwindPackagePath !== "string") {
|
|
399
|
-
warnInvalidPatchTargetRecord(normalizedBase, recordPath, "缺少 tailwindPackagePath 字段");
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
return {
|
|
403
|
-
baseDir: normalizedBase,
|
|
404
|
-
path: recordPath,
|
|
405
|
-
record: parsed
|
|
406
|
-
};
|
|
407
|
-
} catch (error) {
|
|
408
|
-
warnInvalidPatchTargetRecord(normalizedBase, recordPath, error instanceof Error ? error.message : String(error));
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
async function saveCliPatchTargetRecord(baseDir, patcher, options) {
|
|
414
|
-
if (!baseDir || !patcher?.packageInfo?.rootPath) return;
|
|
415
|
-
const normalizedBase = path.normalize(baseDir);
|
|
416
|
-
const location = resolveRecordLocation(normalizedBase);
|
|
417
|
-
const recordPath = options?.recordPath ? path.normalize(options.recordPath) : location.recordPath;
|
|
418
|
-
const record = {
|
|
419
|
-
tailwindPackagePath: path.normalize(patcher.packageInfo.rootPath),
|
|
420
|
-
packageVersion: patcher.packageInfo.version,
|
|
421
|
-
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
422
|
-
source: options?.source ?? "cli",
|
|
423
|
-
tailwindcssBasedir: normalizedBase,
|
|
424
|
-
cwd: options?.cwd ? path.normalize(options.cwd) : normalizedBase,
|
|
425
|
-
patchVersion: WEAPP_TW_VERSION,
|
|
426
|
-
packageJsonPath: options?.packageJsonPath ?? location.packageJsonPath,
|
|
427
|
-
recordKey: options?.recordKey ?? location.recordKey
|
|
428
|
-
};
|
|
429
|
-
try {
|
|
430
|
-
await mkdir(path.dirname(recordPath), { recursive: true });
|
|
431
|
-
await writeFile(recordPath, `${JSON.stringify(record, null, 2)}\n`, "utf8");
|
|
432
|
-
return recordPath;
|
|
433
|
-
} catch (error) {
|
|
434
|
-
const baseDisplay = formatRelativeToBase(normalizedBase, process.cwd());
|
|
435
|
-
logger.warn("自动更新 Tailwind CSS 补丁记录失败,请在 %s 运行 \"weapp-tw patch --cwd %s\"。", baseDisplay, normalizedBase);
|
|
436
|
-
logger.debug("failed to persist patch target record %s: %O", recordPath, error);
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/tailwindcss/targets/recorder.ts
|
|
442
|
-
function findPatchTargetRecord(baseDir) {
|
|
443
|
-
const visited = /* @__PURE__ */ new Set();
|
|
444
|
-
const fallback = baseDir ?? process.cwd();
|
|
445
|
-
let current = path.resolve(fallback);
|
|
446
|
-
while (!visited.has(current)) {
|
|
447
|
-
const record = readPatchTargetRecord(current);
|
|
448
|
-
if (record) return record;
|
|
449
|
-
const parent = path.dirname(current);
|
|
450
|
-
if (parent === current) break;
|
|
451
|
-
visited.add(current);
|
|
452
|
-
current = parent;
|
|
453
|
-
}
|
|
312
|
+
if (relative.startsWith("..")) return normalized.replace(/\\/g, "/");
|
|
313
|
+
return path.join(".", relative).replace(/\\/g, "/");
|
|
454
314
|
}
|
|
455
|
-
function
|
|
456
|
-
if (!baseDir || !patcher?.packageInfo?.rootPath || options?.recordTarget === false) return;
|
|
457
|
-
const normalizedBase = path.normalize(baseDir);
|
|
458
|
-
const recorded = findPatchTargetRecord(normalizedBase);
|
|
459
|
-
const location = resolveRecordLocation(normalizedBase);
|
|
460
|
-
const expectedPath = path.normalize(patcher.packageInfo.rootPath);
|
|
461
|
-
let reason;
|
|
462
|
-
if (!recorded) reason = "missing";
|
|
463
|
-
else if (path.normalize(recorded.record.tailwindPackagePath) !== expectedPath) reason = "mismatch";
|
|
464
|
-
else if (path.normalize(recorded.path) !== path.normalize(location.recordPath) || !recorded.record.recordKey || recorded.record.recordKey !== location.recordKey) reason = "migrate";
|
|
465
|
-
else if (!recorded.record.patchVersion || recorded.record.patchVersion !== WEAPP_TW_VERSION) reason = "stale";
|
|
466
|
-
else if (options?.cwd && recorded.record.cwd && path.normalize(recorded.record.cwd) !== path.normalize(options.cwd)) reason = "metadata";
|
|
467
|
-
else if (!recorded.record.cwd && options?.cwd) reason = "metadata";
|
|
468
|
-
if (!(options?.alwaysRecord || !recorded || Boolean(reason))) return;
|
|
469
|
-
let message;
|
|
470
|
-
switch (reason) {
|
|
471
|
-
case "mismatch":
|
|
472
|
-
message = "检测到 Tailwind CSS 目标记录与当前解析结果不一致,正在自动重新 patch 并刷新缓存。";
|
|
473
|
-
break;
|
|
474
|
-
case "migrate":
|
|
475
|
-
case "stale":
|
|
476
|
-
message = "正在刷新当前子包的 Tailwind CSS 补丁记录,确保缓存隔离。";
|
|
477
|
-
break;
|
|
478
|
-
case "missing":
|
|
479
|
-
message = "未找到当前子包的 Tailwind CSS 目标记录,正在生成。";
|
|
480
|
-
break;
|
|
481
|
-
default: break;
|
|
482
|
-
}
|
|
483
|
-
const onPatched = async () => saveCliPatchTargetRecord(normalizedBase, patcher, {
|
|
484
|
-
cwd: options?.cwd ?? normalizedBase,
|
|
485
|
-
source: options?.source ?? "cli",
|
|
486
|
-
recordPath: location.recordPath,
|
|
487
|
-
recordKey: location.recordKey,
|
|
488
|
-
packageJsonPath: location.packageJsonPath
|
|
489
|
-
});
|
|
490
|
-
return {
|
|
491
|
-
recordPath: location.recordPath,
|
|
492
|
-
message,
|
|
493
|
-
reason,
|
|
494
|
-
onPatched
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
//#endregion
|
|
498
|
-
//#region src/tailwindcss/targets.ts
|
|
499
|
-
function logTailwindcssTarget(kind, patcher, baseDir) {
|
|
315
|
+
function logTailwindcssTarget(patcher, baseDir) {
|
|
500
316
|
const packageInfo = patcher?.packageInfo;
|
|
501
|
-
const label =
|
|
317
|
+
const label = "Weapp-tailwindcss";
|
|
502
318
|
if (!packageInfo?.rootPath) {
|
|
503
319
|
logger.warn("%s 未找到 Tailwind CSS 依赖,请检查在 %s 是否已安装 tailwindcss", label, baseDir ?? process.cwd());
|
|
504
320
|
return;
|
|
505
321
|
}
|
|
506
322
|
const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
|
|
507
323
|
const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
logger.info("%s 绑定 Tailwind CSS -> %s%s", label, displayPath, version);
|
|
324
|
+
logRuntimeTailwindcssTarget(baseDir, packageInfo.rootPath, packageInfo.version);
|
|
325
|
+
logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
|
|
513
326
|
}
|
|
514
327
|
//#endregion
|
|
515
328
|
//#region src/context/compiler-context-cache.ts
|
|
@@ -531,7 +344,7 @@ function withCircularGuard(value, stack, factory) {
|
|
|
531
344
|
}
|
|
532
345
|
function encodeTaggedValue(type, value) {
|
|
533
346
|
const record = { __type: type };
|
|
534
|
-
if (value !== void 0) record
|
|
347
|
+
if (value !== void 0) record["value"] = value;
|
|
535
348
|
return record;
|
|
536
349
|
}
|
|
537
350
|
function hasExplicitOptionBasedir(opts) {
|
|
@@ -539,7 +352,7 @@ function hasExplicitOptionBasedir(opts) {
|
|
|
539
352
|
}
|
|
540
353
|
function shouldProbeCallerLocation(opts) {
|
|
541
354
|
if (hasExplicitOptionBasedir(opts)) return false;
|
|
542
|
-
return !(process.env
|
|
355
|
+
return !(process.env["WEAPP_TAILWINDCSS_BASEDIR"] || process.env["WEAPP_TAILWINDCSS_BASE_DIR"] || process.env["TAILWINDCSS_BASEDIR"] || process.env["TAILWINDCSS_BASE_DIR"]);
|
|
543
356
|
}
|
|
544
357
|
function detectCallerLocation() {
|
|
545
358
|
const stack = (/* @__PURE__ */ new Error("compiler-context-cache stack probe")).stack;
|
|
@@ -559,19 +372,19 @@ function getRuntimeCacheScope(opts) {
|
|
|
559
372
|
const runtimeScope = {
|
|
560
373
|
caller: void 0,
|
|
561
374
|
cwd: process.cwd(),
|
|
562
|
-
init_cwd: process.env
|
|
563
|
-
npm_config_local_prefix: process.env
|
|
564
|
-
npm_package_json: process.env
|
|
565
|
-
pnpm_package_name: process.env
|
|
566
|
-
pwd: process.env
|
|
567
|
-
tailwindcss_base_dir: process.env
|
|
568
|
-
tailwindcss_basedir: process.env
|
|
569
|
-
uni_app_input_dir: process.env
|
|
570
|
-
uni_cli_root: process.env
|
|
571
|
-
uni_input_dir: process.env
|
|
572
|
-
uni_input_root: process.env
|
|
573
|
-
weapp_tailwindcss_base_dir: process.env
|
|
574
|
-
weapp_tailwindcss_basedir: process.env
|
|
375
|
+
init_cwd: process.env["INIT_CWD"],
|
|
376
|
+
npm_config_local_prefix: process.env["npm_config_local_prefix"],
|
|
377
|
+
npm_package_json: process.env["npm_package_json"],
|
|
378
|
+
pnpm_package_name: process.env["PNPM_PACKAGE_NAME"],
|
|
379
|
+
pwd: process.env["PWD"],
|
|
380
|
+
tailwindcss_base_dir: process.env["TAILWINDCSS_BASE_DIR"],
|
|
381
|
+
tailwindcss_basedir: process.env["TAILWINDCSS_BASEDIR"],
|
|
382
|
+
uni_app_input_dir: process.env["UNI_APP_INPUT_DIR"],
|
|
383
|
+
uni_cli_root: process.env["UNI_CLI_ROOT"],
|
|
384
|
+
uni_input_dir: process.env["UNI_INPUT_DIR"],
|
|
385
|
+
uni_input_root: process.env["UNI_INPUT_ROOT"],
|
|
386
|
+
weapp_tailwindcss_base_dir: process.env["WEAPP_TAILWINDCSS_BASE_DIR"],
|
|
387
|
+
weapp_tailwindcss_basedir: process.env["WEAPP_TAILWINDCSS_BASEDIR"]
|
|
575
388
|
};
|
|
576
389
|
if (shouldProbeCallerLocation(opts)) runtimeScope.caller = detectCallerLocation();
|
|
577
390
|
return runtimeScope;
|
|
@@ -714,6 +527,15 @@ function toCustomAttributesEntities(customAttributes) {
|
|
|
714
527
|
return Object.entries(customAttributes);
|
|
715
528
|
}
|
|
716
529
|
//#endregion
|
|
530
|
+
//#region src/constants.ts
|
|
531
|
+
const pluginName = "weapp-tailwindcss";
|
|
532
|
+
const vitePluginName = "weapp-tailwindcss:adaptor";
|
|
533
|
+
const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
534
|
+
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
535
|
+
"class-variance-authority": "@weapp-tailwindcss/cva",
|
|
536
|
+
"tailwind-variants": "@weapp-tailwindcss/variants"
|
|
537
|
+
};
|
|
538
|
+
//#endregion
|
|
717
539
|
//#region src/babel/index.ts
|
|
718
540
|
function _interopDefaultCompat(e) {
|
|
719
541
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
@@ -727,6 +549,7 @@ function buildFuzzyMatcher(fuzzyStrings) {
|
|
|
727
549
|
if (fuzzyStrings.length === 0) return;
|
|
728
550
|
if (fuzzyStrings.length === 1) {
|
|
729
551
|
const [needle] = fuzzyStrings;
|
|
552
|
+
if (needle === void 0) return;
|
|
730
553
|
return (value) => value.includes(needle);
|
|
731
554
|
}
|
|
732
555
|
const unique = [...new Set(fuzzyStrings)];
|
|
@@ -750,11 +573,13 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
750
573
|
const exactStringCount = exactStrings?.size ?? 0;
|
|
751
574
|
if (exactStringCount === 1 && regexList.length === 0) {
|
|
752
575
|
const [needle] = exactStrings;
|
|
576
|
+
if (needle === void 0) return NEVER_MATCH_NAME$1;
|
|
753
577
|
return (value) => value === needle;
|
|
754
578
|
}
|
|
755
579
|
if (regexList.length === 0) return (value) => exactStrings.has(value);
|
|
756
580
|
if (exactStringCount === 0 && regexList.length === 1) {
|
|
757
581
|
const [regex] = regexList;
|
|
582
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
758
583
|
return (value) => regex.test(value);
|
|
759
584
|
}
|
|
760
585
|
return (value) => {
|
|
@@ -767,6 +592,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
767
592
|
if (fuzzyMatcher && !hasRegex) return fuzzyMatcher;
|
|
768
593
|
if (!fuzzyMatcher && regexList.length === 1) {
|
|
769
594
|
const [regex] = regexList;
|
|
595
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
770
596
|
return (value) => regex.test(value);
|
|
771
597
|
}
|
|
772
598
|
return (value) => {
|
|
@@ -804,10 +630,10 @@ function replaceWxml(original, options = {
|
|
|
804
630
|
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
805
631
|
let res = original;
|
|
806
632
|
if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
|
|
807
|
-
res = escape(res, {
|
|
633
|
+
res = escape(res, omitUndefined({
|
|
808
634
|
map: escapeMap,
|
|
809
635
|
ignoreHead
|
|
810
|
-
});
|
|
636
|
+
}));
|
|
811
637
|
return res;
|
|
812
638
|
}
|
|
813
639
|
//#endregion
|
|
@@ -1345,6 +1171,44 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
1345
1171
|
}
|
|
1346
1172
|
}
|
|
1347
1173
|
//#endregion
|
|
1174
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
1175
|
+
function _typeof(o) {
|
|
1176
|
+
"@babel/helpers - typeof";
|
|
1177
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
1178
|
+
return typeof o;
|
|
1179
|
+
} : function(o) {
|
|
1180
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1181
|
+
}, _typeof(o);
|
|
1182
|
+
}
|
|
1183
|
+
//#endregion
|
|
1184
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
1185
|
+
function toPrimitive(t, r) {
|
|
1186
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
1187
|
+
var e = t[Symbol.toPrimitive];
|
|
1188
|
+
if (void 0 !== e) {
|
|
1189
|
+
var i = e.call(t, r || "default");
|
|
1190
|
+
if ("object" != _typeof(i)) return i;
|
|
1191
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1192
|
+
}
|
|
1193
|
+
return ("string" === r ? String : Number)(t);
|
|
1194
|
+
}
|
|
1195
|
+
//#endregion
|
|
1196
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
1197
|
+
function toPropertyKey(t) {
|
|
1198
|
+
var i = toPrimitive(t, "string");
|
|
1199
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
1200
|
+
}
|
|
1201
|
+
//#endregion
|
|
1202
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
1203
|
+
function _defineProperty(e, r, t) {
|
|
1204
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1205
|
+
value: t,
|
|
1206
|
+
enumerable: !0,
|
|
1207
|
+
configurable: !0,
|
|
1208
|
+
writable: !0
|
|
1209
|
+
}) : e[r] = t, e;
|
|
1210
|
+
}
|
|
1211
|
+
//#endregion
|
|
1348
1212
|
//#region src/js/JsTokenUpdater.ts
|
|
1349
1213
|
/**
|
|
1350
1214
|
* Lightweight helper that batches updates to {@link MagicString}.
|
|
@@ -1353,6 +1217,7 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
1353
1217
|
*/
|
|
1354
1218
|
var JsTokenUpdater = class {
|
|
1355
1219
|
constructor({ value } = {}) {
|
|
1220
|
+
_defineProperty(this, "tokens", void 0);
|
|
1356
1221
|
this.tokens = value ? [...value] : [];
|
|
1357
1222
|
}
|
|
1358
1223
|
addToken(token) {
|
|
@@ -1386,7 +1251,7 @@ var JsTokenUpdater = class {
|
|
|
1386
1251
|
var IgnoredExportsTracker = class {
|
|
1387
1252
|
constructor(options) {
|
|
1388
1253
|
this.options = options;
|
|
1389
|
-
this
|
|
1254
|
+
_defineProperty(this, "ignoredExportNames", /* @__PURE__ */ new Map());
|
|
1390
1255
|
}
|
|
1391
1256
|
addIgnoredExport(filename, exportName) {
|
|
1392
1257
|
if (!exportName) return;
|
|
@@ -1505,8 +1370,16 @@ var IgnoredExportsTracker = class {
|
|
|
1505
1370
|
//#region src/js/ModuleGraph.ts
|
|
1506
1371
|
var JsModuleGraph = class {
|
|
1507
1372
|
constructor(entry, graphOptions) {
|
|
1508
|
-
this
|
|
1509
|
-
this
|
|
1373
|
+
_defineProperty(this, "modules", /* @__PURE__ */ new Map());
|
|
1374
|
+
_defineProperty(this, "queue", []);
|
|
1375
|
+
_defineProperty(this, "resolve", void 0);
|
|
1376
|
+
_defineProperty(this, "load", void 0);
|
|
1377
|
+
_defineProperty(this, "filter", void 0);
|
|
1378
|
+
_defineProperty(this, "maxDepth", void 0);
|
|
1379
|
+
_defineProperty(this, "baseOptions", void 0);
|
|
1380
|
+
_defineProperty(this, "parserOptions", void 0);
|
|
1381
|
+
_defineProperty(this, "rootFilename", void 0);
|
|
1382
|
+
_defineProperty(this, "ignoredExports", void 0);
|
|
1510
1383
|
this.resolve = graphOptions.resolve;
|
|
1511
1384
|
this.load = graphOptions.load;
|
|
1512
1385
|
this.filter = graphOptions.filter;
|
|
@@ -1678,6 +1551,12 @@ const NEVER_MATCH_NAME = () => false;
|
|
|
1678
1551
|
*/
|
|
1679
1552
|
var NodePathWalker = class {
|
|
1680
1553
|
constructor({ ignoreCallExpressionIdentifiers, callback } = {}) {
|
|
1554
|
+
_defineProperty(this, "ignoreCallExpressionIdentifiers", void 0);
|
|
1555
|
+
_defineProperty(this, "callback", void 0);
|
|
1556
|
+
_defineProperty(this, "isIgnoredCallIdentifier", void 0);
|
|
1557
|
+
_defineProperty(this, "hasIgnoredCallIdentifiers", void 0);
|
|
1558
|
+
_defineProperty(this, "importsStore", void 0);
|
|
1559
|
+
_defineProperty(this, "visitedStore", void 0);
|
|
1681
1560
|
this.hasIgnoredCallIdentifiers = Boolean(ignoreCallExpressionIdentifiers && ignoreCallExpressionIdentifiers.length > 0);
|
|
1682
1561
|
this.ignoreCallExpressionIdentifiers = ignoreCallExpressionIdentifiers ?? EMPTY_IGNORE_CALL_EXPRESSION_IDENTIFIERS;
|
|
1683
1562
|
this.callback = callback ?? NOOP_STRING_PATH_CALLBACK;
|
|
@@ -1940,7 +1819,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1940
1819
|
const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
|
|
1941
1820
|
const ignoredPaths = needScope ? /* @__PURE__ */ new WeakSet() : EMPTY_IGNORED_PATHS;
|
|
1942
1821
|
const walker = needScope ? new NodePathWalker({
|
|
1943
|
-
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
1822
|
+
...options.ignoreCallExpressionIdentifiers === void 0 ? {} : { ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers },
|
|
1944
1823
|
callback(path) {
|
|
1945
1824
|
ignoredPaths.add(path);
|
|
1946
1825
|
}
|
|
@@ -1950,7 +1829,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1950
1829
|
function getTaggedTemplateIgnore() {
|
|
1951
1830
|
if (!taggedTemplateIgnore) taggedTemplateIgnore = createTaggedTemplateIgnore({
|
|
1952
1831
|
matcher: getIgnoredTaggedTemplateMatcher(options),
|
|
1953
|
-
names: options.ignoreTaggedTemplateExpressionIdentifiers
|
|
1832
|
+
...options.ignoreTaggedTemplateExpressionIdentifiers === void 0 ? {} : { names: options.ignoreTaggedTemplateExpressionIdentifiers }
|
|
1954
1833
|
});
|
|
1955
1834
|
return taggedTemplateIgnore;
|
|
1956
1835
|
}
|
|
@@ -2104,7 +1983,6 @@ function getOptionsFingerprint(options) {
|
|
|
2104
1983
|
options.uniAppX ? "1" : "0",
|
|
2105
1984
|
options.wrapExpression ? "1" : "0",
|
|
2106
1985
|
String(options.tailwindcssMajorVersion ?? ""),
|
|
2107
|
-
String(options.staleClassNameFallback ?? ""),
|
|
2108
1986
|
String(options.jsArbitraryValueFallback ?? ""),
|
|
2109
1987
|
JSON.stringify(options.arbitraryValues ?? null),
|
|
2110
1988
|
JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
|
|
@@ -2128,7 +2006,6 @@ function shouldCacheJsResult(rawSource, options) {
|
|
|
2128
2006
|
function createJsHandler(options) {
|
|
2129
2007
|
const defaults = {
|
|
2130
2008
|
escapeMap: options.escapeMap,
|
|
2131
|
-
staleClassNameFallback: options.staleClassNameFallback,
|
|
2132
2009
|
jsArbitraryValueFallback: options.jsArbitraryValueFallback,
|
|
2133
2010
|
tailwindcssMajorVersion: options.tailwindcssMajorVersion,
|
|
2134
2011
|
arbitraryValues: options.arbitraryValues,
|
|
@@ -2290,11 +2167,7 @@ function generateCode(match, options = {}) {
|
|
|
2290
2167
|
const initial = jsHandler(match, runtimeSet, wrapExpression ? WRAP_EXPRESSION_HANDLER_OPTIONS : void 0);
|
|
2291
2168
|
if (!initial.error || wrapExpression) return initial.code;
|
|
2292
2169
|
return jsHandler(match, runtimeSet, WRAP_EXPRESSION_HANDLER_OPTIONS).code;
|
|
2293
|
-
} else
|
|
2294
|
-
/**
|
|
2295
|
-
* @deprecated
|
|
2296
|
-
*/
|
|
2297
|
-
return rewriteLegacyExpression(match, options);
|
|
2170
|
+
} else return rewriteLegacyExpression(match, options);
|
|
2298
2171
|
} catch {
|
|
2299
2172
|
return match;
|
|
2300
2173
|
}
|
|
@@ -2323,6 +2196,13 @@ function isAllWhitespace(value) {
|
|
|
2323
2196
|
//#region src/wxml/Tokenizer.ts
|
|
2324
2197
|
var Tokenizer = class {
|
|
2325
2198
|
constructor() {
|
|
2199
|
+
_defineProperty(this, "state", void 0);
|
|
2200
|
+
_defineProperty(this, "buffer", void 0);
|
|
2201
|
+
_defineProperty(this, "tokens", void 0);
|
|
2202
|
+
_defineProperty(this, "bufferStartIndex", void 0);
|
|
2203
|
+
_defineProperty(this, "expressionStartIndex", void 0);
|
|
2204
|
+
_defineProperty(this, "expressionBuffer", void 0);
|
|
2205
|
+
_defineProperty(this, "expressions", void 0);
|
|
2326
2206
|
this.reset();
|
|
2327
2207
|
}
|
|
2328
2208
|
processChar(char, index) {
|
|
@@ -2413,6 +2293,7 @@ var Tokenizer = class {
|
|
|
2413
2293
|
this.reset();
|
|
2414
2294
|
for (let i = 0; i < input.length; i++) {
|
|
2415
2295
|
const char = input[i];
|
|
2296
|
+
if (char === void 0) continue;
|
|
2416
2297
|
this.processChar(char, i);
|
|
2417
2298
|
}
|
|
2418
2299
|
if (this.buffer.length > 0) this.tokens.push({
|
|
@@ -2475,6 +2356,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
2475
2356
|
}
|
|
2476
2357
|
if (tokens.length > 0) {
|
|
2477
2358
|
const lastToken = tokens[tokens.length - 1];
|
|
2359
|
+
if (!lastToken) return;
|
|
2478
2360
|
if (lastToken.end < ms.original.length) updateWhitespaceGap(ms, lastToken.end, ms.original.length, options);
|
|
2479
2361
|
}
|
|
2480
2362
|
}
|
|
@@ -2549,7 +2431,7 @@ async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
|
2549
2431
|
}, { xmlMode: true });
|
|
2550
2432
|
parser.write(rawSource);
|
|
2551
2433
|
parser.end();
|
|
2552
|
-
for (const { data, endIndex, startIndex } of wxsArray ?? []) {
|
|
2434
|
+
if (jsHandler) for (const { data, endIndex, startIndex } of wxsArray ?? []) {
|
|
2553
2435
|
const { code } = await jsHandler(data, runtimeSet);
|
|
2554
2436
|
if (code !== data) getMagicString().update(startIndex, endIndex, code);
|
|
2555
2437
|
}
|
|
@@ -2588,7 +2470,7 @@ function resolveRuntimePackageReplacements(option) {
|
|
|
2588
2470
|
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
2589
2471
|
}
|
|
2590
2472
|
function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
|
|
2591
|
-
const { cssPreflight, cssPreflightRange, escapeMap, cssChildCombinatorReplaceValue, injectAdditionalCssVarScope, cssSelectorReplacement, rem2rpx, postcssOptions, cssRemoveProperty, cssRemoveHoverPseudoClass, cssPresetEnv, autoprefixer, uniAppX, px2rpx, unitsToPx, arbitraryValues, jsPreserveClass,
|
|
2473
|
+
const { cssPreflight, cssPreflightRange, escapeMap, cssChildCombinatorReplaceValue, injectAdditionalCssVarScope, cssSelectorReplacement, rem2rpx, postcssOptions, cssRemoveProperty, cssRemoveHoverPseudoClass, cssPresetEnv, autoprefixer, uniAppX, px2rpx, unitsToPx, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
|
|
2592
2474
|
const uniAppXEnabled = isUniAppXEnabled(uniAppX);
|
|
2593
2475
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
2594
2476
|
const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
|
|
@@ -2616,7 +2498,6 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
2616
2498
|
escapeMap,
|
|
2617
2499
|
arbitraryValues,
|
|
2618
2500
|
jsPreserveClass,
|
|
2619
|
-
staleClassNameFallback,
|
|
2620
2501
|
jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
|
|
2621
2502
|
tailwindcssMajorVersion,
|
|
2622
2503
|
generateMap: true,
|
|
@@ -2684,9 +2565,10 @@ function createInternalCompilerContext(opts) {
|
|
|
2684
2565
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
2685
2566
|
applyLoggerLevel(ctx.logLevel);
|
|
2686
2567
|
const twPatcher = createTailwindcssPatcherFromContext(ctx);
|
|
2687
|
-
logTailwindcssTarget(
|
|
2568
|
+
logTailwindcssTarget(twPatcher, ctx.tailwindcssBasedir);
|
|
2688
2569
|
logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, twPatcher.packageInfo?.rootPath, twPatcher.packageInfo?.version);
|
|
2689
|
-
warnMissingCssEntries(ctx, twPatcher);
|
|
2570
|
+
if (opts?.__internalDeferMissingCssEntriesWarning !== true) warnMissingCssEntries(ctx, twPatcher);
|
|
2571
|
+
ctx.cssPreflight = resolveDefaultCssPreflight(opts?.cssPreflight, twPatcher.majorVersion);
|
|
2690
2572
|
const cssCalcOptions = applyV4CssCalcDefaults(ctx.cssCalc, twPatcher);
|
|
2691
2573
|
ctx.cssCalc = cssCalcOptions;
|
|
2692
2574
|
const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, twPatcher.majorVersion);
|
|
@@ -2712,9 +2594,9 @@ function createInternalCompilerContext(opts) {
|
|
|
2712
2594
|
return ctx;
|
|
2713
2595
|
}
|
|
2714
2596
|
/**
|
|
2715
|
-
*
|
|
2597
|
+
* 获取用户定义选项的内部表示,并初始化相关的处理程序和 Tailwind 运行时。
|
|
2716
2598
|
* @param opts - 用户定义的选项,可选。
|
|
2717
|
-
* @returns 返回一个包含内部用户定义选项的对象,包括样式、JS和模板处理程序,以及Tailwind CSS
|
|
2599
|
+
* @returns 返回一个包含内部用户定义选项的对象,包括样式、JS 和模板处理程序,以及 Tailwind CSS 运行时。
|
|
2718
2600
|
*/
|
|
2719
2601
|
function getCompilerContext(opts) {
|
|
2720
2602
|
return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
|
|
@@ -2734,7 +2616,7 @@ const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+f
|
|
|
2734
2616
|
* @returns 如果可以跳过转换返回 `true`,否则返回 `false`
|
|
2735
2617
|
*/
|
|
2736
2618
|
function shouldSkipJsTransform(rawSource, options) {
|
|
2737
|
-
if (process.env
|
|
2619
|
+
if (process.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
|
|
2738
2620
|
if (!rawSource) return true;
|
|
2739
2621
|
if (options?.alwaysEscape) return false;
|
|
2740
2622
|
if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
|
|
@@ -2743,21 +2625,4 @@ function shouldSkipJsTransform(rawSource, options) {
|
|
|
2743
2625
|
return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
|
|
2744
2626
|
}
|
|
2745
2627
|
//#endregion
|
|
2746
|
-
|
|
2747
|
-
function setupPatchRecorder(patcher, baseDir, options) {
|
|
2748
|
-
const recorder = createPatchTargetRecorder(baseDir, patcher, options);
|
|
2749
|
-
if (recorder?.message && options?.logMessage !== false) {
|
|
2750
|
-
const prefix = options?.messagePrefix ? `${options.messagePrefix} ` : "";
|
|
2751
|
-
logger$1.info("%s%s", prefix, recorder.message);
|
|
2752
|
-
}
|
|
2753
|
-
const onPatchCompleted = recorder?.onPatched ? async () => {
|
|
2754
|
-
await recorder.onPatched();
|
|
2755
|
-
} : void 0;
|
|
2756
|
-
return {
|
|
2757
|
-
recorder,
|
|
2758
|
-
patchPromise: patcher ? createTailwindPatchPromise(patcher, onPatchCompleted) : Promise.resolve(),
|
|
2759
|
-
onPatchCompleted
|
|
2760
|
-
};
|
|
2761
|
-
}
|
|
2762
|
-
//#endregion
|
|
2763
|
-
export { refreshTailwindRuntimeState as _, createAttributeMatcher as a, isClassContextLiteralPath as c, traverse as d, toCustomAttributesEntities as f, ensureRuntimeClassSet as g, collectRuntimeClassSet as h, generateCode as i, replaceWxml as l, vitePluginName as m, shouldSkipJsTransform as n, analyzeSource as o, pluginName as p, getCompilerContext as r, JsTokenUpdater as s, setupPatchRecorder as t, babelParse as u, createDebug as v };
|
|
2628
|
+
export { ensureRuntimeClassSet as _, analyzeSource as a, isClassContextLiteralPath as c, traverse as d, pluginName as f, createTailwindRuntimeReadyPromise as g, collectRuntimeClassSet as h, createAttributeMatcher as i, replaceWxml as l, toCustomAttributesEntities as m, getCompilerContext as n, JsTokenUpdater as o, vitePluginName as p, generateCode as r, _defineProperty as s, shouldSkipJsTransform as t, babelParse as u, refreshTailwindRuntimeState as v };
|