weapp-tailwindcss 4.11.2 → 4.12.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/bin/weapp-tailwindcss.js +21 -1
- package/dist/{chunk-AV3XB6EQ.js → chunk-2A4NRLSY.js} +5 -5
- package/dist/{chunk-WJIRXC26.js → chunk-6JBFHYFM.js} +134 -128
- package/dist/{chunk-OMARW5NC.mjs → chunk-AYJ4HLWZ.mjs} +4 -2
- package/dist/{chunk-W3DXDWYC.mjs → chunk-CMNCGACY.mjs} +66 -60
- package/dist/{chunk-ZZ36BKM5.mjs → chunk-CQMHHQRN.mjs} +6 -2
- package/dist/{chunk-OYSABARD.js → chunk-E7I5TW5K.js} +3 -2
- package/dist/{chunk-7LKMJZD2.js → chunk-GMKSBLNY.js} +2 -2
- package/dist/{chunk-EFBQ4SQR.mjs → chunk-HL3US2OT.mjs} +1 -1
- package/dist/{chunk-AB2RGZQO.mjs → chunk-LWEVOVRD.mjs} +144 -76
- package/dist/{chunk-QK6VNNNL.js → chunk-NIS74SI6.js} +8 -6
- package/dist/{chunk-CRDOWYG4.js → chunk-ONLKZIRQ.js} +1 -1
- package/dist/{chunk-3QHYEMEW.js → chunk-PAAX4FDD.js} +45 -40
- package/dist/{chunk-JIERVBTX.mjs → chunk-SHDJA4GG.mjs} +1 -1
- package/dist/{chunk-SUKOZ6OG.js → chunk-SRAG3FST.js} +10 -6
- package/dist/{chunk-TT5WHNGS.js → chunk-YVRX3F6S.js} +149 -81
- package/dist/{chunk-2LH6PZH3.mjs → chunk-ZCH4YINE.mjs} +3 -2
- package/dist/{chunk-VGPAKLMZ.mjs → chunk-ZGIN2OAY.mjs} +12 -7
- package/dist/cli.js +2233 -158
- package/dist/cli.mjs +2238 -163
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +14 -9
- package/dist/core.mjs +10 -5
- package/dist/css-macro/postcss.js +4 -4
- package/dist/css-macro/postcss.mjs +2 -2
- package/dist/css-macro.js +5 -5
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.d.mts +1 -1
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.d.mts +1 -1
- package/dist/gulp.d.ts +1 -1
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +4 -4
- package/dist/{index-CoXntW_P.d.mts → index-BXrmQelt.d.mts} +29 -1
- package/dist/{index-CoXntW_P.d.ts → index-BXrmQelt.d.ts} +29 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/index.mjs +7 -7
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.d.mts +8 -1
- package/dist/presets.d.ts +8 -1
- package/dist/presets.js +7 -6
- package/dist/presets.mjs +3 -2
- package/dist/reset.d.mts +1 -31
- package/dist/reset.d.ts +3 -32
- package/dist/reset.js +3 -160
- package/dist/reset.mjs +3 -160
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +6 -6
- package/dist/vite.mjs +4 -4
- package/dist/weapp-tw-css-import-rewrite-loader.js +10 -5
- package/dist/weapp-tw-runtime-classset-loader.js +9 -4
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +7 -7
- package/dist/webpack.mjs +5 -5
- package/dist/webpack4.d.mts +1 -1
- package/dist/webpack4.d.ts +1 -1
- package/dist/webpack4.js +65 -56
- package/dist/webpack4.mjs +35 -26
- package/package.json +12 -7
- package/scripts/postinstall.mjs +59 -0
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkNIS74SI6js = require('./chunk-NIS74SI6.js');
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
var _chunkA5PB4KZTjs = require('./chunk-A5PB4KZT.js');
|
|
@@ -39,7 +40,7 @@ var debug = createDebug("[tailwindcss:runtime] ");
|
|
|
39
40
|
var refreshTailwindcssPatcherSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
|
|
40
41
|
function createTailwindPatchPromise(twPatcher, onPatched) {
|
|
41
42
|
return Promise.resolve(twPatcher.patch()).then(async () => {
|
|
42
|
-
|
|
43
|
+
_chunkNIS74SI6js.invalidateRuntimeClassSet.call(void 0, twPatcher);
|
|
43
44
|
if (onPatched) {
|
|
44
45
|
try {
|
|
45
46
|
await onPatched();
|
|
@@ -94,7 +95,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
94
95
|
}
|
|
95
96
|
await state.patchPromise;
|
|
96
97
|
const entry = getRuntimeClassSetStateEntry(state);
|
|
97
|
-
const signature =
|
|
98
|
+
const signature = _chunkNIS74SI6js.getRuntimeClassSetSignature.call(void 0, state.twPatcher);
|
|
98
99
|
const signatureChanged = entry.signature !== signature;
|
|
99
100
|
const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
|
|
100
101
|
if (!shouldForceCollect) {
|
|
@@ -129,7 +130,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
129
130
|
try {
|
|
130
131
|
const runtimeSet = await task;
|
|
131
132
|
entry.value = runtimeSet;
|
|
132
|
-
entry.signature =
|
|
133
|
+
entry.signature = _chunkNIS74SI6js.getRuntimeClassSetSignature.call(void 0, state.twPatcher);
|
|
133
134
|
return runtimeSet;
|
|
134
135
|
} finally {
|
|
135
136
|
if (entry.promise === task) {
|
|
@@ -186,8 +187,8 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
|
-
const entry =
|
|
190
|
-
const signature =
|
|
190
|
+
const entry = _chunkNIS74SI6js.getRuntimeClassSetCacheEntry.call(void 0, activePatcher);
|
|
191
|
+
const signature = _chunkNIS74SI6js.getRuntimeClassSetSignature.call(void 0, activePatcher);
|
|
191
192
|
if (!options.force) {
|
|
192
193
|
if (entry.value && entry.signature === signature) {
|
|
193
194
|
return entry.value;
|
|
@@ -428,7 +429,7 @@ function formatRelativeToBase(targetPath, baseDir) {
|
|
|
428
429
|
}
|
|
429
430
|
function resolveRecordLocation(baseDir) {
|
|
430
431
|
const normalizedBase = _path2.default.normalize(baseDir);
|
|
431
|
-
const packageRoot = _nullishCoalesce(
|
|
432
|
+
const packageRoot = _nullishCoalesce(_chunkNIS74SI6js.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
|
|
432
433
|
const packageJsonPath = _path2.default.join(packageRoot, "package.json");
|
|
433
434
|
const hasPackageJson = _fs.existsSync.call(void 0, packageJsonPath);
|
|
434
435
|
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
@@ -465,7 +466,7 @@ function getRecordFileCandidates(baseDir) {
|
|
|
465
466
|
// package.json
|
|
466
467
|
var package_default = {
|
|
467
468
|
name: "weapp-tailwindcss",
|
|
468
|
-
version: "4.
|
|
469
|
+
version: "4.12.0-alpha.2",
|
|
469
470
|
description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
|
|
470
471
|
author: "ice breaker <1324318532@qq.com>",
|
|
471
472
|
license: "MIT",
|
|
@@ -615,13 +616,14 @@ var package_default = {
|
|
|
615
616
|
"dist",
|
|
616
617
|
"index.css",
|
|
617
618
|
"preflight.css",
|
|
619
|
+
"scripts/postinstall.mjs",
|
|
618
620
|
"theme.css",
|
|
619
621
|
"uni-app-x.css",
|
|
620
622
|
"utilities.css",
|
|
621
623
|
"with-layer.css"
|
|
622
624
|
],
|
|
623
625
|
engines: {
|
|
624
|
-
node: "^
|
|
626
|
+
node: "^20.19.0 || >=22.12.0"
|
|
625
627
|
},
|
|
626
628
|
scripts: {
|
|
627
629
|
dev: "tsup --watch --sourcemap",
|
|
@@ -630,7 +632,7 @@ var package_default = {
|
|
|
630
632
|
"build:cli": "cd plugins/cli && pnpm run build",
|
|
631
633
|
"build:css": "tsx scripts/build-css.ts",
|
|
632
634
|
"build:weapp-theme": "tsx scripts/build-weapp-theme.ts",
|
|
633
|
-
test: "
|
|
635
|
+
test: "pnpm run cli:patch && vitest run",
|
|
634
636
|
"test:dev": "vitest",
|
|
635
637
|
"test:ui": "vitest --ui",
|
|
636
638
|
bench: "vitest bench --config ./vitest.config.ts",
|
|
@@ -647,7 +649,7 @@ var package_default = {
|
|
|
647
649
|
release: "tsx scripts/release.ts",
|
|
648
650
|
lint: "eslint .",
|
|
649
651
|
"lint:fix": "eslint ./src --fix",
|
|
650
|
-
postinstall: "node
|
|
652
|
+
postinstall: "node scripts/postinstall.mjs",
|
|
651
653
|
"bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts",
|
|
652
654
|
"test:watch-hmr": "node --import tsx scripts/watch-hmr-regression/index.ts"
|
|
653
655
|
},
|
|
@@ -667,6 +669,7 @@ var package_default = {
|
|
|
667
669
|
"@weapp-core/regex": "~1.0.1",
|
|
668
670
|
"@weapp-tailwindcss/logger": "workspace:*",
|
|
669
671
|
"@weapp-tailwindcss/postcss": "workspace:*",
|
|
672
|
+
"@weapp-tailwindcss/reset": "workspace:*",
|
|
670
673
|
"@weapp-tailwindcss/shared": "workspace:*",
|
|
671
674
|
cac: "6.7.14",
|
|
672
675
|
"comment-json": "^4.6.2",
|
|
@@ -681,6 +684,9 @@ var package_default = {
|
|
|
681
684
|
"tailwindcss-patch": "catalog:tailwindcssPatch",
|
|
682
685
|
"webpack-sources": "3.3.4",
|
|
683
686
|
yaml: "^2.8.3"
|
|
687
|
+
},
|
|
688
|
+
devDependencies: {
|
|
689
|
+
"fast-check": "^4.7.0"
|
|
684
690
|
}
|
|
685
691
|
};
|
|
686
692
|
|
|
@@ -1164,6 +1170,9 @@ function toCustomAttributesEntities(customAttributes) {
|
|
|
1164
1170
|
// src/context/handlers.ts
|
|
1165
1171
|
var _postcss = require('@weapp-tailwindcss/postcss');
|
|
1166
1172
|
|
|
1173
|
+
// src/js/index.ts
|
|
1174
|
+
|
|
1175
|
+
|
|
1167
1176
|
// src/babel/index.ts
|
|
1168
1177
|
var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefault(_traverse);
|
|
1169
1178
|
var _parser = require('@babel/parser');
|
|
@@ -2802,6 +2811,7 @@ var EMPTY_IMPORT_DECLARATIONS = /* @__PURE__ */ new Set();
|
|
|
2802
2811
|
var EMPTY_EXPORT_DECLARATIONS = /* @__PURE__ */ new Set();
|
|
2803
2812
|
var EMPTY_REQUIRE_CALL_PATHS = [];
|
|
2804
2813
|
var ignoredTaggedTemplateMatcherCache = /* @__PURE__ */ new WeakMap();
|
|
2814
|
+
var defaultEvalHandler;
|
|
2805
2815
|
function getIgnoredTaggedTemplateMatcher(options) {
|
|
2806
2816
|
const cached = ignoredTaggedTemplateMatcherCache.get(options);
|
|
2807
2817
|
if (cached) {
|
|
@@ -2811,6 +2821,12 @@ function getIgnoredTaggedTemplateMatcher(options) {
|
|
|
2811
2821
|
ignoredTaggedTemplateMatcherCache.set(options, created);
|
|
2812
2822
|
return created;
|
|
2813
2823
|
}
|
|
2824
|
+
function getDefaultEvalHandler() {
|
|
2825
|
+
if (!defaultEvalHandler) {
|
|
2826
|
+
throw new Error("Default JS eval handler is not initialized.");
|
|
2827
|
+
}
|
|
2828
|
+
return defaultEvalHandler;
|
|
2829
|
+
}
|
|
2814
2830
|
function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
2815
2831
|
const jsTokenUpdater = new JsTokenUpdater();
|
|
2816
2832
|
const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
|
|
@@ -2838,7 +2854,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
2838
2854
|
const importDeclarations = collectModuleMetadata ? /* @__PURE__ */ new Set() : EMPTY_IMPORT_DECLARATIONS;
|
|
2839
2855
|
const exportDeclarations = collectModuleMetadata ? /* @__PURE__ */ new Set() : EMPTY_EXPORT_DECLARATIONS;
|
|
2840
2856
|
const requireCallPaths = collectModuleMetadata ? [] : EMPTY_REQUIRE_CALL_PATHS;
|
|
2841
|
-
const evalHandler = _nullishCoalesce(handler, () => (
|
|
2857
|
+
const evalHandler = _nullishCoalesce(handler, () => ( getDefaultEvalHandler()));
|
|
2842
2858
|
const templateElementEnter = hasTaggedTemplateIgnoreIdentifiers ? (p) => {
|
|
2843
2859
|
const pp = p.parentPath;
|
|
2844
2860
|
if (pp.isTemplateLiteral()) {
|
|
@@ -2979,8 +2995,52 @@ function jsHandler(rawSource, options) {
|
|
|
2979
2995
|
}
|
|
2980
2996
|
return result;
|
|
2981
2997
|
}
|
|
2998
|
+
defaultEvalHandler = jsHandler;
|
|
2982
2999
|
|
|
2983
3000
|
// src/js/index.ts
|
|
3001
|
+
var RESULT_CACHE_MAX = 512;
|
|
3002
|
+
var classNameSetIds = /* @__PURE__ */ new WeakMap();
|
|
3003
|
+
var nextClassNameSetId = 0;
|
|
3004
|
+
function getClassNameSetId(set) {
|
|
3005
|
+
if (!set) {
|
|
3006
|
+
return "none";
|
|
3007
|
+
}
|
|
3008
|
+
const existing = classNameSetIds.get(set);
|
|
3009
|
+
if (existing !== void 0) {
|
|
3010
|
+
return String(existing);
|
|
3011
|
+
}
|
|
3012
|
+
const id = nextClassNameSetId++;
|
|
3013
|
+
classNameSetIds.set(set, id);
|
|
3014
|
+
return String(id);
|
|
3015
|
+
}
|
|
3016
|
+
var fingerprintCache = /* @__PURE__ */ new WeakMap();
|
|
3017
|
+
function getOptionsFingerprint(options) {
|
|
3018
|
+
const cached = fingerprintCache.get(options);
|
|
3019
|
+
if (cached) {
|
|
3020
|
+
return cached;
|
|
3021
|
+
}
|
|
3022
|
+
const parts = [
|
|
3023
|
+
getClassNameSetId(options.classNameSet),
|
|
3024
|
+
JSON.stringify(_nullishCoalesce(options.escapeMap, () => ( null))),
|
|
3025
|
+
options.needEscaped ? "1" : "0",
|
|
3026
|
+
options.alwaysEscape ? "1" : "0",
|
|
3027
|
+
options.unescapeUnicode ? "1" : "0",
|
|
3028
|
+
options.generateMap ? "1" : "0",
|
|
3029
|
+
options.uniAppX ? "1" : "0",
|
|
3030
|
+
options.wrapExpression ? "1" : "0",
|
|
3031
|
+
String(_nullishCoalesce(options.tailwindcssMajorVersion, () => ( ""))),
|
|
3032
|
+
String(_nullishCoalesce(options.staleClassNameFallback, () => ( ""))),
|
|
3033
|
+
String(_nullishCoalesce(options.jsArbitraryValueFallback, () => ( ""))),
|
|
3034
|
+
JSON.stringify(_nullishCoalesce(options.arbitraryValues, () => ( null))),
|
|
3035
|
+
JSON.stringify(_nullishCoalesce(options.ignoreCallExpressionIdentifiers, () => ( null))),
|
|
3036
|
+
JSON.stringify(_nullishCoalesce(_optionalChain([options, 'access', _99 => _99.ignoreTaggedTemplateExpressionIdentifiers, 'optionalAccess', _100 => _100.map, 'call', _101 => _101((v) => v instanceof RegExp ? v.source : v)]), () => ( null))),
|
|
3037
|
+
JSON.stringify(_nullishCoalesce(options.moduleSpecifierReplacements, () => ( null))),
|
|
3038
|
+
JSON.stringify(_nullishCoalesce(options.babelParserOptions, () => ( null)))
|
|
3039
|
+
];
|
|
3040
|
+
const fingerprint = parts.join("|");
|
|
3041
|
+
fingerprintCache.set(options, fingerprint);
|
|
3042
|
+
return fingerprint;
|
|
3043
|
+
}
|
|
2984
3044
|
function hasDefinedOverrides(options) {
|
|
2985
3045
|
if (!options) {
|
|
2986
3046
|
return false;
|
|
@@ -2992,17 +3052,6 @@ function hasDefinedOverrides(options) {
|
|
|
2992
3052
|
}
|
|
2993
3053
|
return false;
|
|
2994
3054
|
}
|
|
2995
|
-
var CACHEABLE_SOURCE_MAX_LENGTH = 512;
|
|
2996
|
-
var RESULT_CACHE_LIMIT = 256;
|
|
2997
|
-
function shouldCacheJsResult(rawSource, options) {
|
|
2998
|
-
if (rawSource.length === 0 || rawSource.length > CACHEABLE_SOURCE_MAX_LENGTH) {
|
|
2999
|
-
return false;
|
|
3000
|
-
}
|
|
3001
|
-
if (options.moduleGraph || options.filename) {
|
|
3002
|
-
return false;
|
|
3003
|
-
}
|
|
3004
|
-
return true;
|
|
3005
|
-
}
|
|
3006
3055
|
function createJsHandler(options) {
|
|
3007
3056
|
const defaults = {
|
|
3008
3057
|
escapeMap: options.escapeMap,
|
|
@@ -3021,11 +3070,10 @@ function createJsHandler(options) {
|
|
|
3021
3070
|
uniAppX: options.uniAppX,
|
|
3022
3071
|
moduleSpecifierReplacements: options.moduleSpecifierReplacements
|
|
3023
3072
|
};
|
|
3024
|
-
const
|
|
3073
|
+
const defaultOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
3025
3074
|
let resolvedOptionsWithoutClassNameSet;
|
|
3026
|
-
const
|
|
3027
|
-
const
|
|
3028
|
-
const resultCache = /* @__PURE__ */ new WeakMap();
|
|
3075
|
+
const overrideOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
3076
|
+
const resultCache = new (0, _lrucache.LRUCache)({ max: RESULT_CACHE_MAX });
|
|
3029
3077
|
function resolveDefaultOptions(classNameSet) {
|
|
3030
3078
|
if (!classNameSet) {
|
|
3031
3079
|
if (!resolvedOptionsWithoutClassNameSet) {
|
|
@@ -3036,7 +3084,7 @@ function createJsHandler(options) {
|
|
|
3036
3084
|
}
|
|
3037
3085
|
return resolvedOptionsWithoutClassNameSet;
|
|
3038
3086
|
}
|
|
3039
|
-
const cached =
|
|
3087
|
+
const cached = defaultOptionsCache.get(classNameSet);
|
|
3040
3088
|
if (cached) {
|
|
3041
3089
|
return cached;
|
|
3042
3090
|
}
|
|
@@ -3044,42 +3092,36 @@ function createJsHandler(options) {
|
|
|
3044
3092
|
...defaults,
|
|
3045
3093
|
classNameSet
|
|
3046
3094
|
};
|
|
3047
|
-
|
|
3095
|
+
defaultOptionsCache.set(classNameSet, created);
|
|
3048
3096
|
return created;
|
|
3049
3097
|
}
|
|
3050
3098
|
function getCachedJsResult(rawSource, resolvedOptions) {
|
|
3051
|
-
if (
|
|
3099
|
+
if (rawSource.length === 0) {
|
|
3052
3100
|
return void 0;
|
|
3053
3101
|
}
|
|
3054
|
-
const
|
|
3055
|
-
return
|
|
3102
|
+
const key = `${getOptionsFingerprint(resolvedOptions)}:${_node.md5.call(void 0, rawSource)}`;
|
|
3103
|
+
return resultCache.get(key);
|
|
3056
3104
|
}
|
|
3057
3105
|
function setCachedJsResult(rawSource, resolvedOptions, result) {
|
|
3058
|
-
if (
|
|
3106
|
+
if (rawSource.length === 0 || result.error || result.linked) {
|
|
3059
3107
|
return result;
|
|
3060
3108
|
}
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
cache = /* @__PURE__ */ new Map();
|
|
3064
|
-
resultCache.set(resolvedOptions, cache);
|
|
3065
|
-
}
|
|
3066
|
-
cache.set(rawSource, result);
|
|
3067
|
-
if (cache.size > RESULT_CACHE_LIMIT) {
|
|
3068
|
-
const firstKey = cache.keys().next().value;
|
|
3069
|
-
if (typeof firstKey === "string") {
|
|
3070
|
-
cache.delete(firstKey);
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3109
|
+
const key = `${getOptionsFingerprint(resolvedOptions)}:${_node.md5.call(void 0, rawSource)}`;
|
|
3110
|
+
resultCache.set(key, result);
|
|
3073
3111
|
return result;
|
|
3074
3112
|
}
|
|
3075
3113
|
function resolveOptions(classNameSet, overrideOptions) {
|
|
3076
3114
|
if (!hasDefinedOverrides(overrideOptions)) {
|
|
3077
3115
|
return resolveDefaultOptions(classNameSet);
|
|
3078
3116
|
}
|
|
3117
|
+
let entry = overrideOptionsCache.get(overrideOptions);
|
|
3118
|
+
if (!entry) {
|
|
3119
|
+
entry = { bySet: /* @__PURE__ */ new WeakMap() };
|
|
3120
|
+
overrideOptionsCache.set(overrideOptions, entry);
|
|
3121
|
+
}
|
|
3079
3122
|
if (!classNameSet) {
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
return cached2;
|
|
3123
|
+
if (entry.noSet) {
|
|
3124
|
+
return entry.noSet;
|
|
3083
3125
|
}
|
|
3084
3126
|
const created2 = _chunkDYLQ6UOIjs.defuOverrideArray.call(void 0,
|
|
3085
3127
|
{
|
|
@@ -3088,15 +3130,10 @@ function createJsHandler(options) {
|
|
|
3088
3130
|
},
|
|
3089
3131
|
defaults
|
|
3090
3132
|
);
|
|
3091
|
-
|
|
3133
|
+
entry.noSet = created2;
|
|
3092
3134
|
return created2;
|
|
3093
3135
|
}
|
|
3094
|
-
|
|
3095
|
-
if (!cache) {
|
|
3096
|
-
cache = /* @__PURE__ */ new WeakMap();
|
|
3097
|
-
resolvedOverrideOptionsByClassNameSet.set(overrideOptions, cache);
|
|
3098
|
-
}
|
|
3099
|
-
const cached = cache.get(classNameSet);
|
|
3136
|
+
const cached = entry.bySet.get(classNameSet);
|
|
3100
3137
|
if (cached) {
|
|
3101
3138
|
return cached;
|
|
3102
3139
|
}
|
|
@@ -3107,7 +3144,7 @@ function createJsHandler(options) {
|
|
|
3107
3144
|
},
|
|
3108
3145
|
defaults
|
|
3109
3146
|
);
|
|
3110
|
-
|
|
3147
|
+
entry.bySet.set(classNameSet, created);
|
|
3111
3148
|
return created;
|
|
3112
3149
|
}
|
|
3113
3150
|
function handler(rawSource, classNameSet, options2) {
|
|
@@ -3200,7 +3237,7 @@ function shouldSkipLegacyStringLiteral(path5) {
|
|
|
3200
3237
|
return true;
|
|
3201
3238
|
}
|
|
3202
3239
|
return Boolean(
|
|
3203
|
-
t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access',
|
|
3240
|
+
t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access', _102 => _102.parentPath, 'optionalAccess', _103 => _103.parent])) || t.isLogicalExpression(_optionalChain([path5, 'access', _104 => _104.parentPath, 'optionalAccess', _105 => _105.parent])))
|
|
3204
3241
|
);
|
|
3205
3242
|
}
|
|
3206
3243
|
function createLegacyTraverseOptions(options, jsTokenUpdater) {
|
|
@@ -3542,7 +3579,7 @@ async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
|
3542
3579
|
return;
|
|
3543
3580
|
}
|
|
3544
3581
|
const shouldHandleDefault = defaultTemplateHandlerEnabled && isDefaultTemplateAttribute(name);
|
|
3545
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall',
|
|
3582
|
+
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _106 => _106(tag, name)]), () => ( false));
|
|
3546
3583
|
if (!shouldHandleDefault && !shouldHandleCustom) {
|
|
3547
3584
|
return;
|
|
3548
3585
|
}
|
|
@@ -3582,7 +3619,7 @@ async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
|
3582
3619
|
getMagicString().update(startIndex, endIndex, code);
|
|
3583
3620
|
}
|
|
3584
3621
|
}
|
|
3585
|
-
return _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
3622
|
+
return _nullishCoalesce(_optionalChain([s, 'optionalAccess', _107 => _107.toString, 'call', _108 => _108()]), () => ( rawSource));
|
|
3586
3623
|
}
|
|
3587
3624
|
|
|
3588
3625
|
// src/wxml/utils.ts
|
|
@@ -3594,7 +3631,7 @@ function createTemplateHandler(options = {}) {
|
|
|
3594
3631
|
let cachedRuntimeSet;
|
|
3595
3632
|
let cachedOptionsWithRuntimeSet;
|
|
3596
3633
|
return (rawSource, opt) => {
|
|
3597
|
-
const runtimeSet = _optionalChain([opt, 'optionalAccess',
|
|
3634
|
+
const runtimeSet = _optionalChain([opt, 'optionalAccess', _109 => _109.runtimeSet]);
|
|
3598
3635
|
if (runtimeSet === void 0) {
|
|
3599
3636
|
return customTemplateHandler(rawSource, defaultOptions, cachedMatcher);
|
|
3600
3637
|
}
|
|
@@ -3637,6 +3674,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
3637
3674
|
cssRemoveProperty,
|
|
3638
3675
|
cssRemoveHoverPseudoClass,
|
|
3639
3676
|
cssPresetEnv,
|
|
3677
|
+
autoprefixer,
|
|
3640
3678
|
uniAppX,
|
|
3641
3679
|
px2rpx,
|
|
3642
3680
|
unitsToPx,
|
|
@@ -3651,7 +3689,8 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
3651
3689
|
disabledDefaultTemplateHandler,
|
|
3652
3690
|
replaceRuntimePackages
|
|
3653
3691
|
} = ctx;
|
|
3654
|
-
const uniAppXEnabled =
|
|
3692
|
+
const uniAppXEnabled = _chunkNIS74SI6js.isUniAppXEnabled.call(void 0, uniAppX);
|
|
3693
|
+
const resolvedUniAppXOptions = _chunkNIS74SI6js.resolveUniAppXOptions.call(void 0, uniAppX);
|
|
3655
3694
|
const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
|
|
3656
3695
|
const styleHandler = _postcss.createStyleHandler.call(void 0, {
|
|
3657
3696
|
cssPreflight,
|
|
@@ -3665,10 +3704,13 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
3665
3704
|
cssRemoveProperty,
|
|
3666
3705
|
cssRemoveHoverPseudoClass,
|
|
3667
3706
|
cssPresetEnv,
|
|
3707
|
+
autoprefixer,
|
|
3668
3708
|
uniAppX: uniAppXEnabled,
|
|
3709
|
+
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
3669
3710
|
cssCalc: cssCalcOptions,
|
|
3670
3711
|
px2rpx,
|
|
3671
|
-
unitsToPx
|
|
3712
|
+
unitsToPx,
|
|
3713
|
+
majorVersion: tailwindcssMajorVersion
|
|
3672
3714
|
});
|
|
3673
3715
|
const jsHandler2 = createJsHandler({
|
|
3674
3716
|
escapeMap,
|
|
@@ -3715,7 +3757,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3715
3757
|
if (!patcher) {
|
|
3716
3758
|
return;
|
|
3717
3759
|
}
|
|
3718
|
-
const cacheOptions = _optionalChain([patcher, 'access',
|
|
3760
|
+
const cacheOptions = _optionalChain([patcher, 'access', _110 => _110.options, 'optionalAccess', _111 => _111.cache]);
|
|
3719
3761
|
if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
|
|
3720
3762
|
return;
|
|
3721
3763
|
}
|
|
@@ -3726,19 +3768,19 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3726
3768
|
_logger.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
|
|
3727
3769
|
}
|
|
3728
3770
|
}
|
|
3729
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3771
|
+
if (!_optionalChain([options, 'optionalAccess', _112 => _112.removeDirectory])) {
|
|
3730
3772
|
return;
|
|
3731
3773
|
}
|
|
3732
3774
|
const cachePaths = /* @__PURE__ */ new Map();
|
|
3733
3775
|
const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
|
|
3734
|
-
if (_optionalChain([normalizedCacheOptions, 'optionalAccess',
|
|
3776
|
+
if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _113 => _113.path])) {
|
|
3735
3777
|
cachePaths.set(normalizedCacheOptions.path, false);
|
|
3736
3778
|
}
|
|
3737
|
-
const privateCachePath = _optionalChain([patcher, 'optionalAccess',
|
|
3779
|
+
const privateCachePath = _optionalChain([patcher, 'optionalAccess', _114 => _114.cacheStore, 'optionalAccess', _115 => _115.options, 'optionalAccess', _116 => _116.path]);
|
|
3738
3780
|
if (privateCachePath) {
|
|
3739
3781
|
cachePaths.set(privateCachePath, false);
|
|
3740
3782
|
}
|
|
3741
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3783
|
+
if (_optionalChain([options, 'optionalAccess', _117 => _117.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _118 => _118.dir])) {
|
|
3742
3784
|
cachePaths.set(normalizedCacheOptions.dir, true);
|
|
3743
3785
|
}
|
|
3744
3786
|
if (!cachePaths.size) {
|
|
@@ -3749,7 +3791,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3749
3791
|
await _promises.rm.call(void 0, cachePath, { force: true, recursive });
|
|
3750
3792
|
} catch (error) {
|
|
3751
3793
|
const err = error;
|
|
3752
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
3794
|
+
if (_optionalChain([err, 'optionalAccess', _119 => _119.code]) === "ENOENT") {
|
|
3753
3795
|
continue;
|
|
3754
3796
|
}
|
|
3755
3797
|
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
@@ -3764,15 +3806,15 @@ function createInternalCompilerContext(opts) {
|
|
|
3764
3806
|
);
|
|
3765
3807
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
3766
3808
|
applyLoggerLevel(ctx.logLevel);
|
|
3767
|
-
const twPatcher =
|
|
3809
|
+
const twPatcher = _chunkNIS74SI6js.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
3768
3810
|
logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
|
|
3769
3811
|
logRuntimeTailwindcssVersion(
|
|
3770
3812
|
ctx.tailwindcssBasedir,
|
|
3771
|
-
_optionalChain([twPatcher, 'access',
|
|
3772
|
-
_optionalChain([twPatcher, 'access',
|
|
3813
|
+
_optionalChain([twPatcher, 'access', _120 => _120.packageInfo, 'optionalAccess', _121 => _121.rootPath]),
|
|
3814
|
+
_optionalChain([twPatcher, 'access', _122 => _122.packageInfo, 'optionalAccess', _123 => _123.version])
|
|
3773
3815
|
);
|
|
3774
|
-
|
|
3775
|
-
const cssCalcOptions =
|
|
3816
|
+
_chunkNIS74SI6js.warnMissingCssEntries.call(void 0, ctx, twPatcher);
|
|
3817
|
+
const cssCalcOptions = _chunkNIS74SI6js.applyV4CssCalcDefaults.call(void 0, ctx.cssCalc, twPatcher);
|
|
3776
3818
|
ctx.cssCalc = cssCalcOptions;
|
|
3777
3819
|
const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
|
|
3778
3820
|
const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
|
|
@@ -3788,11 +3830,11 @@ function createInternalCompilerContext(opts) {
|
|
|
3788
3830
|
ctx.twPatcher = twPatcher;
|
|
3789
3831
|
const refreshTailwindcssPatcher = async (options) => {
|
|
3790
3832
|
const previousPatcher = ctx.twPatcher;
|
|
3791
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3833
|
+
if (_optionalChain([options, 'optionalAccess', _124 => _124.clearCache]) !== false) {
|
|
3792
3834
|
await clearTailwindcssPatcherCache(previousPatcher);
|
|
3793
3835
|
}
|
|
3794
|
-
|
|
3795
|
-
const nextPatcher =
|
|
3836
|
+
_chunkNIS74SI6js.invalidateRuntimeClassSet.call(void 0, previousPatcher);
|
|
3837
|
+
const nextPatcher = _chunkNIS74SI6js.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
3796
3838
|
Object.assign(previousPatcher, nextPatcher);
|
|
3797
3839
|
ctx.twPatcher = previousPatcher;
|
|
3798
3840
|
return previousPatcher;
|
|
@@ -3808,14 +3850,39 @@ function getCompilerContext(opts) {
|
|
|
3808
3850
|
return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
|
|
3809
3851
|
}
|
|
3810
3852
|
|
|
3853
|
+
// src/js/precheck.ts
|
|
3854
|
+
var FAST_JS_TRANSFORM_HINT_RE = /className\b|class\s*=|classList\.|\b(?:twMerge|clsx|classnames|cn|cva)\b|\[["'`]class["'`]\]|text-\[|bg-\[|\b(?:[whpm]|px|py|mx|my|rounded|flex|grid|gap)-/;
|
|
3855
|
+
var DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
|
|
3856
|
+
function shouldSkipJsTransform(rawSource, options) {
|
|
3857
|
+
if (process.env.WEAPP_TW_DISABLE_JS_PRECHECK === "1") {
|
|
3858
|
+
return false;
|
|
3859
|
+
}
|
|
3860
|
+
if (!rawSource) {
|
|
3861
|
+
return true;
|
|
3862
|
+
}
|
|
3863
|
+
if (_optionalChain([options, 'optionalAccess', _125 => _125.alwaysEscape])) {
|
|
3864
|
+
return false;
|
|
3865
|
+
}
|
|
3866
|
+
if (_optionalChain([options, 'optionalAccess', _126 => _126.moduleSpecifierReplacements]) && Object.keys(options.moduleSpecifierReplacements).length > 0) {
|
|
3867
|
+
return false;
|
|
3868
|
+
}
|
|
3869
|
+
if (_optionalChain([options, 'optionalAccess', _127 => _127.wrapExpression])) {
|
|
3870
|
+
return false;
|
|
3871
|
+
}
|
|
3872
|
+
if (DEPENDENCY_HINT_RE.test(rawSource)) {
|
|
3873
|
+
return false;
|
|
3874
|
+
}
|
|
3875
|
+
return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3811
3878
|
// src/tailwindcss/recorder.ts
|
|
3812
3879
|
function setupPatchRecorder(patcher, baseDir, options) {
|
|
3813
3880
|
const recorder = createPatchTargetRecorder(baseDir, patcher, options);
|
|
3814
|
-
if (_optionalChain([recorder, 'optionalAccess',
|
|
3815
|
-
const prefix = _optionalChain([options, 'optionalAccess',
|
|
3816
|
-
|
|
3881
|
+
if (_optionalChain([recorder, 'optionalAccess', _128 => _128.message]) && _optionalChain([options, 'optionalAccess', _129 => _129.logMessage]) !== false) {
|
|
3882
|
+
const prefix = _optionalChain([options, 'optionalAccess', _130 => _130.messagePrefix]) ? `${options.messagePrefix} ` : "";
|
|
3883
|
+
_chunkNIS74SI6js.logger.info("%s%s", prefix, recorder.message);
|
|
3817
3884
|
}
|
|
3818
|
-
const onPatchCompleted = _optionalChain([recorder, 'optionalAccess',
|
|
3885
|
+
const onPatchCompleted = _optionalChain([recorder, 'optionalAccess', _131 => _131.onPatched]) ? async () => {
|
|
3819
3886
|
await recorder.onPatched();
|
|
3820
3887
|
} : void 0;
|
|
3821
3888
|
const patchPromise = patcher ? createTailwindPatchPromise(patcher, onPatchCompleted) : Promise.resolve();
|
|
@@ -3844,4 +3911,5 @@ function setupPatchRecorder(patcher, baseDir, options) {
|
|
|
3844
3911
|
|
|
3845
3912
|
|
|
3846
3913
|
|
|
3847
|
-
|
|
3914
|
+
|
|
3915
|
+
exports.createDebug = createDebug; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.ensureRuntimeClassSet = ensureRuntimeClassSet; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.traverse = traverse; exports.babelParse = babelParse; exports.replaceWxml = replaceWxml; exports.isClassContextLiteralPath = isClassContextLiteralPath; exports.JsTokenUpdater = JsTokenUpdater; exports.analyzeSource = analyzeSource; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.getCompilerContext = getCompilerContext; exports.shouldSkipJsTransform = shouldSkipJsTransform; exports.setupPatchRecorder = setupPatchRecorder;
|
|
@@ -33,12 +33,13 @@ function ifndef(text) {
|
|
|
33
33
|
}
|
|
34
34
|
var QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
35
35
|
function matchCustomPropertyFromValue(str, cb) {
|
|
36
|
-
let arr;
|
|
37
36
|
let index = 0;
|
|
38
37
|
QUERY_KEY_REGEX.lastIndex = 0;
|
|
39
|
-
|
|
38
|
+
let arr = QUERY_KEY_REGEX.exec(str);
|
|
39
|
+
while (arr !== null) {
|
|
40
40
|
cb(arr, index);
|
|
41
41
|
index++;
|
|
42
|
+
arr = QUERY_KEY_REGEX.exec(str);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
isMpx,
|
|
12
12
|
patchMpxLoaderResolve,
|
|
13
13
|
setupMpxTailwindcssRedirect
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-SHDJA4GG.mjs";
|
|
15
15
|
import {
|
|
16
16
|
pushConcurrentTaskFactories,
|
|
17
17
|
resolveDisabledOptions,
|
|
@@ -27,18 +27,19 @@ import {
|
|
|
27
27
|
ensureRuntimeClassSet,
|
|
28
28
|
getCompilerContext,
|
|
29
29
|
pluginName,
|
|
30
|
-
setupPatchRecorder
|
|
31
|
-
|
|
30
|
+
setupPatchRecorder,
|
|
31
|
+
shouldSkipJsTransform
|
|
32
|
+
} from "./chunk-LWEVOVRD.mjs";
|
|
32
33
|
import {
|
|
33
34
|
getRuntimeClassSetSignature,
|
|
34
35
|
resolveTailwindcssOptions
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-AYJ4HLWZ.mjs";
|
|
36
37
|
import {
|
|
37
38
|
getGroupedEntries
|
|
38
39
|
} from "./chunk-OOHJLO5M.mjs";
|
|
39
40
|
import {
|
|
40
41
|
__dirname
|
|
41
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-HL3US2OT.mjs";
|
|
42
43
|
|
|
43
44
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
44
45
|
import process3 from "process";
|
|
@@ -236,7 +237,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
236
237
|
const currentAsset = compilation.getAsset(file);
|
|
237
238
|
const currentSourceValue = currentAsset?.source.source();
|
|
238
239
|
const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
|
|
239
|
-
const
|
|
240
|
+
const handlerOptions = {
|
|
240
241
|
staleClassNameFallback,
|
|
241
242
|
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
242
243
|
filename: absoluteFile,
|
|
@@ -244,7 +245,11 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
244
245
|
babelParserOptions: {
|
|
245
246
|
sourceFilename: absoluteFile
|
|
246
247
|
}
|
|
247
|
-
}
|
|
248
|
+
};
|
|
249
|
+
if (shouldSkipJsTransform(currentSource, handlerOptions)) {
|
|
250
|
+
return { result: new ConcatSource(currentSource) };
|
|
251
|
+
}
|
|
252
|
+
const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
248
253
|
const source = new ConcatSource(code);
|
|
249
254
|
compilerOptions.onUpdate(file, currentSource, code);
|
|
250
255
|
debug2("js handle: %s", file);
|