weapp-tailwindcss 5.0.0-next.32 → 5.0.0-next.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bundle-state-C4ib5xPG.js → bundle-state-Co_ksa-C.js} +1 -1
- package/dist/{bundle-state-BIsgsoNW.mjs → bundle-state-DUIidcox.mjs} +1 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
- package/dist/cli.js +3 -6
- package/dist/cli.mjs +4 -7
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/gulp.js +2 -2
- package/dist/gulp.mjs +2 -2
- package/dist/{incremental-runtime-class-set-CLP1Qv8F.js → incremental-runtime-class-set-BE8RVbuz.js} +67 -5
- package/dist/{incremental-runtime-class-set-D2fsgk5t.mjs → incremental-runtime-class-set-BXYUYjCd.mjs} +67 -5
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{precheck-CQeqnfo5.js → precheck-D_KT1pis.js} +4 -6
- package/dist/{precheck-nITnYBDn.mjs → precheck-mM9IVd1f.mjs} +6 -8
- package/dist/{vite-CYkkJZ3Q.js → vite-BVbIr2vs.js} +99 -38
- package/dist/{vite-BAHjBu8j.mjs → vite-C8vSTuBQ.mjs} +99 -38
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +0 -1
- package/dist/{webpack-CPwDaKy3.js → webpack-DlHo84RT.js} +3 -3
- package/dist/{webpack-xxmiRxcy.mjs → webpack-dva53gYi.mjs} +3 -3
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_precheck = require("./precheck-D_KT1pis.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as traverse, h as babelParse, o as Parser } from "./precheck-
|
|
1
|
+
import { g as traverse, h as babelParse, o as Parser } from "./precheck-mM9IVd1f.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import path from "node:path";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function collectUnescapedDynamicCandidates(source: string): string[];
|
|
1
|
+
export declare function collectUnescapedDynamicCandidates(source: string, allowedCandidates?: Set<string>): string[];
|
|
2
2
|
export declare function collectLegacyContainerCompatCandidates(sourceCandidates: Set<string>, candidates: Set<string>): Set<string>;
|
|
@@ -14,6 +14,7 @@ interface GenerateBundleContext {
|
|
|
14
14
|
ensureBundleRuntimeClassSet: (snapshot: BundleSnapshot, forceRefresh?: boolean, options?: {
|
|
15
15
|
allowBaselineOnlyInitialSync?: boolean | undefined;
|
|
16
16
|
baseClassSet?: Set<string> | undefined;
|
|
17
|
+
transformOnly?: boolean | undefined;
|
|
17
18
|
}) => Promise<Set<string>>;
|
|
18
19
|
debug: (format: string, ...args: unknown[]) => void;
|
|
19
20
|
getResolvedConfig: () => ResolvedConfig | undefined;
|
|
@@ -20,6 +20,7 @@ export declare function createViteRuntimeClassSet(options: CreateViteRuntimeClas
|
|
|
20
20
|
ensureBundleRuntimeClassSet: (snapshot: BundleSnapshot, forceRefresh?: boolean, options?: {
|
|
21
21
|
allowBaselineOnlyInitialSync?: boolean | undefined;
|
|
22
22
|
baseClassSet?: Set<string> | undefined;
|
|
23
|
+
transformOnly?: boolean | undefined;
|
|
23
24
|
}) => Promise<Set<string>>;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
package/dist/cli.js
CHANGED
|
@@ -49,7 +49,6 @@ let _babel_parser = require("@babel/parser");
|
|
|
49
49
|
let magic_string = require("magic-string");
|
|
50
50
|
magic_string = __toESM(magic_string);
|
|
51
51
|
let _ast_core_escape = require("@ast-core/escape");
|
|
52
|
-
let _weapp_tailwindcss_shared_extractors = require("@weapp-tailwindcss/shared/extractors");
|
|
53
52
|
require("@babel/types");
|
|
54
53
|
//#region src/js/babel/cache-options.ts
|
|
55
54
|
const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
|
|
@@ -1039,8 +1038,7 @@ function hasIgnoreComment(node) {
|
|
|
1039
1038
|
}
|
|
1040
1039
|
return false;
|
|
1041
1040
|
}
|
|
1042
|
-
function extractLiteralValue(path, { unescapeUnicode
|
|
1043
|
-
const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
|
|
1041
|
+
function extractLiteralValue(path, { unescapeUnicode }) {
|
|
1044
1042
|
const { node } = path;
|
|
1045
1043
|
let offset = 0;
|
|
1046
1044
|
let original;
|
|
@@ -1052,7 +1050,6 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
1052
1050
|
let literal = original;
|
|
1053
1051
|
if (unescapeUnicode && original.includes("\\u")) literal = decodeUnicode2(original);
|
|
1054
1052
|
return {
|
|
1055
|
-
allowDoubleQuotes,
|
|
1056
1053
|
literal,
|
|
1057
1054
|
offset,
|
|
1058
1055
|
original
|
|
@@ -1106,8 +1103,8 @@ function replaceHandleValue(path, options) {
|
|
|
1106
1103
|
const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
|
|
1107
1104
|
if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
|
|
1108
1105
|
if (hasIgnoreComment(path.node)) return;
|
|
1109
|
-
const { literal, original,
|
|
1110
|
-
const candidates = (0,
|
|
1106
|
+
const { literal, original, offset } = extractLiteralValue(path, options);
|
|
1107
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
1111
1108
|
if (candidates.length === 0) return;
|
|
1112
1109
|
const debugEnabled = debug$1.enabled;
|
|
1113
1110
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import semver from "semver";
|
|
4
|
-
import { createTailwindcssPatchCli } from "tailwindcss-patch";
|
|
4
|
+
import { createTailwindcssPatchCli, splitCandidateTokens } from "tailwindcss-patch";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
7
7
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
@@ -20,7 +20,6 @@ import _babelTraverse from "@babel/traverse";
|
|
|
20
20
|
import { parse } from "@babel/parser";
|
|
21
21
|
import MagicString from "magic-string";
|
|
22
22
|
import { jsStringEscape } from "@ast-core/escape";
|
|
23
|
-
import { splitCode } from "@weapp-tailwindcss/shared/extractors";
|
|
24
23
|
import "@babel/types";
|
|
25
24
|
//#region src/js/babel/cache-options.ts
|
|
26
25
|
const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
|
|
@@ -1010,8 +1009,7 @@ function hasIgnoreComment(node) {
|
|
|
1010
1009
|
}
|
|
1011
1010
|
return false;
|
|
1012
1011
|
}
|
|
1013
|
-
function extractLiteralValue(path, { unescapeUnicode
|
|
1014
|
-
const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
|
|
1012
|
+
function extractLiteralValue(path, { unescapeUnicode }) {
|
|
1015
1013
|
const { node } = path;
|
|
1016
1014
|
let offset = 0;
|
|
1017
1015
|
let original;
|
|
@@ -1023,7 +1021,6 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
1023
1021
|
let literal = original;
|
|
1024
1022
|
if (unescapeUnicode && original.includes("\\u")) literal = decodeUnicode2(original);
|
|
1025
1023
|
return {
|
|
1026
|
-
allowDoubleQuotes,
|
|
1027
1024
|
literal,
|
|
1028
1025
|
offset,
|
|
1029
1026
|
original
|
|
@@ -1077,8 +1074,8 @@ function replaceHandleValue(path, options) {
|
|
|
1077
1074
|
const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
|
|
1078
1075
|
if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
|
|
1079
1076
|
if (hasIgnoreComment(path.node)) return;
|
|
1080
|
-
const { literal, original,
|
|
1081
|
-
const candidates =
|
|
1077
|
+
const { literal, original, offset } = extractLiteralValue(path, options);
|
|
1078
|
+
const candidates = splitCandidateTokens(literal);
|
|
1082
1079
|
if (candidates.length === 0) return;
|
|
1083
1080
|
const debugEnabled = debug.enabled;
|
|
1084
1081
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_precheck = require("./precheck-D_KT1pis.js");
|
|
3
3
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
4
4
|
//#region src/core.ts
|
|
5
5
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as ensureRuntimeClassSet, n as getCompilerContext, t as shouldSkipJsTransform, y as createTailwindRuntimeReadyPromise } from "./precheck-
|
|
1
|
+
import { b as ensureRuntimeClassSet, n as getCompilerContext, t as shouldSkipJsTransform, y as createTailwindRuntimeReadyPromise } from "./precheck-mM9IVd1f.mjs";
|
|
2
2
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
3
3
|
//#region src/core.ts
|
|
4
4
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
package/dist/gulp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
3
3
|
const require_v3_engine = require("./v3-engine-DwY4Fixu.js");
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BE8RVbuz.js");
|
|
5
|
+
const require_precheck = require("./precheck-D_KT1pis.js");
|
|
6
6
|
const require_tailwindcss = require("./tailwindcss-Cl7hUlYV.js");
|
|
7
7
|
const require_source_candidates = require("./source-candidates-7Q-kTOSb.js");
|
|
8
8
|
let node_fs = require("node:fs");
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as ensureRuntimeClassSet, n as getCompilerContext, t as shouldSkipJsTransform, y as createTailwindRuntimeReadyPromise } from "./precheck-
|
|
1
|
+
import { b as ensureRuntimeClassSet, n as getCompilerContext, t as shouldSkipJsTransform, y as createTailwindRuntimeReadyPromise } from "./precheck-mM9IVd1f.mjs";
|
|
2
2
|
import { B as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-C_KeUQG3.mjs";
|
|
3
|
-
import { c as hasTailwindRootDirectives, i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager, u as normalizeTailwindSourceForGenerator } from "./incremental-runtime-class-set-
|
|
3
|
+
import { c as hasTailwindRootDirectives, i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager, u as normalizeTailwindSourceForGenerator } from "./incremental-runtime-class-set-BXYUYjCd.mjs";
|
|
4
4
|
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-udhXxMX9.mjs";
|
|
5
5
|
import { t as createSourceCandidateCollector } from "./source-candidates-_x8bq0Mz.mjs";
|
|
6
6
|
import fs from "node:fs";
|
package/dist/{incremental-runtime-class-set-CLP1Qv8F.js → incremental-runtime-class-set-BE8RVbuz.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
2
|
const require_v3_engine = require("./v3-engine-DwY4Fixu.js");
|
|
3
3
|
const require_generator = require("./generator-BEXaaUzP.js");
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
4
|
+
const require_precheck = require("./precheck-D_KT1pis.js");
|
|
5
5
|
let node_fs = require("node:fs");
|
|
6
6
|
let postcss = require("postcss");
|
|
7
7
|
postcss = require_chunk.__toESM(postcss);
|
|
@@ -2095,6 +2095,63 @@ function createNonSourceBaseClassSet(baseClassSet, candidateCountByClass) {
|
|
|
2095
2095
|
for (const candidate of candidateCountByClass.keys()) nextBaseClassSet.delete(candidate);
|
|
2096
2096
|
return nextBaseClassSet;
|
|
2097
2097
|
}
|
|
2098
|
+
function isHighConfidenceV3Candidate(candidate) {
|
|
2099
|
+
return candidate.includes("[") || candidate.includes(":") || candidate.includes("/");
|
|
2100
|
+
}
|
|
2101
|
+
function isRawCandidateInClassContext(source, start, extension) {
|
|
2102
|
+
if (typeof start !== "number" || start <= 0) return false;
|
|
2103
|
+
const before = source.slice(Math.max(0, start - 200), start);
|
|
2104
|
+
if (extension === "html") return /\bclass\s*=\s*["'][^"']*$/i.test(before);
|
|
2105
|
+
return /\bclass(?:Name)?\s*[:=]\s*["'][^"']*$/i.test(before) || /\.classList\.(?:add|remove|toggle|contains)\([^)]*$/i.test(before);
|
|
2106
|
+
}
|
|
2107
|
+
function resolveQuotedLiteralRange(source, start) {
|
|
2108
|
+
if (typeof start !== "number" || start <= 0) return;
|
|
2109
|
+
let quote;
|
|
2110
|
+
let literalStart = -1;
|
|
2111
|
+
for (let index = start - 1; index >= 0; index--) {
|
|
2112
|
+
const char = source[index];
|
|
2113
|
+
if (char !== "\"" && char !== "'" && char !== "`") continue;
|
|
2114
|
+
quote = char;
|
|
2115
|
+
literalStart = index;
|
|
2116
|
+
break;
|
|
2117
|
+
}
|
|
2118
|
+
if (!quote) return;
|
|
2119
|
+
let escaped = false;
|
|
2120
|
+
for (let index = literalStart + 1; index < source.length; index++) {
|
|
2121
|
+
const char = source[index];
|
|
2122
|
+
if (escaped) {
|
|
2123
|
+
escaped = false;
|
|
2124
|
+
continue;
|
|
2125
|
+
}
|
|
2126
|
+
if (char === "\\") {
|
|
2127
|
+
escaped = true;
|
|
2128
|
+
continue;
|
|
2129
|
+
}
|
|
2130
|
+
if (char === quote) {
|
|
2131
|
+
if (start < index) return {
|
|
2132
|
+
start: literalStart,
|
|
2133
|
+
end: index
|
|
2134
|
+
};
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function createHighConfidenceLiteralRanges(source, matches) {
|
|
2140
|
+
const ranges = [];
|
|
2141
|
+
for (const match of matches) {
|
|
2142
|
+
const candidate = match?.rawCandidate;
|
|
2143
|
+
if (typeof candidate !== "string" || !isHighConfidenceV3Candidate(candidate)) continue;
|
|
2144
|
+
const range = resolveQuotedLiteralRange(source, match.start);
|
|
2145
|
+
if (range) ranges.push(range);
|
|
2146
|
+
}
|
|
2147
|
+
return ranges;
|
|
2148
|
+
}
|
|
2149
|
+
function isRawCandidateInRanges(start, ranges) {
|
|
2150
|
+
return typeof start === "number" && ranges.some((range) => start > range.start && start < range.end);
|
|
2151
|
+
}
|
|
2152
|
+
function isRawCandidateAllowedForV3(source, candidate, start, extension, knownSourceCandidates, highConfidenceLiteralRanges = []) {
|
|
2153
|
+
return isHighConfidenceV3Candidate(candidate) || knownSourceCandidates?.has(candidate) === true || isRawCandidateInClassContext(source, start, extension) || isRawCandidateInRanges(start, highConfidenceLiteralRanges);
|
|
2154
|
+
}
|
|
2098
2155
|
function createBundleRuntimeClassSetManager(options = {}) {
|
|
2099
2156
|
const customExtractCandidates = options.extractCandidates;
|
|
2100
2157
|
const extractCandidates = customExtractCandidates ?? tailwindcss_patch.extractValidCandidates;
|
|
@@ -2153,12 +2210,17 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2153
2210
|
const validCandidates = new Set(await extractCandidates(createExtractOptions(context, source)));
|
|
2154
2211
|
for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
2155
2212
|
}
|
|
2156
|
-
async function extractEntryRawCandidates(entry) {
|
|
2157
|
-
const
|
|
2213
|
+
async function extractEntryRawCandidates(entry, patcher, knownSourceCandidates) {
|
|
2214
|
+
const extension = resolveEntryExtension(entry);
|
|
2215
|
+
const matches = await extractRawCandidates(entry.source, extension);
|
|
2216
|
+
const highConfidenceLiteralRanges = patcher.majorVersion === 3 && !customExtractCandidates ? createHighConfidenceLiteralRanges(entry.source, matches) : [];
|
|
2158
2217
|
const candidates = /* @__PURE__ */ new Set();
|
|
2159
2218
|
for (const match of matches) {
|
|
2160
2219
|
const candidate = match?.rawCandidate;
|
|
2161
|
-
if (typeof candidate === "string" && candidate.length > 0)
|
|
2220
|
+
if (typeof candidate === "string" && candidate.length > 0) {
|
|
2221
|
+
if (patcher.majorVersion === 3 && !customExtractCandidates && !isRawCandidateAllowedForV3(entry.source, candidate, match.start, extension, knownSourceCandidates, highConfidenceLiteralRanges)) continue;
|
|
2222
|
+
candidates.add(candidate);
|
|
2223
|
+
}
|
|
2162
2224
|
}
|
|
2163
2225
|
return candidates;
|
|
2164
2226
|
}
|
|
@@ -2191,7 +2253,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2191
2253
|
await Promise.all(changedRuntimeFiles.map(async (file) => {
|
|
2192
2254
|
const entry = runtimeEntriesByFile.get(file);
|
|
2193
2255
|
if (!entry) return;
|
|
2194
|
-
const candidates = await extractEntryRawCandidates(entry);
|
|
2256
|
+
const candidates = await extractEntryRawCandidates(entry, patcher, nextBaseClassSet);
|
|
2195
2257
|
rawCandidatesByFile.set(file, candidates);
|
|
2196
2258
|
for (const candidate of candidates) if (!candidateValidityCache.has(candidate)) unknownCandidates.add(candidate);
|
|
2197
2259
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as replaceWxml, r as resolveStyleOptionsFromContext } from "./precheck-
|
|
1
|
+
import { m as replaceWxml, r as resolveStyleOptionsFromContext } from "./precheck-mM9IVd1f.mjs";
|
|
2
2
|
import { B as createDebug, D as loadTailwindV4DesignSystem, E as filterUnsupportedMiniProgramTailwindV4Candidates, R as resolveTailwindV4CssSourceBase, S as resolveTailwindV4SourceOptionsFromPatcher, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, n as resolveTailwindV3SourceFromPatcher, q as omitUndefined, r as resolveTailwindV3SourceOptionsFromPatcher, t as resolveTailwindV3Source, x as resolveTailwindV4SourceFromPatcher, y as resolveTailwindV4Source$1 } from "./v3-engine-C_KeUQG3.mjs";
|
|
3
3
|
import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-CpsHA4Wd.mjs";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -2091,6 +2091,63 @@ function createNonSourceBaseClassSet(baseClassSet, candidateCountByClass) {
|
|
|
2091
2091
|
for (const candidate of candidateCountByClass.keys()) nextBaseClassSet.delete(candidate);
|
|
2092
2092
|
return nextBaseClassSet;
|
|
2093
2093
|
}
|
|
2094
|
+
function isHighConfidenceV3Candidate(candidate) {
|
|
2095
|
+
return candidate.includes("[") || candidate.includes(":") || candidate.includes("/");
|
|
2096
|
+
}
|
|
2097
|
+
function isRawCandidateInClassContext(source, start, extension) {
|
|
2098
|
+
if (typeof start !== "number" || start <= 0) return false;
|
|
2099
|
+
const before = source.slice(Math.max(0, start - 200), start);
|
|
2100
|
+
if (extension === "html") return /\bclass\s*=\s*["'][^"']*$/i.test(before);
|
|
2101
|
+
return /\bclass(?:Name)?\s*[:=]\s*["'][^"']*$/i.test(before) || /\.classList\.(?:add|remove|toggle|contains)\([^)]*$/i.test(before);
|
|
2102
|
+
}
|
|
2103
|
+
function resolveQuotedLiteralRange(source, start) {
|
|
2104
|
+
if (typeof start !== "number" || start <= 0) return;
|
|
2105
|
+
let quote;
|
|
2106
|
+
let literalStart = -1;
|
|
2107
|
+
for (let index = start - 1; index >= 0; index--) {
|
|
2108
|
+
const char = source[index];
|
|
2109
|
+
if (char !== "\"" && char !== "'" && char !== "`") continue;
|
|
2110
|
+
quote = char;
|
|
2111
|
+
literalStart = index;
|
|
2112
|
+
break;
|
|
2113
|
+
}
|
|
2114
|
+
if (!quote) return;
|
|
2115
|
+
let escaped = false;
|
|
2116
|
+
for (let index = literalStart + 1; index < source.length; index++) {
|
|
2117
|
+
const char = source[index];
|
|
2118
|
+
if (escaped) {
|
|
2119
|
+
escaped = false;
|
|
2120
|
+
continue;
|
|
2121
|
+
}
|
|
2122
|
+
if (char === "\\") {
|
|
2123
|
+
escaped = true;
|
|
2124
|
+
continue;
|
|
2125
|
+
}
|
|
2126
|
+
if (char === quote) {
|
|
2127
|
+
if (start < index) return {
|
|
2128
|
+
start: literalStart,
|
|
2129
|
+
end: index
|
|
2130
|
+
};
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
function createHighConfidenceLiteralRanges(source, matches) {
|
|
2136
|
+
const ranges = [];
|
|
2137
|
+
for (const match of matches) {
|
|
2138
|
+
const candidate = match?.rawCandidate;
|
|
2139
|
+
if (typeof candidate !== "string" || !isHighConfidenceV3Candidate(candidate)) continue;
|
|
2140
|
+
const range = resolveQuotedLiteralRange(source, match.start);
|
|
2141
|
+
if (range) ranges.push(range);
|
|
2142
|
+
}
|
|
2143
|
+
return ranges;
|
|
2144
|
+
}
|
|
2145
|
+
function isRawCandidateInRanges(start, ranges) {
|
|
2146
|
+
return typeof start === "number" && ranges.some((range) => start > range.start && start < range.end);
|
|
2147
|
+
}
|
|
2148
|
+
function isRawCandidateAllowedForV3(source, candidate, start, extension, knownSourceCandidates, highConfidenceLiteralRanges = []) {
|
|
2149
|
+
return isHighConfidenceV3Candidate(candidate) || knownSourceCandidates?.has(candidate) === true || isRawCandidateInClassContext(source, start, extension) || isRawCandidateInRanges(start, highConfidenceLiteralRanges);
|
|
2150
|
+
}
|
|
2094
2151
|
function createBundleRuntimeClassSetManager(options = {}) {
|
|
2095
2152
|
const customExtractCandidates = options.extractCandidates;
|
|
2096
2153
|
const extractCandidates = customExtractCandidates ?? extractValidCandidates;
|
|
@@ -2149,12 +2206,17 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2149
2206
|
const validCandidates = new Set(await extractCandidates(createExtractOptions(context, source)));
|
|
2150
2207
|
for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
2151
2208
|
}
|
|
2152
|
-
async function extractEntryRawCandidates(entry) {
|
|
2153
|
-
const
|
|
2209
|
+
async function extractEntryRawCandidates(entry, patcher, knownSourceCandidates) {
|
|
2210
|
+
const extension = resolveEntryExtension(entry);
|
|
2211
|
+
const matches = await extractRawCandidates(entry.source, extension);
|
|
2212
|
+
const highConfidenceLiteralRanges = patcher.majorVersion === 3 && !customExtractCandidates ? createHighConfidenceLiteralRanges(entry.source, matches) : [];
|
|
2154
2213
|
const candidates = /* @__PURE__ */ new Set();
|
|
2155
2214
|
for (const match of matches) {
|
|
2156
2215
|
const candidate = match?.rawCandidate;
|
|
2157
|
-
if (typeof candidate === "string" && candidate.length > 0)
|
|
2216
|
+
if (typeof candidate === "string" && candidate.length > 0) {
|
|
2217
|
+
if (patcher.majorVersion === 3 && !customExtractCandidates && !isRawCandidateAllowedForV3(entry.source, candidate, match.start, extension, knownSourceCandidates, highConfidenceLiteralRanges)) continue;
|
|
2218
|
+
candidates.add(candidate);
|
|
2219
|
+
}
|
|
2158
2220
|
}
|
|
2159
2221
|
return candidates;
|
|
2160
2222
|
}
|
|
@@ -2187,7 +2249,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2187
2249
|
await Promise.all(changedRuntimeFiles.map(async (file) => {
|
|
2188
2250
|
const entry = runtimeEntriesByFile.get(file);
|
|
2189
2251
|
if (!entry) return;
|
|
2190
|
-
const candidates = await extractEntryRawCandidates(entry);
|
|
2252
|
+
const candidates = await extractEntryRawCandidates(entry, patcher, nextBaseClassSet);
|
|
2191
2253
|
rawCandidatesByFile.set(file, candidates);
|
|
2192
2254
|
for (const candidate of candidates) if (!candidateValidityCache.has(candidate)) unknownCandidates.add(candidate);
|
|
2193
2255
|
}));
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_generator = require("./generator-BEXaaUzP.js");
|
|
3
3
|
const require_gulp = require("./gulp.js");
|
|
4
4
|
const require_postcss = require("./postcss-DN7IQzYb.js");
|
|
5
|
-
const require_vite = require("./vite-
|
|
6
|
-
const require_webpack = require("./webpack-
|
|
5
|
+
const require_vite = require("./vite-BVbIr2vs.js");
|
|
6
|
+
const require_webpack = require("./webpack-DlHo84RT.js");
|
|
7
7
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
8
8
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
9
9
|
exports.createPlugins = require_gulp.createPlugins;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as createWeappTailwindcssGenerator } from "./generator-CpsHA4Wd.mjs";
|
|
2
2
|
import { WeappTailwindcss as createPlugins } from "./gulp.mjs";
|
|
3
3
|
import { t as weappTailwindcssPostcssPlugin } from "./postcss-BvkdIZr8.mjs";
|
|
4
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
5
|
-
import { n as weappTailwindcssPackageDir } from "./webpack-
|
|
4
|
+
import { t as WeappTailwindcss } from "./vite-C8vSTuBQ.mjs";
|
|
5
|
+
import { n as weappTailwindcssPackageDir } from "./webpack-dva53gYi.mjs";
|
|
6
6
|
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
|
|
7
7
|
export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
|
@@ -8,6 +8,7 @@ node_process = require_chunk.__toESM(node_process);
|
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
node_path = require_chunk.__toESM(node_path);
|
|
10
10
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
11
|
+
let tailwindcss_patch = require("tailwindcss-patch");
|
|
11
12
|
let node_fs_promises = require("node:fs/promises");
|
|
12
13
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
13
14
|
let node_buffer = require("node:buffer");
|
|
@@ -20,7 +21,6 @@ let _babel_parser = require("@babel/parser");
|
|
|
20
21
|
let magic_string = require("magic-string");
|
|
21
22
|
magic_string = require_chunk.__toESM(magic_string);
|
|
22
23
|
let _ast_core_escape = require("@ast-core/escape");
|
|
23
|
-
let _weapp_tailwindcss_shared_extractors = require("@weapp-tailwindcss/shared/extractors");
|
|
24
24
|
let _babel_types = require("@babel/types");
|
|
25
25
|
_babel_types = require_chunk.__toESM(_babel_types);
|
|
26
26
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
@@ -920,8 +920,7 @@ function hasIgnoreComment(node) {
|
|
|
920
920
|
}
|
|
921
921
|
return false;
|
|
922
922
|
}
|
|
923
|
-
function extractLiteralValue(path, { unescapeUnicode
|
|
924
|
-
const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
|
|
923
|
+
function extractLiteralValue(path, { unescapeUnicode }) {
|
|
925
924
|
const { node } = path;
|
|
926
925
|
let offset = 0;
|
|
927
926
|
let original;
|
|
@@ -933,7 +932,6 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
933
932
|
let literal = original;
|
|
934
933
|
if (unescapeUnicode && original.includes("\\u")) literal = decodeUnicode2(original);
|
|
935
934
|
return {
|
|
936
|
-
allowDoubleQuotes,
|
|
937
935
|
literal,
|
|
938
936
|
offset,
|
|
939
937
|
original
|
|
@@ -987,8 +985,8 @@ function replaceHandleValue(path, options) {
|
|
|
987
985
|
const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
|
|
988
986
|
if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
|
|
989
987
|
if (hasIgnoreComment(path.node)) return;
|
|
990
|
-
const { literal, original,
|
|
991
|
-
const candidates = (0,
|
|
988
|
+
const { literal, original, offset } = extractLiteralValue(path, options);
|
|
989
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
992
990
|
if (candidates.length === 0) return;
|
|
993
991
|
const debugEnabled = debug.enabled;
|
|
994
992
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as createDebug, C as createTailwindV4Engine, K as resolveBooleanObjectOption, c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, q as omitUndefined, s as ensureTailwindcssRuntimePatch, u as getRuntimeClassSetSignatureWithSources, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-C_KeUQG3.mjs";
|
|
1
|
+
import { B as createDebug, C as createTailwindV4Engine$1, K as resolveBooleanObjectOption, c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, q as omitUndefined, s as ensureTailwindcssRuntimePatch, u as getRuntimeClassSetSignatureWithSources, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-C_KeUQG3.mjs";
|
|
2
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-8xrgzxFY.mjs";
|
|
3
3
|
import { i as isMap, n as defuOverrideArray } from "./utils-DsaS975I.mjs";
|
|
4
4
|
import { a as applyV4CssCalcDefaults, i as resolveUniAppXOptions, o as warnMissingCssEntries, t as createTailwindcssPatcherFromContext } from "./tailwindcss-udhXxMX9.mjs";
|
|
@@ -6,6 +6,7 @@ import { createRequire } from "node:module";
|
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { logger, pc } from "@weapp-tailwindcss/logger";
|
|
9
|
+
import { splitCandidateTokens } from "tailwindcss-patch";
|
|
9
10
|
import { rm } from "node:fs/promises";
|
|
10
11
|
import { createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
11
12
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
@@ -16,7 +17,6 @@ import _babelTraverse from "@babel/traverse";
|
|
|
16
17
|
import { parse, parseExpression } from "@babel/parser";
|
|
17
18
|
import MagicString from "magic-string";
|
|
18
19
|
import { jsStringEscape } from "@ast-core/escape";
|
|
19
|
-
import { splitCode } from "@weapp-tailwindcss/shared/extractors";
|
|
20
20
|
import * as t from "@babel/types";
|
|
21
21
|
//#region \0rolldown/runtime.js
|
|
22
22
|
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -207,7 +207,7 @@ function tryGetRuntimeClassSetSync(twPatcher) {
|
|
|
207
207
|
}
|
|
208
208
|
async function collectTailwindV4GeneratorClassSet(twPatcher) {
|
|
209
209
|
try {
|
|
210
|
-
const generated = await createTailwindV4Engine(await resolveTailwindV4SourceFromPatcher(twPatcher)).generate({
|
|
210
|
+
const generated = await createTailwindV4Engine$1(await resolveTailwindV4SourceFromPatcher(twPatcher)).generate({
|
|
211
211
|
scanSources: true,
|
|
212
212
|
target: "tailwind"
|
|
213
213
|
});
|
|
@@ -919,8 +919,7 @@ function hasIgnoreComment(node) {
|
|
|
919
919
|
}
|
|
920
920
|
return false;
|
|
921
921
|
}
|
|
922
|
-
function extractLiteralValue(path, { unescapeUnicode
|
|
923
|
-
const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
|
|
922
|
+
function extractLiteralValue(path, { unescapeUnicode }) {
|
|
924
923
|
const { node } = path;
|
|
925
924
|
let offset = 0;
|
|
926
925
|
let original;
|
|
@@ -932,7 +931,6 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
932
931
|
let literal = original;
|
|
933
932
|
if (unescapeUnicode && original.includes("\\u")) literal = decodeUnicode2(original);
|
|
934
933
|
return {
|
|
935
|
-
allowDoubleQuotes,
|
|
936
934
|
literal,
|
|
937
935
|
offset,
|
|
938
936
|
original
|
|
@@ -986,8 +984,8 @@ function replaceHandleValue(path, options) {
|
|
|
986
984
|
const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
|
|
987
985
|
if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
|
|
988
986
|
if (hasIgnoreComment(path.node)) return;
|
|
989
|
-
const { literal, original,
|
|
990
|
-
const candidates =
|
|
987
|
+
const { literal, original, offset } = extractLiteralValue(path, options);
|
|
988
|
+
const candidates = splitCandidateTokens(literal);
|
|
991
989
|
if (candidates.length === 0) return;
|
|
992
990
|
const debugEnabled = debug.enabled;
|
|
993
991
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
2
|
const require_v3_engine = require("./v3-engine-DwY4Fixu.js");
|
|
3
3
|
const require_generator = require("./generator-BEXaaUzP.js");
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BE8RVbuz.js");
|
|
5
|
+
const require_precheck = require("./precheck-D_KT1pis.js");
|
|
6
6
|
const require_utils = require("./utils-D7Ygohep.js");
|
|
7
7
|
const require_tailwindcss = require("./tailwindcss-Cl7hUlYV.js");
|
|
8
8
|
const require_source_candidates = require("./source-candidates-7Q-kTOSb.js");
|
|
9
|
-
const require_bundle_state = require("./bundle-state-
|
|
9
|
+
const require_bundle_state = require("./bundle-state-Co_ksa-C.js");
|
|
10
10
|
require("./logger-TlKT3xmR.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -17,10 +17,10 @@ node_process = require_chunk.__toESM(node_process);
|
|
|
17
17
|
let node_path = require("node:path");
|
|
18
18
|
node_path = require_chunk.__toESM(node_path);
|
|
19
19
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
20
|
+
let tailwindcss_patch = require("tailwindcss-patch");
|
|
20
21
|
let node_fs_promises = require("node:fs/promises");
|
|
21
22
|
let magic_string = require("magic-string");
|
|
22
23
|
magic_string = require_chunk.__toESM(magic_string);
|
|
23
|
-
let _weapp_tailwindcss_shared_extractors = require("@weapp-tailwindcss/shared/extractors");
|
|
24
24
|
let _weapp_tailwindcss_postcss_html_transform = require("@weapp-tailwindcss/postcss/html-transform");
|
|
25
25
|
_weapp_tailwindcss_postcss_html_transform = require_chunk.__toESM(_weapp_tailwindcss_postcss_html_transform);
|
|
26
26
|
let comment_json = require("comment-json");
|
|
@@ -21916,14 +21916,11 @@ function createStableHash(input) {
|
|
|
21916
21916
|
return (hash >>> 0).toString(36);
|
|
21917
21917
|
}
|
|
21918
21918
|
function extractLiteralValue(path) {
|
|
21919
|
-
const allowDoubleQuotes = path.isTemplateElement();
|
|
21920
21919
|
if (path.isStringLiteral()) return {
|
|
21921
|
-
allowDoubleQuotes,
|
|
21922
21920
|
literal: path.node.value,
|
|
21923
21921
|
offset: 1
|
|
21924
21922
|
};
|
|
21925
21923
|
return {
|
|
21926
|
-
allowDoubleQuotes,
|
|
21927
21924
|
literal: typeof path.node.value === "string" ? path.node.value : path.node.value.raw,
|
|
21928
21925
|
offset: 0
|
|
21929
21926
|
};
|
|
@@ -21955,7 +21952,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21955
21952
|
return alias;
|
|
21956
21953
|
}
|
|
21957
21954
|
rewriteLiteral(literal, shouldInclude) {
|
|
21958
|
-
const candidates = (0,
|
|
21955
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
21959
21956
|
if (candidates.length === 0) return literal;
|
|
21960
21957
|
let rewritten = literal;
|
|
21961
21958
|
for (const candidate of candidates) {
|
|
@@ -21975,8 +21972,8 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21975
21972
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
21976
21973
|
}), {}, void 0, false);
|
|
21977
21974
|
for (const path of analysis.targetPaths) {
|
|
21978
|
-
const { literal
|
|
21979
|
-
const candidates = (0,
|
|
21975
|
+
const { literal } = extractLiteralValue(path);
|
|
21976
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
21980
21977
|
const classContext = options.wrapExpression || require_precheck.isClassContextLiteralPath(path);
|
|
21981
21978
|
for (const candidate of candidates) {
|
|
21982
21979
|
if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
@@ -21996,8 +21993,8 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21996
21993
|
if (analysis.targetPaths.length === 0) return rawSource;
|
|
21997
21994
|
const updater = new require_precheck.JsTokenUpdater();
|
|
21998
21995
|
for (const path of analysis.targetPaths) {
|
|
21999
|
-
const { literal,
|
|
22000
|
-
const candidates = (0,
|
|
21996
|
+
const { literal, offset } = extractLiteralValue(path);
|
|
21997
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
22001
21998
|
if (candidates.length === 0) continue;
|
|
22002
21999
|
let rewritten = literal;
|
|
22003
22000
|
let mutated = false;
|
|
@@ -22552,19 +22549,60 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
22552
22549
|
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
22553
22550
|
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
22554
22551
|
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
22552
|
+
const CLASS_ATTRIBUTE_RE = /\bclass\s*=\s*/g;
|
|
22553
|
+
const MUSTACHE_OPEN = "{{";
|
|
22554
|
+
const MUSTACHE_CLOSE = "}}";
|
|
22555
|
+
function isUrlLikeCandidate(candidate) {
|
|
22556
|
+
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
22557
|
+
}
|
|
22555
22558
|
function isArbitraryValueCandidate(candidate) {
|
|
22556
|
-
return candidate.includes("[") && candidate.includes("]");
|
|
22559
|
+
return candidate.includes("[") && candidate.includes("]") && !isUrlLikeCandidate(candidate.trim());
|
|
22557
22560
|
}
|
|
22558
|
-
function
|
|
22561
|
+
function collectClassAttributeValues(source) {
|
|
22562
|
+
const values = [];
|
|
22563
|
+
CLASS_ATTRIBUTE_RE.lastIndex = 0;
|
|
22564
|
+
let matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22565
|
+
while (matched !== null) {
|
|
22566
|
+
const quoteIndex = CLASS_ATTRIBUTE_RE.lastIndex;
|
|
22567
|
+
const quote = source[quoteIndex];
|
|
22568
|
+
if (quote !== "\"" && quote !== "'") {
|
|
22569
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22570
|
+
continue;
|
|
22571
|
+
}
|
|
22572
|
+
let expressionDepth = 0;
|
|
22573
|
+
for (let index = quoteIndex + 1; index < source.length; index++) {
|
|
22574
|
+
if (source.startsWith(MUSTACHE_OPEN, index)) {
|
|
22575
|
+
expressionDepth++;
|
|
22576
|
+
index += 1;
|
|
22577
|
+
continue;
|
|
22578
|
+
}
|
|
22579
|
+
if (expressionDepth > 0 && source.startsWith(MUSTACHE_CLOSE, index)) {
|
|
22580
|
+
expressionDepth--;
|
|
22581
|
+
index += 1;
|
|
22582
|
+
continue;
|
|
22583
|
+
}
|
|
22584
|
+
if (expressionDepth === 0 && source[index] === quote) {
|
|
22585
|
+
values.push(source.slice(quoteIndex + 1, index));
|
|
22586
|
+
CLASS_ATTRIBUTE_RE.lastIndex = index + 1;
|
|
22587
|
+
break;
|
|
22588
|
+
}
|
|
22589
|
+
}
|
|
22590
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22591
|
+
}
|
|
22592
|
+
return values;
|
|
22593
|
+
}
|
|
22594
|
+
function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
22559
22595
|
const matches = /* @__PURE__ */ new Set();
|
|
22560
|
-
|
|
22596
|
+
const shouldFilterByAllowedCandidates = allowedCandidates !== void 0 && allowedCandidates.size > 0;
|
|
22597
|
+
for (const classValue of collectClassAttributeValues(source)) for (const expression of classValue.match(MUSTACHE_EXPRESSION_RE) ?? []) {
|
|
22561
22598
|
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
22562
22599
|
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
22563
22600
|
while (quoted !== null) {
|
|
22564
22601
|
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
22565
|
-
for (const candidate of (0,
|
|
22602
|
+
for (const candidate of (0, tailwindcss_patch.splitCandidateTokens)(literal)) {
|
|
22566
22603
|
const normalized = candidate.trim();
|
|
22567
22604
|
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
22605
|
+
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
22568
22606
|
matches.add(normalized);
|
|
22569
22607
|
}
|
|
22570
22608
|
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
@@ -22942,6 +22980,7 @@ function createGenerateBundleHook(context) {
|
|
|
22942
22980
|
const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
22943
22981
|
const useV3OxideSourceRuntime = runtimeState.twPatcher.majorVersion === 3 && sourceCandidates.size > 0 && hasCssAssetEntry && !forceRuntimeRefreshByEnv && !disableV3OxideSourceRuntime;
|
|
22944
22982
|
const runtimeStart = performance.now();
|
|
22983
|
+
const transformBaseRuntime = useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, { transformOnly: true }) : void 0;
|
|
22945
22984
|
const runtime = isWebGeneratorTarget && !shouldGenerateWebCssByGenerator ? /* @__PURE__ */ new Set() : useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, {
|
|
22946
22985
|
allowBaselineOnlyInitialSync: true,
|
|
22947
22986
|
baseClassSet: sourceCandidates
|
|
@@ -22950,8 +22989,8 @@ function createGenerateBundleHook(context) {
|
|
|
22950
22989
|
const shouldFilterTailwindV4MiniProgramCandidates = runtimeState.twPatcher.majorVersion === 4 && generatorOptions.target === "weapp";
|
|
22951
22990
|
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
22952
22991
|
let generatorRuntime = collectLegacyContainerCompatCandidates(sourceCandidates, shouldFilterTailwindV4MiniProgramCandidates ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates);
|
|
22953
|
-
let transformRuntime = runtime;
|
|
22954
|
-
if (runtimeState.twPatcher.majorVersion === 3 && generatorRuntime.size > 0
|
|
22992
|
+
let transformRuntime = transformBaseRuntime ?? runtime;
|
|
22993
|
+
if (runtimeState.twPatcher.majorVersion === 3 && generatorRuntime.size > 0) {
|
|
22955
22994
|
const cssEntries = snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset");
|
|
22956
22995
|
const mainCssEntry = cssEntries.find((entry) => getCssHandlerOptions(entry.file).isMainChunk) ?? cssEntries[0];
|
|
22957
22996
|
if (mainCssEntry) {
|
|
@@ -22979,6 +23018,11 @@ function createGenerateBundleHook(context) {
|
|
|
22979
23018
|
const generatorCandidatesChanged = state.generatorCandidateSignature !== generatorCandidateSignature;
|
|
22980
23019
|
const runtimeLinkedCssFiles = collectRuntimeLinkedCssFiles(snapshot);
|
|
22981
23020
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
23021
|
+
const dynamicRetryCandidates = new Set([
|
|
23022
|
+
...sourceCandidates,
|
|
23023
|
+
...generatorRuntime,
|
|
23024
|
+
...transformRuntime
|
|
23025
|
+
]);
|
|
22982
23026
|
const defaultTemplateHandlerOptions = { runtimeSet: transformRuntime };
|
|
22983
23027
|
metrics.runtimeSet = measureElapsed(runtimeStart);
|
|
22984
23028
|
timingDetails["runtime"] = metrics.runtimeSet;
|
|
@@ -23025,11 +23069,18 @@ function createGenerateBundleHook(context) {
|
|
|
23025
23069
|
const start = performance.now();
|
|
23026
23070
|
let transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
23027
23071
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
23072
|
+
let retryRuntimeSet;
|
|
23028
23073
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
23029
|
-
|
|
23030
|
-
|
|
23031
|
-
|
|
23032
|
-
|
|
23074
|
+
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
23075
|
+
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
23076
|
+
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
23077
|
+
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet.has(candidate));
|
|
23078
|
+
}
|
|
23079
|
+
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
23080
|
+
_weapp_tailwindcss_logger.logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
23081
|
+
transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
|
|
23082
|
+
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
23083
|
+
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
23033
23084
|
}
|
|
23034
23085
|
metrics.html.elapsed += measureElapsed(start);
|
|
23035
23086
|
metrics.html.transformed++;
|
|
@@ -23579,6 +23630,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
23579
23630
|
refreshTailwindcssPatcher
|
|
23580
23631
|
};
|
|
23581
23632
|
const bundleRuntimeClassSetManager = require_incremental_runtime_class_set.createBundleRuntimeClassSetManager();
|
|
23633
|
+
const transformRuntimeClassSetManager = require_incremental_runtime_class_set.createBundleRuntimeClassSetManager();
|
|
23582
23634
|
let runtimeSet;
|
|
23583
23635
|
let runtimeSetPromise;
|
|
23584
23636
|
let runtimeRefreshSignature;
|
|
@@ -23646,6 +23698,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
23646
23698
|
runtimeSet = void 0;
|
|
23647
23699
|
runtimeSetPromise = void 0;
|
|
23648
23700
|
await bundleRuntimeClassSetManager.reset();
|
|
23701
|
+
await transformRuntimeClassSetManager.reset();
|
|
23649
23702
|
}
|
|
23650
23703
|
if (runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) try {
|
|
23651
23704
|
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
@@ -23655,22 +23708,30 @@ function createViteRuntimeClassSet(options) {
|
|
|
23655
23708
|
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
23656
23709
|
await bundleRuntimeClassSetManager.reset();
|
|
23657
23710
|
}
|
|
23658
|
-
if (runtimeState.twPatcher.majorVersion === 3 && !forceRuntimeRefresh)
|
|
23659
|
-
|
|
23660
|
-
|
|
23661
|
-
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
}
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
|
|
23672
|
-
|
|
23673
|
-
|
|
23711
|
+
if (runtimeState.twPatcher.majorVersion === 3 && !forceRuntimeRefresh) {
|
|
23712
|
+
if (options.transformOnly) try {
|
|
23713
|
+
return await transformRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
23714
|
+
} catch (error) {
|
|
23715
|
+
debug("incremental transform runtime set sync failed, fallback to full collect: %O", error);
|
|
23716
|
+
await transformRuntimeClassSetManager.reset();
|
|
23717
|
+
}
|
|
23718
|
+
try {
|
|
23719
|
+
let baseClassSet = options.baseClassSet;
|
|
23720
|
+
if (!baseClassSet && (!runtimeSet || shouldRefreshPatcher)) baseClassSet = await require_precheck.collectRuntimeClassSet(runtimeState.twPatcher, {
|
|
23721
|
+
force: true,
|
|
23722
|
+
skipRefresh: shouldRefreshPatcher,
|
|
23723
|
+
clearCache: shouldRefreshPatcher
|
|
23724
|
+
});
|
|
23725
|
+
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot, {
|
|
23726
|
+
baseClassSet: baseClassSet ?? (options.allowBaselineOnlyInitialSync === true ? runtimeSet : void 0),
|
|
23727
|
+
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync === true && Boolean(runtimeSet)
|
|
23728
|
+
});
|
|
23729
|
+
runtimeSet = nextRuntimeSet;
|
|
23730
|
+
return nextRuntimeSet;
|
|
23731
|
+
} catch (error) {
|
|
23732
|
+
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
23733
|
+
await bundleRuntimeClassSetManager.reset();
|
|
23734
|
+
}
|
|
23674
23735
|
}
|
|
23675
23736
|
if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) return runtimeSet;
|
|
23676
23737
|
const task = require_precheck.collectRuntimeClassSet(runtimeState.twPatcher, {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { C as __esmMin, S as __commonJSMin, _ as toCustomAttributesEntities, a as vitePluginName, c as createAttributeMatcher, d as _defineProperty, f as init_defineProperty, h as babelParse, l as analyzeSource, m as replaceWxml, n as getCompilerContext, p as isClassContextLiteralPath, s as generateCode, t as shouldSkipJsTransform, u as JsTokenUpdater, v as collectRuntimeClassSet, w as __require, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-
|
|
1
|
+
import { C as __esmMin, S as __commonJSMin, _ as toCustomAttributesEntities, a as vitePluginName, c as createAttributeMatcher, d as _defineProperty, f as init_defineProperty, h as babelParse, l as analyzeSource, m as replaceWxml, n as getCompilerContext, p as isClassContextLiteralPath, s as generateCode, t as shouldSkipJsTransform, u as JsTokenUpdater, v as collectRuntimeClassSet, w as __require, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-mM9IVd1f.mjs";
|
|
2
2
|
import { B as createDebug, E as filterUnsupportedMiniProgramTailwindV4Candidates, J as findNearestPackageRoot, U as findTailwindConfig, W as resolveTailwindcssOptions, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, q as omitUndefined, v as resolveViteTailwindV4CssDependencies } from "./v3-engine-C_KeUQG3.mjs";
|
|
3
3
|
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-CpsHA4Wd.mjs";
|
|
4
|
-
import { a as validateCandidatesByGenerator, c as hasTailwindRootDirectives, d as hasTailwindGeneratedCssMarkers, i as generateCssByGenerator, l as hasTailwindSourceDirectives, n as createHmrTimingRecorder, o as mergeMarkedUserLayerComponentsCss, s as processCachedTask, t as createBundleRuntimeClassSetManager, u as normalizeTailwindSourceForGenerator } from "./incremental-runtime-class-set-
|
|
4
|
+
import { a as validateCandidatesByGenerator, c as hasTailwindRootDirectives, d as hasTailwindGeneratedCssMarkers, i as generateCssByGenerator, l as hasTailwindSourceDirectives, n as createHmrTimingRecorder, o as mergeMarkedUserLayerComponentsCss, s as processCachedTask, t as createBundleRuntimeClassSetManager, u as normalizeTailwindSourceForGenerator } from "./incremental-runtime-class-set-BXYUYjCd.mjs";
|
|
5
5
|
import { o as resolveUniUtsPlatform } from "./utils-DsaS975I.mjs";
|
|
6
6
|
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-udhXxMX9.mjs";
|
|
7
7
|
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-_x8bq0Mz.mjs";
|
|
8
|
-
import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-
|
|
8
|
+
import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-DUIidcox.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
10
10
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
11
11
|
import postcss from "postcss";
|
|
12
12
|
import process$1 from "node:process";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
15
|
+
import { splitCandidateTokens } from "tailwindcss-patch";
|
|
15
16
|
import { readFile } from "node:fs/promises";
|
|
16
17
|
import MagicString from "magic-string";
|
|
17
|
-
import { splitCode } from "@weapp-tailwindcss/shared/extractors";
|
|
18
18
|
import postcssHtmlTransform from "@weapp-tailwindcss/postcss/html-transform";
|
|
19
19
|
import { parse } from "comment-json";
|
|
20
20
|
import postcssrc from "postcss-load-config";
|
|
@@ -21907,14 +21907,11 @@ function createStableHash(input) {
|
|
|
21907
21907
|
return (hash >>> 0).toString(36);
|
|
21908
21908
|
}
|
|
21909
21909
|
function extractLiteralValue(path) {
|
|
21910
|
-
const allowDoubleQuotes = path.isTemplateElement();
|
|
21911
21910
|
if (path.isStringLiteral()) return {
|
|
21912
|
-
allowDoubleQuotes,
|
|
21913
21911
|
literal: path.node.value,
|
|
21914
21912
|
offset: 1
|
|
21915
21913
|
};
|
|
21916
21914
|
return {
|
|
21917
|
-
allowDoubleQuotes,
|
|
21918
21915
|
literal: typeof path.node.value === "string" ? path.node.value : path.node.value.raw,
|
|
21919
21916
|
offset: 0
|
|
21920
21917
|
};
|
|
@@ -21946,7 +21943,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21946
21943
|
return alias;
|
|
21947
21944
|
}
|
|
21948
21945
|
rewriteLiteral(literal, shouldInclude) {
|
|
21949
|
-
const candidates =
|
|
21946
|
+
const candidates = splitCandidateTokens(literal);
|
|
21950
21947
|
if (candidates.length === 0) return literal;
|
|
21951
21948
|
let rewritten = literal;
|
|
21952
21949
|
for (const candidate of candidates) {
|
|
@@ -21966,8 +21963,8 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21966
21963
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
21967
21964
|
}), {}, void 0, false);
|
|
21968
21965
|
for (const path of analysis.targetPaths) {
|
|
21969
|
-
const { literal
|
|
21970
|
-
const candidates =
|
|
21966
|
+
const { literal } = extractLiteralValue(path);
|
|
21967
|
+
const candidates = splitCandidateTokens(literal);
|
|
21971
21968
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
|
21972
21969
|
for (const candidate of candidates) {
|
|
21973
21970
|
if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
@@ -21987,8 +21984,8 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21987
21984
|
if (analysis.targetPaths.length === 0) return rawSource;
|
|
21988
21985
|
const updater = new JsTokenUpdater();
|
|
21989
21986
|
for (const path of analysis.targetPaths) {
|
|
21990
|
-
const { literal,
|
|
21991
|
-
const candidates =
|
|
21987
|
+
const { literal, offset } = extractLiteralValue(path);
|
|
21988
|
+
const candidates = splitCandidateTokens(literal);
|
|
21992
21989
|
if (candidates.length === 0) continue;
|
|
21993
21990
|
let rewritten = literal;
|
|
21994
21991
|
let mutated = false;
|
|
@@ -22543,19 +22540,60 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
22543
22540
|
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
22544
22541
|
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
22545
22542
|
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
22543
|
+
const CLASS_ATTRIBUTE_RE = /\bclass\s*=\s*/g;
|
|
22544
|
+
const MUSTACHE_OPEN = "{{";
|
|
22545
|
+
const MUSTACHE_CLOSE = "}}";
|
|
22546
|
+
function isUrlLikeCandidate(candidate) {
|
|
22547
|
+
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
22548
|
+
}
|
|
22546
22549
|
function isArbitraryValueCandidate(candidate) {
|
|
22547
|
-
return candidate.includes("[") && candidate.includes("]");
|
|
22550
|
+
return candidate.includes("[") && candidate.includes("]") && !isUrlLikeCandidate(candidate.trim());
|
|
22548
22551
|
}
|
|
22549
|
-
function
|
|
22552
|
+
function collectClassAttributeValues(source) {
|
|
22553
|
+
const values = [];
|
|
22554
|
+
CLASS_ATTRIBUTE_RE.lastIndex = 0;
|
|
22555
|
+
let matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22556
|
+
while (matched !== null) {
|
|
22557
|
+
const quoteIndex = CLASS_ATTRIBUTE_RE.lastIndex;
|
|
22558
|
+
const quote = source[quoteIndex];
|
|
22559
|
+
if (quote !== "\"" && quote !== "'") {
|
|
22560
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22561
|
+
continue;
|
|
22562
|
+
}
|
|
22563
|
+
let expressionDepth = 0;
|
|
22564
|
+
for (let index = quoteIndex + 1; index < source.length; index++) {
|
|
22565
|
+
if (source.startsWith(MUSTACHE_OPEN, index)) {
|
|
22566
|
+
expressionDepth++;
|
|
22567
|
+
index += 1;
|
|
22568
|
+
continue;
|
|
22569
|
+
}
|
|
22570
|
+
if (expressionDepth > 0 && source.startsWith(MUSTACHE_CLOSE, index)) {
|
|
22571
|
+
expressionDepth--;
|
|
22572
|
+
index += 1;
|
|
22573
|
+
continue;
|
|
22574
|
+
}
|
|
22575
|
+
if (expressionDepth === 0 && source[index] === quote) {
|
|
22576
|
+
values.push(source.slice(quoteIndex + 1, index));
|
|
22577
|
+
CLASS_ATTRIBUTE_RE.lastIndex = index + 1;
|
|
22578
|
+
break;
|
|
22579
|
+
}
|
|
22580
|
+
}
|
|
22581
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22582
|
+
}
|
|
22583
|
+
return values;
|
|
22584
|
+
}
|
|
22585
|
+
function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
22550
22586
|
const matches = /* @__PURE__ */ new Set();
|
|
22551
|
-
|
|
22587
|
+
const shouldFilterByAllowedCandidates = allowedCandidates !== void 0 && allowedCandidates.size > 0;
|
|
22588
|
+
for (const classValue of collectClassAttributeValues(source)) for (const expression of classValue.match(MUSTACHE_EXPRESSION_RE) ?? []) {
|
|
22552
22589
|
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
22553
22590
|
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
22554
22591
|
while (quoted !== null) {
|
|
22555
22592
|
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
22556
|
-
for (const candidate of
|
|
22593
|
+
for (const candidate of splitCandidateTokens(literal)) {
|
|
22557
22594
|
const normalized = candidate.trim();
|
|
22558
22595
|
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
22596
|
+
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
22559
22597
|
matches.add(normalized);
|
|
22560
22598
|
}
|
|
22561
22599
|
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
@@ -22933,6 +22971,7 @@ function createGenerateBundleHook(context) {
|
|
|
22933
22971
|
const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
22934
22972
|
const useV3OxideSourceRuntime = runtimeState.twPatcher.majorVersion === 3 && sourceCandidates.size > 0 && hasCssAssetEntry && !forceRuntimeRefreshByEnv && !disableV3OxideSourceRuntime;
|
|
22935
22973
|
const runtimeStart = performance.now();
|
|
22974
|
+
const transformBaseRuntime = useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, { transformOnly: true }) : void 0;
|
|
22936
22975
|
const runtime = isWebGeneratorTarget && !shouldGenerateWebCssByGenerator ? /* @__PURE__ */ new Set() : useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, {
|
|
22937
22976
|
allowBaselineOnlyInitialSync: true,
|
|
22938
22977
|
baseClassSet: sourceCandidates
|
|
@@ -22941,8 +22980,8 @@ function createGenerateBundleHook(context) {
|
|
|
22941
22980
|
const shouldFilterTailwindV4MiniProgramCandidates = runtimeState.twPatcher.majorVersion === 4 && generatorOptions.target === "weapp";
|
|
22942
22981
|
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
22943
22982
|
let generatorRuntime = collectLegacyContainerCompatCandidates(sourceCandidates, shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates);
|
|
22944
|
-
let transformRuntime = runtime;
|
|
22945
|
-
if (runtimeState.twPatcher.majorVersion === 3 && generatorRuntime.size > 0
|
|
22983
|
+
let transformRuntime = transformBaseRuntime ?? runtime;
|
|
22984
|
+
if (runtimeState.twPatcher.majorVersion === 3 && generatorRuntime.size > 0) {
|
|
22946
22985
|
const cssEntries = snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset");
|
|
22947
22986
|
const mainCssEntry = cssEntries.find((entry) => getCssHandlerOptions(entry.file).isMainChunk) ?? cssEntries[0];
|
|
22948
22987
|
if (mainCssEntry) {
|
|
@@ -22970,6 +23009,11 @@ function createGenerateBundleHook(context) {
|
|
|
22970
23009
|
const generatorCandidatesChanged = state.generatorCandidateSignature !== generatorCandidateSignature;
|
|
22971
23010
|
const runtimeLinkedCssFiles = collectRuntimeLinkedCssFiles(snapshot);
|
|
22972
23011
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
23012
|
+
const dynamicRetryCandidates = new Set([
|
|
23013
|
+
...sourceCandidates,
|
|
23014
|
+
...generatorRuntime,
|
|
23015
|
+
...transformRuntime
|
|
23016
|
+
]);
|
|
22973
23017
|
const defaultTemplateHandlerOptions = { runtimeSet: transformRuntime };
|
|
22974
23018
|
metrics.runtimeSet = measureElapsed(runtimeStart);
|
|
22975
23019
|
timingDetails["runtime"] = metrics.runtimeSet;
|
|
@@ -23016,11 +23060,18 @@ function createGenerateBundleHook(context) {
|
|
|
23016
23060
|
const start = performance.now();
|
|
23017
23061
|
let transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
23018
23062
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
23063
|
+
let retryRuntimeSet;
|
|
23019
23064
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
23020
|
-
|
|
23021
|
-
|
|
23022
|
-
|
|
23023
|
-
|
|
23065
|
+
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
23066
|
+
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
23067
|
+
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
23068
|
+
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet.has(candidate));
|
|
23069
|
+
}
|
|
23070
|
+
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
23071
|
+
logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
23072
|
+
transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
|
|
23073
|
+
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
23074
|
+
if (unresolvedDynamicCandidates.length > 0) logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
23024
23075
|
}
|
|
23025
23076
|
metrics.html.elapsed += measureElapsed(start);
|
|
23026
23077
|
metrics.html.transformed++;
|
|
@@ -23570,6 +23621,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
23570
23621
|
refreshTailwindcssPatcher
|
|
23571
23622
|
};
|
|
23572
23623
|
const bundleRuntimeClassSetManager = createBundleRuntimeClassSetManager();
|
|
23624
|
+
const transformRuntimeClassSetManager = createBundleRuntimeClassSetManager();
|
|
23573
23625
|
let runtimeSet;
|
|
23574
23626
|
let runtimeSetPromise;
|
|
23575
23627
|
let runtimeRefreshSignature;
|
|
@@ -23637,6 +23689,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
23637
23689
|
runtimeSet = void 0;
|
|
23638
23690
|
runtimeSetPromise = void 0;
|
|
23639
23691
|
await bundleRuntimeClassSetManager.reset();
|
|
23692
|
+
await transformRuntimeClassSetManager.reset();
|
|
23640
23693
|
}
|
|
23641
23694
|
if (runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) try {
|
|
23642
23695
|
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
@@ -23646,22 +23699,30 @@ function createViteRuntimeClassSet(options) {
|
|
|
23646
23699
|
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
23647
23700
|
await bundleRuntimeClassSetManager.reset();
|
|
23648
23701
|
}
|
|
23649
|
-
if (runtimeState.twPatcher.majorVersion === 3 && !forceRuntimeRefresh)
|
|
23650
|
-
|
|
23651
|
-
|
|
23652
|
-
|
|
23653
|
-
|
|
23654
|
-
|
|
23655
|
-
}
|
|
23656
|
-
|
|
23657
|
-
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
|
|
23661
|
-
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
|
|
23702
|
+
if (runtimeState.twPatcher.majorVersion === 3 && !forceRuntimeRefresh) {
|
|
23703
|
+
if (options.transformOnly) try {
|
|
23704
|
+
return await transformRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
23705
|
+
} catch (error) {
|
|
23706
|
+
debug("incremental transform runtime set sync failed, fallback to full collect: %O", error);
|
|
23707
|
+
await transformRuntimeClassSetManager.reset();
|
|
23708
|
+
}
|
|
23709
|
+
try {
|
|
23710
|
+
let baseClassSet = options.baseClassSet;
|
|
23711
|
+
if (!baseClassSet && (!runtimeSet || shouldRefreshPatcher)) baseClassSet = await collectRuntimeClassSet(runtimeState.twPatcher, {
|
|
23712
|
+
force: true,
|
|
23713
|
+
skipRefresh: shouldRefreshPatcher,
|
|
23714
|
+
clearCache: shouldRefreshPatcher
|
|
23715
|
+
});
|
|
23716
|
+
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot, {
|
|
23717
|
+
baseClassSet: baseClassSet ?? (options.allowBaselineOnlyInitialSync === true ? runtimeSet : void 0),
|
|
23718
|
+
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync === true && Boolean(runtimeSet)
|
|
23719
|
+
});
|
|
23720
|
+
runtimeSet = nextRuntimeSet;
|
|
23721
|
+
return nextRuntimeSet;
|
|
23722
|
+
} catch (error) {
|
|
23723
|
+
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
23724
|
+
await bundleRuntimeClassSetManager.reset();
|
|
23725
|
+
}
|
|
23665
23726
|
}
|
|
23666
23727
|
if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) return runtimeSet;
|
|
23667
23728
|
const task = collectRuntimeClassSet(runtimeState.twPatcher, {
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-BVbIr2vs.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-C8vSTuBQ.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -30,7 +30,6 @@ _babel_traverse = require_runtime_registry.__toESM(_babel_traverse);
|
|
|
30
30
|
require("@babel/parser");
|
|
31
31
|
require("@babel/types");
|
|
32
32
|
require("@ast-core/escape");
|
|
33
|
-
require("@weapp-tailwindcss/shared/extractors");
|
|
34
33
|
//#region src/bundlers/shared/css-imports.ts
|
|
35
34
|
const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
|
|
36
35
|
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
2
|
const require_v3_engine = require("./v3-engine-DwY4Fixu.js");
|
|
3
3
|
const require_generator = require("./generator-BEXaaUzP.js");
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BE8RVbuz.js");
|
|
5
|
+
const require_precheck = require("./precheck-D_KT1pis.js");
|
|
6
6
|
const require_utils = require("./utils-D7Ygohep.js");
|
|
7
7
|
const require_tailwindcss = require("./tailwindcss-Cl7hUlYV.js");
|
|
8
|
-
const require_bundle_state = require("./bundle-state-
|
|
8
|
+
const require_bundle_state = require("./bundle-state-Co_ksa-C.js");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
10
10
|
node_fs = require_chunk.__toESM(node_fs);
|
|
11
11
|
let node_module = require("node:module");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { b as ensureRuntimeClassSet, d as _defineProperty, f as init_defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-
|
|
1
|
+
import { b as ensureRuntimeClassSet, d as _defineProperty, f as init_defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-mM9IVd1f.mjs";
|
|
2
2
|
import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-C_KeUQG3.mjs";
|
|
3
3
|
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-CpsHA4Wd.mjs";
|
|
4
|
-
import { i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-
|
|
4
|
+
import { i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-BXYUYjCd.mjs";
|
|
5
5
|
import { r as getGroupedEntries } from "./utils-DsaS975I.mjs";
|
|
6
6
|
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-udhXxMX9.mjs";
|
|
7
|
-
import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-
|
|
7
|
+
import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-DUIidcox.mjs";
|
|
8
8
|
import Module, { createRequire } from "node:module";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import process from "node:process";
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_webpack = require("./webpack-
|
|
2
|
+
const require_webpack = require("./webpack-DlHo84RT.js");
|
|
3
3
|
exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_webpack.WeappTailwindcss;
|
|
5
5
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-dva53gYi.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.33",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -182,13 +182,13 @@
|
|
|
182
182
|
"micromatch": "^4.0.8",
|
|
183
183
|
"postcss-load-config": "^6.0.1",
|
|
184
184
|
"semver": "~7.8.1",
|
|
185
|
-
"tailwindcss-patch": "9.
|
|
185
|
+
"tailwindcss-patch": "9.4.1",
|
|
186
186
|
"yaml": "^2.9.0",
|
|
187
187
|
"@weapp-tailwindcss/logger": "2.0.0-next.0",
|
|
188
|
+
"@weapp-tailwindcss/postcss": "3.0.0-next.9",
|
|
188
189
|
"@weapp-tailwindcss/reset": "0.1.1-next.1",
|
|
189
|
-
"@weapp-tailwindcss/
|
|
190
|
-
"tailwindcss-config": "2.0.0-next.
|
|
191
|
-
"@weapp-tailwindcss/shared": "2.0.0-next.0"
|
|
190
|
+
"@weapp-tailwindcss/shared": "2.0.0-next.1",
|
|
191
|
+
"tailwindcss-config": "2.0.0-next.3"
|
|
192
192
|
},
|
|
193
193
|
"devDependencies": {
|
|
194
194
|
"@vue/compiler-dom": "^3.5.35",
|