weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/bundle-state-BnV8o2Yn.js +530 -0
- package/dist/bundle-state-CLnuf2CW.mjs +414 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
- package/dist/bundlers/shared/generator-css.d.ts +16 -22
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
- package/dist/bundlers/vite/source-candidates.d.ts +16 -1
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +605 -611
- package/dist/cli.mjs +614 -620
- package/dist/constants.d.ts +1 -2
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +3 -2
- package/dist/css-macro/postcss.mjs +3 -2
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults-B1igPF_e.mjs +150 -0
- package/dist/defaults-IHhYxNeU.js +193 -0
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +6 -131
- package/dist/defaults.mjs +2 -129
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +9 -8
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-B4RNgMLx.js +55 -0
- package/dist/generator-DvyhmC76.mjs +32 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +185 -47
- package/dist/gulp.mjs +179 -41
- package/dist/incremental-runtime-class-set-C7Q7fC5u.mjs +1863 -0
- package/dist/incremental-runtime-class-set-DZsbM0-a.js +1926 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/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-CFa6-qO9.js +237 -0
- package/dist/postcss-Drpy7j-g.mjs +228 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/{recorder-gYSNLfOP.js → precheck-8pQbjqpq.js} +218 -314
- package/dist/{recorder-zsgatmkB.mjs → precheck-D1O5AWzy.mjs} +186 -281
- package/dist/presets.js +13 -11
- package/dist/presets.mjs +11 -9
- package/dist/reset.d.ts +1 -0
- package/dist/runtime-registry-CdCV3Opt.js +5496 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-CUTNdsiz.js +222 -0
- package/dist/source-candidates-CnD4vyic.mjs +209 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-B_JAdOQf.mjs +600 -0
- package/dist/tailwindcss-whZE3HpL.js +651 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +51 -48
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +23 -23
- package/dist/types/user-defined-options/important.d.ts +31 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
- package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
- package/dist/v3-engine-CCwvhRrQ.js +3473 -0
- package/dist/v3-engine-DyIcbpZm.mjs +3190 -0
- package/dist/{vite-CrlzCNqz.mjs → vite-B8IiXgVD.mjs} +1256 -1088
- package/dist/vite-BcnwgJMt.js +2368 -0
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +4533 -16
- package/dist/weapp-tw-runtime-classset-loader.js +33 -7
- package/dist/webpack-C4zI624R.js +846 -0
- package/dist/webpack-DTkshAtp.mjs +836 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +27 -37
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
- package/dist/generator-css-B5ejWUMv.mjs +0 -1098
- package/dist/generator-css-D3OdPRiS.js +0 -1125
- package/dist/generator-mmhXzZnv.js +0 -1276
- package/dist/js/syntax.d.ts +0 -10
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
- package/dist/loader-anchors-CNkWT8hx.js +0 -273
- package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/vite-BC9U7ahn.js +0 -2199
- package/dist/webpack-Bu6M-Hbw.mjs +0 -441
- package/dist/webpack-DD7A6V0u.js +0 -456
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
- /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
- /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getDefaultOptions } from "./defaults.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { B as createDebug, C as createTailwindV4Engine, G as omitUndefined, c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, s as ensureTailwindcssRuntimePatch, u as getRuntimeClassSetSignatureWithSources, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-DyIcbpZm.mjs";
|
|
2
|
+
import { a as resolveDefaultCssPreflight, i as getDefaultOptions, o as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, s as HARD_PARSE_CACHE_MAX_ENTRIES } from "./defaults-B1igPF_e.mjs";
|
|
3
|
+
import { i as isMap, n as defuOverrideArray } from "./utils-CGBVVNm6.mjs";
|
|
4
|
+
import { a as applyV4CssCalcDefaults, i as resolveUniAppXOptions, o as warnMissingCssEntries, r as isUniAppXEnabled, t as createTailwindcssPatcherFromContext } from "./tailwindcss-B_JAdOQf.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
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
7
|
import { logger, pc } from "@weapp-tailwindcss/logger";
|
|
8
|
+
import { rm } from "node:fs/promises";
|
|
9
|
+
import { createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
10
|
+
import { Buffer } from "node:buffer";
|
|
11
11
|
import { LRUCache } from "lru-cache";
|
|
12
12
|
import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
|
|
13
13
|
import { MappingChars2String, escape } from "@weapp-core/escape";
|
|
14
|
-
import _createDebug from "debug";
|
|
15
14
|
import _babelTraverse from "@babel/traverse";
|
|
16
15
|
import { parse, parseExpression } from "@babel/parser";
|
|
17
16
|
import { escapeStringRegexp } from "@weapp-core/regex";
|
|
@@ -102,33 +101,13 @@ function initializeCache(cacheConfig) {
|
|
|
102
101
|
return cacheConfig;
|
|
103
102
|
}
|
|
104
103
|
//#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
104
|
//#region src/tailwindcss/runtime.ts
|
|
122
105
|
const debug$1 = createDebug("[tailwindcss:runtime] ");
|
|
123
106
|
const refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
|
|
124
|
-
function
|
|
125
|
-
return Promise.resolve(
|
|
107
|
+
function createTailwindRuntimeReadyPromise(twPatcher) {
|
|
108
|
+
return Promise.resolve().then(async () => {
|
|
109
|
+
await ensureTailwindcssRuntimePatch(twPatcher);
|
|
126
110
|
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
111
|
});
|
|
133
112
|
}
|
|
134
113
|
const runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -146,14 +125,14 @@ async function refreshTailwindRuntimeState(state, forceOrOptions) {
|
|
|
146
125
|
const clearCache = normalizedOptions.clearCache === true;
|
|
147
126
|
if (!force) return false;
|
|
148
127
|
debug$1("refresh runtime state start, clearCache=%s major=%s", clearCache, state.twPatcher.majorVersion ?? "unknown");
|
|
149
|
-
await state.
|
|
128
|
+
await state.readyPromise;
|
|
150
129
|
let refreshed = false;
|
|
151
130
|
if (typeof state.refreshTailwindcssPatcher === "function") {
|
|
152
131
|
const next = await state.refreshTailwindcssPatcher({ clearCache });
|
|
153
132
|
if (next !== state.twPatcher) state.twPatcher = next;
|
|
154
133
|
refreshed = true;
|
|
155
134
|
}
|
|
156
|
-
if (refreshed) state.
|
|
135
|
+
if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(state.twPatcher);
|
|
157
136
|
debug$1("refresh runtime state end, refreshed=%s major=%s", refreshed, state.twPatcher.majorVersion ?? "unknown");
|
|
158
137
|
return refreshed;
|
|
159
138
|
}
|
|
@@ -166,9 +145,9 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
166
145
|
force: true,
|
|
167
146
|
clearCache
|
|
168
147
|
});
|
|
169
|
-
await state.
|
|
148
|
+
await state.readyPromise;
|
|
170
149
|
const entry = getRuntimeClassSetStateEntry(state);
|
|
171
|
-
const signature =
|
|
150
|
+
const signature = await getRuntimeClassSetSignatureWithSources(state.twPatcher);
|
|
172
151
|
const signatureChanged = entry.signature !== signature;
|
|
173
152
|
const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
|
|
174
153
|
if (!shouldForceCollect) {
|
|
@@ -186,7 +165,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
186
165
|
force: true,
|
|
187
166
|
clearCache: true
|
|
188
167
|
});
|
|
189
|
-
await state.
|
|
168
|
+
await state.readyPromise;
|
|
190
169
|
return collectRuntimeClassSet(state.twPatcher, {
|
|
191
170
|
force: true,
|
|
192
171
|
skipRefresh: true,
|
|
@@ -197,7 +176,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
197
176
|
try {
|
|
198
177
|
const runtimeSet = await task;
|
|
199
178
|
entry.value = runtimeSet;
|
|
200
|
-
entry.signature =
|
|
179
|
+
entry.signature = await getRuntimeClassSetSignatureWithSources(state.twPatcher);
|
|
201
180
|
return runtimeSet;
|
|
202
181
|
} finally {
|
|
203
182
|
if (entry.promise === task) entry.promise = void 0;
|
|
@@ -222,6 +201,19 @@ function tryGetRuntimeClassSetSync(twPatcher) {
|
|
|
222
201
|
return;
|
|
223
202
|
}
|
|
224
203
|
}
|
|
204
|
+
async function collectTailwindV4GeneratorClassSet(twPatcher) {
|
|
205
|
+
try {
|
|
206
|
+
const generated = await createTailwindV4Engine(await resolveTailwindV4SourceFromPatcher(twPatcher)).generate({
|
|
207
|
+
scanSources: true,
|
|
208
|
+
target: "tailwind"
|
|
209
|
+
});
|
|
210
|
+
debug$1("runtime class set resolved via tailwindcss v4 generator source scan, size=%d", generated.classSet.size);
|
|
211
|
+
return generated.classSet;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
debug$1("tailwindcss v4 generator source scan failed, continuing fallback chain: %O", error);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
225
217
|
async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
226
218
|
let activePatcher = twPatcher;
|
|
227
219
|
if (options.force && !options.skipRefresh) {
|
|
@@ -234,12 +226,13 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
234
226
|
}
|
|
235
227
|
}
|
|
236
228
|
const entry = getRuntimeClassSetCacheEntry(activePatcher);
|
|
237
|
-
const signature =
|
|
229
|
+
const signature = await getRuntimeClassSetSignatureWithSources(activePatcher);
|
|
238
230
|
if (!options.force) {
|
|
239
231
|
if (entry.value && entry.signature === signature) return entry.value;
|
|
240
232
|
if (entry.promise) return entry.promise;
|
|
241
233
|
} else entry.value = void 0;
|
|
242
234
|
const task = (async () => {
|
|
235
|
+
await ensureTailwindcssRuntimePatch(activePatcher);
|
|
243
236
|
const preExtractSyncSet = options.force ? tryGetRuntimeClassSetSync(activePatcher) : void 0;
|
|
244
237
|
if (preExtractSyncSet) debug$1("runtime class set snapshot via getClassSetSync() before extract(), size=%d", preExtractSyncSet.size);
|
|
245
238
|
const preferExtract = options.force === true;
|
|
@@ -250,12 +243,20 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
250
243
|
debug$1("runtime class set resolved via extract(), size=%d", result.classSet.size);
|
|
251
244
|
return result.classSet;
|
|
252
245
|
}
|
|
253
|
-
if (preferExtract
|
|
246
|
+
if (preferExtract && activePatcher.majorVersion !== 4) {
|
|
247
|
+
debug$1("runtime class set resolved via empty extract() on force collect, size=0");
|
|
248
|
+
return result.classSet;
|
|
249
|
+
}
|
|
250
|
+
if (preferExtract) debug$1("runtime class set from extract() is empty on force collect, fallback to generator/sync/async class set");
|
|
254
251
|
else debug$1("runtime class set from extract() is empty, fallback to sync/async class set");
|
|
255
252
|
}
|
|
256
253
|
} catch (error) {
|
|
257
254
|
debug$1("extract() failed, fallback to getClassSet(): %O", error);
|
|
258
255
|
}
|
|
256
|
+
if (activePatcher.majorVersion === 4) {
|
|
257
|
+
const generatorClassSet = await collectTailwindV4GeneratorClassSet(activePatcher);
|
|
258
|
+
if (generatorClassSet && generatorClassSet.size > 0) return generatorClassSet;
|
|
259
|
+
}
|
|
259
260
|
if (preExtractSyncSet) {
|
|
260
261
|
debug$1("runtime class set fallback to pre-extract sync snapshot, size=%d", preExtractSyncSet.size);
|
|
261
262
|
return preExtractSyncSet;
|
|
@@ -319,197 +320,29 @@ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
|
|
|
319
320
|
return;
|
|
320
321
|
}
|
|
321
322
|
if (!markRuntimeLog("missing", baseDir, rootPath, version)) return;
|
|
322
|
-
logger.warn(`${pc.cyanBright("Tailwind CSS")}
|
|
323
|
+
logger.warn(`${pc.cyanBright("Tailwind CSS")} 未安装,已跳过版本检测与运行时初始化。`);
|
|
323
324
|
}
|
|
324
325
|
//#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
|
-
}
|
|
326
|
+
//#region src/tailwindcss/targets.ts
|
|
332
327
|
function formatRelativeToBase(targetPath, baseDir) {
|
|
333
|
-
|
|
334
|
-
|
|
328
|
+
const normalized = path.normalize(targetPath);
|
|
329
|
+
if (!baseDir) return normalized.replace(/\\/g, "/");
|
|
330
|
+
const relative = path.relative(baseDir, normalized);
|
|
335
331
|
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.2";
|
|
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
|
-
}
|
|
454
|
-
}
|
|
455
|
-
function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
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
|
-
};
|
|
332
|
+
if (relative.startsWith("..")) return normalized.replace(/\\/g, "/");
|
|
333
|
+
return path.join(".", relative).replace(/\\/g, "/");
|
|
496
334
|
}
|
|
497
|
-
|
|
498
|
-
//#region src/tailwindcss/targets.ts
|
|
499
|
-
function logTailwindcssTarget(kind, patcher, baseDir) {
|
|
335
|
+
function logTailwindcssTarget(patcher, baseDir) {
|
|
500
336
|
const packageInfo = patcher?.packageInfo;
|
|
501
|
-
const label =
|
|
337
|
+
const label = "Weapp-tailwindcss";
|
|
502
338
|
if (!packageInfo?.rootPath) {
|
|
503
339
|
logger.warn("%s 未找到 Tailwind CSS 依赖,请检查在 %s 是否已安装 tailwindcss", label, baseDir ?? process.cwd());
|
|
504
340
|
return;
|
|
505
341
|
}
|
|
506
342
|
const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
|
|
507
343
|
const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
logger.info("%s 绑定 Tailwind CSS -> %s%s", label, displayPath, version);
|
|
344
|
+
logRuntimeTailwindcssTarget(baseDir, packageInfo.rootPath, packageInfo.version);
|
|
345
|
+
logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
|
|
513
346
|
}
|
|
514
347
|
//#endregion
|
|
515
348
|
//#region src/context/compiler-context-cache.ts
|
|
@@ -531,7 +364,7 @@ function withCircularGuard(value, stack, factory) {
|
|
|
531
364
|
}
|
|
532
365
|
function encodeTaggedValue(type, value) {
|
|
533
366
|
const record = { __type: type };
|
|
534
|
-
if (value !== void 0) record
|
|
367
|
+
if (value !== void 0) record["value"] = value;
|
|
535
368
|
return record;
|
|
536
369
|
}
|
|
537
370
|
function hasExplicitOptionBasedir(opts) {
|
|
@@ -539,7 +372,7 @@ function hasExplicitOptionBasedir(opts) {
|
|
|
539
372
|
}
|
|
540
373
|
function shouldProbeCallerLocation(opts) {
|
|
541
374
|
if (hasExplicitOptionBasedir(opts)) return false;
|
|
542
|
-
return !(process.env
|
|
375
|
+
return !(process.env["WEAPP_TAILWINDCSS_BASEDIR"] || process.env["WEAPP_TAILWINDCSS_BASE_DIR"] || process.env["TAILWINDCSS_BASEDIR"] || process.env["TAILWINDCSS_BASE_DIR"]);
|
|
543
376
|
}
|
|
544
377
|
function detectCallerLocation() {
|
|
545
378
|
const stack = (/* @__PURE__ */ new Error("compiler-context-cache stack probe")).stack;
|
|
@@ -559,19 +392,19 @@ function getRuntimeCacheScope(opts) {
|
|
|
559
392
|
const runtimeScope = {
|
|
560
393
|
caller: void 0,
|
|
561
394
|
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
|
|
395
|
+
init_cwd: process.env["INIT_CWD"],
|
|
396
|
+
npm_config_local_prefix: process.env["npm_config_local_prefix"],
|
|
397
|
+
npm_package_json: process.env["npm_package_json"],
|
|
398
|
+
pnpm_package_name: process.env["PNPM_PACKAGE_NAME"],
|
|
399
|
+
pwd: process.env["PWD"],
|
|
400
|
+
tailwindcss_base_dir: process.env["TAILWINDCSS_BASE_DIR"],
|
|
401
|
+
tailwindcss_basedir: process.env["TAILWINDCSS_BASEDIR"],
|
|
402
|
+
uni_app_input_dir: process.env["UNI_APP_INPUT_DIR"],
|
|
403
|
+
uni_cli_root: process.env["UNI_CLI_ROOT"],
|
|
404
|
+
uni_input_dir: process.env["UNI_INPUT_DIR"],
|
|
405
|
+
uni_input_root: process.env["UNI_INPUT_ROOT"],
|
|
406
|
+
weapp_tailwindcss_base_dir: process.env["WEAPP_TAILWINDCSS_BASE_DIR"],
|
|
407
|
+
weapp_tailwindcss_basedir: process.env["WEAPP_TAILWINDCSS_BASEDIR"]
|
|
575
408
|
};
|
|
576
409
|
if (shouldProbeCallerLocation(opts)) runtimeScope.caller = detectCallerLocation();
|
|
577
410
|
return runtimeScope;
|
|
@@ -714,6 +547,15 @@ function toCustomAttributesEntities(customAttributes) {
|
|
|
714
547
|
return Object.entries(customAttributes);
|
|
715
548
|
}
|
|
716
549
|
//#endregion
|
|
550
|
+
//#region src/constants.ts
|
|
551
|
+
const pluginName = "weapp-tailwindcss";
|
|
552
|
+
const vitePluginName = "weapp-tailwindcss:adaptor";
|
|
553
|
+
const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
554
|
+
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
555
|
+
"class-variance-authority": "@weapp-tailwindcss/cva",
|
|
556
|
+
"tailwind-variants": "@weapp-tailwindcss/variants"
|
|
557
|
+
};
|
|
558
|
+
//#endregion
|
|
717
559
|
//#region src/babel/index.ts
|
|
718
560
|
function _interopDefaultCompat(e) {
|
|
719
561
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
@@ -727,6 +569,7 @@ function buildFuzzyMatcher(fuzzyStrings) {
|
|
|
727
569
|
if (fuzzyStrings.length === 0) return;
|
|
728
570
|
if (fuzzyStrings.length === 1) {
|
|
729
571
|
const [needle] = fuzzyStrings;
|
|
572
|
+
if (needle === void 0) return;
|
|
730
573
|
return (value) => value.includes(needle);
|
|
731
574
|
}
|
|
732
575
|
const unique = [...new Set(fuzzyStrings)];
|
|
@@ -750,11 +593,13 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
750
593
|
const exactStringCount = exactStrings?.size ?? 0;
|
|
751
594
|
if (exactStringCount === 1 && regexList.length === 0) {
|
|
752
595
|
const [needle] = exactStrings;
|
|
596
|
+
if (needle === void 0) return NEVER_MATCH_NAME$1;
|
|
753
597
|
return (value) => value === needle;
|
|
754
598
|
}
|
|
755
599
|
if (regexList.length === 0) return (value) => exactStrings.has(value);
|
|
756
600
|
if (exactStringCount === 0 && regexList.length === 1) {
|
|
757
601
|
const [regex] = regexList;
|
|
602
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
758
603
|
return (value) => regex.test(value);
|
|
759
604
|
}
|
|
760
605
|
return (value) => {
|
|
@@ -767,6 +612,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
767
612
|
if (fuzzyMatcher && !hasRegex) return fuzzyMatcher;
|
|
768
613
|
if (!fuzzyMatcher && regexList.length === 1) {
|
|
769
614
|
const [regex] = regexList;
|
|
615
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
770
616
|
return (value) => regex.test(value);
|
|
771
617
|
}
|
|
772
618
|
return (value) => {
|
|
@@ -777,20 +623,40 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
777
623
|
}
|
|
778
624
|
//#endregion
|
|
779
625
|
//#region src/js/babel/parse.ts
|
|
780
|
-
const parseCache = new LRUCache({ max:
|
|
626
|
+
const parseCache = new LRUCache({ max: HARD_PARSE_CACHE_MAX_ENTRIES });
|
|
781
627
|
function genCacheKey(source, options) {
|
|
782
|
-
if (typeof options === "string") return source
|
|
783
|
-
return source
|
|
628
|
+
if (typeof options === "string") return `${md5Hash(source)}:${options}`;
|
|
629
|
+
return `${md5Hash(source)}:${JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val)}`;
|
|
630
|
+
}
|
|
631
|
+
function normalizeCacheMaxEntries(value) {
|
|
632
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 128;
|
|
633
|
+
return Math.min(Math.max(Math.floor(value), 0), HARD_PARSE_CACHE_MAX_ENTRIES);
|
|
634
|
+
}
|
|
635
|
+
function normalizeCacheMaxSourceLength(value) {
|
|
636
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH;
|
|
637
|
+
return Math.max(Math.floor(value), 0);
|
|
638
|
+
}
|
|
639
|
+
function trimParseCache(maxEntries) {
|
|
640
|
+
while (parseCache.size > maxEntries) parseCache.pop();
|
|
784
641
|
}
|
|
785
642
|
function babelParse(code, opts = {}) {
|
|
786
|
-
const { cache, cacheKey, ...rest } = opts;
|
|
787
|
-
const
|
|
643
|
+
const { cache, cacheKey, cacheMaxEntries, cacheMaxSourceLength, ...rest } = opts;
|
|
644
|
+
const maxEntries = normalizeCacheMaxEntries(cacheMaxEntries);
|
|
645
|
+
const maxSourceLength = normalizeCacheMaxSourceLength(cacheMaxSourceLength);
|
|
646
|
+
const shouldCache = cache === true && maxEntries > 0 && code.length <= maxSourceLength;
|
|
647
|
+
const cacheKeyString = shouldCache ? genCacheKey(code, cacheKey ?? rest) : void 0;
|
|
788
648
|
let result;
|
|
789
|
-
if (
|
|
649
|
+
if (shouldCache) {
|
|
650
|
+
trimParseCache(maxEntries);
|
|
651
|
+
result = parseCache.get(cacheKeyString);
|
|
652
|
+
}
|
|
790
653
|
if (!result) {
|
|
791
|
-
const { cache: _cache, cacheKey: _cacheKey, ...parseOptions } = opts;
|
|
654
|
+
const { cache: _cache, cacheKey: _cacheKey, cacheMaxEntries: _cacheMaxEntries, cacheMaxSourceLength: _cacheMaxSourceLength, ...parseOptions } = opts;
|
|
792
655
|
result = parse(code, parseOptions);
|
|
793
|
-
if (
|
|
656
|
+
if (shouldCache) {
|
|
657
|
+
parseCache.set(cacheKeyString, result);
|
|
658
|
+
trimParseCache(maxEntries);
|
|
659
|
+
}
|
|
794
660
|
}
|
|
795
661
|
return result;
|
|
796
662
|
}
|
|
@@ -804,10 +670,10 @@ function replaceWxml(original, options = {
|
|
|
804
670
|
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
805
671
|
let res = original;
|
|
806
672
|
if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
|
|
807
|
-
res = escape(res, {
|
|
673
|
+
res = escape(res, omitUndefined({
|
|
808
674
|
map: escapeMap,
|
|
809
675
|
ignoreHead
|
|
810
|
-
});
|
|
676
|
+
}));
|
|
811
677
|
return res;
|
|
812
678
|
}
|
|
813
679
|
//#endregion
|
|
@@ -1345,6 +1211,44 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
1345
1211
|
}
|
|
1346
1212
|
}
|
|
1347
1213
|
//#endregion
|
|
1214
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
1215
|
+
function _typeof(o) {
|
|
1216
|
+
"@babel/helpers - typeof";
|
|
1217
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
1218
|
+
return typeof o;
|
|
1219
|
+
} : function(o) {
|
|
1220
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1221
|
+
}, _typeof(o);
|
|
1222
|
+
}
|
|
1223
|
+
//#endregion
|
|
1224
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
1225
|
+
function toPrimitive(t, r) {
|
|
1226
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
1227
|
+
var e = t[Symbol.toPrimitive];
|
|
1228
|
+
if (void 0 !== e) {
|
|
1229
|
+
var i = e.call(t, r || "default");
|
|
1230
|
+
if ("object" != _typeof(i)) return i;
|
|
1231
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1232
|
+
}
|
|
1233
|
+
return ("string" === r ? String : Number)(t);
|
|
1234
|
+
}
|
|
1235
|
+
//#endregion
|
|
1236
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
1237
|
+
function toPropertyKey(t) {
|
|
1238
|
+
var i = toPrimitive(t, "string");
|
|
1239
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
1240
|
+
}
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
1243
|
+
function _defineProperty(e, r, t) {
|
|
1244
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1245
|
+
value: t,
|
|
1246
|
+
enumerable: !0,
|
|
1247
|
+
configurable: !0,
|
|
1248
|
+
writable: !0
|
|
1249
|
+
}) : e[r] = t, e;
|
|
1250
|
+
}
|
|
1251
|
+
//#endregion
|
|
1348
1252
|
//#region src/js/JsTokenUpdater.ts
|
|
1349
1253
|
/**
|
|
1350
1254
|
* Lightweight helper that batches updates to {@link MagicString}.
|
|
@@ -1353,6 +1257,7 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
1353
1257
|
*/
|
|
1354
1258
|
var JsTokenUpdater = class {
|
|
1355
1259
|
constructor({ value } = {}) {
|
|
1260
|
+
_defineProperty(this, "tokens", void 0);
|
|
1356
1261
|
this.tokens = value ? [...value] : [];
|
|
1357
1262
|
}
|
|
1358
1263
|
addToken(token) {
|
|
@@ -1386,7 +1291,7 @@ var JsTokenUpdater = class {
|
|
|
1386
1291
|
var IgnoredExportsTracker = class {
|
|
1387
1292
|
constructor(options) {
|
|
1388
1293
|
this.options = options;
|
|
1389
|
-
this
|
|
1294
|
+
_defineProperty(this, "ignoredExportNames", /* @__PURE__ */ new Map());
|
|
1390
1295
|
}
|
|
1391
1296
|
addIgnoredExport(filename, exportName) {
|
|
1392
1297
|
if (!exportName) return;
|
|
@@ -1505,8 +1410,16 @@ var IgnoredExportsTracker = class {
|
|
|
1505
1410
|
//#region src/js/ModuleGraph.ts
|
|
1506
1411
|
var JsModuleGraph = class {
|
|
1507
1412
|
constructor(entry, graphOptions) {
|
|
1508
|
-
this
|
|
1509
|
-
this
|
|
1413
|
+
_defineProperty(this, "modules", /* @__PURE__ */ new Map());
|
|
1414
|
+
_defineProperty(this, "queue", []);
|
|
1415
|
+
_defineProperty(this, "resolve", void 0);
|
|
1416
|
+
_defineProperty(this, "load", void 0);
|
|
1417
|
+
_defineProperty(this, "filter", void 0);
|
|
1418
|
+
_defineProperty(this, "maxDepth", void 0);
|
|
1419
|
+
_defineProperty(this, "baseOptions", void 0);
|
|
1420
|
+
_defineProperty(this, "parserOptions", void 0);
|
|
1421
|
+
_defineProperty(this, "rootFilename", void 0);
|
|
1422
|
+
_defineProperty(this, "ignoredExports", void 0);
|
|
1510
1423
|
this.resolve = graphOptions.resolve;
|
|
1511
1424
|
this.load = graphOptions.load;
|
|
1512
1425
|
this.filter = graphOptions.filter;
|
|
@@ -1678,6 +1591,12 @@ const NEVER_MATCH_NAME = () => false;
|
|
|
1678
1591
|
*/
|
|
1679
1592
|
var NodePathWalker = class {
|
|
1680
1593
|
constructor({ ignoreCallExpressionIdentifiers, callback } = {}) {
|
|
1594
|
+
_defineProperty(this, "ignoreCallExpressionIdentifiers", void 0);
|
|
1595
|
+
_defineProperty(this, "callback", void 0);
|
|
1596
|
+
_defineProperty(this, "isIgnoredCallIdentifier", void 0);
|
|
1597
|
+
_defineProperty(this, "hasIgnoredCallIdentifiers", void 0);
|
|
1598
|
+
_defineProperty(this, "importsStore", void 0);
|
|
1599
|
+
_defineProperty(this, "visitedStore", void 0);
|
|
1681
1600
|
this.hasIgnoredCallIdentifiers = Boolean(ignoreCallExpressionIdentifiers && ignoreCallExpressionIdentifiers.length > 0);
|
|
1682
1601
|
this.ignoreCallExpressionIdentifiers = ignoreCallExpressionIdentifiers ?? EMPTY_IGNORE_CALL_EXPRESSION_IDENTIFIERS;
|
|
1683
1602
|
this.callback = callback ?? NOOP_STRING_PATH_CALLBACK;
|
|
@@ -1940,7 +1859,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1940
1859
|
const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
|
|
1941
1860
|
const ignoredPaths = needScope ? /* @__PURE__ */ new WeakSet() : EMPTY_IGNORED_PATHS;
|
|
1942
1861
|
const walker = needScope ? new NodePathWalker({
|
|
1943
|
-
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
1862
|
+
...options.ignoreCallExpressionIdentifiers === void 0 ? {} : { ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers },
|
|
1944
1863
|
callback(path) {
|
|
1945
1864
|
ignoredPaths.add(path);
|
|
1946
1865
|
}
|
|
@@ -1950,7 +1869,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1950
1869
|
function getTaggedTemplateIgnore() {
|
|
1951
1870
|
if (!taggedTemplateIgnore) taggedTemplateIgnore = createTaggedTemplateIgnore({
|
|
1952
1871
|
matcher: getIgnoredTaggedTemplateMatcher(options),
|
|
1953
|
-
names: options.ignoreTaggedTemplateExpressionIdentifiers
|
|
1872
|
+
...options.ignoreTaggedTemplateExpressionIdentifiers === void 0 ? {} : { names: options.ignoreTaggedTemplateExpressionIdentifiers }
|
|
1954
1873
|
});
|
|
1955
1874
|
return taggedTemplateIgnore;
|
|
1956
1875
|
}
|
|
@@ -2104,7 +2023,6 @@ function getOptionsFingerprint(options) {
|
|
|
2104
2023
|
options.uniAppX ? "1" : "0",
|
|
2105
2024
|
options.wrapExpression ? "1" : "0",
|
|
2106
2025
|
String(options.tailwindcssMajorVersion ?? ""),
|
|
2107
|
-
String(options.staleClassNameFallback ?? ""),
|
|
2108
2026
|
String(options.jsArbitraryValueFallback ?? ""),
|
|
2109
2027
|
JSON.stringify(options.arbitraryValues ?? null),
|
|
2110
2028
|
JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
|
|
@@ -2128,7 +2046,6 @@ function shouldCacheJsResult(rawSource, options) {
|
|
|
2128
2046
|
function createJsHandler(options) {
|
|
2129
2047
|
const defaults = {
|
|
2130
2048
|
escapeMap: options.escapeMap,
|
|
2131
|
-
staleClassNameFallback: options.staleClassNameFallback,
|
|
2132
2049
|
jsArbitraryValueFallback: options.jsArbitraryValueFallback,
|
|
2133
2050
|
tailwindcssMajorVersion: options.tailwindcssMajorVersion,
|
|
2134
2051
|
arbitraryValues: options.arbitraryValues,
|
|
@@ -2290,11 +2207,7 @@ function generateCode(match, options = {}) {
|
|
|
2290
2207
|
const initial = jsHandler(match, runtimeSet, wrapExpression ? WRAP_EXPRESSION_HANDLER_OPTIONS : void 0);
|
|
2291
2208
|
if (!initial.error || wrapExpression) return initial.code;
|
|
2292
2209
|
return jsHandler(match, runtimeSet, WRAP_EXPRESSION_HANDLER_OPTIONS).code;
|
|
2293
|
-
} else
|
|
2294
|
-
/**
|
|
2295
|
-
* @deprecated
|
|
2296
|
-
*/
|
|
2297
|
-
return rewriteLegacyExpression(match, options);
|
|
2210
|
+
} else return rewriteLegacyExpression(match, options);
|
|
2298
2211
|
} catch {
|
|
2299
2212
|
return match;
|
|
2300
2213
|
}
|
|
@@ -2323,6 +2236,13 @@ function isAllWhitespace(value) {
|
|
|
2323
2236
|
//#region src/wxml/Tokenizer.ts
|
|
2324
2237
|
var Tokenizer = class {
|
|
2325
2238
|
constructor() {
|
|
2239
|
+
_defineProperty(this, "state", void 0);
|
|
2240
|
+
_defineProperty(this, "buffer", void 0);
|
|
2241
|
+
_defineProperty(this, "tokens", void 0);
|
|
2242
|
+
_defineProperty(this, "bufferStartIndex", void 0);
|
|
2243
|
+
_defineProperty(this, "expressionStartIndex", void 0);
|
|
2244
|
+
_defineProperty(this, "expressionBuffer", void 0);
|
|
2245
|
+
_defineProperty(this, "expressions", void 0);
|
|
2326
2246
|
this.reset();
|
|
2327
2247
|
}
|
|
2328
2248
|
processChar(char, index) {
|
|
@@ -2413,6 +2333,7 @@ var Tokenizer = class {
|
|
|
2413
2333
|
this.reset();
|
|
2414
2334
|
for (let i = 0; i < input.length; i++) {
|
|
2415
2335
|
const char = input[i];
|
|
2336
|
+
if (char === void 0) continue;
|
|
2416
2337
|
this.processChar(char, i);
|
|
2417
2338
|
}
|
|
2418
2339
|
if (this.buffer.length > 0) this.tokens.push({
|
|
@@ -2475,6 +2396,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
2475
2396
|
}
|
|
2476
2397
|
if (tokens.length > 0) {
|
|
2477
2398
|
const lastToken = tokens[tokens.length - 1];
|
|
2399
|
+
if (!lastToken) return;
|
|
2478
2400
|
if (lastToken.end < ms.original.length) updateWhitespaceGap(ms, lastToken.end, ms.original.length, options);
|
|
2479
2401
|
}
|
|
2480
2402
|
}
|
|
@@ -2549,7 +2471,7 @@ async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
|
2549
2471
|
}, { xmlMode: true });
|
|
2550
2472
|
parser.write(rawSource);
|
|
2551
2473
|
parser.end();
|
|
2552
|
-
for (const { data, endIndex, startIndex } of wxsArray ?? []) {
|
|
2474
|
+
if (jsHandler) for (const { data, endIndex, startIndex } of wxsArray ?? []) {
|
|
2553
2475
|
const { code } = await jsHandler(data, runtimeSet);
|
|
2554
2476
|
if (code !== data) getMagicString().update(startIndex, endIndex, code);
|
|
2555
2477
|
}
|
|
@@ -2588,7 +2510,7 @@ function resolveRuntimePackageReplacements(option) {
|
|
|
2588
2510
|
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
2589
2511
|
}
|
|
2590
2512
|
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,
|
|
2513
|
+
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
2514
|
const uniAppXEnabled = isUniAppXEnabled(uniAppX);
|
|
2593
2515
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
2594
2516
|
const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
|
|
@@ -2616,7 +2538,6 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
2616
2538
|
escapeMap,
|
|
2617
2539
|
arbitraryValues,
|
|
2618
2540
|
jsPreserveClass,
|
|
2619
|
-
staleClassNameFallback,
|
|
2620
2541
|
jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
|
|
2621
2542
|
tailwindcssMajorVersion,
|
|
2622
2543
|
generateMap: true,
|
|
@@ -2684,9 +2605,10 @@ function createInternalCompilerContext(opts) {
|
|
|
2684
2605
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
2685
2606
|
applyLoggerLevel(ctx.logLevel);
|
|
2686
2607
|
const twPatcher = createTailwindcssPatcherFromContext(ctx);
|
|
2687
|
-
logTailwindcssTarget(
|
|
2608
|
+
logTailwindcssTarget(twPatcher, ctx.tailwindcssBasedir);
|
|
2688
2609
|
logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, twPatcher.packageInfo?.rootPath, twPatcher.packageInfo?.version);
|
|
2689
|
-
warnMissingCssEntries(ctx, twPatcher);
|
|
2610
|
+
if (opts?.__internalDeferMissingCssEntriesWarning !== true) warnMissingCssEntries(ctx, twPatcher);
|
|
2611
|
+
ctx.cssPreflight = resolveDefaultCssPreflight(opts?.cssPreflight, twPatcher.majorVersion);
|
|
2690
2612
|
const cssCalcOptions = applyV4CssCalcDefaults(ctx.cssCalc, twPatcher);
|
|
2691
2613
|
ctx.cssCalc = cssCalcOptions;
|
|
2692
2614
|
const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, twPatcher.majorVersion);
|
|
@@ -2712,9 +2634,9 @@ function createInternalCompilerContext(opts) {
|
|
|
2712
2634
|
return ctx;
|
|
2713
2635
|
}
|
|
2714
2636
|
/**
|
|
2715
|
-
*
|
|
2637
|
+
* 获取用户定义选项的内部表示,并初始化相关的处理程序和 Tailwind 运行时。
|
|
2716
2638
|
* @param opts - 用户定义的选项,可选。
|
|
2717
|
-
* @returns 返回一个包含内部用户定义选项的对象,包括样式、JS和模板处理程序,以及Tailwind CSS
|
|
2639
|
+
* @returns 返回一个包含内部用户定义选项的对象,包括样式、JS 和模板处理程序,以及 Tailwind CSS 运行时。
|
|
2718
2640
|
*/
|
|
2719
2641
|
function getCompilerContext(opts) {
|
|
2720
2642
|
return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
|
|
@@ -2734,7 +2656,7 @@ const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+f
|
|
|
2734
2656
|
* @returns 如果可以跳过转换返回 `true`,否则返回 `false`
|
|
2735
2657
|
*/
|
|
2736
2658
|
function shouldSkipJsTransform(rawSource, options) {
|
|
2737
|
-
if (process.env
|
|
2659
|
+
if (process.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
|
|
2738
2660
|
if (!rawSource) return true;
|
|
2739
2661
|
if (options?.alwaysEscape) return false;
|
|
2740
2662
|
if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
|
|
@@ -2743,21 +2665,4 @@ function shouldSkipJsTransform(rawSource, options) {
|
|
|
2743
2665
|
return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
|
|
2744
2666
|
}
|
|
2745
2667
|
//#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 };
|
|
2668
|
+
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 };
|