weapp-tailwindcss 5.4.2 → 5.5.1
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 +13 -1
- package/README.zh-CN.md +13 -1
- package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
- package/dist/bundlers/vite/capability-profile.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/web-plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-handler-options.d.ts +32 -0
- package/dist/bundlers/vite/{generate-bundle/css-output.d.ts → css-output.d.ts} +1 -1
- package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +2 -32
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/runtime.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -5
- package/dist/bundlers/vite/shared/create-css-only-plugins-runtime.d.ts +3 -0
- package/dist/cache-CBJFB1HN.cjs +223 -0
- package/dist/compiler/events.d.ts +32 -0
- package/dist/compiler/host.d.ts +13 -0
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/runtime-state.d.ts +17 -0
- package/dist/compiler-B0YSc0DY.js +4877 -0
- package/dist/{wxml-o-CUulAM.cjs → compiler-D2ZJc3uA.cjs} +3649 -283
- package/dist/core.cjs +6 -3
- package/dist/core.d.ts +2 -0
- package/dist/core.js +4 -4
- package/dist/defaults-B5ep0ojb.js +120 -0
- package/dist/defaults-BI9j1znS.cjs +156 -0
- package/dist/defaults.cjs +5 -121
- package/dist/defaults.js +1 -116
- package/dist/final-css-cleanup-B0HUBtiE.js +308 -0
- package/dist/final-css-cleanup-DSjczga3.cjs +138 -0
- package/dist/{generator-WlhrtNa3.cjs → generator-DsrQ9txU.cjs} +62 -5
- package/dist/{generator-BjK5PRR-.js → generator-DyXTBPmE.js} +47 -2
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-ChecVI6A.cjs → gulp-C9ENAx3f.cjs} +30 -28
- package/dist/{gulp-D6LcfRz_.js → gulp-DXeQfvVC.js} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-afnWvy7u.cjs → hmr-timing-Cz4IesEM.cjs} +6 -229
- package/dist/{hmr-timing-CqDfjvqE.js → hmr-timing-DNxQm-bN.js} +6 -1258
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-DxPFMGxz.cjs → pipeline-helpers-CSGnR5gh.cjs} +6 -5
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +4 -4
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/runtime-state-BBQcA0n5.cjs +54 -0
- package/dist/{source-candidate-scan-signature-FywFU3Rg.cjs → scoped-generator-TVjEaOeP.cjs} +5 -123
- package/dist/{source-candidate-scan-signature-BVScymyM.js → scoped-generator-kRj_5Axx.js} +4 -92
- package/dist/source-candidate-scan-signature-B7cUxqqX.cjs +129 -0
- package/dist/source-candidate-scan-signature-CsP4BQNa.js +92 -0
- package/dist/style-injector/internal.d.ts +1 -1
- package/dist/style-injector/vite-web.d.ts +3 -0
- package/dist/{tailwindcss-9xmoCkaR.js → tailwindcss-BK9S7zuq.js} +1 -2
- package/dist/{tailwindcss-D3jltF7M.cjs → tailwindcss-C-jBBQfw.cjs} +8 -9
- package/dist/{transform-DQhgAarN.js → transform-CfOzh007.js} +3 -3
- package/dist/{transform-C6k9zTQR.cjs → transform-DUPOPZ54.cjs} +27 -27
- package/dist/uni-app-x/vite/style-source.d.ts +11 -0
- package/dist/{v4-generation-core-CPKNwzjz.cjs → v4-generation-core-CRNUU_Rr.cjs} +29 -1172
- package/dist/vite/web.cjs +27 -0
- package/dist/vite/web.d.ts +1 -0
- package/dist/vite/web.js +25 -0
- package/dist/{vite-D3aCtpmv.js → vite-BXe-axax.js} +263 -3587
- package/dist/{vite-D-gmOkPN.cjs → vite-D_mAIfTU.cjs} +514 -3798
- package/dist/vite-web.d.ts +4 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/web-B2Ea9K4B.cjs +4361 -0
- package/dist/web-Cv7ualrU.js +3796 -0
- package/dist/{webpack-B-6a8Z8F.js → webpack-7Um2GFtx.js} +13 -12
- package/dist/{webpack-yAne9ZYu.cjs → webpack-Ce04-btG.cjs} +51 -49
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +13 -4
- package/dist/cache-options-DavPxrhC.cjs +0 -16
- package/dist/cache-options-DwBtLwQe.js +0 -5
- package/dist/compiler-B-m9VGqj.cjs +0 -2316
- package/dist/compiler-BgMj2E5l.js +0 -2051
- package/dist/local-style-matcher-DRpFEu1s.cjs +0 -34
- package/dist/local-style-matcher-DsiI2wIc.js +0 -17
- package/dist/object-B-8IHefx.js +0 -47
- package/dist/object-DbHtAXRk.cjs +0 -58
- package/dist/wxml-CvKyV69S.js +0 -1822
|
@@ -0,0 +1,4361 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
|
+
const require_framework = require("./framework.cjs");
|
|
3
|
+
const require_generator = require("./generator-DsrQ9txU.cjs");
|
|
4
|
+
const require_tailwindcss = require("./tailwindcss-C-jBBQfw.cjs");
|
|
5
|
+
const require_v4_generation_core = require("./v4-generation-core-CRNUU_Rr.cjs");
|
|
6
|
+
const require_compiler = require("./compiler-D2ZJc3uA.cjs");
|
|
7
|
+
const require_runtime_state = require("./runtime-state-BBQcA0n5.cjs");
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-Cz4IesEM.cjs");
|
|
9
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-B7cUxqqX.cjs");
|
|
10
|
+
const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
|
|
11
|
+
let node_fs = require("node:fs");
|
|
12
|
+
let node_path = require("node:path");
|
|
13
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
14
|
+
let node_process = require("node:process");
|
|
15
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
16
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
17
|
+
let lru_cache = require("lru-cache");
|
|
18
|
+
let node_fs_promises = require("node:fs/promises");
|
|
19
|
+
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
20
|
+
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
21
|
+
let node_url = require("node:url");
|
|
22
|
+
let weapp_style_injector_vite = require("weapp-style-injector/vite");
|
|
23
|
+
let node_async_hooks = require("node:async_hooks");
|
|
24
|
+
//#region src/bundlers/vite/capability-profile.ts
|
|
25
|
+
const frameworkViteCapabilityProfile = {
|
|
26
|
+
name: "framework",
|
|
27
|
+
frameworkName: "generic",
|
|
28
|
+
generatorTarget: void 0,
|
|
29
|
+
platformFamily: "unknown",
|
|
30
|
+
sourceCandidates: true,
|
|
31
|
+
frameworkExtras: true,
|
|
32
|
+
serveJsTransform: true,
|
|
33
|
+
styleInjector: true
|
|
34
|
+
};
|
|
35
|
+
function createGenericWebViteCapabilityProfile(options) {
|
|
36
|
+
return {
|
|
37
|
+
name: "generic-web",
|
|
38
|
+
cssOnly: true,
|
|
39
|
+
frameworkName: "generic",
|
|
40
|
+
generatorTarget: "web",
|
|
41
|
+
platformFamily: "web",
|
|
42
|
+
sourceCandidates: options.cssSourceTrace === true || typeof options.cssSourceTrace === "object",
|
|
43
|
+
frameworkExtras: false,
|
|
44
|
+
serveJsTransform: false,
|
|
45
|
+
styleInjector: options.styleInjector !== void 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/bundlers/vite/source-output-relations.ts
|
|
50
|
+
const activeRelationOwnerStorage = new node_async_hooks.AsyncLocalStorage();
|
|
51
|
+
function normalizeSourceFile(sourceFile) {
|
|
52
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, ""));
|
|
53
|
+
}
|
|
54
|
+
function normalizeOutputFile(outputFile) {
|
|
55
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
56
|
+
}
|
|
57
|
+
function collectOwnedSources(output) {
|
|
58
|
+
if (output.type === "chunk") {
|
|
59
|
+
if (output.facadeModuleId) return [output.facadeModuleId];
|
|
60
|
+
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
61
|
+
return moduleIds.length === 1 ? moduleIds : [];
|
|
62
|
+
}
|
|
63
|
+
return [output.originalFileName, ...Array.isArray(output.originalFileNames) ? output.originalFileNames : []].filter((sourceFile) => typeof sourceFile === "string" && sourceFile.length > 0);
|
|
64
|
+
}
|
|
65
|
+
function createViteSourceOutputRelationOwner() {
|
|
66
|
+
const outputsBySource = /* @__PURE__ */ new Map();
|
|
67
|
+
const sourcesByOutput = /* @__PURE__ */ new Map();
|
|
68
|
+
const deletedSources = /* @__PURE__ */ new Set();
|
|
69
|
+
const dirtySources = /* @__PURE__ */ new Set();
|
|
70
|
+
const consumers = /* @__PURE__ */ new Set();
|
|
71
|
+
let disposed = false;
|
|
72
|
+
const unlinkSourceFromOutput = (sourceFile, outputFile) => {
|
|
73
|
+
const outputs = outputsBySource.get(sourceFile);
|
|
74
|
+
outputs?.delete(outputFile);
|
|
75
|
+
if (outputs?.size === 0) outputsBySource.delete(sourceFile);
|
|
76
|
+
const sources = sourcesByOutput.get(outputFile);
|
|
77
|
+
sources?.delete(sourceFile);
|
|
78
|
+
if (sources?.size === 0) sourcesByOutput.delete(outputFile);
|
|
79
|
+
};
|
|
80
|
+
const unlinkSource = (sourceFile) => {
|
|
81
|
+
const outputs = [...outputsBySource.get(sourceFile) ?? []];
|
|
82
|
+
for (const outputFile of outputs) unlinkSourceFromOutput(sourceFile, outputFile);
|
|
83
|
+
return outputs;
|
|
84
|
+
};
|
|
85
|
+
const queueRemovedOutputs = (outputFiles) => {
|
|
86
|
+
for (const outputFile of outputFiles) {
|
|
87
|
+
if (sourcesByOutput.has(outputFile)) continue;
|
|
88
|
+
for (const consumer of consumers) consumer.pending.add(outputFile);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const recordOwnedOutput = (sourceFile, outputFile) => {
|
|
92
|
+
if (disposed) return;
|
|
93
|
+
const sourceKey = normalizeSourceFile(sourceFile);
|
|
94
|
+
const outputKey = normalizeOutputFile(outputFile);
|
|
95
|
+
if (!sourceKey || !outputKey || deletedSources.has(sourceKey)) return;
|
|
96
|
+
if (dirtySources.delete(sourceKey)) queueRemovedOutputs(unlinkSource(sourceKey));
|
|
97
|
+
const outputs = outputsBySource.get(sourceKey) ?? /* @__PURE__ */ new Set();
|
|
98
|
+
outputs.add(outputKey);
|
|
99
|
+
outputsBySource.set(sourceKey, outputs);
|
|
100
|
+
const sources = sourcesByOutput.get(outputKey) ?? /* @__PURE__ */ new Set();
|
|
101
|
+
sources.add(sourceKey);
|
|
102
|
+
sourcesByOutput.set(outputKey, sources);
|
|
103
|
+
};
|
|
104
|
+
const replaceOutputOwners = (outputFile, sourceFiles) => {
|
|
105
|
+
const outputKey = normalizeOutputFile(outputFile);
|
|
106
|
+
for (const sourceFile of [...sourcesByOutput.get(outputKey) ?? []]) unlinkSourceFromOutput(sourceFile, outputKey);
|
|
107
|
+
for (const sourceFile of sourceFiles) {
|
|
108
|
+
deletedSources.delete(normalizeSourceFile(sourceFile));
|
|
109
|
+
recordOwnedOutput(sourceFile, outputKey);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
createRemovalConsumer() {
|
|
114
|
+
const state = { pending: /* @__PURE__ */ new Set() };
|
|
115
|
+
consumers.add(state);
|
|
116
|
+
return { consume(currentBundleFiles) {
|
|
117
|
+
if (disposed || state.pending.size === 0) return [];
|
|
118
|
+
const currentFiles = new Set([...currentBundleFiles].map(normalizeOutputFile));
|
|
119
|
+
const removedFiles = [...state.pending].filter((file) => !currentFiles.has(file));
|
|
120
|
+
state.pending.clear();
|
|
121
|
+
return removedFiles;
|
|
122
|
+
} };
|
|
123
|
+
},
|
|
124
|
+
dispose() {
|
|
125
|
+
disposed = true;
|
|
126
|
+
outputsBySource.clear();
|
|
127
|
+
sourcesByOutput.clear();
|
|
128
|
+
deletedSources.clear();
|
|
129
|
+
dirtySources.clear();
|
|
130
|
+
consumers.clear();
|
|
131
|
+
},
|
|
132
|
+
getStats() {
|
|
133
|
+
return {
|
|
134
|
+
consumers: consumers.size,
|
|
135
|
+
dirtySources: dirtySources.size,
|
|
136
|
+
outputs: sourcesByOutput.size,
|
|
137
|
+
pendingOutputs: new Set([...consumers].flatMap((consumer) => [...consumer.pending])).size,
|
|
138
|
+
sources: outputsBySource.size
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
getOutputSources(outputFile) {
|
|
142
|
+
return new Set(sourcesByOutput.get(normalizeOutputFile(outputFile)) ?? []);
|
|
143
|
+
},
|
|
144
|
+
getOwnedOutputs(sourceFile) {
|
|
145
|
+
return new Set(outputsBySource.get(normalizeSourceFile(sourceFile)) ?? []);
|
|
146
|
+
},
|
|
147
|
+
observeSource(sourceFile) {
|
|
148
|
+
if (!disposed) {
|
|
149
|
+
const sourceKey = normalizeSourceFile(sourceFile);
|
|
150
|
+
deletedSources.delete(sourceKey);
|
|
151
|
+
if (outputsBySource.has(sourceKey)) dirtySources.add(sourceKey);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
recordBundle(bundle) {
|
|
155
|
+
if (disposed) return;
|
|
156
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
157
|
+
const ownedSources = collectOwnedSources(output);
|
|
158
|
+
if (ownedSources.length > 0) replaceOutputOwners(output.fileName || bundleFile, ownedSources);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
recordOwnedOutput,
|
|
162
|
+
removeSource(sourceFile) {
|
|
163
|
+
if (disposed) return /* @__PURE__ */ new Set();
|
|
164
|
+
const sourceKey = normalizeSourceFile(sourceFile);
|
|
165
|
+
deletedSources.add(sourceKey);
|
|
166
|
+
dirtySources.delete(sourceKey);
|
|
167
|
+
const removedOutputs = /* @__PURE__ */ new Set();
|
|
168
|
+
for (const outputFile of unlinkSource(sourceKey)) if (!sourcesByOutput.has(outputFile)) removedOutputs.add(outputFile);
|
|
169
|
+
queueRemovedOutputs(removedOutputs);
|
|
170
|
+
return removedOutputs;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function getActiveViteSourceOutputRelationOwner() {
|
|
175
|
+
return activeRelationOwnerStorage.getStore();
|
|
176
|
+
}
|
|
177
|
+
function withViteSourceOutputRelationOwner(owner, run) {
|
|
178
|
+
return activeRelationOwnerStorage.run(owner, run);
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/bundlers/vite/css-asset-identity.ts
|
|
182
|
+
function createViteCssAssetIdentityResolver(options) {
|
|
183
|
+
const identityByAsset = /* @__PURE__ */ new WeakMap();
|
|
184
|
+
const placeholderFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve(options.generatorPlaceholderFile));
|
|
185
|
+
return (asset, file) => {
|
|
186
|
+
const cached = identityByAsset.get(asset);
|
|
187
|
+
if (cached) return cached;
|
|
188
|
+
const candidates = [
|
|
189
|
+
file,
|
|
190
|
+
asset.originalFileName,
|
|
191
|
+
...asset.originalFileNames ?? []
|
|
192
|
+
].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
193
|
+
const placeholderSourceFile = candidates.find((candidate) => require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve(candidate.replace(/[?#].*$/, ""))) === placeholderFile);
|
|
194
|
+
let identity;
|
|
195
|
+
if (placeholderSourceFile) identity = {
|
|
196
|
+
kind: "generator-placeholder",
|
|
197
|
+
sourceFile: placeholderSourceFile
|
|
198
|
+
};
|
|
199
|
+
else {
|
|
200
|
+
const processedSourceFile = candidates.find(options.isKnownProcessedSource);
|
|
201
|
+
identity = processedSourceFile ? {
|
|
202
|
+
kind: "bundler-generated",
|
|
203
|
+
sourceFile: processedSourceFile
|
|
204
|
+
} : { kind: "user" };
|
|
205
|
+
}
|
|
206
|
+
identityByAsset.set(asset, identity);
|
|
207
|
+
return identity;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/bundlers/vite/css-handler-options.ts
|
|
212
|
+
function resolveViteCssHandlerExtraOptions(file) {
|
|
213
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, "")).includes("/") ? { isMainChunk: false } : {};
|
|
214
|
+
}
|
|
215
|
+
function createCssHandlerOptionsCache(options) {
|
|
216
|
+
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
217
|
+
const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
218
|
+
const getCssHandlerOptions = (file) => {
|
|
219
|
+
const majorVersion = options.getMajorVersion();
|
|
220
|
+
const appType = options.getAppType();
|
|
221
|
+
const isMainChunk = options.mainCssChunkMatcher(file, appType);
|
|
222
|
+
const outputRoot = options.getOutputRoot?.();
|
|
223
|
+
const sourceFile = require_v4_generation_core.stripRequestQuery(file);
|
|
224
|
+
const from = node_path.default.isAbsolute(sourceFile) ? sourceFile : outputRoot ? node_path.default.resolve(outputRoot, sourceFile) : sourceFile;
|
|
225
|
+
const extraOptions = options.getExtraOptions?.(file) ?? {};
|
|
226
|
+
const dynamicCssOptions = options.getDynamicCssOptions?.() ?? {};
|
|
227
|
+
const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}:${JSON.stringify(dynamicCssOptions)}`;
|
|
228
|
+
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
229
|
+
if (cached) return cached;
|
|
230
|
+
const created = {
|
|
231
|
+
isMainChunk,
|
|
232
|
+
...extraOptions,
|
|
233
|
+
...dynamicCssOptions,
|
|
234
|
+
postcssOptions: { options: { from } },
|
|
235
|
+
majorVersion: require_compiler.normalizeStyleHandlerMajorVersion(majorVersion),
|
|
236
|
+
sourceOptions: {
|
|
237
|
+
outputRoot,
|
|
238
|
+
...sourceFile === file ? {} : { requestFile: file }
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
cssHandlerOptionsCache.set(cacheKey, created);
|
|
242
|
+
return created;
|
|
243
|
+
};
|
|
244
|
+
const getCssUserHandlerOptions = (file) => {
|
|
245
|
+
const majorVersion = options.getMajorVersion();
|
|
246
|
+
const outputRoot = options.getOutputRoot?.();
|
|
247
|
+
const cacheKey = `${majorVersion ?? "unknown"}:${outputRoot ?? ""}:${file}`;
|
|
248
|
+
const cached = cssUserHandlerOptionsCache.get(cacheKey);
|
|
249
|
+
if (cached) return cached;
|
|
250
|
+
const created = {
|
|
251
|
+
...getCssHandlerOptions(file),
|
|
252
|
+
isMainChunk: false
|
|
253
|
+
};
|
|
254
|
+
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
255
|
+
return created;
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
getCssHandlerOptions,
|
|
259
|
+
getCssUserHandlerOptions
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/bundlers/vite/utils.ts
|
|
264
|
+
function slash(p) {
|
|
265
|
+
return (0, _weapp_tailwindcss_shared.ensurePosix)(p);
|
|
266
|
+
}
|
|
267
|
+
const isWindows = node_process.default.platform === "win32";
|
|
268
|
+
const cssLangRE = new RegExp(`\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)`);
|
|
269
|
+
const htmlLangRE = /\.html?(?:$|\?)/;
|
|
270
|
+
function isCSSRequest(request) {
|
|
271
|
+
return cssLangRE.test(request) || require_v4_generation_core.isSourceStyleRequest(request);
|
|
272
|
+
}
|
|
273
|
+
function isWeappViteSidecarRequest(request) {
|
|
274
|
+
const queryIndex = request.indexOf("?");
|
|
275
|
+
if (queryIndex < 0) return false;
|
|
276
|
+
const hashIndex = request.indexOf("#", queryIndex);
|
|
277
|
+
const query = request.slice(queryIndex + 1, hashIndex < 0 ? void 0 : hashIndex);
|
|
278
|
+
return new URLSearchParams(query).has("weapp-vite-sidecar");
|
|
279
|
+
}
|
|
280
|
+
function resolveViteCssPipelineRequestFile(request) {
|
|
281
|
+
return isWeappViteSidecarRequest(request) ? (0, _weapp_tailwindcss_shared.cleanUrl)(request) : request;
|
|
282
|
+
}
|
|
283
|
+
function isHTMLRequest(request) {
|
|
284
|
+
return htmlLangRE.test(request);
|
|
285
|
+
}
|
|
286
|
+
function normalizePath(id) {
|
|
287
|
+
return node_path.default.posix.normalize(isWindows ? (0, _weapp_tailwindcss_shared.ensurePosix)(id) : id);
|
|
288
|
+
}
|
|
289
|
+
async function formatPostcssSourceMap(rawMap, file) {
|
|
290
|
+
const inputFileDir = node_path.default.dirname(file);
|
|
291
|
+
const sources = rawMap.sources.map((source) => {
|
|
292
|
+
const cleanSource = (0, _weapp_tailwindcss_shared.cleanUrl)(decodeURIComponent(source));
|
|
293
|
+
if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
|
|
294
|
+
return normalizePath(node_path.default.resolve(inputFileDir, cleanSource));
|
|
295
|
+
});
|
|
296
|
+
return {
|
|
297
|
+
file,
|
|
298
|
+
mappings: rawMap.mappings,
|
|
299
|
+
names: rawMap.names,
|
|
300
|
+
sources,
|
|
301
|
+
sourcesContent: rawMap.sourcesContent,
|
|
302
|
+
version: rawMap.version
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/bundlers/vite/css-output.ts
|
|
307
|
+
const SOURCE_STYLE_OUTPUT_EXT_RE = /\.(?:less|sass|scss|styl|stylus|pcss|postcss)$/i;
|
|
308
|
+
const CSS_SOURCE_OUTPUT_EXT_RE = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)$/i;
|
|
309
|
+
const SOURCE_STYLE_NON_CSS_SYNTAX_RE = /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@(?:use|forward|mixin|include|function)\b)/;
|
|
310
|
+
const FALLBACK_STYLE_OUTPUT_EXTENSION = ".css";
|
|
311
|
+
const COMMON_MINI_PROGRAM_STYLE_OUTPUT_EXTENSIONS = [
|
|
312
|
+
".wxss",
|
|
313
|
+
".acss",
|
|
314
|
+
".ttss",
|
|
315
|
+
".qss",
|
|
316
|
+
".jxss",
|
|
317
|
+
".tyss"
|
|
318
|
+
];
|
|
319
|
+
function resolveCssOutputRealPath(value) {
|
|
320
|
+
const resolved = node_path.default.resolve(value);
|
|
321
|
+
let current = resolved;
|
|
322
|
+
const pendingSegments = [];
|
|
323
|
+
while (!(0, node_fs.existsSync)(current)) {
|
|
324
|
+
const parent = node_path.default.dirname(current);
|
|
325
|
+
if (parent === current) return resolved;
|
|
326
|
+
pendingSegments.unshift(node_path.default.basename(current));
|
|
327
|
+
current = parent;
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
const realPath = node_fs.realpathSync.native(current);
|
|
331
|
+
return pendingSegments.length > 0 ? node_path.default.join(realPath, ...pendingSegments) : realPath;
|
|
332
|
+
} catch {
|
|
333
|
+
return resolved;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function normalizeStyleOutputExtension(value) {
|
|
337
|
+
if (typeof value !== "string" || value.trim().length === 0) return;
|
|
338
|
+
const normalized = value.trim().toLowerCase();
|
|
339
|
+
return normalized.startsWith(".") ? normalized : `.${normalized}`;
|
|
340
|
+
}
|
|
341
|
+
function getMatchedStyleOutputExtension(file, cssMatcher) {
|
|
342
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
343
|
+
if (!cssMatcher?.(cleanFile)) return;
|
|
344
|
+
const ext = node_path.default.extname(cleanFile);
|
|
345
|
+
if (!ext || ext === ".css") return;
|
|
346
|
+
return ext;
|
|
347
|
+
}
|
|
348
|
+
function resolveStyleOutputExtensionFromFiles(files, cssMatcher, stem) {
|
|
349
|
+
let extension;
|
|
350
|
+
for (const file of files ?? []) {
|
|
351
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
352
|
+
const matchedExtension = getMatchedStyleOutputExtension(cleanFile, cssMatcher);
|
|
353
|
+
if (!matchedExtension) continue;
|
|
354
|
+
if (stem && cleanFile.slice(0, -matchedExtension.length) !== stem) continue;
|
|
355
|
+
if (extension && extension !== matchedExtension) return;
|
|
356
|
+
extension = matchedExtension;
|
|
357
|
+
}
|
|
358
|
+
return extension;
|
|
359
|
+
}
|
|
360
|
+
function resolveStyleOutputExtensionFromMatcher(cssMatcher, stem) {
|
|
361
|
+
if (!cssMatcher || !stem) return;
|
|
362
|
+
return COMMON_MINI_PROGRAM_STYLE_OUTPUT_EXTENSIONS.find((extension) => cssMatcher(`${stem}${extension}`));
|
|
363
|
+
}
|
|
364
|
+
function resolveStyleOutputFileFromFiles(files, cssMatcher, stem) {
|
|
365
|
+
const cleanStem = require_source_candidate_scan_signature.normalizeOutputPathKey(stem);
|
|
366
|
+
const stemSuffix = `/${cleanStem}`;
|
|
367
|
+
const matchedFiles = /* @__PURE__ */ new Set();
|
|
368
|
+
for (const file of files ?? []) {
|
|
369
|
+
const cleanFile = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
370
|
+
if (!cssMatcher?.(cleanFile)) continue;
|
|
371
|
+
const extension = node_path.default.extname(cleanFile);
|
|
372
|
+
if (!extension || extension === ".css") continue;
|
|
373
|
+
const outputStem = cleanFile.slice(0, -extension.length);
|
|
374
|
+
const outputStemSuffix = `/${outputStem}`;
|
|
375
|
+
if (outputStem === cleanStem || outputStem.endsWith(stemSuffix) || cleanStem.endsWith(outputStemSuffix) || cleanStem.endsWith(`/${outputStem}`)) matchedFiles.add(cleanFile);
|
|
376
|
+
}
|
|
377
|
+
return matchedFiles.size === 1 ? [...matchedFiles][0] : void 0;
|
|
378
|
+
}
|
|
379
|
+
function resolveMiniProgramStyleOutputExtension(options = {}) {
|
|
380
|
+
return resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher, options.stem) ?? resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher) ?? resolveStyleOutputExtensionFromMatcher(options.cssMatcher, options.stem) ?? normalizeStyleOutputExtension(options.fallback) ?? FALLBACK_STYLE_OUTPUT_EXTENSION;
|
|
381
|
+
}
|
|
382
|
+
function resolveReplayCssOutputFile(rootDir, file) {
|
|
383
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
384
|
+
const nextFile = node_path.default.isAbsolute(cleanFile) ? node_path.default.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(cleanFile)) : cleanFile;
|
|
385
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(nextFile);
|
|
386
|
+
if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.basename(cleanFile));
|
|
387
|
+
return normalizedFile;
|
|
388
|
+
}
|
|
389
|
+
function normalizeViteSourceRoot(rootDir, sourceRoot) {
|
|
390
|
+
if (typeof sourceRoot !== "string" || sourceRoot.trim().length === 0) return;
|
|
391
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.isAbsolute(sourceRoot) ? node_path.default.relative(rootDir, sourceRoot) : sourceRoot).replace(/\/+$/, "");
|
|
392
|
+
}
|
|
393
|
+
function resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot) {
|
|
394
|
+
const outputFile = resolveReplayCssOutputFile(rootDir, file);
|
|
395
|
+
const normalizedSourceRoot = normalizeViteSourceRoot(rootDir, sourceRoot);
|
|
396
|
+
if (!normalizedSourceRoot) return outputFile;
|
|
397
|
+
if (outputFile === normalizedSourceRoot) return node_path.default.posix.basename(outputFile);
|
|
398
|
+
if (outputFile.startsWith(`${normalizedSourceRoot}/`)) return outputFile.slice(normalizedSourceRoot.length + 1);
|
|
399
|
+
return outputFile;
|
|
400
|
+
}
|
|
401
|
+
function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssExtension = false, styleOutputExtension, styleOutputFiles) {
|
|
402
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
403
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !isCSSRequest(file)) return cleanFile;
|
|
404
|
+
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
405
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, resolveMiniProgramStyleOutputExtension({
|
|
406
|
+
cssMatcher: opts.cssMatcher,
|
|
407
|
+
fallback: styleOutputExtension,
|
|
408
|
+
files: styleOutputFiles,
|
|
409
|
+
stem
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
function resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
413
|
+
const sourceStyleRequest = isCSSRequest(file);
|
|
414
|
+
const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot).replace(/[?#].*$/, "");
|
|
415
|
+
const sourceExtension = node_path.default.extname(cleanFile);
|
|
416
|
+
if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
|
|
417
|
+
const stem = cleanFile.slice(0, -sourceExtension.length);
|
|
418
|
+
return `${stem}${resolveMiniProgramStyleOutputExtension({
|
|
419
|
+
cssMatcher: opts.cssMatcher,
|
|
420
|
+
fallback: styleOutputExtension,
|
|
421
|
+
files: styleOutputFiles,
|
|
422
|
+
stem
|
|
423
|
+
})}`;
|
|
424
|
+
}
|
|
425
|
+
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
426
|
+
const matchedStyleExtension = !isWebGeneratorTarget && !preserveCssExtension ? resolveStyleOutputExtensionFromFiles(styleOutputFiles, opts.cssMatcher, stem) : void 0;
|
|
427
|
+
if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) && sourceStyleRequest) return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, matchedStyleExtension);
|
|
428
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
|
|
429
|
+
const fallbackExtension = normalizeStyleOutputExtension(styleOutputExtension);
|
|
430
|
+
if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanFile)) return cleanFile;
|
|
431
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, fallbackExtension ?? FALLBACK_STYLE_OUTPUT_EXTENSION);
|
|
432
|
+
}
|
|
433
|
+
function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
434
|
+
const sourceStyleRequest = isCSSRequest(sourceFile);
|
|
435
|
+
const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, sourceFile, sourceRoot).replace(/[?#].*$/, "");
|
|
436
|
+
const sourceExtension = node_path.default.extname(cleanFile);
|
|
437
|
+
if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
|
|
438
|
+
const stem = cleanFile.slice(0, -sourceExtension.length);
|
|
439
|
+
return resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem) ?? `${stem}${resolveMiniProgramStyleOutputExtension({
|
|
440
|
+
cssMatcher: opts.cssMatcher,
|
|
441
|
+
fallback: styleOutputExtension,
|
|
442
|
+
files: styleOutputFiles,
|
|
443
|
+
stem
|
|
444
|
+
})}`;
|
|
445
|
+
}
|
|
446
|
+
if (isWebGeneratorTarget || preserveCssExtension || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
|
|
447
|
+
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
448
|
+
const matchedStyleFile = resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem);
|
|
449
|
+
if (matchedStyleFile) return matchedStyleFile;
|
|
450
|
+
const styleExtension = resolveStyleOutputExtensionFromFiles(styleOutputFiles, opts.cssMatcher, stem) ?? resolveMiniProgramStyleOutputExtension({
|
|
451
|
+
cssMatcher: opts.cssMatcher,
|
|
452
|
+
fallback: styleOutputExtension,
|
|
453
|
+
files: styleOutputFiles,
|
|
454
|
+
stem
|
|
455
|
+
}) ?? normalizeStyleOutputExtension(styleOutputExtension);
|
|
456
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, styleExtension);
|
|
457
|
+
}
|
|
458
|
+
function canProcessViteSourceStyleAsCss(source, file) {
|
|
459
|
+
if (SOURCE_STYLE_NON_CSS_SYNTAX_RE.test(source)) return false;
|
|
460
|
+
try {
|
|
461
|
+
_weapp_tailwindcss_postcss.postcss.parse(source, { from: file });
|
|
462
|
+
return true;
|
|
463
|
+
} catch {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function normalizeCssSourceForCompare(css) {
|
|
468
|
+
return css.trim();
|
|
469
|
+
}
|
|
470
|
+
function stripStyleFileExtension(file) {
|
|
471
|
+
const normalized = file.replace(/[?#].*$/, "");
|
|
472
|
+
const ext = node_path.default.extname(normalized);
|
|
473
|
+
return ext ? normalized.slice(0, -ext.length) : normalized;
|
|
474
|
+
}
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
477
|
+
let _lazyMatch = () => {
|
|
478
|
+
var __lib__ = (() => {
|
|
479
|
+
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
480
|
+
for (var n in e) m(r, n, {
|
|
481
|
+
get: e[n],
|
|
482
|
+
enumerable: true
|
|
483
|
+
});
|
|
484
|
+
}, H = (r, e, n, a) => {
|
|
485
|
+
if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, {
|
|
486
|
+
get: () => e[t],
|
|
487
|
+
enumerable: !(a = V(e, t)) || a.enumerable
|
|
488
|
+
});
|
|
489
|
+
return r;
|
|
490
|
+
}, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
|
|
491
|
+
q(w, { default: () => re });
|
|
492
|
+
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
493
|
+
const e = /* @__PURE__ */ new Map();
|
|
494
|
+
return (n) => {
|
|
495
|
+
const a = e.get(n);
|
|
496
|
+
if (a) return a;
|
|
497
|
+
const t = r(n);
|
|
498
|
+
return e.set(n, t), t;
|
|
499
|
+
};
|
|
500
|
+
}, rr = (r, e, n = {}) => {
|
|
501
|
+
const a = {
|
|
502
|
+
cache: {},
|
|
503
|
+
input: r,
|
|
504
|
+
index: 0,
|
|
505
|
+
indexMax: 0,
|
|
506
|
+
options: n,
|
|
507
|
+
output: []
|
|
508
|
+
};
|
|
509
|
+
if (v(e)(a) && a.index === r.length) return a.output;
|
|
510
|
+
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
511
|
+
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
512
|
+
const n = {};
|
|
513
|
+
for (const a of r) {
|
|
514
|
+
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
515
|
+
const t = a.charCodeAt(0);
|
|
516
|
+
n[t] = true;
|
|
517
|
+
}
|
|
518
|
+
return (a) => {
|
|
519
|
+
const t = a.index, o = a.input;
|
|
520
|
+
for (; a.index < o.length && o.charCodeAt(a.index) in n;) a.index += 1;
|
|
521
|
+
const u = a.index;
|
|
522
|
+
if (u > t) {
|
|
523
|
+
if (!h(e) && !a.options.silent) {
|
|
524
|
+
const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
|
|
525
|
+
h(c) || a.output.push(c);
|
|
526
|
+
}
|
|
527
|
+
a.indexMax = Math.max(a.indexMax, a.index);
|
|
528
|
+
}
|
|
529
|
+
return true;
|
|
530
|
+
};
|
|
531
|
+
}, nr = (r, e) => {
|
|
532
|
+
const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
|
|
533
|
+
return g((o) => {
|
|
534
|
+
t.lastIndex = o.index;
|
|
535
|
+
const u = t.exec(o.input);
|
|
536
|
+
if (u) {
|
|
537
|
+
if (!h(e) && !o.options.silent) {
|
|
538
|
+
const s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
539
|
+
h(s) || o.output.push(s);
|
|
540
|
+
}
|
|
541
|
+
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
|
|
542
|
+
} else return false;
|
|
543
|
+
});
|
|
544
|
+
}, ar = (r, e) => (n) => {
|
|
545
|
+
if (n.input.startsWith(r, n.index)) {
|
|
546
|
+
if (!h(e) && !n.options.silent) {
|
|
547
|
+
const t = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
548
|
+
h(t) || n.output.push(t);
|
|
549
|
+
}
|
|
550
|
+
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
|
|
551
|
+
} else return false;
|
|
552
|
+
}, C = (r, e, n, a) => {
|
|
553
|
+
const t = v(r);
|
|
554
|
+
return g(_(M((o) => {
|
|
555
|
+
let u = 0;
|
|
556
|
+
for (; u < n;) {
|
|
557
|
+
const s = o.index;
|
|
558
|
+
if (!t(o) || (u += 1, o.index === s)) break;
|
|
559
|
+
}
|
|
560
|
+
return u >= e;
|
|
561
|
+
})));
|
|
562
|
+
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
563
|
+
const n = r.map(v);
|
|
564
|
+
return g(_(M((a) => {
|
|
565
|
+
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
|
|
566
|
+
return true;
|
|
567
|
+
})));
|
|
568
|
+
}, l = (r, e) => {
|
|
569
|
+
const n = r.map(v);
|
|
570
|
+
return g(_((a) => {
|
|
571
|
+
for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
|
|
572
|
+
return false;
|
|
573
|
+
}));
|
|
574
|
+
}, M = (r, e = false) => {
|
|
575
|
+
const n = v(r);
|
|
576
|
+
return (a) => {
|
|
577
|
+
const t = a.index, o = a.output.length, u = n(a);
|
|
578
|
+
return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
|
|
579
|
+
};
|
|
580
|
+
}, _ = (r, e) => {
|
|
581
|
+
return v(r);
|
|
582
|
+
}, g = (() => {
|
|
583
|
+
let r = 0;
|
|
584
|
+
return (e) => {
|
|
585
|
+
const n = v(e), a = r += 1;
|
|
586
|
+
return (t) => {
|
|
587
|
+
var o;
|
|
588
|
+
if (t.options.memoization === false) return n(t);
|
|
589
|
+
const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
590
|
+
if (c === false) return false;
|
|
591
|
+
if (W(c)) return t.index = c, true;
|
|
592
|
+
if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), true;
|
|
593
|
+
{
|
|
594
|
+
const Z = t.output.length;
|
|
595
|
+
if (n(t)) {
|
|
596
|
+
const D = t.index, U = t.output.length;
|
|
597
|
+
if (U > Z) {
|
|
598
|
+
const ee = t.output.slice(Z, U);
|
|
599
|
+
s.set(u, {
|
|
600
|
+
index: D,
|
|
601
|
+
output: ee
|
|
602
|
+
});
|
|
603
|
+
} else s.set(u, D);
|
|
604
|
+
return true;
|
|
605
|
+
} else return s.set(u, false), false;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
})(), E = (r) => {
|
|
610
|
+
let e;
|
|
611
|
+
return (n) => (e || (e = v(r())), e(n));
|
|
612
|
+
}, v = Y((r) => {
|
|
613
|
+
if (d(r)) return Q(r) ? E(r) : r;
|
|
614
|
+
if (b(r) || X(r)) return i(r);
|
|
615
|
+
if (A(r)) return x(r);
|
|
616
|
+
if (K(r)) return l(Object.values(r));
|
|
617
|
+
throw new Error("Invalid rule");
|
|
618
|
+
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
619
|
+
let e = "";
|
|
620
|
+
for (; r > 0;) e = P[(r - 1) % 26] + e, r = Math.floor((r - 1) / 26);
|
|
621
|
+
return e;
|
|
622
|
+
}, O = (r) => {
|
|
623
|
+
let e = 0;
|
|
624
|
+
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
625
|
+
return e;
|
|
626
|
+
}, S = (r, e) => {
|
|
627
|
+
if (e < r) return S(e, r);
|
|
628
|
+
const n = [];
|
|
629
|
+
for (; r <= e;) n.push(r++);
|
|
630
|
+
return n;
|
|
631
|
+
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
|
|
632
|
+
const e = {};
|
|
633
|
+
return (n) => e[n] ?? (e[n] = r(n));
|
|
634
|
+
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), fr = l([i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), i(/^(!!)+/, "")]), j = l([
|
|
635
|
+
i(/\/(\*\*\/)+/, "(?:/.+/|/)"),
|
|
636
|
+
i(/^(\*\*\/)+/, "(?:^|.*/)"),
|
|
637
|
+
i(/\/(\*\*)$/, "(?:/.*|$)"),
|
|
638
|
+
i(/\*\*/, ".*")
|
|
639
|
+
]), N = l([i(/\*\/(?!\*\*\/)/, "[^/]*/"), i(/\*/, "[^/]*")]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Er = l([
|
|
640
|
+
y,
|
|
641
|
+
i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`),
|
|
642
|
+
br,
|
|
643
|
+
i(/[^\]]/, p)
|
|
644
|
+
]), B = x([
|
|
645
|
+
$r,
|
|
646
|
+
tr(Ar),
|
|
647
|
+
f(Er),
|
|
648
|
+
wr
|
|
649
|
+
]), Pr = i("{", "(?:"), Or = i("}", ")"), I = x([
|
|
650
|
+
Pr,
|
|
651
|
+
l([
|
|
652
|
+
i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")),
|
|
653
|
+
i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")),
|
|
654
|
+
i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase())
|
|
655
|
+
]),
|
|
656
|
+
Or
|
|
657
|
+
]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), F = x([
|
|
658
|
+
kr,
|
|
659
|
+
f(l([
|
|
660
|
+
j,
|
|
661
|
+
N,
|
|
662
|
+
k,
|
|
663
|
+
B,
|
|
664
|
+
I,
|
|
665
|
+
E(() => F),
|
|
666
|
+
y,
|
|
667
|
+
Fr,
|
|
668
|
+
Ir,
|
|
669
|
+
Lr
|
|
670
|
+
])),
|
|
671
|
+
Br
|
|
672
|
+
]), L = z(f(l([
|
|
673
|
+
sr,
|
|
674
|
+
cr,
|
|
675
|
+
lr,
|
|
676
|
+
fr,
|
|
677
|
+
j,
|
|
678
|
+
N,
|
|
679
|
+
k,
|
|
680
|
+
B,
|
|
681
|
+
I,
|
|
682
|
+
F,
|
|
683
|
+
y,
|
|
684
|
+
pr,
|
|
685
|
+
vr
|
|
686
|
+
]))), Tr = i(/\\./, p), qr = i(/./, p), Yr = z(f(l([
|
|
687
|
+
Tr,
|
|
688
|
+
i(/\*\*\*+/, "*"),
|
|
689
|
+
i(/([^/{[(!])\*\*/, (r, e) => `${e}*`),
|
|
690
|
+
i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`),
|
|
691
|
+
qr
|
|
692
|
+
]))), $ = (r, e) => {
|
|
693
|
+
const n = Array.isArray(r) ? r : [r];
|
|
694
|
+
if (!n.length) return false;
|
|
695
|
+
const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
|
|
696
|
+
return a.some((s) => s.test(o));
|
|
697
|
+
};
|
|
698
|
+
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
699
|
+
var re = $;
|
|
700
|
+
return J(w);
|
|
701
|
+
})();
|
|
702
|
+
return __lib__.default || __lib__;
|
|
703
|
+
};
|
|
704
|
+
let _match;
|
|
705
|
+
const zeptomatch = (path, pattern) => {
|
|
706
|
+
if (!_match) {
|
|
707
|
+
_match = _lazyMatch();
|
|
708
|
+
_lazyMatch = null;
|
|
709
|
+
}
|
|
710
|
+
return _match(path, pattern);
|
|
711
|
+
};
|
|
712
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
713
|
+
function normalizeWindowsPath(input = "") {
|
|
714
|
+
if (!input) return input;
|
|
715
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
716
|
+
}
|
|
717
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
718
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
719
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
720
|
+
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
721
|
+
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
722
|
+
const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
723
|
+
const normalize = function(path) {
|
|
724
|
+
if (path.length === 0) return ".";
|
|
725
|
+
path = normalizeWindowsPath(path);
|
|
726
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
727
|
+
const isPathAbsolute = isAbsolute(path);
|
|
728
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
729
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
730
|
+
if (path.length === 0) {
|
|
731
|
+
if (isPathAbsolute) return "/";
|
|
732
|
+
return trailingSeparator ? "./" : ".";
|
|
733
|
+
}
|
|
734
|
+
if (trailingSeparator) path += "/";
|
|
735
|
+
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
736
|
+
if (isUNCPath) {
|
|
737
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
738
|
+
return `//${path}`;
|
|
739
|
+
}
|
|
740
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
741
|
+
};
|
|
742
|
+
const join = function(...segments) {
|
|
743
|
+
let path = "";
|
|
744
|
+
for (const seg of segments) {
|
|
745
|
+
if (!seg) continue;
|
|
746
|
+
if (path.length > 0) {
|
|
747
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
748
|
+
const segLeading = seg[0] === "/";
|
|
749
|
+
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
750
|
+
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
751
|
+
} else path += seg;
|
|
752
|
+
}
|
|
753
|
+
return normalize(path);
|
|
754
|
+
};
|
|
755
|
+
function cwd() {
|
|
756
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
757
|
+
return "/";
|
|
758
|
+
}
|
|
759
|
+
const resolve = function(...arguments_) {
|
|
760
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
761
|
+
let resolvedPath = "";
|
|
762
|
+
let resolvedAbsolute = false;
|
|
763
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
764
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
765
|
+
if (!path || path.length === 0) continue;
|
|
766
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
767
|
+
resolvedAbsolute = isAbsolute(path);
|
|
768
|
+
}
|
|
769
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
770
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
771
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
772
|
+
};
|
|
773
|
+
function normalizeString(path, allowAboveRoot) {
|
|
774
|
+
let res = "";
|
|
775
|
+
let lastSegmentLength = 0;
|
|
776
|
+
let lastSlash = -1;
|
|
777
|
+
let dots = 0;
|
|
778
|
+
let char = null;
|
|
779
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
780
|
+
if (index < path.length) char = path[index];
|
|
781
|
+
else if (char === "/") break;
|
|
782
|
+
else char = "/";
|
|
783
|
+
if (char === "/") {
|
|
784
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
785
|
+
else if (dots === 2) {
|
|
786
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
787
|
+
if (res.length > 2) {
|
|
788
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
789
|
+
if (lastSlashIndex === -1) {
|
|
790
|
+
res = "";
|
|
791
|
+
lastSegmentLength = 0;
|
|
792
|
+
} else {
|
|
793
|
+
res = res.slice(0, lastSlashIndex);
|
|
794
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
795
|
+
}
|
|
796
|
+
lastSlash = index;
|
|
797
|
+
dots = 0;
|
|
798
|
+
continue;
|
|
799
|
+
} else if (res.length > 0) {
|
|
800
|
+
res = "";
|
|
801
|
+
lastSegmentLength = 0;
|
|
802
|
+
lastSlash = index;
|
|
803
|
+
dots = 0;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (allowAboveRoot) {
|
|
808
|
+
res += res.length > 0 ? "/.." : "..";
|
|
809
|
+
lastSegmentLength = 2;
|
|
810
|
+
}
|
|
811
|
+
} else {
|
|
812
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
813
|
+
else res = path.slice(lastSlash + 1, index);
|
|
814
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
815
|
+
}
|
|
816
|
+
lastSlash = index;
|
|
817
|
+
dots = 0;
|
|
818
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
819
|
+
else dots = -1;
|
|
820
|
+
}
|
|
821
|
+
return res;
|
|
822
|
+
}
|
|
823
|
+
const isAbsolute = function(p) {
|
|
824
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
825
|
+
};
|
|
826
|
+
const toNamespacedPath = function(p) {
|
|
827
|
+
return normalizeWindowsPath(p);
|
|
828
|
+
};
|
|
829
|
+
const extname = function(p) {
|
|
830
|
+
if (p === "..") return "";
|
|
831
|
+
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
832
|
+
return match && match[1] || "";
|
|
833
|
+
};
|
|
834
|
+
const relative = function(from, to) {
|
|
835
|
+
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
836
|
+
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
837
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
|
|
838
|
+
const _fromCopy = [..._from];
|
|
839
|
+
for (const segment of _fromCopy) {
|
|
840
|
+
if (_to[0] !== segment) break;
|
|
841
|
+
_from.shift();
|
|
842
|
+
_to.shift();
|
|
843
|
+
}
|
|
844
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
845
|
+
};
|
|
846
|
+
const dirname = function(p) {
|
|
847
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
848
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
849
|
+
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
850
|
+
};
|
|
851
|
+
const format = function(p) {
|
|
852
|
+
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
853
|
+
const segments = [
|
|
854
|
+
p.root,
|
|
855
|
+
p.dir,
|
|
856
|
+
p.base ?? (p.name ?? "") + ext
|
|
857
|
+
].filter(Boolean);
|
|
858
|
+
return normalizeWindowsPath(p.root ? resolve(...segments) : segments.join("/"));
|
|
859
|
+
};
|
|
860
|
+
const basename = function(p, extension) {
|
|
861
|
+
const segments = normalizeWindowsPath(p).split("/");
|
|
862
|
+
let lastSegment = "";
|
|
863
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
864
|
+
const val = segments[i];
|
|
865
|
+
if (val) {
|
|
866
|
+
lastSegment = val;
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
871
|
+
};
|
|
872
|
+
const parse = function(p) {
|
|
873
|
+
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
874
|
+
const base = basename(p);
|
|
875
|
+
const extension = extname(base);
|
|
876
|
+
return {
|
|
877
|
+
root,
|
|
878
|
+
dir: dirname(p),
|
|
879
|
+
base,
|
|
880
|
+
ext: extension,
|
|
881
|
+
name: base.slice(0, base.length - extension.length)
|
|
882
|
+
};
|
|
883
|
+
};
|
|
884
|
+
const matchesGlob = (path, pattern) => {
|
|
885
|
+
return zeptomatch(pattern, normalize(path));
|
|
886
|
+
};
|
|
887
|
+
const _path = {
|
|
888
|
+
__proto__: null,
|
|
889
|
+
basename,
|
|
890
|
+
dirname,
|
|
891
|
+
extname,
|
|
892
|
+
format,
|
|
893
|
+
isAbsolute,
|
|
894
|
+
join,
|
|
895
|
+
matchesGlob,
|
|
896
|
+
normalize,
|
|
897
|
+
normalizeString,
|
|
898
|
+
parse,
|
|
899
|
+
relative,
|
|
900
|
+
resolve,
|
|
901
|
+
sep: "/",
|
|
902
|
+
toNamespacedPath
|
|
903
|
+
};
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
|
|
906
|
+
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
|
907
|
+
const _platforms = {
|
|
908
|
+
posix: void 0,
|
|
909
|
+
win32: void 0
|
|
910
|
+
};
|
|
911
|
+
const mix = (del = delimiter) => {
|
|
912
|
+
return new Proxy(_path, { get(_, prop) {
|
|
913
|
+
if (prop === "delimiter") return del;
|
|
914
|
+
if (prop === "posix") return posix;
|
|
915
|
+
if (prop === "win32") return win32;
|
|
916
|
+
return _platforms[prop] || _path[prop];
|
|
917
|
+
} });
|
|
918
|
+
};
|
|
919
|
+
const posix = /* @__PURE__ */ mix(":");
|
|
920
|
+
const win32 = /* @__PURE__ */ mix(";");
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/bundlers/vite/processed-css-assets/style-files.ts
|
|
923
|
+
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
924
|
+
function isCssOutputFile(file) {
|
|
925
|
+
return CSS_OUTPUT_FILE_RE.test(file);
|
|
926
|
+
}
|
|
927
|
+
function isRootStyleOutputFile(file) {
|
|
928
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
929
|
+
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
930
|
+
}
|
|
931
|
+
function isMiniProgramStyleOutputFile(file) {
|
|
932
|
+
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
933
|
+
}
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/bundlers/vite/processed-css-assets/markers-imports.ts
|
|
936
|
+
function createCssAssetPipelineContext(options, file, bundle) {
|
|
937
|
+
const context = options.createCssPipelineContext?.(file);
|
|
938
|
+
return context ? {
|
|
939
|
+
...context,
|
|
940
|
+
bundle
|
|
941
|
+
} : void 0;
|
|
942
|
+
}
|
|
943
|
+
function getAssetFile(bundleFile, asset) {
|
|
944
|
+
return asset.fileName || bundleFile;
|
|
945
|
+
}
|
|
946
|
+
function readAssetSource$1(asset) {
|
|
947
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
948
|
+
}
|
|
949
|
+
function clearAssetSource(asset) {
|
|
950
|
+
asset.source = "";
|
|
951
|
+
}
|
|
952
|
+
function appendCss(baseCss, css) {
|
|
953
|
+
if (baseCss.length === 0) return css;
|
|
954
|
+
if (css.length === 0) return baseCss;
|
|
955
|
+
return `${baseCss}\n${css}`;
|
|
956
|
+
}
|
|
957
|
+
function normalizeCssRecordIdentity(css) {
|
|
958
|
+
return css.trim();
|
|
959
|
+
}
|
|
960
|
+
function hasNonCommentCss(css) {
|
|
961
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
962
|
+
}
|
|
963
|
+
function dedupeViteCssResults(records) {
|
|
964
|
+
const seen = /* @__PURE__ */ new Set();
|
|
965
|
+
return records.filter((record) => {
|
|
966
|
+
const key = `${require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
967
|
+
if (seen.has(key)) return false;
|
|
968
|
+
seen.add(key);
|
|
969
|
+
return true;
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
function removeTailwindSourceMediaWrappersRoot(root) {
|
|
973
|
+
let changed = false;
|
|
974
|
+
root.walkAtRules("media", (atRule) => {
|
|
975
|
+
if (!atRule.params.startsWith("source(")) return;
|
|
976
|
+
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
977
|
+
else atRule.remove();
|
|
978
|
+
changed = true;
|
|
979
|
+
});
|
|
980
|
+
if (changed) root.walkAtRules((atRule) => {
|
|
981
|
+
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
982
|
+
});
|
|
983
|
+
return changed;
|
|
984
|
+
}
|
|
985
|
+
function removeTailwindSourceMediaWrappersFallback(css) {
|
|
986
|
+
return css.replace(/@media\s+source\([^)]*\)\s*\{\s*\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/?\s*\}/gi, "").replace(/@media\s+source\([^)]*\)\s*\{\s*\}/gi, "");
|
|
987
|
+
}
|
|
988
|
+
function removeTailwindEntryDirectivesFromCss(css) {
|
|
989
|
+
try {
|
|
990
|
+
const source = require_generator.stripGeneratorPlaceholderMarkers(css);
|
|
991
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
992
|
+
const removedMediaWrappers = removeTailwindSourceMediaWrappersRoot(root);
|
|
993
|
+
const removedTailwindDirectives = (0, _weapp_tailwindcss_postcss.removeTailwindSourceDirectivesRoot)(root);
|
|
994
|
+
return removedMediaWrappers || removedTailwindDirectives ? root.toString() : source;
|
|
995
|
+
} catch {
|
|
996
|
+
return require_generator.removeTailwindSourceDirectives(removeTailwindSourceMediaWrappersFallback(css));
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
function removeUnsupportedMiniProgramCssImportsFallback(css, file) {
|
|
1000
|
+
if (!isMiniProgramStyleOutputFile(file) || !css.includes("@import")) return css;
|
|
1001
|
+
return css.split(/\r?\n/).filter((line) => {
|
|
1002
|
+
const trimmed = line.trim();
|
|
1003
|
+
if (!trimmed.startsWith("@import")) return true;
|
|
1004
|
+
const params = trimmed.slice(7).trim().replace(/;$/, "").trim();
|
|
1005
|
+
const request = (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(params);
|
|
1006
|
+
return request === void 0 || (0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request);
|
|
1007
|
+
}).join("\n");
|
|
1008
|
+
}
|
|
1009
|
+
function normalizeInjectableCssForTarget(css, file) {
|
|
1010
|
+
return normalizeInjectableCssForTargetWithImports(css, file).css;
|
|
1011
|
+
}
|
|
1012
|
+
function normalizeInjectableCssForTargetWithImports(css, file) {
|
|
1013
|
+
if (!css.includes("@import")) return {
|
|
1014
|
+
css,
|
|
1015
|
+
importedStyleFiles: /* @__PURE__ */ new Set()
|
|
1016
|
+
};
|
|
1017
|
+
try {
|
|
1018
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1019
|
+
const changed = isMiniProgramStyleOutputFile(file) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramCssImportsRoot)(root) : false;
|
|
1020
|
+
const importedStyleFiles = collectImportedStyleFilesRoot(root, file);
|
|
1021
|
+
return {
|
|
1022
|
+
css: changed ? root.toString() : css,
|
|
1023
|
+
importedStyleFiles: importedStyleFiles.size > 0 ? importedStyleFiles : collectImportedStyleFilesFallback(css, file)
|
|
1024
|
+
};
|
|
1025
|
+
} catch {
|
|
1026
|
+
const fallbackCss = removeUnsupportedMiniProgramCssImportsFallback(css, file);
|
|
1027
|
+
return {
|
|
1028
|
+
css: fallbackCss,
|
|
1029
|
+
importedStyleFiles: collectImportedStyleFiles(fallbackCss, file)
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
function stripStyleExtension(file) {
|
|
1034
|
+
return file.replace(/[?#].*$/, "").replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)$/i, "");
|
|
1035
|
+
}
|
|
1036
|
+
function isStyleImportRequest(request) {
|
|
1037
|
+
return typeof request === "string" && request.length > 0 && !/^(?:https?:)?\/\//i.test(request) && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request);
|
|
1038
|
+
}
|
|
1039
|
+
function resolveImportedStyleFile(targetFile, request) {
|
|
1040
|
+
if (!isStyleImportRequest(request)) return;
|
|
1041
|
+
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
1042
|
+
if (cleanRequest.startsWith("/")) return require_source_candidate_scan_signature.normalizeOutputPathKey(cleanRequest.slice(1));
|
|
1043
|
+
const targetDir = posix.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
1044
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
1045
|
+
}
|
|
1046
|
+
function collectImportedStyleFilesFromRequests(requests, targetFile) {
|
|
1047
|
+
const imports = /* @__PURE__ */ new Set();
|
|
1048
|
+
for (const request of requests) {
|
|
1049
|
+
const importedFile = resolveImportedStyleFile(targetFile, request);
|
|
1050
|
+
if (importedFile) imports.add(importedFile);
|
|
1051
|
+
}
|
|
1052
|
+
return imports;
|
|
1053
|
+
}
|
|
1054
|
+
function collectImportedStyleFilesRoot(root, targetFile) {
|
|
1055
|
+
return collectImportedStyleFilesFromRequests((0, _weapp_tailwindcss_postcss.collectCssImportRequestsRoot)(root), targetFile);
|
|
1056
|
+
}
|
|
1057
|
+
function collectImportedStyleFilesFallback(css, targetFile) {
|
|
1058
|
+
return collectImportedStyleFilesFromRequests([...css.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s;)]+))/g)].map((match) => match[1] ?? match[2] ?? match[3]).filter((request) => typeof request === "string" && request.length > 0), targetFile);
|
|
1059
|
+
}
|
|
1060
|
+
function collectImportedStyleFiles(css, targetFile) {
|
|
1061
|
+
if (!css.includes("@import")) return /* @__PURE__ */ new Set();
|
|
1062
|
+
try {
|
|
1063
|
+
const imports = collectImportedStyleFilesRoot(_weapp_tailwindcss_postcss.postcss.parse(css), targetFile);
|
|
1064
|
+
return imports.size > 0 ? imports : collectImportedStyleFilesFallback(css, targetFile);
|
|
1065
|
+
} catch {}
|
|
1066
|
+
return collectImportedStyleFilesFallback(css, targetFile);
|
|
1067
|
+
}
|
|
1068
|
+
function normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile) {
|
|
1069
|
+
return resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile;
|
|
1070
|
+
}
|
|
1071
|
+
function isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
|
|
1072
|
+
if (!markerFile) return false;
|
|
1073
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(targetFile)) === require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile)));
|
|
1074
|
+
}
|
|
1075
|
+
function resolveViteProcessedCssAssetSource(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
1076
|
+
const blocks = require_v4_generation_core.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
1077
|
+
if (blocks.length <= 1) return require_v4_generation_core.stripBundlerGeneratedCssMarkers(rawSource);
|
|
1078
|
+
const matchedCss = blocks.filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.css);
|
|
1079
|
+
return matchedCss.length > 0 ? matchedCss.join("\n") : require_v4_generation_core.stripBundlerGeneratedCssMarkers(rawSource);
|
|
1080
|
+
}
|
|
1081
|
+
function collectMatchingGeneratedCssMarkerFiles(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
1082
|
+
return require_v4_generation_core.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite").filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.file).filter((markerFile) => typeof markerFile === "string" && markerFile.length > 0);
|
|
1083
|
+
}
|
|
1084
|
+
function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
1085
|
+
const sources = [];
|
|
1086
|
+
const excludedFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(excludedFile);
|
|
1087
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1088
|
+
if (output.type !== "asset") continue;
|
|
1089
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile(bundleFile, output));
|
|
1090
|
+
if (file === excludedFileKey || !isRootStyleOutputFile(file)) continue;
|
|
1091
|
+
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$1(output)).trim();
|
|
1092
|
+
if (source.length > 0) sources.push(source);
|
|
1093
|
+
}
|
|
1094
|
+
return sources;
|
|
1095
|
+
}
|
|
1096
|
+
function isHtmlOutputFile(file) {
|
|
1097
|
+
return /\.html(?:$|[?#])/i.test(file);
|
|
1098
|
+
}
|
|
1099
|
+
function stripQueryAndHash(file) {
|
|
1100
|
+
return file.replace(/[?#].*$/, "");
|
|
1101
|
+
}
|
|
1102
|
+
function resolveHtmlLinkedStyleFile(htmlFile, request) {
|
|
1103
|
+
if (!isStyleImportRequest(request)) return;
|
|
1104
|
+
const cleanRequest = stripQueryAndHash(request);
|
|
1105
|
+
if (cleanRequest.startsWith("/")) return require_source_candidate_scan_signature.normalizeOutputPathKey(cleanRequest.slice(1));
|
|
1106
|
+
const htmlDir = posix.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(stripQueryAndHash(htmlFile)));
|
|
1107
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.posix.join(htmlDir === "." ? "" : htmlDir, cleanRequest));
|
|
1108
|
+
}
|
|
1109
|
+
function collectHtmlLinkedStyleFiles(bundle) {
|
|
1110
|
+
const linkedFiles = /* @__PURE__ */ new Set();
|
|
1111
|
+
const linkedBasenames = /* @__PURE__ */ new Set();
|
|
1112
|
+
const linkHrefRE = /<link\s[^>]*href\s*=\s*(["'])([^"']+)\1[^>]*>/gi;
|
|
1113
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1114
|
+
if (output.type !== "asset") continue;
|
|
1115
|
+
const htmlFile = getAssetFile(bundleFile, output);
|
|
1116
|
+
if (!isHtmlOutputFile(htmlFile)) continue;
|
|
1117
|
+
const html = readAssetSource$1(output);
|
|
1118
|
+
for (const match of html.matchAll(linkHrefRE)) {
|
|
1119
|
+
const href = match[2];
|
|
1120
|
+
if (!href) continue;
|
|
1121
|
+
const linkedFile = resolveHtmlLinkedStyleFile(htmlFile, href);
|
|
1122
|
+
if (!linkedFile || !isRootStyleOutputFile(linkedFile)) continue;
|
|
1123
|
+
linkedFiles.add(linkedFile);
|
|
1124
|
+
linkedBasenames.add(posix.posix.basename(linkedFile));
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
return {
|
|
1128
|
+
linkedBasenames,
|
|
1129
|
+
linkedFiles
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
function isLinkedStyleFile(file, linked) {
|
|
1133
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(stripQueryAndHash(file));
|
|
1134
|
+
return linked.linkedFiles.has(fileKey) || isRootStyleOutputFile(fileKey) && linked.linkedBasenames.has(posix.posix.basename(fileKey));
|
|
1135
|
+
}
|
|
1136
|
+
function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options = {}) {
|
|
1137
|
+
const linked = collectHtmlLinkedStyleFiles(bundle);
|
|
1138
|
+
if (linked.linkedFiles.size === 0 && linked.linkedBasenames.size === 0) return 0;
|
|
1139
|
+
const linkedSources = /* @__PURE__ */ new Set();
|
|
1140
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1141
|
+
if (output.type !== "asset") continue;
|
|
1142
|
+
const file = getAssetFile(bundleFile, output);
|
|
1143
|
+
if (!isCssOutputFile(file) || isMiniProgramStyleOutputFile(file) || !isLinkedStyleFile(file, linked)) continue;
|
|
1144
|
+
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$1(output)).trim();
|
|
1145
|
+
if (source.length > 0) linkedSources.add(source);
|
|
1146
|
+
}
|
|
1147
|
+
if (linkedSources.size === 0) return 0;
|
|
1148
|
+
let removed = 0;
|
|
1149
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1150
|
+
if (output.type !== "asset") continue;
|
|
1151
|
+
const file = getAssetFile(bundleFile, output);
|
|
1152
|
+
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
1153
|
+
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$1(output)).trim();
|
|
1154
|
+
if (!linkedSources.has(source)) continue;
|
|
1155
|
+
delete bundle[bundleFile];
|
|
1156
|
+
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
1157
|
+
removed++;
|
|
1158
|
+
}
|
|
1159
|
+
return removed;
|
|
1160
|
+
}
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/bundlers/vite/generate-bundle/style-matching.ts
|
|
1163
|
+
function resolveStyleMatchingRealPath(value) {
|
|
1164
|
+
const resolved = node_path.default.resolve(value);
|
|
1165
|
+
let current = resolved;
|
|
1166
|
+
const pendingSegments = [];
|
|
1167
|
+
while (!(0, node_fs.existsSync)(current)) {
|
|
1168
|
+
const parent = node_path.default.dirname(current);
|
|
1169
|
+
if (parent === current) return resolved;
|
|
1170
|
+
pendingSegments.unshift(node_path.default.basename(current));
|
|
1171
|
+
current = parent;
|
|
1172
|
+
}
|
|
1173
|
+
try {
|
|
1174
|
+
const realPath = node_fs.realpathSync.native(current);
|
|
1175
|
+
return pendingSegments.length > 0 ? node_path.default.join(realPath, ...pendingSegments) : realPath;
|
|
1176
|
+
} catch {
|
|
1177
|
+
return resolved;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function isMatchingCssSourceFile(outputFile, cssSourceFile, outputRoot) {
|
|
1181
|
+
return stripStyleFileExtension(node_path.default.resolve(outputRoot, outputFile)) === stripStyleFileExtension(node_path.default.resolve(cssSourceFile));
|
|
1182
|
+
}
|
|
1183
|
+
function collectStyleFileMatchBases(file, roots) {
|
|
1184
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
1185
|
+
const bases = /* @__PURE__ */ new Set();
|
|
1186
|
+
const addBase = (candidate) => {
|
|
1187
|
+
const base = slash(stripStyleFileExtension(candidate));
|
|
1188
|
+
if (base.length > 0) bases.add(base);
|
|
1189
|
+
};
|
|
1190
|
+
addBase(normalizedFile);
|
|
1191
|
+
const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => node_path.default.resolve(root));
|
|
1192
|
+
if (node_path.default.isAbsolute(normalizedFile)) for (const root of resolvedRoots) {
|
|
1193
|
+
const relative = node_path.default.relative(resolveStyleMatchingRealPath(root), resolveStyleMatchingRealPath(normalizedFile));
|
|
1194
|
+
if (relative && !relative.startsWith("..") && !node_path.default.isAbsolute(relative)) addBase(relative);
|
|
1195
|
+
}
|
|
1196
|
+
else for (const root of resolvedRoots) addBase(node_path.default.resolve(root, normalizedFile));
|
|
1197
|
+
return bases;
|
|
1198
|
+
}
|
|
1199
|
+
function collectParentDirectories(file) {
|
|
1200
|
+
const directories = [];
|
|
1201
|
+
let current = node_path.default.dirname(node_path.default.resolve(file.replace(/[?#].*$/, "")));
|
|
1202
|
+
while (true) {
|
|
1203
|
+
directories.push(current);
|
|
1204
|
+
const parent = node_path.default.dirname(current);
|
|
1205
|
+
if (parent === current) break;
|
|
1206
|
+
current = parent;
|
|
1207
|
+
}
|
|
1208
|
+
return directories;
|
|
1209
|
+
}
|
|
1210
|
+
function hasMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) {
|
|
1211
|
+
return scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) > 0;
|
|
1212
|
+
}
|
|
1213
|
+
function scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) {
|
|
1214
|
+
const outputBases = collectStyleFileMatchBases(outputFile, [outputRoot]);
|
|
1215
|
+
const sourceBases = collectStyleFileMatchBases(sourceFile, [sourceRoot, ...collectParentDirectories(sourceFile)]);
|
|
1216
|
+
let bestScore = 0;
|
|
1217
|
+
const hasDirectorySegment = (value) => slash(value).includes("/");
|
|
1218
|
+
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
|
|
1219
|
+
else if (hasDirectorySegment(sourceBase) && outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
|
|
1220
|
+
else if (hasDirectorySegment(outputBase) && sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
1221
|
+
return bestScore;
|
|
1222
|
+
}
|
|
1223
|
+
//#endregion
|
|
1224
|
+
//#region src/bundlers/vite/generate-bundle/sfc-style-source.ts
|
|
1225
|
+
const SFC_STYLE_SOURCE_EXTENSIONS = [
|
|
1226
|
+
".vue",
|
|
1227
|
+
".uvue",
|
|
1228
|
+
".nvue",
|
|
1229
|
+
".svelte",
|
|
1230
|
+
".mpx"
|
|
1231
|
+
];
|
|
1232
|
+
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
1233
|
+
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
1234
|
+
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
1235
|
+
function isSfcStyleSourceFile(file) {
|
|
1236
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
1237
|
+
return SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => normalizedFile.endsWith(extension));
|
|
1238
|
+
}
|
|
1239
|
+
function extractSfcStyleBlocks(source) {
|
|
1240
|
+
const styleSources = [];
|
|
1241
|
+
SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
|
|
1242
|
+
let index = 0;
|
|
1243
|
+
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1244
|
+
while (match !== null) {
|
|
1245
|
+
const attrs = match[1] ?? "";
|
|
1246
|
+
styleSources.push({
|
|
1247
|
+
attrs,
|
|
1248
|
+
index,
|
|
1249
|
+
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
1250
|
+
source: match[2] ?? ""
|
|
1251
|
+
});
|
|
1252
|
+
index += 1;
|
|
1253
|
+
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1254
|
+
}
|
|
1255
|
+
return styleSources;
|
|
1256
|
+
}
|
|
1257
|
+
function extractSfcStyleSources(source) {
|
|
1258
|
+
return extractSfcStyleBlocks(source).map((style) => style.source);
|
|
1259
|
+
}
|
|
1260
|
+
function hasSfcStyleSources(source) {
|
|
1261
|
+
return extractSfcStyleSources(source).length > 0;
|
|
1262
|
+
}
|
|
1263
|
+
function resolveSfcStyleBlockLang(attrs) {
|
|
1264
|
+
const match = SFC_LANG_STYLE_ATTR_RE.exec(attrs);
|
|
1265
|
+
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
1266
|
+
}
|
|
1267
|
+
function resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks) {
|
|
1268
|
+
const scopedStyleBlock = styleBlocks.find((style) => style.scoped);
|
|
1269
|
+
return scopedStyleBlock ? [`${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true`, ...resolveSfcStyleBlockLang(scopedStyleBlock.attrs) ? [`lang=${encodeURIComponent(resolveSfcStyleBlockLang(scopedStyleBlock.attrs))}`] : []].join("&") : sourceFile;
|
|
1270
|
+
}
|
|
1271
|
+
function normalizeSfcStyleSourceForCompare(source) {
|
|
1272
|
+
return source.replace(/\r\n?/g, "\n").trim();
|
|
1273
|
+
}
|
|
1274
|
+
function createSfcStyleRequest(sourceFile, styleBlock) {
|
|
1275
|
+
const params = new URLSearchParams();
|
|
1276
|
+
params.set("vue", "");
|
|
1277
|
+
params.set("type", "style");
|
|
1278
|
+
params.set("index", String(styleBlock.index));
|
|
1279
|
+
if (styleBlock.scoped) params.set("scoped", "true");
|
|
1280
|
+
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
1281
|
+
if (lang) params.set("lang", lang);
|
|
1282
|
+
return `${sourceFile}?${params.toString()}`;
|
|
1283
|
+
}
|
|
1284
|
+
function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSource, currentRequest) {
|
|
1285
|
+
if (!sfcSource) return sourceFile;
|
|
1286
|
+
const styleBlocks = extractSfcStyleBlocks(sfcSource);
|
|
1287
|
+
if (styleBlocks.length === 0) return sourceFile;
|
|
1288
|
+
const normalizedStyleSource = normalizeSfcStyleSourceForCompare(styleSource);
|
|
1289
|
+
const matchedBlocks = styleBlocks.filter((styleBlock) => {
|
|
1290
|
+
const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
|
|
1291
|
+
return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
|
|
1292
|
+
});
|
|
1293
|
+
const requestIndex = currentRequest ? Number.parseInt(new URLSearchParams(currentRequest.split("?", 2)[1] ?? "").get("index") ?? "", 10) : NaN;
|
|
1294
|
+
const styleBlock = (Number.isInteger(requestIndex) ? styleBlocks.find((styleBlock) => styleBlock.index === requestIndex) : void 0) ?? (matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0);
|
|
1295
|
+
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
1296
|
+
}
|
|
1297
|
+
function hasTailwindGenerationSource(source, options = {}) {
|
|
1298
|
+
const allowRootDirectives = options.allowRootDirectives !== false;
|
|
1299
|
+
return require_generator.hasTailwindNonRootGenerationDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindSourceDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindRootDirectives(source, { importFallback: true }) || require_generator.hasTailwindApplyDirective(source);
|
|
1300
|
+
}
|
|
1301
|
+
function hasTailwindGenerationSourceForFile(file, source) {
|
|
1302
|
+
if (require_generator.isTailwindV4CssEntry(file)) return hasTailwindGenerationSource(source);
|
|
1303
|
+
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
1304
|
+
}
|
|
1305
|
+
async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, getSfcSource, debug) {
|
|
1306
|
+
const sourceFile = resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug);
|
|
1307
|
+
if (!sourceFile) {
|
|
1308
|
+
debug("sfc style source infer skipped: no source file for %s", outputFile);
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
const source = getSfcSource?.(sourceFile);
|
|
1312
|
+
if (source == null) {
|
|
1313
|
+
debug("sfc style source infer skipped: missing known source for %s -> %s", outputFile, sourceFile);
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
const styleBlocks = extractSfcStyleBlocks(source);
|
|
1317
|
+
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
1318
|
+
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1319
|
+
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
debug("sfc style source inferred: %s -> %s", outputFile, sourceFile);
|
|
1323
|
+
return {
|
|
1324
|
+
outputFile,
|
|
1325
|
+
rawSource,
|
|
1326
|
+
sourceFile: resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks)
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
function normalizeSfcSourceFileForCompare(file) {
|
|
1330
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1331
|
+
}
|
|
1332
|
+
function collectChunkModuleIds(output) {
|
|
1333
|
+
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
1334
|
+
return [
|
|
1335
|
+
output.facadeModuleId,
|
|
1336
|
+
...moduleIds,
|
|
1337
|
+
...Object.keys(output.modules ?? {})
|
|
1338
|
+
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
1339
|
+
}
|
|
1340
|
+
function normalizeSourceStyleModuleId(id) {
|
|
1341
|
+
const file = id.replace(/[?#].*$/, "");
|
|
1342
|
+
if (!CSS_SOURCE_OUTPUT_EXT_RE.test(file)) return;
|
|
1343
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
1344
|
+
return node_path.default.resolve(file);
|
|
1345
|
+
}
|
|
1346
|
+
function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
|
|
1347
|
+
const normalizedOutputFile = outputFile.replace(/[?#].*$/, "");
|
|
1348
|
+
if (cssMatcher?.(normalizedOutputFile)) {
|
|
1349
|
+
const extension = node_path.default.extname(normalizedOutputFile);
|
|
1350
|
+
return extension ? `${normalizedOutputFile.slice(0, -extension.length)}.js` : void 0;
|
|
1351
|
+
}
|
|
1352
|
+
if (CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedOutputFile)) return normalizedOutputFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".js");
|
|
1353
|
+
}
|
|
1354
|
+
function normalizeSfcModuleId(id) {
|
|
1355
|
+
const file = id.replace(/[?#].*$/, "");
|
|
1356
|
+
if (!isSfcStyleSourceFile(file)) return;
|
|
1357
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
1358
|
+
return node_path.default.resolve(file);
|
|
1359
|
+
}
|
|
1360
|
+
function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug) {
|
|
1361
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, cssMatcher);
|
|
1362
|
+
if (!siblingJsFile) {
|
|
1363
|
+
debug("sfc style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
1367
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
1368
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
1369
|
+
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
const sourceFiles = collectChunkModuleIds(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1373
|
+
if (sourceFiles.length === 0) {
|
|
1374
|
+
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1378
|
+
sourceFile,
|
|
1379
|
+
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
1380
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1381
|
+
debug("sfc style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
1382
|
+
const bestScore = scoredSources[0]?.score;
|
|
1383
|
+
if (!bestScore) return;
|
|
1384
|
+
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
1385
|
+
if (bestSources.length !== 1) {
|
|
1386
|
+
debug("sfc style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
return bestSources[0]?.sourceFile;
|
|
1390
|
+
}
|
|
1391
|
+
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
1392
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
1393
|
+
if (!siblingJsFile) {
|
|
1394
|
+
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
1398
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
1399
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
1400
|
+
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
const sourceFiles = collectChunkModuleIds(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1404
|
+
if (sourceFiles.length === 0) {
|
|
1405
|
+
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
if (sourceFiles.length === 1) {
|
|
1409
|
+
debug("source style sibling chunk inferred from single css module: %s -> %s", outputFile, sourceFiles[0]);
|
|
1410
|
+
return sourceFiles[0];
|
|
1411
|
+
}
|
|
1412
|
+
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1413
|
+
sourceFile,
|
|
1414
|
+
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
1415
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1416
|
+
debug("source style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
1417
|
+
const bestScore = scoredSources[0]?.score;
|
|
1418
|
+
if (!bestScore) return;
|
|
1419
|
+
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
1420
|
+
if (bestSources.length !== 1) {
|
|
1421
|
+
debug("source style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
return bestSources[0]?.sourceFile;
|
|
1425
|
+
}
|
|
1426
|
+
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
1427
|
+
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
1428
|
+
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
1429
|
+
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1430
|
+
const cachedSources = [...getSourceStyleSources?.() ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1431
|
+
file,
|
|
1432
|
+
source,
|
|
1433
|
+
score: require_v4_generation_core.scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1434
|
+
outputRoot,
|
|
1435
|
+
projectRoot: sourceRoot
|
|
1436
|
+
})
|
|
1437
|
+
}));
|
|
1438
|
+
const configuredSources = [...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1439
|
+
file,
|
|
1440
|
+
source,
|
|
1441
|
+
score: require_v4_generation_core.scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1442
|
+
outputRoot,
|
|
1443
|
+
projectRoot: sourceRoot
|
|
1444
|
+
})
|
|
1445
|
+
}));
|
|
1446
|
+
const scoredSources = [...cachedSources, ...configuredSources].filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1447
|
+
const bestScore = scoredSources[0]?.score;
|
|
1448
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
1449
|
+
if (bestSources.length === 1) {
|
|
1450
|
+
sourceFile = bestSources[0].file;
|
|
1451
|
+
rawSource = bestSources[0].source;
|
|
1452
|
+
debug("source style source inferred from cache: %s -> %s", outputFile, sourceFile);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
if (!sourceFile || !rawSource) return;
|
|
1456
|
+
if (!hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1457
|
+
debug("source style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
return {
|
|
1461
|
+
outputFile,
|
|
1462
|
+
rawSource,
|
|
1463
|
+
sourceFile
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
//#endregion
|
|
1467
|
+
//#region src/bundlers/vite/web-css-compat.ts
|
|
1468
|
+
/**
|
|
1469
|
+
* Web target 的 Tailwind 兼容转换由 generator-css 负责;Vite 外层只处理非 Web 生成目标
|
|
1470
|
+
* 落到 WebView 产物时的最终兼容需求,避免同一份 CSS 在 dev/build 中被重复解析转换。
|
|
1471
|
+
*/
|
|
1472
|
+
function shouldApplyViteWebCssCompat(context, strategy) {
|
|
1473
|
+
if (strategy?.shouldApplyWebCssCompat?.(context) !== true) return false;
|
|
1474
|
+
return !context.currentGeneratorBranch.isWeb || context.currentGeneratorOptions.webCompat !== void 0;
|
|
1475
|
+
}
|
|
1476
|
+
function resolveViteWebCssCompatOptions(context) {
|
|
1477
|
+
return context.currentGeneratorBranch.isWeb ? context.currentGeneratorOptions.webCompat : context.currentGeneratorOptions.webCompat ?? true;
|
|
1478
|
+
}
|
|
1479
|
+
//#endregion
|
|
1480
|
+
//#region src/bundlers/vite/query.ts
|
|
1481
|
+
function parseVueRequest(id) {
|
|
1482
|
+
const [filename = id, rawQuery] = id.split(`?`, 2);
|
|
1483
|
+
const searchParams = new URLSearchParams(rawQuery);
|
|
1484
|
+
const query = Object.fromEntries(searchParams);
|
|
1485
|
+
if (query.vue != null) query.vue = true;
|
|
1486
|
+
if (query.index != null) query.index = Number(query.index);
|
|
1487
|
+
if (query.raw != null) query.raw = true;
|
|
1488
|
+
if (query.url != null) query.url = true;
|
|
1489
|
+
if (query.scoped != null) query.scoped = true;
|
|
1490
|
+
const langTypeMatch = [...searchParams.keys()].find((key) => key.startsWith("lang."));
|
|
1491
|
+
const langType = query.lang || (langTypeMatch ? langTypeMatch.slice(5) : void 0);
|
|
1492
|
+
if (langType) query.lang = langType;
|
|
1493
|
+
return {
|
|
1494
|
+
filename,
|
|
1495
|
+
query
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region src/bundlers/vite/module-identity.ts
|
|
1500
|
+
const WINDOWS_DRIVE_RE = /^\/?[a-z]:[\\/]/i;
|
|
1501
|
+
const WINDOWS_UNC_RE = /^(?:\\\\|\/\/)/;
|
|
1502
|
+
function unique(values) {
|
|
1503
|
+
return [...new Set([...values].filter((value) => typeof value === "string" && value.length > 0))];
|
|
1504
|
+
}
|
|
1505
|
+
function decodeFileId(id) {
|
|
1506
|
+
try {
|
|
1507
|
+
return decodeURIComponent(id);
|
|
1508
|
+
} catch {
|
|
1509
|
+
return id;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
function stripViteFsPrefix(id) {
|
|
1513
|
+
if (!id.startsWith("/@fs/")) return id;
|
|
1514
|
+
const file = id.slice(5);
|
|
1515
|
+
return file.startsWith("/") || WINDOWS_DRIVE_RE.test(file) ? file : `/${file}`;
|
|
1516
|
+
}
|
|
1517
|
+
function stripFileProtocol(id) {
|
|
1518
|
+
if (!id.startsWith("file://")) return id;
|
|
1519
|
+
try {
|
|
1520
|
+
return (0, node_url.fileURLToPath)(id);
|
|
1521
|
+
} catch {
|
|
1522
|
+
return id;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
function isWindowsFile(file) {
|
|
1526
|
+
return WINDOWS_DRIVE_RE.test(file) || WINDOWS_UNC_RE.test(file);
|
|
1527
|
+
}
|
|
1528
|
+
function normalizeWindowsFile(file) {
|
|
1529
|
+
const withoutDriveSlash = /^\/[a-z]:[\\/]/i.test(file) ? file.slice(1) : file;
|
|
1530
|
+
return slash(node_path.default.win32.resolve(withoutDriveSlash));
|
|
1531
|
+
}
|
|
1532
|
+
function normalizeFile(file, root) {
|
|
1533
|
+
if (isWindowsFile(file) || isWindowsFile(root)) return normalizeWindowsFile(isWindowsFile(file) ? file : node_path.default.win32.resolve(root, file.replace(/^\//, "")));
|
|
1534
|
+
if (node_path.default.isAbsolute(file)) {
|
|
1535
|
+
if (file === root || file.startsWith(`${root}${node_path.default.sep}`) || (0, node_fs.existsSync)(file) || (0, node_fs.existsSync)(node_path.default.dirname(file))) return slash(node_path.default.resolve(file));
|
|
1536
|
+
const rootRelativeFile = node_path.default.resolve(root, file.slice(1));
|
|
1537
|
+
return (0, node_fs.existsSync)(rootRelativeFile) || (0, node_fs.existsSync)(node_path.default.dirname(rootRelativeFile)) ? slash(rootRelativeFile) : slash(node_path.default.resolve(file));
|
|
1538
|
+
}
|
|
1539
|
+
return slash(node_path.default.resolve(root, file));
|
|
1540
|
+
}
|
|
1541
|
+
function resolveRealFile(file) {
|
|
1542
|
+
if (node_process.default.platform !== "win32" && isWindowsFile(file)) return file;
|
|
1543
|
+
let current = file;
|
|
1544
|
+
const missingSegments = [];
|
|
1545
|
+
try {
|
|
1546
|
+
while (true) try {
|
|
1547
|
+
const resolvedParent = node_fs.realpathSync.native(current);
|
|
1548
|
+
return slash(node_path.default.join(resolvedParent, ...missingSegments));
|
|
1549
|
+
} catch {
|
|
1550
|
+
const parent = node_path.default.dirname(current);
|
|
1551
|
+
if (parent === current) return file;
|
|
1552
|
+
missingSegments.unshift(node_path.default.basename(current));
|
|
1553
|
+
current = parent;
|
|
1554
|
+
}
|
|
1555
|
+
} catch {
|
|
1556
|
+
return file;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
function normalizeIdentityKey(file) {
|
|
1560
|
+
return isWindowsFile(file) || node_process.default.platform === "win32" ? file.toLowerCase() : file;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* 将 Vite URL、文件路径和 Windows 的等价路径收敛为同一个模块身份。
|
|
1564
|
+
*/
|
|
1565
|
+
function resolveViteModuleIdentity(id, root = node_process.default.cwd()) {
|
|
1566
|
+
const cleanId = decodeFileId((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
1567
|
+
const decodedRoot = decodeFileId((0, _weapp_tailwindcss_shared.cleanUrl)(root));
|
|
1568
|
+
const normalizedRoot = isWindowsFile(decodedRoot) ? normalizeWindowsFile(decodedRoot) : slash(node_path.default.resolve(decodedRoot));
|
|
1569
|
+
const unwrappedId = stripFileProtocol(stripViteFsPrefix(cleanId));
|
|
1570
|
+
const file = unwrappedId.startsWith("\0") ? void 0 : normalizeFile(unwrappedId, normalizedRoot);
|
|
1571
|
+
const realFile = file ? resolveRealFile(file) : void 0;
|
|
1572
|
+
const key = realFile ? normalizeIdentityKey(realFile) : cleanId;
|
|
1573
|
+
const pathApi = isWindowsFile(normalizedRoot) ? node_path.default.win32 : node_path.default.posix;
|
|
1574
|
+
const relativeUrl = realFile && normalizeIdentityKey(realFile).startsWith(`${normalizeIdentityKey(normalizedRoot)}/`) ? `/${slash(pathApi.relative(normalizedRoot, realFile))}` : void 0;
|
|
1575
|
+
return {
|
|
1576
|
+
cleanId,
|
|
1577
|
+
file: realFile,
|
|
1578
|
+
key,
|
|
1579
|
+
lookupFiles: unique([file, realFile]),
|
|
1580
|
+
lookupIds: unique([
|
|
1581
|
+
id,
|
|
1582
|
+
cleanId,
|
|
1583
|
+
unwrappedId,
|
|
1584
|
+
file,
|
|
1585
|
+
realFile,
|
|
1586
|
+
realFile ? `/@fs/${realFile}` : void 0,
|
|
1587
|
+
relativeUrl
|
|
1588
|
+
])
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
function hasSameViteModuleIdentity(left, right, root = node_process.default.cwd()) {
|
|
1592
|
+
if (!left || !right) return false;
|
|
1593
|
+
return resolveViteModuleIdentity(left, root).key === resolveViteModuleIdentity(right, root).key;
|
|
1594
|
+
}
|
|
1595
|
+
//#endregion
|
|
1596
|
+
//#region src/bundlers/vite/hot-css-modules.ts
|
|
1597
|
+
async function resolveHotModulesByIds(ctx, ids, acceptModule) {
|
|
1598
|
+
const modules = [];
|
|
1599
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
1600
|
+
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
1601
|
+
const seenFileIdentities = /* @__PURE__ */ new Set();
|
|
1602
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
1603
|
+
const collectModule = (mod) => {
|
|
1604
|
+
if (mod == null || seenModules.has(mod) || !acceptModule(mod)) return;
|
|
1605
|
+
seenModules.add(mod);
|
|
1606
|
+
modules.push(mod);
|
|
1607
|
+
};
|
|
1608
|
+
for (const id of ids) {
|
|
1609
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
1610
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
1611
|
+
for (const moduleId of identity.lookupIds) {
|
|
1612
|
+
if (seenModuleIds.has(moduleId)) continue;
|
|
1613
|
+
seenModuleIds.add(moduleId);
|
|
1614
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(moduleId));
|
|
1615
|
+
if (moduleId.startsWith("/")) collectModule(await ctx.server.moduleGraph.getModuleByUrl?.(moduleId));
|
|
1616
|
+
}
|
|
1617
|
+
if (seenFileIdentities.has(identity.key)) continue;
|
|
1618
|
+
seenFileIdentities.add(identity.key);
|
|
1619
|
+
for (const file of identity.lookupFiles) for (const mod of ctx.server.moduleGraph.getModulesByFile?.(file) ?? []) collectModule(mod);
|
|
1620
|
+
}
|
|
1621
|
+
return modules;
|
|
1622
|
+
}
|
|
1623
|
+
async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds, selectModules) {
|
|
1624
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
1625
|
+
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
1626
|
+
const isHotSourceStyleModule = (id) => {
|
|
1627
|
+
if (!require_v4_generation_core.isSourceStyleRequest(id)) return false;
|
|
1628
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
1629
|
+
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
1630
|
+
if (outDir) {
|
|
1631
|
+
const identity = resolveViteModuleIdentity(file, root);
|
|
1632
|
+
if (identity.key === outDir.key || identity.key.startsWith(`${outDir.key}/`)) return false;
|
|
1633
|
+
}
|
|
1634
|
+
return true;
|
|
1635
|
+
};
|
|
1636
|
+
const modules = await resolveHotModulesByIds(ctx, tailwindRootCssModuleIds, (mod) => {
|
|
1637
|
+
const modId = mod.id ?? mod.url;
|
|
1638
|
+
return isHotSourceStyleModule(modId);
|
|
1639
|
+
});
|
|
1640
|
+
const seenHotModules = new Set(modules);
|
|
1641
|
+
for (let index = 0; index < modules.length; index++) for (const importer of modules[index]?.importers ?? []) {
|
|
1642
|
+
const importerId = importer.id ?? importer.url;
|
|
1643
|
+
if (!seenHotModules.has(importer) && isHotSourceStyleModule(importerId)) {
|
|
1644
|
+
seenHotModules.add(importer);
|
|
1645
|
+
modules.push(importer);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
const selectedModules = selectModules?.(modules) ?? modules;
|
|
1649
|
+
for (const mod of selectedModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
1650
|
+
return selectedModules;
|
|
1651
|
+
}
|
|
1652
|
+
async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
1653
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
1654
|
+
const sourceIds = new Set(ids);
|
|
1655
|
+
for (const id of ids) {
|
|
1656
|
+
if (typeof id !== "string" || !/\.(?:uvue|nvue|vue|tsx?|jsx?)(?:$|[?#])/i.test(id)) continue;
|
|
1657
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
1658
|
+
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${(0, _weapp_tailwindcss_shared.cleanUrl)(lookupId)}?import`);
|
|
1659
|
+
}
|
|
1660
|
+
return resolveHotModulesByIds(ctx, sourceIds, (mod) => {
|
|
1661
|
+
const modId = mod.id ?? mod.url;
|
|
1662
|
+
return !require_v4_generation_core.isSourceStyleRequest(modId);
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
async function resolveHotSourceModules(ctx) {
|
|
1666
|
+
const modules = [];
|
|
1667
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
1668
|
+
const collectModule = (mod) => {
|
|
1669
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
1670
|
+
const modId = mod.id ?? mod.url;
|
|
1671
|
+
if (require_v4_generation_core.isSourceStyleRequest(modId)) return;
|
|
1672
|
+
seenModules.add(mod);
|
|
1673
|
+
modules.push(mod);
|
|
1674
|
+
};
|
|
1675
|
+
for (const mod of ctx.modules) collectModule(mod);
|
|
1676
|
+
for (const mod of await resolveHotSourceModulesByIds(ctx, [ctx.file])) collectModule(mod);
|
|
1677
|
+
return modules;
|
|
1678
|
+
}
|
|
1679
|
+
function mergeHotModulesByIdentity(root, ...groups) {
|
|
1680
|
+
const modules = [];
|
|
1681
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
1682
|
+
const seenIdentities = /* @__PURE__ */ new Set();
|
|
1683
|
+
for (const mod of groups.flat()) {
|
|
1684
|
+
if (seenModules.has(mod)) continue;
|
|
1685
|
+
const ids = [
|
|
1686
|
+
mod.id,
|
|
1687
|
+
mod.url,
|
|
1688
|
+
mod.file
|
|
1689
|
+
].filter((id) => typeof id === "string" && id.length > 0);
|
|
1690
|
+
const moduleKind = ids.some(require_v4_generation_core.isSourceStyleRequest) ? "style" : "source";
|
|
1691
|
+
const keys = ids.map((id) => `${moduleKind}:${resolveViteModuleIdentity(id, root).key}`);
|
|
1692
|
+
if (keys.some((key) => seenIdentities.has(key))) continue;
|
|
1693
|
+
seenModules.add(mod);
|
|
1694
|
+
keys.forEach((key) => seenIdentities.add(key));
|
|
1695
|
+
modules.push(mod);
|
|
1696
|
+
}
|
|
1697
|
+
return modules;
|
|
1698
|
+
}
|
|
1699
|
+
function resolveModuleHotUrl(mod) {
|
|
1700
|
+
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
1701
|
+
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
1702
|
+
}
|
|
1703
|
+
function isAbsoluteFilePath(file) {
|
|
1704
|
+
return node_path.default.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
1705
|
+
}
|
|
1706
|
+
function normalizeAbsoluteFilePath(file) {
|
|
1707
|
+
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(node_path.default.win32.resolve(file));
|
|
1708
|
+
return slash(node_path.default.resolve(file));
|
|
1709
|
+
}
|
|
1710
|
+
function isRootMiniProgramStyleUrl(file) {
|
|
1711
|
+
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
1712
|
+
}
|
|
1713
|
+
function resolveCssHotUrl(id, root) {
|
|
1714
|
+
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
1715
|
+
const cleanId = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
1716
|
+
if (/^\/(?!@fs\/|[A-Z]:)/i.test(cleanId) && !cleanId.startsWith(slash(root))) {
|
|
1717
|
+
if (isRootMiniProgramStyleUrl(cleanId)) return;
|
|
1718
|
+
return `${cleanId}${suffix}`;
|
|
1719
|
+
}
|
|
1720
|
+
const file = resolveViteModuleIdentity(id, root).file ?? cleanId;
|
|
1721
|
+
if (!isAbsoluteFilePath(file)) return;
|
|
1722
|
+
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
1723
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
1724
|
+
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
1725
|
+
return `/${slash(node_path.default.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
1726
|
+
}
|
|
1727
|
+
function includesHotModule(modules, target, root) {
|
|
1728
|
+
const targetUrl = resolveModuleHotUrl(target);
|
|
1729
|
+
const targetId = target.id;
|
|
1730
|
+
return modules.some((mod) => {
|
|
1731
|
+
if (mod === target) return true;
|
|
1732
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId || [
|
|
1733
|
+
target.id,
|
|
1734
|
+
target.url,
|
|
1735
|
+
target.file
|
|
1736
|
+
].some((targetIdentity) => [
|
|
1737
|
+
mod.id,
|
|
1738
|
+
mod.url,
|
|
1739
|
+
mod.file
|
|
1740
|
+
].some((moduleIdentity) => hasSameViteModuleIdentity(targetIdentity, moduleIdentity, root)));
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
function includesHotId(modules, targetId, root) {
|
|
1744
|
+
return modules.some((mod) => [
|
|
1745
|
+
mod.id,
|
|
1746
|
+
mod.url,
|
|
1747
|
+
mod.file
|
|
1748
|
+
].some((moduleId) => hasSameViteModuleIdentity(targetId, moduleId, root)));
|
|
1749
|
+
}
|
|
1750
|
+
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
1751
|
+
return {
|
|
1752
|
+
type: "js-update",
|
|
1753
|
+
timestamp,
|
|
1754
|
+
path: hotUrl,
|
|
1755
|
+
acceptedPath: hotUrl,
|
|
1756
|
+
explicitImportRequired: false,
|
|
1757
|
+
isWithinCircularImport: false
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
1761
|
+
return modules.some((mod) => {
|
|
1762
|
+
const modId = mod.id ?? mod.url;
|
|
1763
|
+
return !require_v4_generation_core.isSourceStyleRequest(modId) && mod.isSelfAccepting === true;
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = [], handledModules = ctx.modules) {
|
|
1767
|
+
const seenUrls = /* @__PURE__ */ new Set();
|
|
1768
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
1769
|
+
const updates = [];
|
|
1770
|
+
for (const id of fallbackSourceIds) {
|
|
1771
|
+
if (includesHotId(handledModules, id, root)) continue;
|
|
1772
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
1773
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
1774
|
+
seenUrls.add(hotUrl);
|
|
1775
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
1776
|
+
}
|
|
1777
|
+
for (const id of fallbackCssIds) {
|
|
1778
|
+
if (!require_v4_generation_core.isSourceStyleRequest(id) || includesHotId(handledModules, id, root)) continue;
|
|
1779
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
1780
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
1781
|
+
seenUrls.add(hotUrl);
|
|
1782
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
1783
|
+
}
|
|
1784
|
+
for (const mod of cssModules) {
|
|
1785
|
+
if (includesHotModule(handledModules, mod, root)) continue;
|
|
1786
|
+
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
1787
|
+
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
1788
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
1789
|
+
seenUrls.add(hotUrl);
|
|
1790
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
1791
|
+
}
|
|
1792
|
+
if (updates.length === 0) return;
|
|
1793
|
+
queueMicrotask(() => {
|
|
1794
|
+
ctx.server.ws?.send?.({
|
|
1795
|
+
type: "update",
|
|
1796
|
+
updates
|
|
1797
|
+
});
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
1801
|
+
ctx.server.ws?.send?.({
|
|
1802
|
+
type: "full-reload",
|
|
1803
|
+
path: "*",
|
|
1804
|
+
triggeredBy: ctx.file
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
//#endregion
|
|
1808
|
+
//#region src/bundlers/vite/shared/generic-web-production-fast-path.ts
|
|
1809
|
+
/**
|
|
1810
|
+
* Generic Web 非 watch 生产构建由 Tailwind Scanner 直接提供候选,不需要重复维护小程序候选状态。
|
|
1811
|
+
*/
|
|
1812
|
+
function shouldSkipGenericWebProductionSourceCandidates(options) {
|
|
1813
|
+
return options.frameworkName === "generic" && options.command === "build" && options.watch == null && options.isWebGeneratorTarget && options.requiresSourceCandidateState !== true;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* 在 Vite 解析插件列表时排除无需维护的候选层,避免其 hooks 进入模块图。
|
|
1817
|
+
*/
|
|
1818
|
+
function createGenericWebProductionSourceCandidatesApply(options) {
|
|
1819
|
+
return (config, env) => !shouldSkipGenericWebProductionSourceCandidates({
|
|
1820
|
+
command: env.command,
|
|
1821
|
+
frameworkName: options.frameworkName,
|
|
1822
|
+
isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
|
|
1823
|
+
requiresSourceCandidateState: options.requiresSourceCandidateState,
|
|
1824
|
+
watch: config.build?.watch
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Generic Web 生产构建的 CSS 已在 Vite transform 阶段生成时,不需要再建立面向小程序的完整产物快照。
|
|
1829
|
+
*/
|
|
1830
|
+
function shouldUseGenericWebProductionFastPath(options) {
|
|
1831
|
+
return shouldSkipGenericWebProductionSourceCandidates(options) && options.hasProcessedCss;
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Finalizer fast path 只处理无小程序结构语义的 Generic Web 生产产物。
|
|
1835
|
+
*/
|
|
1836
|
+
function shouldUseGenericWebFinalizerFastPath(options) {
|
|
1837
|
+
return shouldUseGenericWebProductionFastPath(options) && !options.hasFrameworkRootImportShells && !options.isHarmonyAppStyleTarget && !options.isNativeAppStyleTarget;
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* 将 Generic Web fast path 的判定和跳过生命周期集中起来,供 generateBundle hook 直接消费。
|
|
1841
|
+
*/
|
|
1842
|
+
function createGenericWebProductionBundleHooks(options) {
|
|
1843
|
+
return {
|
|
1844
|
+
onSkipProcessBundle: () => {
|
|
1845
|
+
options.onStart();
|
|
1846
|
+
options.onEnd();
|
|
1847
|
+
},
|
|
1848
|
+
shouldProcessBundle: () => {
|
|
1849
|
+
const config = options.getResolvedConfig();
|
|
1850
|
+
return !shouldUseGenericWebProductionFastPath({
|
|
1851
|
+
command: config?.command,
|
|
1852
|
+
frameworkName: options.frameworkName,
|
|
1853
|
+
hasProcessedCss: options.getHasProcessedCss(),
|
|
1854
|
+
isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
|
|
1855
|
+
watch: config?.build?.watch
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
//#endregion
|
|
1861
|
+
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
1862
|
+
function inferPlatformFromViteOutDir(outDir) {
|
|
1863
|
+
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
1864
|
+
if (!segment) return;
|
|
1865
|
+
const normalized = segment.trim().toLowerCase();
|
|
1866
|
+
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
1867
|
+
}
|
|
1868
|
+
function isAddWatchFileInvalidRollupPhaseError(error) {
|
|
1869
|
+
const candidate = error;
|
|
1870
|
+
return candidate?.code === "INVALID_ROLLUP_PHASE" || candidate?.pluginCode === "INVALID_ROLLUP_PHASE" || candidate?.message?.includes("Cannot call \"addWatchFile\" after the build has finished.") === true;
|
|
1871
|
+
}
|
|
1872
|
+
function registerGeneratorDependencies(ctx, dependencies) {
|
|
1873
|
+
if (typeof ctx.addWatchFile !== "function") return;
|
|
1874
|
+
for (const dependency of dependencies ?? []) try {
|
|
1875
|
+
ctx.addWatchFile(dependency);
|
|
1876
|
+
} catch (error) {
|
|
1877
|
+
if (isAddWatchFileInvalidRollupPhaseError(error)) {
|
|
1878
|
+
_weapp_tailwindcss_logger.logger.debug("跳过生成模式依赖监听注册,当前 Rollup 阶段不允许 addWatchFile: %s", dependency);
|
|
1879
|
+
continue;
|
|
1880
|
+
}
|
|
1881
|
+
throw error;
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
function createCssHandlerOptions(opts, majorVersion, file, outputRoot, extraOptions = {}) {
|
|
1885
|
+
const from = node_path.default.isAbsolute(file) ? file : outputRoot ? node_path.default.resolve(outputRoot, file) : file;
|
|
1886
|
+
return {
|
|
1887
|
+
...extraOptions,
|
|
1888
|
+
cssPreflight: opts.cssPreflight,
|
|
1889
|
+
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
1890
|
+
postcssOptions: { options: { from } },
|
|
1891
|
+
...require_compiler.normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, processed) {
|
|
1895
|
+
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
1896
|
+
appType: opts.appType,
|
|
1897
|
+
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
1898
|
+
tailwindcssMajorVersion: majorVersion,
|
|
1899
|
+
uniAppX: opts.uniAppX
|
|
1900
|
+
});
|
|
1901
|
+
if (!generatorOptions.enabled) return false;
|
|
1902
|
+
if (require_generator.hasLocalCssImport(rawSource)) return false;
|
|
1903
|
+
if (require_generator.hasTailwindGeneratedCssMarkers(rawSource)) return true;
|
|
1904
|
+
if (require_generator.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
1905
|
+
return processed && require_generator.hasTailwindApplyDirective(rawSource) && shouldFinalizeProcessedCssAsset(opts, file);
|
|
1906
|
+
}
|
|
1907
|
+
function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
1908
|
+
return opts.mainCssChunkMatcher(file, opts.appType);
|
|
1909
|
+
}
|
|
1910
|
+
function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
1911
|
+
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
1912
|
+
}
|
|
1913
|
+
function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
1914
|
+
const shouldApplyWebCssCompat = shouldApplyViteWebCssCompat(context, cssPipelineStrategy);
|
|
1915
|
+
const defaultWebCssCompat = (value) => (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(value, resolveViteWebCssCompatOptions(context));
|
|
1916
|
+
return cssPipelineStrategy?.transformGeneratedCss?.(css, {
|
|
1917
|
+
...context,
|
|
1918
|
+
defaultWebCssCompat,
|
|
1919
|
+
removeScopedPreflight: (value) => value,
|
|
1920
|
+
shouldApplyWebCssCompat
|
|
1921
|
+
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
1922
|
+
}
|
|
1923
|
+
//#endregion
|
|
1924
|
+
//#region src/bundlers/vite/css-finalizer/generic-web-fast-path.ts
|
|
1925
|
+
function readAssetSource(asset) {
|
|
1926
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1927
|
+
}
|
|
1928
|
+
function collectCssAssets(bundle, context) {
|
|
1929
|
+
const assets = /* @__PURE__ */ new Map();
|
|
1930
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1931
|
+
if (output.type !== "asset") continue;
|
|
1932
|
+
const file = output.fileName || bundleFile;
|
|
1933
|
+
if (!context.opts.cssMatcher(file) || context.opts.htmlMatcher(file)) continue;
|
|
1934
|
+
assets.set(require_source_candidate_scan_signature.normalizeOutputPathKey(file), {
|
|
1935
|
+
asset: output,
|
|
1936
|
+
file,
|
|
1937
|
+
original: readAssetSource(output)
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
return assets;
|
|
1941
|
+
}
|
|
1942
|
+
function resolveProcessedCssOutputFile(file, options, bundleFiles) {
|
|
1943
|
+
return resolveViteCssPipelineOutputFile(file, options.context.opts, options.rootDir, true, false, options.sourceRoot, ".css", bundleFiles);
|
|
1944
|
+
}
|
|
1945
|
+
function resolveProcessedCssAssets(cssAssets, records, options, bundleFiles) {
|
|
1946
|
+
const assetBySourceFile = /* @__PURE__ */ new Map();
|
|
1947
|
+
for (const output of cssAssets.values()) {
|
|
1948
|
+
const identity = options.context.resolveCssAssetIdentity?.(output.asset, output.file);
|
|
1949
|
+
if (identity?.kind === "bundler-generated" && identity.sourceFile) assetBySourceFile.set(require_source_candidate_scan_signature.normalizeOutputPathKey(identity.sourceFile), output);
|
|
1950
|
+
for (const sourceFile of collectMatchingGeneratedCssMarkerFiles(output.file, output.original, (file) => resolveProcessedCssOutputFile(file, options, bundleFiles))) assetBySourceFile.set(require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile), output);
|
|
1951
|
+
}
|
|
1952
|
+
const processedAssets = /* @__PURE__ */ new Map();
|
|
1953
|
+
const htmlOwnedAssets = [...cssAssets.values()].filter((output) => [output.asset.originalFileName, ...output.asset.originalFileNames ?? []].some((file) => typeof file === "string" && /\.html(?:$|[?#])/i.test(file)));
|
|
1954
|
+
for (const [file, record] of records) {
|
|
1955
|
+
const recordCss = typeof record === "string" ? record : record.css;
|
|
1956
|
+
const outputFile = typeof record === "string" ? resolveProcessedCssOutputFile(file, options, bundleFiles) : record.outputFile ?? resolveProcessedCssOutputFile(file, options, bundleFiles);
|
|
1957
|
+
let output = assetBySourceFile.get(require_source_candidate_scan_signature.normalizeOutputPathKey(file)) ?? (outputFile ? cssAssets.get(require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile)) : void 0);
|
|
1958
|
+
let useAssetSource = output !== void 0;
|
|
1959
|
+
if (!output) {
|
|
1960
|
+
const matchingAssets = [...cssAssets.values()].filter((candidate) => options.context.isCssAssetProcessed(candidate.asset, candidate.file) && resolveViteProcessedCssAssetSource(candidate.file, candidate.original, (sourceFile) => resolveProcessedCssOutputFile(sourceFile, options, bundleFiles)) === recordCss);
|
|
1961
|
+
if (matchingAssets.length === 1) {
|
|
1962
|
+
output = matchingAssets[0];
|
|
1963
|
+
useAssetSource = true;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
if (!output && records.length === 1 && htmlOwnedAssets.length === 1) {
|
|
1967
|
+
output = htmlOwnedAssets[0];
|
|
1968
|
+
useAssetSource = require_generator.hasTailwindGeneratedCss(output.original) || require_generator.hasTailwindGeneratedCssMarkers(output.original);
|
|
1969
|
+
}
|
|
1970
|
+
if (!output) return;
|
|
1971
|
+
const existing = processedAssets.get(output);
|
|
1972
|
+
if (existing !== void 0 && existing.css !== recordCss) return;
|
|
1973
|
+
processedAssets.set(output, {
|
|
1974
|
+
css: recordCss,
|
|
1975
|
+
useAssetSource
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
return processedAssets;
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Generic Web 的 transform 结果能唯一映射到最终 CSS asset 时,只做一次 marker 清理和 Web 兼容收尾。
|
|
1982
|
+
*/
|
|
1983
|
+
function tryFinalizeGenericWebCss(options) {
|
|
1984
|
+
const { bundle, context } = options;
|
|
1985
|
+
const resolvedConfig = context.getResolvedConfig();
|
|
1986
|
+
const collectStartedAt = performance.now();
|
|
1987
|
+
const processedCssResults = [...context.getViteProcessedCssAssetResults?.() ?? []];
|
|
1988
|
+
if (!shouldUseGenericWebFinalizerFastPath({
|
|
1989
|
+
command: resolvedConfig?.command,
|
|
1990
|
+
frameworkName: context.frameworkName ?? "",
|
|
1991
|
+
hasFrameworkRootImportShells: (context.frameworkRootImportShellTargetByFile?.size ?? 0) > 0,
|
|
1992
|
+
hasProcessedCss: processedCssResults.length > 0,
|
|
1993
|
+
isHarmonyAppStyleTarget: options.isHarmonyAppStyleTarget,
|
|
1994
|
+
isNativeAppStyleTarget: options.isNativeAppStyleTarget,
|
|
1995
|
+
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
1996
|
+
watch: resolvedConfig?.build?.watch
|
|
1997
|
+
})) return false;
|
|
1998
|
+
const enumerateStartedAt = performance.now();
|
|
1999
|
+
const cssAssets = collectCssAssets(bundle, context);
|
|
2000
|
+
const bundleFiles = [...cssAssets.values()].map((item) => item.file);
|
|
2001
|
+
options.recordTiming("assets.enumerate", enumerateStartedAt);
|
|
2002
|
+
const processedAssets = resolveProcessedCssAssets(cssAssets, processedCssResults, options, bundleFiles);
|
|
2003
|
+
options.recordTiming("processedCss.collect", collectStartedAt);
|
|
2004
|
+
if (!processedAssets) return false;
|
|
2005
|
+
const writeStartedAt = performance.now();
|
|
2006
|
+
for (const [{ asset, file, original }, processed] of processedAssets) {
|
|
2007
|
+
const finalizeStartedAt = performance.now();
|
|
2008
|
+
const finalCssSource = processed.useAssetSource ? original : processed.css;
|
|
2009
|
+
const generated = finalizeWebCss(require_v4_generation_core.stripBundlerGeneratedCssMarkers(finalCssSource), {
|
|
2010
|
+
...options.createCssPipelineContext(file),
|
|
2011
|
+
file
|
|
2012
|
+
}, context.cssPipelineStrategy);
|
|
2013
|
+
options.recordTiming("finalizeWebCss", finalizeStartedAt);
|
|
2014
|
+
asset.source = generated;
|
|
2015
|
+
context.markCssAssetProcessed(asset, file);
|
|
2016
|
+
context.recordCssAssetResult?.(file, generated);
|
|
2017
|
+
if (generated !== original) context.opts.onUpdate(file, original, generated);
|
|
2018
|
+
}
|
|
2019
|
+
options.recordTiming("processedCss.inject", performance.now());
|
|
2020
|
+
options.recordTiming("assets.markerCleanupWrite", writeStartedAt);
|
|
2021
|
+
return true;
|
|
2022
|
+
}
|
|
2023
|
+
//#endregion
|
|
2024
|
+
//#region src/bundlers/vite/css-finalizer/web-plugin.ts
|
|
2025
|
+
/**
|
|
2026
|
+
* Generic Web 专用 CSS finalizer。
|
|
2027
|
+
*
|
|
2028
|
+
* 该插件只处理已经在 CSS transform 阶段记录的 CSS asset,不扫描或改写
|
|
2029
|
+
* HTML、JavaScript、模板和小程序分包产物。
|
|
2030
|
+
*/
|
|
2031
|
+
function createViteWebCssFinalizerOutputPlugin(context) {
|
|
2032
|
+
return {
|
|
2033
|
+
name: "weapp-tailwindcss:adaptor:web-css-finalizer",
|
|
2034
|
+
enforce: "post",
|
|
2035
|
+
async closeBundle() {
|
|
2036
|
+
if (context.getResolvedConfig()?.build?.watch != null) return;
|
|
2037
|
+
await require_compiler.disposeCompilerOwner(context.runtimeState);
|
|
2038
|
+
},
|
|
2039
|
+
async closeWatcher() {
|
|
2040
|
+
await require_compiler.disposeCompilerOwner(context.runtimeState);
|
|
2041
|
+
},
|
|
2042
|
+
generateBundle: {
|
|
2043
|
+
order: "post",
|
|
2044
|
+
async handler(_options, bundle) {
|
|
2045
|
+
const resolvedConfig = context.getResolvedConfig();
|
|
2046
|
+
if (resolvedConfig?.command !== "build") return;
|
|
2047
|
+
const rootDir = resolvedConfig.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
2048
|
+
const recordTiming = (phase, startedAt) => {
|
|
2049
|
+
context.hmrTimingRecorder?.record(`webCssFinalizer.${phase}`, performance.now() - startedAt);
|
|
2050
|
+
};
|
|
2051
|
+
const startedAt = performance.now();
|
|
2052
|
+
if (!tryFinalizeGenericWebCss({
|
|
2053
|
+
bundle,
|
|
2054
|
+
context,
|
|
2055
|
+
createCssPipelineContext: (file) => ({
|
|
2056
|
+
bundle,
|
|
2057
|
+
currentGeneratorBranch: {
|
|
2058
|
+
isWeb: true,
|
|
2059
|
+
isNativeApp: false,
|
|
2060
|
+
isMiniProgram: false
|
|
2061
|
+
},
|
|
2062
|
+
currentGeneratorOptions: {
|
|
2063
|
+
target: "web",
|
|
2064
|
+
enabled: true
|
|
2065
|
+
},
|
|
2066
|
+
file,
|
|
2067
|
+
opts: context.opts,
|
|
2068
|
+
resolvedConfig,
|
|
2069
|
+
resolveStylePlatform: () => "web"
|
|
2070
|
+
}),
|
|
2071
|
+
isHarmonyAppStyleTarget: false,
|
|
2072
|
+
isNativeAppStyleTarget: false,
|
|
2073
|
+
isWebGeneratorTarget: true,
|
|
2074
|
+
recordTiming,
|
|
2075
|
+
rootDir,
|
|
2076
|
+
sourceRoot: void 0
|
|
2077
|
+
})) context.debug("Generic Web CSS finalizer skipped: no unique processed CSS asset");
|
|
2078
|
+
require_hmr_timing.finalizeCompilerShadowRun(context.runtimeState);
|
|
2079
|
+
context.hmrTimingRecorder?.record("webCssFinalizer.total", performance.now() - startedAt);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
//#endregion
|
|
2085
|
+
//#region src/bundlers/vite/map-cache.ts
|
|
2086
|
+
function touchMapEntry(map, key, value) {
|
|
2087
|
+
map.delete(key);
|
|
2088
|
+
map.set(key, value);
|
|
2089
|
+
}
|
|
2090
|
+
function pruneMapToMaxSize(map, maxSize, onDelete) {
|
|
2091
|
+
while (map.size > maxSize) {
|
|
2092
|
+
const key = map.keys().next().value;
|
|
2093
|
+
if (key === void 0) break;
|
|
2094
|
+
map.delete(key);
|
|
2095
|
+
onDelete?.(key);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
//#endregion
|
|
2099
|
+
//#region src/bundlers/vite/css-memory.ts
|
|
2100
|
+
const VITE_REMEMBERED_CSS_CACHE_MAX = 96;
|
|
2101
|
+
const VITE_KNOWN_SFC_SOURCE_CACHE_MAX = 128;
|
|
2102
|
+
const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
2103
|
+
const SFC_COMPONENT_FILE_RE = /\.(?:vue|uvue|nvue|svelte|mpx)$/i;
|
|
2104
|
+
function toMb$1(bytes) {
|
|
2105
|
+
return Math.round(bytes / 1024 / 1024);
|
|
2106
|
+
}
|
|
2107
|
+
function summarizeStringMapCache(map) {
|
|
2108
|
+
let bytes = 0;
|
|
2109
|
+
for (const value of map.values()) bytes += value.length;
|
|
2110
|
+
return {
|
|
2111
|
+
bytes,
|
|
2112
|
+
mb: toMb$1(bytes),
|
|
2113
|
+
size: map.size
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
function summarizeRememberedCssSources(map) {
|
|
2117
|
+
let bytes = 0;
|
|
2118
|
+
for (const value of map.values()) bytes += value.rawSource.length;
|
|
2119
|
+
return {
|
|
2120
|
+
bytes,
|
|
2121
|
+
mb: toMb$1(bytes),
|
|
2122
|
+
size: map.size
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
function stripSourceHash(sourceFile) {
|
|
2126
|
+
const hashIndex = sourceFile.indexOf("#");
|
|
2127
|
+
return hashIndex === -1 ? sourceFile : sourceFile.slice(0, hashIndex);
|
|
2128
|
+
}
|
|
2129
|
+
function normalizeCssSourceIdentity(sourceFile) {
|
|
2130
|
+
const cleanSourceFile = stripSourceHash(sourceFile);
|
|
2131
|
+
const { filename, query } = parseVueRequest(cleanSourceFile);
|
|
2132
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(filename);
|
|
2133
|
+
if (query.type === "style") return `${normalizedFile}?type=style&index=${query.index ?? 0}`;
|
|
2134
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(require_v4_generation_core.stripRequestQuery(cleanSourceFile));
|
|
2135
|
+
}
|
|
2136
|
+
function hasSfcStyleBlocks(source) {
|
|
2137
|
+
SFC_STYLE_BLOCK_RE.lastIndex = 0;
|
|
2138
|
+
return SFC_STYLE_BLOCK_RE.test(source);
|
|
2139
|
+
}
|
|
2140
|
+
function extractSfcStyleBlock(source, index) {
|
|
2141
|
+
const targetIndex = index ?? 0;
|
|
2142
|
+
SFC_STYLE_BLOCK_RE.lastIndex = 0;
|
|
2143
|
+
let currentIndex = 0;
|
|
2144
|
+
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
2145
|
+
while (match !== null) {
|
|
2146
|
+
if (currentIndex === targetIndex) return match[1] ?? "";
|
|
2147
|
+
currentIndex++;
|
|
2148
|
+
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
function extractSfcStyleSource(source, index) {
|
|
2152
|
+
if (index !== void 0) return extractSfcStyleBlock(source, index);
|
|
2153
|
+
const styleSources = [];
|
|
2154
|
+
SFC_STYLE_BLOCK_RE.lastIndex = 0;
|
|
2155
|
+
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
2156
|
+
while (match !== null) {
|
|
2157
|
+
styleSources.push(match[1] ?? "");
|
|
2158
|
+
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
2159
|
+
}
|
|
2160
|
+
return styleSources.length > 0 ? styleSources.join("\n") : void 0;
|
|
2161
|
+
}
|
|
2162
|
+
function normalizeKnownSfcSourceKey(file) {
|
|
2163
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
2164
|
+
}
|
|
2165
|
+
function shouldCollectTransformedSourceCandidates(id) {
|
|
2166
|
+
if (isWeappViteSidecarRequest(id)) return false;
|
|
2167
|
+
if (id.search(/[?#]/) < 0) return true;
|
|
2168
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
2169
|
+
return !SFC_COMPONENT_FILE_RE.test(file);
|
|
2170
|
+
}
|
|
2171
|
+
function createViteCssMemory(options) {
|
|
2172
|
+
const rememberedCssSources = /* @__PURE__ */ new Map();
|
|
2173
|
+
const rememberedCssSignatureByFile = /* @__PURE__ */ new Map();
|
|
2174
|
+
const knownCssSources = /* @__PURE__ */ new Map();
|
|
2175
|
+
const knownSfcSources = /* @__PURE__ */ new Map();
|
|
2176
|
+
const rememberKnownSfcSource = (id, code) => {
|
|
2177
|
+
if (id.search(/[?#]/) >= 0) return;
|
|
2178
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
2179
|
+
if (!SFC_COMPONENT_FILE_RE.test(file)) return;
|
|
2180
|
+
if (!hasSfcStyleBlocks(code)) return;
|
|
2181
|
+
touchMapEntry(knownSfcSources, normalizeKnownSfcSourceKey(file), code);
|
|
2182
|
+
pruneMapToMaxSize(knownSfcSources, VITE_KNOWN_SFC_SOURCE_CACHE_MAX);
|
|
2183
|
+
};
|
|
2184
|
+
const getKnownSfcSource = (file) => {
|
|
2185
|
+
const scanSource = options.getSourceCandidateSource(file);
|
|
2186
|
+
if (scanSource && hasSfcStyleBlocks(scanSource)) return scanSource;
|
|
2187
|
+
const key = normalizeKnownSfcSourceKey(file);
|
|
2188
|
+
const source = knownSfcSources.get(key);
|
|
2189
|
+
if (source != null) touchMapEntry(knownSfcSources, key, source);
|
|
2190
|
+
return source;
|
|
2191
|
+
};
|
|
2192
|
+
const getKnownCssSource = (file) => {
|
|
2193
|
+
const source = knownCssSources.get(normalizeCssSourceIdentity(file));
|
|
2194
|
+
if (source != null) touchMapEntry(knownCssSources, normalizeCssSourceIdentity(file), source);
|
|
2195
|
+
return source;
|
|
2196
|
+
};
|
|
2197
|
+
const rememberCssSource = (entry, cssRuntimeSignature) => {
|
|
2198
|
+
getActiveViteSourceOutputRelationOwner()?.recordOwnedOutput(entry.sourceFile, entry.outputFile);
|
|
2199
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(entry.outputFile);
|
|
2200
|
+
const normalizedSourceFile = normalizeCssSourceIdentity(entry.sourceFile);
|
|
2201
|
+
const previousOutputEntry = rememberedCssSources.get(outputKey);
|
|
2202
|
+
const key = previousOutputEntry != null && normalizeCssSourceIdentity(previousOutputEntry.sourceFile) !== normalizedSourceFile ? `${outputKey}\0${normalizedSourceFile}` : outputKey;
|
|
2203
|
+
const previous = rememberedCssSources.get(key);
|
|
2204
|
+
touchMapEntry(rememberedCssSources, key, entry);
|
|
2205
|
+
const relatedRememberedEntries = [...rememberedCssSources].filter(([rememberedKey, remembered]) => rememberedKey !== key && normalizeCssSourceIdentity(remembered.sourceFile) === normalizedSourceFile);
|
|
2206
|
+
for (const [rememberedKey, remembered] of relatedRememberedEntries) {
|
|
2207
|
+
touchMapEntry(rememberedCssSources, rememberedKey, {
|
|
2208
|
+
...remembered,
|
|
2209
|
+
outputFile: entry.outputFile,
|
|
2210
|
+
rawSource: entry.rawSource,
|
|
2211
|
+
sourceFile: entry.sourceFile
|
|
2212
|
+
});
|
|
2213
|
+
rememberedCssSignatureByFile.delete(rememberedKey);
|
|
2214
|
+
}
|
|
2215
|
+
if (cssRuntimeSignature) rememberedCssSignatureByFile.set(key, cssRuntimeSignature);
|
|
2216
|
+
else if (previous?.rawSource !== entry.rawSource || previous?.sourceFile !== entry.sourceFile) rememberedCssSignatureByFile.delete(key);
|
|
2217
|
+
pruneMapToMaxSize(rememberedCssSources, VITE_REMEMBERED_CSS_CACHE_MAX, (rememberedKey) => {
|
|
2218
|
+
rememberedCssSignatureByFile.delete(String(rememberedKey));
|
|
2219
|
+
});
|
|
2220
|
+
};
|
|
2221
|
+
const refreshRememberedCssSourceEntry = (rememberedKey, remembered, sourceFile, rawSource) => {
|
|
2222
|
+
if (remembered.rawSource === rawSource && remembered.sourceFile === sourceFile) return remembered;
|
|
2223
|
+
const nextRemembered = {
|
|
2224
|
+
...remembered,
|
|
2225
|
+
rawSource,
|
|
2226
|
+
sourceFile
|
|
2227
|
+
};
|
|
2228
|
+
touchMapEntry(rememberedCssSources, rememberedKey, nextRemembered);
|
|
2229
|
+
rememberedCssSignatureByFile.delete(rememberedKey);
|
|
2230
|
+
return nextRemembered;
|
|
2231
|
+
};
|
|
2232
|
+
const refreshRememberedCssSourceBySourceFile = (sourceFile, rawSource) => {
|
|
2233
|
+
touchMapEntry(knownCssSources, normalizeCssSourceIdentity(sourceFile), rawSource);
|
|
2234
|
+
const normalizedSourceFile = normalizeCssSourceIdentity(sourceFile);
|
|
2235
|
+
const relatedRememberedEntries = [...rememberedCssSources].filter(([, remembered]) => normalizeCssSourceIdentity(remembered.sourceFile) === normalizedSourceFile);
|
|
2236
|
+
for (const [rememberedKey, remembered] of relatedRememberedEntries) refreshRememberedCssSourceEntry(rememberedKey, remembered, sourceFile, rawSource);
|
|
2237
|
+
};
|
|
2238
|
+
const resolveCachedStyleSource = (sourceFile) => {
|
|
2239
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_v4_generation_core.stripRequestQuery(sourceFile));
|
|
2240
|
+
if (SFC_COMPONENT_FILE_RE.test(file)) return getKnownSfcSource(file);
|
|
2241
|
+
if (require_v4_generation_core.isSourceStyleRequest(file)) return options.getSourceCandidateSource(file);
|
|
2242
|
+
};
|
|
2243
|
+
const resolveCurrentStyleSource = (sourceFile) => {
|
|
2244
|
+
const cached = resolveCachedStyleSource(sourceFile);
|
|
2245
|
+
if (cached != null) return cached;
|
|
2246
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_v4_generation_core.stripRequestQuery(sourceFile));
|
|
2247
|
+
const knownSource = knownCssSources.get(normalizeCssSourceIdentity(sourceFile));
|
|
2248
|
+
if (knownSource != null) return knownSource;
|
|
2249
|
+
const candidateSource = options.getSourceCandidateSource(file);
|
|
2250
|
+
if (candidateSource != null) return candidateSource;
|
|
2251
|
+
};
|
|
2252
|
+
const refreshRememberedCssSourceByCurrentFile = async (sourceFile) => {
|
|
2253
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(sourceFile);
|
|
2254
|
+
const normalizedSourceFile = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2255
|
+
const matchedRememberedSources = [...rememberedCssSources.values()].filter((remembered) => require_source_candidate_scan_signature.normalizeOutputPathKey(require_v4_generation_core.stripRequestQuery((0, _weapp_tailwindcss_shared.cleanUrl)(remembered.sourceFile))) === normalizedSourceFile);
|
|
2256
|
+
if (matchedRememberedSources.length === 0) return;
|
|
2257
|
+
const source = await resolveCurrentStyleSource(file);
|
|
2258
|
+
if (source == null) {
|
|
2259
|
+
options.debug("refresh remembered css source skipped: missing cached source for %s", file);
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2262
|
+
if (SFC_COMPONENT_FILE_RE.test(file)) {
|
|
2263
|
+
for (const remembered of matchedRememberedSources) {
|
|
2264
|
+
const { query } = parseVueRequest(remembered.sourceFile);
|
|
2265
|
+
const styleSource = extractSfcStyleSource(source, query.type === "style" ? query.index : void 0);
|
|
2266
|
+
if (styleSource !== void 0) refreshRememberedCssSourceBySourceFile(remembered.sourceFile, styleSource);
|
|
2267
|
+
}
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
if (require_v4_generation_core.isSourceStyleRequest(file)) refreshRememberedCssSourceBySourceFile(file, source);
|
|
2271
|
+
};
|
|
2272
|
+
const prune = (pruneOptions) => {
|
|
2273
|
+
const activeFiles = new Set([...pruneOptions.activeFiles].map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
2274
|
+
for (const [key, remembered] of rememberedCssSources) {
|
|
2275
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.outputFile);
|
|
2276
|
+
const sourceKey = require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.sourceFile);
|
|
2277
|
+
if (!activeFiles.has(key) && !activeFiles.has(outputKey) && !activeFiles.has(sourceKey)) {
|
|
2278
|
+
rememberedCssSources.delete(key);
|
|
2279
|
+
rememberedCssSignatureByFile.delete(key);
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
if (pruneOptions.activeKnownSfcFiles) {
|
|
2283
|
+
const activeKnownSfcFiles = new Set([...pruneOptions.activeKnownSfcFiles].map((file) => normalizeKnownSfcSourceKey(file)).filter((file) => SFC_COMPONENT_FILE_RE.test(file)));
|
|
2284
|
+
for (const key of knownSfcSources.keys()) if (!activeKnownSfcFiles.has(key)) knownSfcSources.delete(key);
|
|
2285
|
+
}
|
|
2286
|
+
pruneMapToMaxSize(rememberedCssSources, VITE_REMEMBERED_CSS_CACHE_MAX, (rememberedKey) => {
|
|
2287
|
+
rememberedCssSignatureByFile.delete(String(rememberedKey));
|
|
2288
|
+
});
|
|
2289
|
+
pruneMapToMaxSize(knownCssSources, VITE_REMEMBERED_CSS_CACHE_MAX);
|
|
2290
|
+
pruneMapToMaxSize(knownSfcSources, VITE_KNOWN_SFC_SOURCE_CACHE_MAX);
|
|
2291
|
+
};
|
|
2292
|
+
return {
|
|
2293
|
+
getKnownSfcSource,
|
|
2294
|
+
getKnownCssSource,
|
|
2295
|
+
getRememberedCssSignature: (file) => rememberedCssSignatureByFile.get(require_source_candidate_scan_signature.normalizeOutputPathKey(file)),
|
|
2296
|
+
getRememberedCssSourceEntry: (file) => rememberedCssSources.get(require_source_candidate_scan_signature.normalizeOutputPathKey(file)),
|
|
2297
|
+
getRememberedCssSources: () => rememberedCssSources,
|
|
2298
|
+
getStats: () => ({
|
|
2299
|
+
rememberedCssSources: rememberedCssSources.size,
|
|
2300
|
+
rememberedCssSourcesRaw: summarizeRememberedCssSources(rememberedCssSources),
|
|
2301
|
+
rememberedCssSignatureByFile: rememberedCssSignatureByFile.size,
|
|
2302
|
+
knownCssSources: knownCssSources.size,
|
|
2303
|
+
knownCssSourcesRaw: summarizeStringMapCache(knownCssSources),
|
|
2304
|
+
knownSfcSources: knownSfcSources.size,
|
|
2305
|
+
knownSfcSourcesRaw: summarizeStringMapCache(knownSfcSources)
|
|
2306
|
+
}),
|
|
2307
|
+
rememberCssSource,
|
|
2308
|
+
rememberKnownSfcSource,
|
|
2309
|
+
refreshRememberedCssSourceByCurrentFile,
|
|
2310
|
+
refreshRememberedCssSourceBySourceFile,
|
|
2311
|
+
setRememberedCssSignature: (file, cssRuntimeSignature) => {
|
|
2312
|
+
rememberedCssSignatureByFile.set(require_source_candidate_scan_signature.normalizeOutputPathKey(file), cssRuntimeSignature);
|
|
2313
|
+
},
|
|
2314
|
+
prune
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
//#endregion
|
|
2318
|
+
//#region src/bundlers/vite/plugin-cache.ts
|
|
2319
|
+
function isMissingInternalCssSource(file, packageDir) {
|
|
2320
|
+
return !(0, node_fs.existsSync)(file) && node_path.default.resolve(file).startsWith(`${packageDir}${node_path.default.sep}`);
|
|
2321
|
+
}
|
|
2322
|
+
function normalizeVitePersistentCacheKey(file) {
|
|
2323
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2324
|
+
}
|
|
2325
|
+
function toMb(bytes) {
|
|
2326
|
+
return Math.round(bytes / 1024 / 1024);
|
|
2327
|
+
}
|
|
2328
|
+
function summarizeStringCache(map) {
|
|
2329
|
+
let bytes = 0;
|
|
2330
|
+
for (const value of map.values()) bytes += value.length;
|
|
2331
|
+
return {
|
|
2332
|
+
bytes,
|
|
2333
|
+
mb: toMb(bytes),
|
|
2334
|
+
size: map.size
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2337
|
+
function summarizeViteProcessedCssResults(map) {
|
|
2338
|
+
let bytes = 0;
|
|
2339
|
+
for (const record of map.values()) bytes += record.css.length;
|
|
2340
|
+
return {
|
|
2341
|
+
bytes,
|
|
2342
|
+
mb: toMb(bytes),
|
|
2343
|
+
size: map.size
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
//#endregion
|
|
2347
|
+
//#region src/bundlers/vite/rewrite-css-imports.ts
|
|
2348
|
+
function joinPosixPath(base, subpath) {
|
|
2349
|
+
if (base.endsWith("/")) return `${base}${subpath}`;
|
|
2350
|
+
return `${base}/${subpath}`;
|
|
2351
|
+
}
|
|
2352
|
+
function isCssLikeImporter(importer) {
|
|
2353
|
+
if (!importer) return false;
|
|
2354
|
+
const normalized = (0, _weapp_tailwindcss_shared.cleanUrl)(importer);
|
|
2355
|
+
return require_v4_generation_core.isSourceStyleRequest(importer) || isCSSRequest(normalized) || normalized.endsWith("/*");
|
|
2356
|
+
}
|
|
2357
|
+
function stripTailwindConfigDirectives(code) {
|
|
2358
|
+
return code.replace(/^\s*@config\s+(?:"[^"]+"|'[^']+')[^;\n]*;\s*$/gm, "");
|
|
2359
|
+
}
|
|
2360
|
+
function createRewriteCssImportsPlugins(options) {
|
|
2361
|
+
if (!options.shouldRewrite && !options.shouldOwnTailwindGeneration) return [];
|
|
2362
|
+
const { appType, getAppType, rootImport, shouldOwnTailwindGeneration, weappTailwindcssDirPosix } = options;
|
|
2363
|
+
const resolveAppType = () => getAppType?.() ?? appType;
|
|
2364
|
+
return [{
|
|
2365
|
+
name: `${require_compiler.vitePluginName}:rewrite-css-imports`,
|
|
2366
|
+
enforce: "pre",
|
|
2367
|
+
resolveId(id, importer) {
|
|
2368
|
+
if (!options.shouldRewrite) return null;
|
|
2369
|
+
const replacement = require_css_imports.resolveTailwindcssImport(id, weappTailwindcssDirPosix, {
|
|
2370
|
+
join: joinPosixPath,
|
|
2371
|
+
appType: resolveAppType(),
|
|
2372
|
+
rootImport
|
|
2373
|
+
});
|
|
2374
|
+
if (!replacement) return null;
|
|
2375
|
+
if (importer && !isCssLikeImporter(importer)) return null;
|
|
2376
|
+
return replacement;
|
|
2377
|
+
},
|
|
2378
|
+
async transform(code, id) {
|
|
2379
|
+
if (!isCSSRequest(id)) return null;
|
|
2380
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
2381
|
+
const normalizedCode = !isSfcStyleSourceFile(file) && (require_generator.hasTailwindRootDirectives(code) || code.includes("@config")) ? require_generator.normalizeTailwindConfigDirectives(code, node_path.default.dirname(file)) : code;
|
|
2382
|
+
await options.onCssSourceTransform?.(id, normalizedCode);
|
|
2383
|
+
const hasTailwindRoot = require_generator.hasTailwindRootDirectives(normalizedCode, { importFallback: true });
|
|
2384
|
+
if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
|
|
2385
|
+
const shouldGenerateInPreTransform = !options.shouldDeferGeneration?.(id, normalizedCode) && (hasTailwindRoot || options.shouldGenerateCss?.(id, normalizedCode));
|
|
2386
|
+
if (options.shouldOwnTailwindGeneration && shouldGenerateInPreTransform) {
|
|
2387
|
+
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, {
|
|
2388
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
2389
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
2390
|
+
cssStage: "raw"
|
|
2391
|
+
});
|
|
2392
|
+
if (generatedCss !== void 0) return {
|
|
2393
|
+
code: generatedCss,
|
|
2394
|
+
map: null
|
|
2395
|
+
};
|
|
2396
|
+
}
|
|
2397
|
+
if (!options.shouldRewrite) {
|
|
2398
|
+
if (normalizedCode !== code) return {
|
|
2399
|
+
code: normalizedCode,
|
|
2400
|
+
map: null
|
|
2401
|
+
};
|
|
2402
|
+
return null;
|
|
2403
|
+
}
|
|
2404
|
+
const rewritten = require_css_imports.rewriteTailwindcssImportsInCode(normalizedCode, weappTailwindcssDirPosix, {
|
|
2405
|
+
join: joinPosixPath,
|
|
2406
|
+
appType: resolveAppType(),
|
|
2407
|
+
rootImport
|
|
2408
|
+
});
|
|
2409
|
+
const nextCode = shouldOwnTailwindGeneration ? stripTailwindConfigDirectives(rewritten ?? normalizedCode) : rewritten;
|
|
2410
|
+
if (!nextCode || nextCode === code) return null;
|
|
2411
|
+
return {
|
|
2412
|
+
code: nextCode,
|
|
2413
|
+
map: null
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
}];
|
|
2417
|
+
}
|
|
2418
|
+
function hasVitePipelineTailwindGenerationDirective(code) {
|
|
2419
|
+
return require_generator.hasTailwindRootDirectives(code) || require_generator.hasTailwindApplyDirective(code);
|
|
2420
|
+
}
|
|
2421
|
+
//#endregion
|
|
2422
|
+
//#region src/bundlers/vite/runtime-class-set.ts
|
|
2423
|
+
function createViteRuntimeClassSet(options) {
|
|
2424
|
+
const { opts, initialTailwindRuntime, refreshTailwindcssRuntime, uniAppXEnabled, customAttributesEntities, disabledDefaultTemplateHandler, debug } = options;
|
|
2425
|
+
const readyPromise = require_compiler.createTailwindRuntimeReadyPromise(initialTailwindRuntime);
|
|
2426
|
+
const runtimeState = require_runtime_state.createCompilerRuntimeState({
|
|
2427
|
+
tailwindRuntime: initialTailwindRuntime,
|
|
2428
|
+
readyPromise,
|
|
2429
|
+
refreshTailwindcssRuntime
|
|
2430
|
+
});
|
|
2431
|
+
const bundleRuntimeClassSetManager = require_hmr_timing.createRuntimeClassSetManager({
|
|
2432
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
2433
|
+
escapeMap: opts.escapeMap
|
|
2434
|
+
});
|
|
2435
|
+
const transformRuntimeClassSetManager = require_hmr_timing.createRuntimeClassSetManager({
|
|
2436
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
2437
|
+
escapeMap: opts.escapeMap
|
|
2438
|
+
});
|
|
2439
|
+
let runtimeSet;
|
|
2440
|
+
let runtimeSetPromise;
|
|
2441
|
+
let runtimeRefreshSignature;
|
|
2442
|
+
let runtimeRefreshOptionsKey;
|
|
2443
|
+
function resolveRuntimeRefreshOptions() {
|
|
2444
|
+
const configPath = require_generator.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options)?.config;
|
|
2445
|
+
const signature = require_tailwindcss.getRuntimeClassSetSignature(runtimeState.tailwindRuntime);
|
|
2446
|
+
const optionsKey = JSON.stringify({
|
|
2447
|
+
appType: opts.appType,
|
|
2448
|
+
uniAppX: uniAppXEnabled,
|
|
2449
|
+
customAttributesEntities,
|
|
2450
|
+
disabledDefaultTemplateHandler,
|
|
2451
|
+
configPath
|
|
2452
|
+
});
|
|
2453
|
+
const changed = signature !== runtimeRefreshSignature || optionsKey !== runtimeRefreshOptionsKey;
|
|
2454
|
+
runtimeRefreshSignature = signature;
|
|
2455
|
+
runtimeRefreshOptionsKey = optionsKey;
|
|
2456
|
+
return {
|
|
2457
|
+
changed,
|
|
2458
|
+
signature,
|
|
2459
|
+
optionsKey
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2462
|
+
async function refreshRuntimeState(force) {
|
|
2463
|
+
const invalidation = resolveRuntimeRefreshOptions();
|
|
2464
|
+
const shouldRefresh = force || invalidation.changed;
|
|
2465
|
+
const refreshed = await require_compiler.refreshTailwindRuntimeState(runtimeState, {
|
|
2466
|
+
force: shouldRefresh,
|
|
2467
|
+
clearCache: force || invalidation.changed
|
|
2468
|
+
});
|
|
2469
|
+
if (invalidation.changed) debug("runtime signature changed, refresh triggered. signature: %s", invalidation.signature);
|
|
2470
|
+
if (refreshed) {
|
|
2471
|
+
runtimeSet = void 0;
|
|
2472
|
+
runtimeSetPromise = void 0;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
async function ensureRuntimeClassSet(force = false) {
|
|
2476
|
+
const forceRuntimeRefresh = force || node_process.default.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1";
|
|
2477
|
+
await refreshRuntimeState(force);
|
|
2478
|
+
await runtimeState.readyPromise;
|
|
2479
|
+
if (!forceRuntimeRefresh && runtimeSet) return runtimeSet;
|
|
2480
|
+
if (forceRuntimeRefresh || !runtimeSetPromise) {
|
|
2481
|
+
const invalidation = resolveRuntimeRefreshOptions();
|
|
2482
|
+
runtimeSetPromise = require_compiler.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
2483
|
+
force: forceRuntimeRefresh || invalidation.changed,
|
|
2484
|
+
skipRefresh: forceRuntimeRefresh,
|
|
2485
|
+
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
const task = runtimeSetPromise;
|
|
2489
|
+
try {
|
|
2490
|
+
runtimeSet = await task;
|
|
2491
|
+
return runtimeSet;
|
|
2492
|
+
} finally {
|
|
2493
|
+
if (runtimeSetPromise === task) runtimeSetPromise = void 0;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false, options = {}) {
|
|
2497
|
+
const forceRuntimeRefresh = forceRefresh || node_process.default.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1";
|
|
2498
|
+
const invalidation = resolveRuntimeRefreshOptions();
|
|
2499
|
+
const shouldRefreshRuntime = forceRuntimeRefresh || invalidation.changed;
|
|
2500
|
+
const forceCollectBySource = snapshot.runtimeAffectingChangedByType.html.size > 0 || snapshot.runtimeAffectingChangedByType.js.size > 0;
|
|
2501
|
+
await refreshRuntimeState(shouldRefreshRuntime);
|
|
2502
|
+
await runtimeState.readyPromise;
|
|
2503
|
+
if (shouldRefreshRuntime) {
|
|
2504
|
+
runtimeSet = void 0;
|
|
2505
|
+
runtimeSetPromise = void 0;
|
|
2506
|
+
await bundleRuntimeClassSetManager.reset();
|
|
2507
|
+
await transformRuntimeClassSetManager.reset();
|
|
2508
|
+
}
|
|
2509
|
+
if (!forceRuntimeRefresh) try {
|
|
2510
|
+
const baseClassSet = options.baseClassSet ?? runtimeSet ?? await require_compiler.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
2511
|
+
force: invalidation.changed,
|
|
2512
|
+
clearCache: invalidation.changed
|
|
2513
|
+
});
|
|
2514
|
+
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.tailwindRuntime, snapshot, {
|
|
2515
|
+
baseClassSet,
|
|
2516
|
+
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync
|
|
2517
|
+
});
|
|
2518
|
+
runtimeSet = nextRuntimeSet;
|
|
2519
|
+
return nextRuntimeSet;
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
2522
|
+
await bundleRuntimeClassSetManager.reset();
|
|
2523
|
+
}
|
|
2524
|
+
if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) return runtimeSet;
|
|
2525
|
+
const task = require_compiler.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
2526
|
+
force: forceRuntimeRefresh || invalidation.changed || forceCollectBySource,
|
|
2527
|
+
skipRefresh: forceRuntimeRefresh,
|
|
2528
|
+
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
2529
|
+
});
|
|
2530
|
+
runtimeSetPromise = task;
|
|
2531
|
+
try {
|
|
2532
|
+
runtimeSet = await task;
|
|
2533
|
+
return runtimeSet;
|
|
2534
|
+
} finally {
|
|
2535
|
+
if (runtimeSetPromise === task) runtimeSetPromise = void 0;
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
return {
|
|
2539
|
+
runtimeState,
|
|
2540
|
+
refreshRuntimeState,
|
|
2541
|
+
ensureRuntimeClassSet,
|
|
2542
|
+
ensureBundleRuntimeClassSet
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
//#endregion
|
|
2546
|
+
//#region src/bundlers/vite/serve-css-generation.ts
|
|
2547
|
+
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
2548
|
+
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
2549
|
+
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
2550
|
+
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
2551
|
+
const DEFERRED_CSS_HMR_QUERY_RE = /[?&](?:hmr(?:[=&]|$)|t=\d+)/;
|
|
2552
|
+
function decodeJsStringLiteral(literal) {
|
|
2553
|
+
try {
|
|
2554
|
+
return JSON.parse(literal);
|
|
2555
|
+
} catch {
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
function encodeJsStringLiteral(value) {
|
|
2560
|
+
return JSON.stringify(value);
|
|
2561
|
+
}
|
|
2562
|
+
function extractViteCssHmrModuleCss(code) {
|
|
2563
|
+
const match = VITE_CSS_CONST_RE.exec(code);
|
|
2564
|
+
if (!match?.[1]) return;
|
|
2565
|
+
const css = decodeJsStringLiteral(match[1]);
|
|
2566
|
+
if (typeof css !== "string") return;
|
|
2567
|
+
return {
|
|
2568
|
+
css,
|
|
2569
|
+
start: match.index + match[0].lastIndexOf(match[1]),
|
|
2570
|
+
end: match.index + match[0].length
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
function replaceViteCssHmrModuleCss(code, css) {
|
|
2574
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
2575
|
+
if (!extracted) return;
|
|
2576
|
+
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
2577
|
+
}
|
|
2578
|
+
function isViteServeStyleRequest(id, command) {
|
|
2579
|
+
return command === "serve" && require_v4_generation_core.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
2580
|
+
}
|
|
2581
|
+
function isViteServeCssRootRequest(id, command) {
|
|
2582
|
+
return command === "serve" && require_v4_generation_core.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
2583
|
+
}
|
|
2584
|
+
function isViteBuildStyleRequest(id, command) {
|
|
2585
|
+
return command === "build" && require_v4_generation_core.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
2586
|
+
}
|
|
2587
|
+
function isViteCssHmrModule(code, id, command) {
|
|
2588
|
+
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && (/[?&](?:direct|vue)(?:&|$)/.test(id) || DEFERRED_CSS_HMR_QUERY_RE.test(id));
|
|
2589
|
+
}
|
|
2590
|
+
function hasViteCssGenerationDirective(code) {
|
|
2591
|
+
return require_generator.hasTailwindRootDirectives(code) || require_generator.hasTailwindSourceDirectives(code, { importFallback: true }) || require_generator.hasTailwindApplyDirective(code);
|
|
2592
|
+
}
|
|
2593
|
+
function hasViteServeCssRootDirective(code) {
|
|
2594
|
+
return require_generator.hasTailwindRootDirectives(code);
|
|
2595
|
+
}
|
|
2596
|
+
function createViteCssGenerationPlugins(options) {
|
|
2597
|
+
return [
|
|
2598
|
+
{
|
|
2599
|
+
name: `${require_compiler.vitePluginName}:generate:serve`,
|
|
2600
|
+
apply: "serve",
|
|
2601
|
+
enforce: "pre",
|
|
2602
|
+
async transform(code, id) {
|
|
2603
|
+
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
2604
|
+
if (!require_generator.hasTailwindRootDirectives(code)) return;
|
|
2605
|
+
if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
|
|
2606
|
+
await options.onTailwindRootCss?.(id, code);
|
|
2607
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
2608
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
2609
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
2610
|
+
cssStage: "raw"
|
|
2611
|
+
});
|
|
2612
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
2613
|
+
return {
|
|
2614
|
+
code: generatedCss,
|
|
2615
|
+
map: null
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
},
|
|
2619
|
+
{
|
|
2620
|
+
name: `${require_compiler.vitePluginName}:generate:build`,
|
|
2621
|
+
apply: "build",
|
|
2622
|
+
enforce: "pre",
|
|
2623
|
+
async transform(code, id) {
|
|
2624
|
+
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
2625
|
+
if (!hasViteCssGenerationDirective(code)) return;
|
|
2626
|
+
if (options.shouldDeferGeneration?.(id, code)) return;
|
|
2627
|
+
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
2628
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
2629
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
2630
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
2631
|
+
cssStage: "raw"
|
|
2632
|
+
});
|
|
2633
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
2634
|
+
return {
|
|
2635
|
+
code: generatedCss,
|
|
2636
|
+
map: null
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
},
|
|
2640
|
+
{
|
|
2641
|
+
name: `${require_compiler.vitePluginName}:generate:serve-hmr`,
|
|
2642
|
+
apply: "serve",
|
|
2643
|
+
enforce: "post",
|
|
2644
|
+
async transform(code, id) {
|
|
2645
|
+
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
2646
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
2647
|
+
if (!extracted) return;
|
|
2648
|
+
if (!hasViteCssGenerationDirective(extracted.css)) return;
|
|
2649
|
+
if (options.shouldDeferGeneration?.(id, extracted.css)) return;
|
|
2650
|
+
if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
|
|
2651
|
+
const generatedCss = await options.generateCss(id, extracted.css, {
|
|
2652
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
2653
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
2654
|
+
cssStage: "framework-processed"
|
|
2655
|
+
});
|
|
2656
|
+
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
2657
|
+
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
2658
|
+
if (nextCode === void 0 || nextCode === code) return;
|
|
2659
|
+
return {
|
|
2660
|
+
code: nextCode,
|
|
2661
|
+
map: null
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
];
|
|
2666
|
+
}
|
|
2667
|
+
//#endregion
|
|
2668
|
+
//#region src/bundlers/vite/shared/framework-css-generation-queue.ts
|
|
2669
|
+
function createFrameworkCssGenerationQueue(normalizeId, generate) {
|
|
2670
|
+
const pendingByFile = /* @__PURE__ */ new Map();
|
|
2671
|
+
return (id, ...args) => {
|
|
2672
|
+
const fileKey = normalizeId(id);
|
|
2673
|
+
const task = (pendingByFile.get(fileKey) ?? Promise.resolve()).then(() => generate(id, ...args));
|
|
2674
|
+
const tail = task.then(() => void 0, () => void 0);
|
|
2675
|
+
pendingByFile.set(fileKey, tail);
|
|
2676
|
+
tail.then(() => {
|
|
2677
|
+
if (pendingByFile.get(fileKey) === tail) pendingByFile.delete(fileKey);
|
|
2678
|
+
});
|
|
2679
|
+
return task;
|
|
2680
|
+
};
|
|
2681
|
+
}
|
|
2682
|
+
//#endregion
|
|
2683
|
+
//#region src/bundlers/vite/shared/framework-hmr-candidate-state.ts
|
|
2684
|
+
function createViteHmrCandidateState(options) {
|
|
2685
|
+
let pendingChange;
|
|
2686
|
+
let pendingCssTargetFiles;
|
|
2687
|
+
let pendingTargetsArmed = false;
|
|
2688
|
+
let pendingFullRegeneration = false;
|
|
2689
|
+
const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
2690
|
+
const clear = () => {
|
|
2691
|
+
pendingChange = void 0;
|
|
2692
|
+
pendingCssTargetFiles = void 0;
|
|
2693
|
+
pendingTargetsArmed = false;
|
|
2694
|
+
pendingFullRegeneration = false;
|
|
2695
|
+
};
|
|
2696
|
+
const queueFullRegeneration = () => {
|
|
2697
|
+
pendingChange = void 0;
|
|
2698
|
+
pendingCssTargetFiles = void 0;
|
|
2699
|
+
pendingTargetsArmed = false;
|
|
2700
|
+
pendingFullRegeneration = true;
|
|
2701
|
+
};
|
|
2702
|
+
const queueChange = (change) => {
|
|
2703
|
+
var _pendingChange;
|
|
2704
|
+
if (pendingFullRegeneration) return;
|
|
2705
|
+
pendingFullRegeneration = false;
|
|
2706
|
+
if (!pendingChange) {
|
|
2707
|
+
pendingChange = {
|
|
2708
|
+
file: change.file,
|
|
2709
|
+
runtimeAffecting: change.runtimeAffecting,
|
|
2710
|
+
addedCandidates: new Set(change.addedCandidates),
|
|
2711
|
+
removedCandidates: new Set(change.removedCandidates)
|
|
2712
|
+
};
|
|
2713
|
+
return;
|
|
2714
|
+
}
|
|
2715
|
+
for (const candidate of change.addedCandidates) {
|
|
2716
|
+
pendingChange.addedCandidates.add(candidate);
|
|
2717
|
+
pendingChange.removedCandidates.delete(candidate);
|
|
2718
|
+
}
|
|
2719
|
+
for (const candidate of change.removedCandidates) if (!pendingChange.addedCandidates.delete(candidate)) pendingChange.removedCandidates.add(candidate);
|
|
2720
|
+
(_pendingChange = pendingChange).runtimeAffecting || (_pendingChange.runtimeAffecting = change.runtimeAffecting);
|
|
2721
|
+
pendingChange.file = change.file;
|
|
2722
|
+
};
|
|
2723
|
+
const createChange = (file, change, changeOptions = {}) => ({
|
|
2724
|
+
...change,
|
|
2725
|
+
file,
|
|
2726
|
+
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || require_v4_generation_core.isSourceStyleRequest(file)
|
|
2727
|
+
});
|
|
2728
|
+
const apply = (change) => {
|
|
2729
|
+
if (require_v4_generation_core.isSourceStyleRequest(change.file)) {
|
|
2730
|
+
clear();
|
|
2731
|
+
return change;
|
|
2732
|
+
}
|
|
2733
|
+
if (change.runtimeAffecting) {
|
|
2734
|
+
queueFullRegeneration();
|
|
2735
|
+
return change;
|
|
2736
|
+
}
|
|
2737
|
+
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
2738
|
+
if (preserveDeletedCss) {
|
|
2739
|
+
if (change.addedCandidates.size > 0) queueChange(change);
|
|
2740
|
+
else if (!pendingChange && !pendingFullRegeneration) clear();
|
|
2741
|
+
return change;
|
|
2742
|
+
}
|
|
2743
|
+
clear();
|
|
2744
|
+
if (!preserveDeletedCss) queueFullRegeneration();
|
|
2745
|
+
return change;
|
|
2746
|
+
};
|
|
2747
|
+
const resolve = (generatorCode, file) => {
|
|
2748
|
+
const fileKey = normalizeCssTargetFile(file);
|
|
2749
|
+
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && require_generator.hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) || pendingTargetsArmed && !pendingCssTargetFiles?.has(fileKey)) return;
|
|
2750
|
+
return pendingChange;
|
|
2751
|
+
};
|
|
2752
|
+
const finishTarget = (file) => {
|
|
2753
|
+
if (!pendingChange && !pendingFullRegeneration) return;
|
|
2754
|
+
if (!pendingTargetsArmed || !pendingCssTargetFiles) return;
|
|
2755
|
+
pendingCssTargetFiles.delete(normalizeCssTargetFile(file));
|
|
2756
|
+
if (pendingCssTargetFiles.size === 0) clear();
|
|
2757
|
+
};
|
|
2758
|
+
const armTargets = (cssModules, fallbackCssIds) => {
|
|
2759
|
+
if (!pendingChange && !pendingFullRegeneration) {
|
|
2760
|
+
pendingCssTargetFiles = void 0;
|
|
2761
|
+
pendingTargetsArmed = false;
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2764
|
+
const targets = /* @__PURE__ */ new Set();
|
|
2765
|
+
const addTarget = (file) => {
|
|
2766
|
+
if (!file) return;
|
|
2767
|
+
const key = normalizeCssTargetFile(file);
|
|
2768
|
+
if (pendingFullRegeneration || options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
2769
|
+
};
|
|
2770
|
+
for (const module of cssModules) {
|
|
2771
|
+
addTarget(module.id);
|
|
2772
|
+
addTarget(module.file);
|
|
2773
|
+
addTarget(module.url);
|
|
2774
|
+
}
|
|
2775
|
+
for (const id of fallbackCssIds) addTarget(id);
|
|
2776
|
+
pendingCssTargetFiles = targets;
|
|
2777
|
+
pendingTargetsArmed = true;
|
|
2778
|
+
};
|
|
2779
|
+
const reconcileRuntimeCandidates = (file, candidates, rootCssIds) => {
|
|
2780
|
+
if (options.getCommand() !== "serve" || pendingFullRegeneration) return;
|
|
2781
|
+
const generatedClassSets = [];
|
|
2782
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
2783
|
+
for (const id of rootCssIds) {
|
|
2784
|
+
const fileKey = normalizeCssTargetFile(id);
|
|
2785
|
+
if (seenFiles.has(fileKey)) continue;
|
|
2786
|
+
seenFiles.add(fileKey);
|
|
2787
|
+
const classSet = options.generatedClassSetByFile.get(fileKey);
|
|
2788
|
+
if (classSet) generatedClassSets.push(classSet);
|
|
2789
|
+
}
|
|
2790
|
+
if (generatedClassSets.length === 0) return;
|
|
2791
|
+
const addedCandidates = /* @__PURE__ */ new Set();
|
|
2792
|
+
for (const candidate of candidates) if (generatedClassSets.some((classSet) => !classSet.has(candidate))) addedCandidates.add(candidate);
|
|
2793
|
+
if (addedCandidates.size === 0) return;
|
|
2794
|
+
apply(createChange(file, {
|
|
2795
|
+
addedCandidates,
|
|
2796
|
+
removedCandidates: /* @__PURE__ */ new Set()
|
|
2797
|
+
}));
|
|
2798
|
+
};
|
|
2799
|
+
return {
|
|
2800
|
+
apply,
|
|
2801
|
+
armTargets,
|
|
2802
|
+
clear,
|
|
2803
|
+
createChange,
|
|
2804
|
+
finishTarget,
|
|
2805
|
+
hasPendingCandidateAppend: () => pendingChange != null && !pendingChange.runtimeAffecting && pendingChange.addedCandidates.size > 0,
|
|
2806
|
+
hasPendingChange: () => pendingChange != null || pendingFullRegeneration,
|
|
2807
|
+
queueFullRegeneration,
|
|
2808
|
+
reconcileRuntimeCandidates,
|
|
2809
|
+
resolve,
|
|
2810
|
+
shouldForceFullRegeneration: (file, resolved) => {
|
|
2811
|
+
if (options.getCommand() !== "serve") return false;
|
|
2812
|
+
if (pendingFullRegeneration) return pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
2813
|
+
return pendingChange != null && !resolved && pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
2814
|
+
},
|
|
2815
|
+
snapshotDebugState: () => ({
|
|
2816
|
+
pendingAddedCandidates: pendingChange?.addedCandidates.size ?? 0,
|
|
2817
|
+
pendingCssTargets: pendingCssTargetFiles?.size ?? 0,
|
|
2818
|
+
pendingFullRegeneration
|
|
2819
|
+
})
|
|
2820
|
+
};
|
|
2821
|
+
}
|
|
2822
|
+
//#endregion
|
|
2823
|
+
//#region src/bundlers/vite/shared/framework-hmr-module-version.ts
|
|
2824
|
+
function acceptVersion(versions, keys, timestamp) {
|
|
2825
|
+
if (keys.some((key) => (versions.get(key) ?? 0) > timestamp)) return false;
|
|
2826
|
+
for (const key of keys) versions.set(key, Math.max(versions.get(key) ?? 0, timestamp));
|
|
2827
|
+
return true;
|
|
2828
|
+
}
|
|
2829
|
+
function createViteHmrCssModuleVersionTracker() {
|
|
2830
|
+
const versions = /* @__PURE__ */ new Map();
|
|
2831
|
+
const keysForId = (id, root) => [resolveViteModuleIdentity(id, root).key];
|
|
2832
|
+
const keysForModule = (mod, root) => [...new Set([
|
|
2833
|
+
mod.id,
|
|
2834
|
+
mod.url,
|
|
2835
|
+
mod.file
|
|
2836
|
+
].filter((id) => typeof id === "string" && id.length > 0).flatMap((id) => keysForId(id, root)))];
|
|
2837
|
+
return {
|
|
2838
|
+
clear() {
|
|
2839
|
+
versions.clear();
|
|
2840
|
+
},
|
|
2841
|
+
filterIds(ids, timestamp, root) {
|
|
2842
|
+
return [...ids].filter((id) => acceptVersion(versions, keysForId(id, root), timestamp));
|
|
2843
|
+
},
|
|
2844
|
+
filterModules(modules, timestamp, root) {
|
|
2845
|
+
return modules.filter((mod) => {
|
|
2846
|
+
const keys = keysForModule(mod, root);
|
|
2847
|
+
return keys.length === 0 || acceptVersion(versions, keys, timestamp);
|
|
2848
|
+
});
|
|
2849
|
+
},
|
|
2850
|
+
reserveRefreshTimestamp(modules, timestamp, root) {
|
|
2851
|
+
const moduleKeys = modules.flatMap((mod) => keysForModule(mod, root));
|
|
2852
|
+
const latestTimestamp = moduleKeys.reduce((latest, key) => Math.max(latest, versions.get(key) ?? 0), 0);
|
|
2853
|
+
const refreshTimestamp = Math.max(Date.now(), timestamp + 1, latestTimestamp + 1);
|
|
2854
|
+
for (const key of moduleKeys) versions.set(key, refreshTimestamp);
|
|
2855
|
+
return refreshTimestamp;
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
}
|
|
2859
|
+
function createViteHmrCssModuleVersionFilterPlugin(tracker) {
|
|
2860
|
+
return {
|
|
2861
|
+
name: "weapp-tailwindcss:hmr-css-module-version",
|
|
2862
|
+
enforce: "post",
|
|
2863
|
+
handleHotUpdate: {
|
|
2864
|
+
order: "post",
|
|
2865
|
+
handler(ctx) {
|
|
2866
|
+
const styleModules = ctx.modules.filter((mod) => {
|
|
2867
|
+
const request = mod.id ?? mod.url;
|
|
2868
|
+
return require_v4_generation_core.isSourceStyleRequest(request);
|
|
2869
|
+
});
|
|
2870
|
+
if (styleModules.length === 0) return;
|
|
2871
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
2872
|
+
const currentStyleModules = tracker.filterModules(styleModules, ctx.timestamp, root);
|
|
2873
|
+
if (currentStyleModules.length === styleModules.length) return;
|
|
2874
|
+
const droppedStyleModules = styleModules.filter((mod) => !currentStyleModules.includes(mod));
|
|
2875
|
+
for (const mod of droppedStyleModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
2876
|
+
const refreshTimestamp = tracker.reserveRefreshTimestamp(droppedStyleModules, ctx.timestamp, root);
|
|
2877
|
+
sendSupplementalCssHotUpdates({
|
|
2878
|
+
...ctx,
|
|
2879
|
+
timestamp: refreshTimestamp
|
|
2880
|
+
}, droppedStyleModules, [], [], []);
|
|
2881
|
+
return [...ctx.modules.filter((mod) => !styleModules.includes(mod)), ...currentStyleModules];
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
//#endregion
|
|
2887
|
+
//#region src/bundlers/vite/official-tailwind-plugins.ts
|
|
2888
|
+
function isTailwindVitePlugin(plugin) {
|
|
2889
|
+
if (!plugin || typeof plugin !== "object" || !("name" in plugin)) return false;
|
|
2890
|
+
const { name } = plugin;
|
|
2891
|
+
return typeof name === "string" && name.startsWith("@tailwindcss/vite");
|
|
2892
|
+
}
|
|
2893
|
+
function removeTailwindVitePlugins(plugins) {
|
|
2894
|
+
let removed = 0;
|
|
2895
|
+
for (let i = plugins.length - 1; i >= 0; i--) if (isTailwindVitePlugin(plugins[i])) {
|
|
2896
|
+
plugins.splice(i, 1);
|
|
2897
|
+
removed++;
|
|
2898
|
+
}
|
|
2899
|
+
return removed;
|
|
2900
|
+
}
|
|
2901
|
+
function disableTailwindVitePlugin(plugin) {
|
|
2902
|
+
if (!isTailwindVitePlugin(plugin)) return false;
|
|
2903
|
+
const mutablePlugin = plugin;
|
|
2904
|
+
for (const hook of [
|
|
2905
|
+
"configResolved",
|
|
2906
|
+
"configureServer",
|
|
2907
|
+
"transform",
|
|
2908
|
+
"hotUpdate",
|
|
2909
|
+
"handleHotUpdate"
|
|
2910
|
+
]) delete mutablePlugin[hook];
|
|
2911
|
+
return true;
|
|
2912
|
+
}
|
|
2913
|
+
function disableAndRemoveTailwindVitePlugins(plugins) {
|
|
2914
|
+
let removed = 0;
|
|
2915
|
+
for (let i = plugins.length - 1; i >= 0; i--) {
|
|
2916
|
+
const plugin = plugins[i];
|
|
2917
|
+
if (Array.isArray(plugin)) {
|
|
2918
|
+
removed += disableAndRemoveTailwindVitePlugins(plugin);
|
|
2919
|
+
if (plugin.length === 0) plugins.splice(i, 1);
|
|
2920
|
+
continue;
|
|
2921
|
+
}
|
|
2922
|
+
if (disableTailwindVitePlugin(plugin)) {
|
|
2923
|
+
plugins.splice(i, 1);
|
|
2924
|
+
removed++;
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
return removed;
|
|
2928
|
+
}
|
|
2929
|
+
//#endregion
|
|
2930
|
+
//#region src/bundlers/vite/tailwind-basedir.ts
|
|
2931
|
+
const PACKAGE_JSON_FILE = "package.json";
|
|
2932
|
+
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
2933
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
2934
|
+
if (!(0, node_fs.existsSync)(resolvedRoot)) return resolvedRoot;
|
|
2935
|
+
const searchRoots = [];
|
|
2936
|
+
let current = resolvedRoot;
|
|
2937
|
+
while (true) {
|
|
2938
|
+
searchRoots.push(current);
|
|
2939
|
+
const parent = node_path.default.dirname(current);
|
|
2940
|
+
if (parent === current) break;
|
|
2941
|
+
current = parent;
|
|
2942
|
+
}
|
|
2943
|
+
const tailwindConfigPath = require_tailwindcss.findTailwindConfig(searchRoots);
|
|
2944
|
+
if (tailwindConfigPath) return node_path.default.dirname(tailwindConfigPath);
|
|
2945
|
+
const packageRoot = require_generator.findNearestPackageRoot(resolvedRoot);
|
|
2946
|
+
if (packageRoot && (0, node_fs.existsSync)(node_path.default.join(packageRoot, PACKAGE_JSON_FILE))) return packageRoot;
|
|
2947
|
+
return resolvedRoot;
|
|
2948
|
+
}
|
|
2949
|
+
//#endregion
|
|
2950
|
+
//#region src/bundlers/vite/shared/framework-post-plugin.ts
|
|
2951
|
+
function createFrameworkPostPlugin(options) {
|
|
2952
|
+
const plugin = {
|
|
2953
|
+
name: `${require_compiler.vitePluginName}:post`,
|
|
2954
|
+
enforce: "post",
|
|
2955
|
+
config(config) {
|
|
2956
|
+
if (!options.shouldOwnTailwindGeneration) return;
|
|
2957
|
+
if (Array.isArray(config.plugins)) {
|
|
2958
|
+
const removed = disableAndRemoveTailwindVitePlugins(config.plugins);
|
|
2959
|
+
if (removed > 0) {
|
|
2960
|
+
_weapp_tailwindcss_logger.logger.warn("检测到 @tailwindcss/vite,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
|
|
2961
|
+
options.debug("disable official tailwind vite plugins in generator mode: %d", removed);
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
const root = config.root ? node_path.default.resolve(config.root) : node_process.default.cwd();
|
|
2965
|
+
const baseConfig = { resolve: { alias: [{
|
|
2966
|
+
find: /^tailwindcss$/,
|
|
2967
|
+
replacement: options.generatorPlaceholderCssFile
|
|
2968
|
+
}] } };
|
|
2969
|
+
if (config.css?.postcss !== void 0) return baseConfig;
|
|
2970
|
+
return (0, _weapp_tailwindcss_postcss.resolvePostcssConfig)(root).then((postcssConfig) => {
|
|
2971
|
+
if (!postcssConfig) return baseConfig;
|
|
2972
|
+
const plugins = [...postcssConfig.plugins];
|
|
2973
|
+
const removed = (0, _weapp_tailwindcss_postcss.removeTailwindPostcssPlugins)(plugins);
|
|
2974
|
+
if (removed > 0) options.debug("inline filtered postcss config without official tailwind plugins in generator mode: %d", removed);
|
|
2975
|
+
return {
|
|
2976
|
+
...baseConfig,
|
|
2977
|
+
css: { postcss: {
|
|
2978
|
+
...postcssConfig.options,
|
|
2979
|
+
plugins
|
|
2980
|
+
} }
|
|
2981
|
+
};
|
|
2982
|
+
});
|
|
2983
|
+
},
|
|
2984
|
+
async configResolved(config) {
|
|
2985
|
+
await options.hmrTimingRecorder.measure("configResolved", async () => {
|
|
2986
|
+
options.setResolvedConfig(config);
|
|
2987
|
+
if (options.shouldOwnTailwindGeneration) {
|
|
2988
|
+
const removed = Array.isArray(config.plugins) ? removeTailwindVitePlugins(config.plugins) : 0;
|
|
2989
|
+
if (removed > 0) options.debug("remove official tailwind vite plugins in generator mode: %d", removed);
|
|
2990
|
+
}
|
|
2991
|
+
const resolvedRoot = config.root ? node_path.default.resolve(config.root) : void 0;
|
|
2992
|
+
let shouldRefreshRuntime = false;
|
|
2993
|
+
if (!options.hasExplicitTailwindcssBasedir && resolvedRoot) {
|
|
2994
|
+
const nextTailwindcssBasedir = resolveImplicitTailwindcssBasedirFromViteRoot(resolvedRoot);
|
|
2995
|
+
if (options.opts.tailwindcssBasedir !== nextTailwindcssBasedir) {
|
|
2996
|
+
const previousBasedir = options.opts.tailwindcssBasedir;
|
|
2997
|
+
options.opts.tailwindcssBasedir = nextTailwindcssBasedir;
|
|
2998
|
+
shouldRefreshRuntime = options.syncCssEntriesFromAnchor(nextTailwindcssBasedir) || shouldRefreshRuntime;
|
|
2999
|
+
options.debug("align tailwindcss basedir with vite root: %s -> %s", previousBasedir ?? "undefined", nextTailwindcssBasedir);
|
|
3000
|
+
shouldRefreshRuntime = true;
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
if (options.shouldInferAppType && resolvedRoot) {
|
|
3004
|
+
const nextAppType = require_framework.resolveImplicitAppTypeFromViteRoot(resolvedRoot, { searchUp: false });
|
|
3005
|
+
if (nextAppType && options.opts.appType !== nextAppType) {
|
|
3006
|
+
const previousAppType = options.opts.appType;
|
|
3007
|
+
options.opts.appType = nextAppType;
|
|
3008
|
+
_weapp_tailwindcss_logger.logger.debug("根据 Vite 项目根目录自动推断 appType -> %s", nextAppType);
|
|
3009
|
+
options.debug("align appType with vite root: %s -> %s", previousAppType ?? "undefined", nextAppType);
|
|
3010
|
+
shouldRefreshRuntime = true;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
if (options.frameworkName === "generic" && !options.hasExplicitGeneratorTarget && options.opts.generator !== false && options.opts.appType === void 0 && options.opts.platform === void 0 && options.opts.cssOptions?.platform === void 0 && !options.resolveViteStylePlatform()) {
|
|
3014
|
+
const generator = options.opts.generator && typeof options.opts.generator === "object" ? options.opts.generator : {};
|
|
3015
|
+
options.opts.generator = {
|
|
3016
|
+
...generator,
|
|
3017
|
+
target: "web"
|
|
3018
|
+
};
|
|
3019
|
+
_weapp_tailwindcss_logger.logger.debug("Generic Vite 项目未指定目标,自动使用 generator.target -> web");
|
|
3020
|
+
options.debug("default generic vite generator target to web after configResolved");
|
|
3021
|
+
shouldRefreshRuntime = true;
|
|
3022
|
+
}
|
|
3023
|
+
if (shouldRefreshRuntime) await options.refreshRuntimeState(true);
|
|
3024
|
+
if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
|
|
3025
|
+
const postcssPlugins = config.css.postcss.plugins;
|
|
3026
|
+
if (options.shouldOwnTailwindGeneration) {
|
|
3027
|
+
const removed = (0, _weapp_tailwindcss_postcss.removeTailwindPostcssPlugins)(postcssPlugins);
|
|
3028
|
+
if (removed > 0) {
|
|
3029
|
+
_weapp_tailwindcss_logger.logger.warn("检测到 @tailwindcss/postcss,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
|
|
3030
|
+
options.debug("remove official tailwind postcss plugins in generator mode: %d", removed);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
require_v4_generation_core.captureFrameworkPostcssOptions(options.opts, config.css?.postcss && typeof config.css.postcss === "object" ? config.css.postcss : void 0);
|
|
3035
|
+
}, { emit: false });
|
|
3036
|
+
}
|
|
3037
|
+
};
|
|
3038
|
+
if (typeof options.generateBundleHook === "function") plugin.generateBundle = {
|
|
3039
|
+
order: "post",
|
|
3040
|
+
handler: options.generateBundleHook
|
|
3041
|
+
};
|
|
3042
|
+
if (options.api) plugin.api = options.api;
|
|
3043
|
+
return plugin;
|
|
3044
|
+
}
|
|
3045
|
+
//#endregion
|
|
3046
|
+
//#region src/bundlers/vite/shared/framework-processed-css-registry.ts
|
|
3047
|
+
function createFrameworkProcessedCssRegistry() {
|
|
3048
|
+
const results = /* @__PURE__ */ new Map();
|
|
3049
|
+
const sourceFiles = /* @__PURE__ */ new Set();
|
|
3050
|
+
const markSource = (file) => {
|
|
3051
|
+
sourceFiles.add(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
3052
|
+
};
|
|
3053
|
+
const record = (file, css, options = {}) => {
|
|
3054
|
+
const key = normalizeVitePersistentCacheKey(file);
|
|
3055
|
+
const previous = results.get(key);
|
|
3056
|
+
const injectIntoMain = previous?.injectIntoMain === true ? true : options.injectIntoMain ?? previous?.injectIntoMain;
|
|
3057
|
+
touchMapEntry(results, key, {
|
|
3058
|
+
css,
|
|
3059
|
+
injectIntoMain,
|
|
3060
|
+
outputFile: options.outputFile ?? previous?.outputFile
|
|
3061
|
+
});
|
|
3062
|
+
};
|
|
3063
|
+
const get = (file) => results.get(normalizeVitePersistentCacheKey(file));
|
|
3064
|
+
const matchesIdentity = (candidate) => {
|
|
3065
|
+
return sourceFiles.has(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(candidate)));
|
|
3066
|
+
};
|
|
3067
|
+
const prune = (activeFiles) => {
|
|
3068
|
+
for (const [key, result] of results) {
|
|
3069
|
+
const outputKey = result.outputFile ? normalizeVitePersistentCacheKey(result.outputFile) : void 0;
|
|
3070
|
+
if (!activeFiles.has(key) && (outputKey == null || !activeFiles.has(outputKey))) results.delete(key);
|
|
3071
|
+
}
|
|
3072
|
+
};
|
|
3073
|
+
return {
|
|
3074
|
+
entries: () => results.entries(),
|
|
3075
|
+
get,
|
|
3076
|
+
getStats: () => ({
|
|
3077
|
+
viteProcessedCssAssetResults: results.size,
|
|
3078
|
+
viteProcessedCssAssetResultsRaw: summarizeViteProcessedCssResults(results)
|
|
3079
|
+
}),
|
|
3080
|
+
markSource,
|
|
3081
|
+
matchesIdentity,
|
|
3082
|
+
prune,
|
|
3083
|
+
record,
|
|
3084
|
+
sourceFiles
|
|
3085
|
+
};
|
|
3086
|
+
}
|
|
3087
|
+
//#endregion
|
|
3088
|
+
//#region src/bundlers/vite/shared/framework-hmr-runtime-signature.ts
|
|
3089
|
+
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
3090
|
+
function createFrameworkHmrRuntimeSignature(file, source) {
|
|
3091
|
+
if (!source || !WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source)) return "";
|
|
3092
|
+
return (isSfcStyleSourceFile((0, _weapp_tailwindcss_shared.cleanUrl)(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => require_compiler.createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
|
|
3093
|
+
}
|
|
3094
|
+
function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
|
|
3095
|
+
return createFrameworkHmrRuntimeSignature(file, previousSource) !== createFrameworkHmrRuntimeSignature(file, nextSource);
|
|
3096
|
+
}
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
3099
|
+
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
3100
|
+
const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
3101
|
+
async function syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx) {
|
|
3102
|
+
const source = typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
3103
|
+
await sourceScanSession.syncChangedFile(ctx.file, source);
|
|
3104
|
+
await sourceScanSession.waitForPendingSyncs();
|
|
3105
|
+
}
|
|
3106
|
+
function createFrameworkSourceScanSession(options) {
|
|
3107
|
+
const sourceCandidateScanCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
3108
|
+
let sourceScanEntries;
|
|
3109
|
+
let sourceScanMatcher;
|
|
3110
|
+
let sourceScanBoundaryMatcher;
|
|
3111
|
+
let sourceScanRoots = [];
|
|
3112
|
+
let sourceScanOutDir;
|
|
3113
|
+
let sourceScanEligibleFiles = /* @__PURE__ */ new Set();
|
|
3114
|
+
let sourceScanEligibleFilesRefresh;
|
|
3115
|
+
const sourceScanIneligibleFiles = /* @__PURE__ */ new Set();
|
|
3116
|
+
let sourceScanDependencies = /* @__PURE__ */ new Set();
|
|
3117
|
+
let sourceScanExplicit = false;
|
|
3118
|
+
let sourceCandidateScanSignature;
|
|
3119
|
+
let sourceCandidateScanInvalidated = true;
|
|
3120
|
+
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
3121
|
+
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
3122
|
+
const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
|
|
3123
|
+
const pendingChangedFiles = /* @__PURE__ */ new Map();
|
|
3124
|
+
let pendingChangedFilesFlush;
|
|
3125
|
+
let isFlushingChangedFiles = false;
|
|
3126
|
+
let cacheDirty = false;
|
|
3127
|
+
let cachedCollectorRevision;
|
|
3128
|
+
const normalizeDependency = (file) => node_path.default.normalize(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
3129
|
+
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
3130
|
+
const invalidate = () => {
|
|
3131
|
+
sourceCandidateScanInvalidated = true;
|
|
3132
|
+
sourceScanIneligibleFiles.clear();
|
|
3133
|
+
};
|
|
3134
|
+
const hasState = () => sourceCandidateScanSignature !== void 0;
|
|
3135
|
+
const collectRoots = (root, entries) => {
|
|
3136
|
+
if (entries?.length) return [{
|
|
3137
|
+
entries,
|
|
3138
|
+
explicit: sourceScanExplicit,
|
|
3139
|
+
root
|
|
3140
|
+
}];
|
|
3141
|
+
if (sourceScanExplicit && entries !== void 0) return [];
|
|
3142
|
+
const roots = [{
|
|
3143
|
+
entries,
|
|
3144
|
+
root
|
|
3145
|
+
}];
|
|
3146
|
+
const seenRoots = /* @__PURE__ */ new Set([node_path.default.resolve(root)]);
|
|
3147
|
+
const basedir = options.opts.tailwindcssBasedir ? node_path.default.resolve(options.opts.tailwindcssBasedir) : void 0;
|
|
3148
|
+
if (basedir && !seenRoots.has(basedir)) {
|
|
3149
|
+
roots.push({ root: basedir });
|
|
3150
|
+
seenRoots.add(basedir);
|
|
3151
|
+
}
|
|
3152
|
+
for (const cssEntry of options.opts.tailwindcss?.v4?.cssEntries ?? []) {
|
|
3153
|
+
if (!require_generator.isTailwindV4CssEntry(cssEntry)) continue;
|
|
3154
|
+
const cssEntryRoot = node_path.default.dirname(node_path.default.resolve(cssEntry));
|
|
3155
|
+
if (seenRoots.has(cssEntryRoot)) continue;
|
|
3156
|
+
roots.push({ root: cssEntryRoot });
|
|
3157
|
+
seenRoots.add(cssEntryRoot);
|
|
3158
|
+
}
|
|
3159
|
+
return roots;
|
|
3160
|
+
};
|
|
3161
|
+
const cacheCurrent = () => {
|
|
3162
|
+
if (!sourceCandidateScanSignature) return;
|
|
3163
|
+
if (isFlushingChangedFiles) {
|
|
3164
|
+
cacheDirty = true;
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3167
|
+
const collectorRevision = options.sourceCandidateCollector.getRevision?.();
|
|
3168
|
+
if (!cacheDirty && cachedCollectorRevision !== void 0 && collectorRevision === cachedCollectorRevision) return;
|
|
3169
|
+
const entry = {
|
|
3170
|
+
eligibleFiles: [...sourceScanEligibleFiles],
|
|
3171
|
+
snapshot: options.sourceCandidateCollector.snapshot()
|
|
3172
|
+
};
|
|
3173
|
+
sourceCandidateScanCache.set(sourceCandidateScanSignature, entry);
|
|
3174
|
+
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, entry);
|
|
3175
|
+
cachedCollectorRevision = collectorRevision;
|
|
3176
|
+
cacheDirty = false;
|
|
3177
|
+
};
|
|
3178
|
+
const updateSourceScanMatchers = (eligibleFiles) => {
|
|
3179
|
+
sourceScanEligibleFiles = new Set(eligibleFiles);
|
|
3180
|
+
const matcherRoots = sourceScanRoots.map((scanRoot) => ({
|
|
3181
|
+
...scanRoot,
|
|
3182
|
+
outDir: sourceScanOutDir
|
|
3183
|
+
}));
|
|
3184
|
+
sourceScanBoundaryMatcher = require_v4_generation_core.createSourceCandidateEligibilityMatcher(matcherRoots);
|
|
3185
|
+
sourceScanMatcher = require_v4_generation_core.createSourceCandidateEligibilityMatcher(matcherRoots, sourceScanEligibleFiles);
|
|
3186
|
+
};
|
|
3187
|
+
const refreshSourceScanEligibleFiles = async () => {
|
|
3188
|
+
sourceScanEligibleFilesRefresh ?? (sourceScanEligibleFilesRefresh = Promise.all(sourceScanRoots.map((scanRoot) => options.sourceCandidateCollector.resolveScanFiles({
|
|
3189
|
+
entries: scanRoot.entries,
|
|
3190
|
+
explicit: scanRoot.explicit,
|
|
3191
|
+
root: scanRoot.root,
|
|
3192
|
+
outDir: sourceScanOutDir
|
|
3193
|
+
}))).then((files) => updateSourceScanMatchers(files.flat())).finally(() => {
|
|
3194
|
+
sourceScanEligibleFilesRefresh = void 0;
|
|
3195
|
+
}));
|
|
3196
|
+
await sourceScanEligibleFilesRefresh;
|
|
3197
|
+
};
|
|
3198
|
+
const shouldDiscoverAutoCssSources = (autoCssSourcesDiscovered) => {
|
|
3199
|
+
if (!autoCssSourcesDiscovered || !options.isWatchLikeBuild()) return true;
|
|
3200
|
+
return sourceCandidateScanInvalidated;
|
|
3201
|
+
};
|
|
3202
|
+
const sync = async (syncOptions = {}) => {
|
|
3203
|
+
if (!options.shouldOwnTailwindGeneration) return;
|
|
3204
|
+
if (!syncOptions.force && options.isWatchLikeBuild() && hasState() && !sourceCandidateScanInvalidated) {
|
|
3205
|
+
options.debug("reuse vite source candidate scan definition for watch rebuild");
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
const resolvedConfig = options.getResolvedConfig();
|
|
3209
|
+
const root = resolvedConfig?.root ?? node_process.default.cwd();
|
|
3210
|
+
const outDir = resolvedConfig?.build?.outDir;
|
|
3211
|
+
const sourceScan = await require_tailwindcss.resolveSourceScanEntries(options.opts, options.runtimeState.tailwindRuntime, {
|
|
3212
|
+
outDir,
|
|
3213
|
+
root
|
|
3214
|
+
});
|
|
3215
|
+
sourceScanEntries = sourceScan?.entries;
|
|
3216
|
+
sourceScanExplicit = sourceScan?.explicit ?? false;
|
|
3217
|
+
sourceScanDependencies = new Set((sourceScan?.dependencies ?? []).map(normalizeDependency));
|
|
3218
|
+
const roots = collectRoots(root, sourceScanEntries);
|
|
3219
|
+
sourceScanRoots = roots;
|
|
3220
|
+
sourceScanOutDir = outDir;
|
|
3221
|
+
const nextScanSignature = require_source_candidate_scan_signature.createSourceCandidateScanSignature({
|
|
3222
|
+
inlineCandidates: sourceScan?.inlineCandidates,
|
|
3223
|
+
outDir,
|
|
3224
|
+
roots,
|
|
3225
|
+
scanAllSources: !sourceScanExplicit
|
|
3226
|
+
});
|
|
3227
|
+
if (hasState() && sourceCandidateScanSignature === nextScanSignature) {
|
|
3228
|
+
options.sourceCandidateCollector.syncInline(sourceScan?.inlineCandidates);
|
|
3229
|
+
cacheCurrent();
|
|
3230
|
+
options.debug("reuse vite source candidate scan for watch rebuild");
|
|
3231
|
+
sourceCandidateScanInvalidated = false;
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
const cachedScan = options.isWatchLikeBuild() ? sourceCandidateScanCache.get(nextScanSignature) ?? sourceCandidateScanSnapshotCache.get(nextScanSignature) : void 0;
|
|
3235
|
+
if (cachedScan) {
|
|
3236
|
+
options.sourceCandidateCollector.restore(cachedScan.snapshot);
|
|
3237
|
+
sourceScanIneligibleFiles.clear();
|
|
3238
|
+
updateSourceScanMatchers(cachedScan.eligibleFiles);
|
|
3239
|
+
sourceCandidateScanSignature = nextScanSignature;
|
|
3240
|
+
options.debug("reuse cached vite source candidate scan for watch rebuild");
|
|
3241
|
+
sourceCandidateScanInvalidated = false;
|
|
3242
|
+
return;
|
|
3243
|
+
}
|
|
3244
|
+
if (options.isWatchLikeBuild()) options.sourceCandidateCollector.resetScan();
|
|
3245
|
+
else options.sourceCandidateCollector.clearScan();
|
|
3246
|
+
options.sourceCandidateCollector.syncInline(sourceScan?.inlineCandidates);
|
|
3247
|
+
const eligibleFiles = /* @__PURE__ */ new Set();
|
|
3248
|
+
sourceScanIneligibleFiles.clear();
|
|
3249
|
+
await Promise.all(roots.map((scanRoot) => options.sourceCandidateCollector.scanRoot({
|
|
3250
|
+
entries: scanRoot.entries,
|
|
3251
|
+
explicit: scanRoot.explicit,
|
|
3252
|
+
root: scanRoot.root,
|
|
3253
|
+
outDir,
|
|
3254
|
+
onFilesResolved: (files) => files.forEach((file) => eligibleFiles.add(file))
|
|
3255
|
+
})));
|
|
3256
|
+
updateSourceScanMatchers(eligibleFiles);
|
|
3257
|
+
sourceCandidateScanSignature = nextScanSignature;
|
|
3258
|
+
sourceCandidateScanInvalidated = false;
|
|
3259
|
+
if (options.isWatchLikeBuild()) cacheCurrent();
|
|
3260
|
+
};
|
|
3261
|
+
const waitForPendingSyncs = async () => {
|
|
3262
|
+
while (true) {
|
|
3263
|
+
if (!pendingChangedFilesFlush && pendingChangedFiles.size === 0 && pendingSourceCandidateSyncs.size === 0) break;
|
|
3264
|
+
await pendingChangedFilesFlush;
|
|
3265
|
+
if (pendingChangedFiles.size > 0) await flushChangedFiles();
|
|
3266
|
+
if (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
3267
|
+
}
|
|
3268
|
+
};
|
|
3269
|
+
const rememberHotUpdateChange = (change) => {
|
|
3270
|
+
if (!change) return;
|
|
3271
|
+
const previous = pendingHotUpdateChangeByFile.get(change.file);
|
|
3272
|
+
if (!previous) {
|
|
3273
|
+
const remembered = {
|
|
3274
|
+
...change,
|
|
3275
|
+
addedCandidates: new Set(change.addedCandidates),
|
|
3276
|
+
removedCandidates: new Set(change.removedCandidates)
|
|
3277
|
+
};
|
|
3278
|
+
pendingHotUpdateChangeByFile.set(change.file, remembered);
|
|
3279
|
+
return remembered;
|
|
3280
|
+
}
|
|
3281
|
+
for (const candidate of change.addedCandidates) {
|
|
3282
|
+
previous.addedCandidates.add(candidate);
|
|
3283
|
+
previous.removedCandidates.delete(candidate);
|
|
3284
|
+
}
|
|
3285
|
+
for (const candidate of change.removedCandidates) if (!previous.addedCandidates.delete(candidate)) previous.removedCandidates.add(candidate);
|
|
3286
|
+
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
3287
|
+
return previous;
|
|
3288
|
+
};
|
|
3289
|
+
const syncChangedFileNow = async (id, sourceOverride, event = "update") => {
|
|
3290
|
+
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return;
|
|
3291
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
3292
|
+
const runtimeAffectingByDependency = isDependency(file);
|
|
3293
|
+
if (runtimeAffectingByDependency) invalidate();
|
|
3294
|
+
const resolvedFile = require_generator.resolveSourceScanPath(file);
|
|
3295
|
+
if (sourceScanMatcher && !sourceScanMatcher(file) && sourceScanBoundaryMatcher?.(file) && !sourceScanIneligibleFiles.has(resolvedFile)) {
|
|
3296
|
+
await refreshSourceScanEligibleFiles();
|
|
3297
|
+
if (!sourceScanMatcher(file)) sourceScanIneligibleFiles.add(resolvedFile);
|
|
3298
|
+
}
|
|
3299
|
+
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
3300
|
+
const change = options.sourceCandidateCollector.remove(file);
|
|
3301
|
+
cacheCurrent();
|
|
3302
|
+
return (require_v4_generation_core.isSourceStyleRequest(file) ? (0, node_fs_promises.readFile)(file, "utf8").then((source) => options.cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
|
|
3303
|
+
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) !== "ENOENT") options.debug("remembered css source watch refresh failed: %s %O", file, error);
|
|
3304
|
+
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
|
|
3305
|
+
}
|
|
3306
|
+
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
3307
|
+
if (existingTask) {
|
|
3308
|
+
await existingTask;
|
|
3309
|
+
return syncChangedFile(id, sourceOverride);
|
|
3310
|
+
}
|
|
3311
|
+
const previousSource = options.sourceCandidateCollector.source(file);
|
|
3312
|
+
if (event === "delete") {
|
|
3313
|
+
const change = options.sourceCandidateCollector.remove(file);
|
|
3314
|
+
cacheDirty = true;
|
|
3315
|
+
const appliedChange = options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency }));
|
|
3316
|
+
return rememberHotUpdateChange(appliedChange);
|
|
3317
|
+
}
|
|
3318
|
+
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
3319
|
+
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
3320
|
+
}).then((change) => {
|
|
3321
|
+
cacheDirty = true;
|
|
3322
|
+
if (!isFlushingChangedFiles) cacheCurrent();
|
|
3323
|
+
const runtimeAffectingBySource = hasFrameworkHmrRuntimeSourceChange(file, previousSource, options.sourceCandidateCollector.source(file));
|
|
3324
|
+
const appliedChange = change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency || runtimeAffectingBySource })) : void 0;
|
|
3325
|
+
return rememberHotUpdateChange(appliedChange) ?? pendingHotUpdateChangeByFile.get(file);
|
|
3326
|
+
}).finally(() => {
|
|
3327
|
+
pendingSourceCandidateSyncs.delete(task);
|
|
3328
|
+
pendingSourceCandidateSyncByFile.delete(file);
|
|
3329
|
+
});
|
|
3330
|
+
pendingSourceCandidateSyncs.add(task);
|
|
3331
|
+
pendingSourceCandidateSyncByFile.set(file, task);
|
|
3332
|
+
return task.then(async (change) => {
|
|
3333
|
+
await options.cssMemory.refreshRememberedCssSourceByCurrentFile(file);
|
|
3334
|
+
return change;
|
|
3335
|
+
});
|
|
3336
|
+
};
|
|
3337
|
+
const queueChangedFile = (change) => {
|
|
3338
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(change.id);
|
|
3339
|
+
const previous = pendingChangedFiles.get(file);
|
|
3340
|
+
if (!previous) {
|
|
3341
|
+
pendingChangedFiles.set(file, {
|
|
3342
|
+
...change,
|
|
3343
|
+
file
|
|
3344
|
+
});
|
|
3345
|
+
return;
|
|
3346
|
+
}
|
|
3347
|
+
previous.event = change.event;
|
|
3348
|
+
if (change.source !== void 0) previous.source = change.source;
|
|
3349
|
+
};
|
|
3350
|
+
const flushChangedFiles = async () => {
|
|
3351
|
+
if (pendingChangedFilesFlush) {
|
|
3352
|
+
const result = await pendingChangedFilesFlush;
|
|
3353
|
+
return pendingChangedFiles.size > 0 ? flushChangedFiles() : result;
|
|
3354
|
+
}
|
|
3355
|
+
if (pendingChangedFiles.size === 0) return /* @__PURE__ */ new Map();
|
|
3356
|
+
const changes = [...pendingChangedFiles.values()];
|
|
3357
|
+
pendingChangedFiles.clear();
|
|
3358
|
+
isFlushingChangedFiles = true;
|
|
3359
|
+
pendingChangedFilesFlush = Promise.all(changes.map(async (change) => [change.file, await syncChangedFileNow(change.file, change.source, change.event)])).then((entries) => new Map(entries)).finally(() => {
|
|
3360
|
+
isFlushingChangedFiles = false;
|
|
3361
|
+
pendingChangedFilesFlush = void 0;
|
|
3362
|
+
cacheCurrent();
|
|
3363
|
+
});
|
|
3364
|
+
return pendingChangedFilesFlush;
|
|
3365
|
+
};
|
|
3366
|
+
const syncChangedFile = async (id, sourceOverride) => {
|
|
3367
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
3368
|
+
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
3369
|
+
if (existingTask) {
|
|
3370
|
+
await existingTask;
|
|
3371
|
+
return syncChangedFile(id, sourceOverride);
|
|
3372
|
+
}
|
|
3373
|
+
return syncChangedFileNow(file, sourceOverride);
|
|
3374
|
+
};
|
|
3375
|
+
return {
|
|
3376
|
+
cacheCurrent,
|
|
3377
|
+
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
3378
|
+
getStats: () => ({
|
|
3379
|
+
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
|
|
3380
|
+
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
3381
|
+
pendingChangedFiles: pendingChangedFiles.size,
|
|
3382
|
+
pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
|
|
3383
|
+
sourceCandidateScanCache: sourceCandidateScanCache.size
|
|
3384
|
+
}),
|
|
3385
|
+
invalidate,
|
|
3386
|
+
isDependency,
|
|
3387
|
+
matches: (file) => sourceScanMatcher?.(file) ?? true,
|
|
3388
|
+
queueChangedFile,
|
|
3389
|
+
flushChangedFiles,
|
|
3390
|
+
shouldDiscoverAutoCssSources,
|
|
3391
|
+
sync,
|
|
3392
|
+
syncChangedFile,
|
|
3393
|
+
waitForPendingSyncs
|
|
3394
|
+
};
|
|
3395
|
+
}
|
|
3396
|
+
//#endregion
|
|
3397
|
+
//#region src/bundlers/vite/shared/framework-tailwind-root-css.ts
|
|
3398
|
+
function createFrameworkTailwindRootCss(options) {
|
|
3399
|
+
const hotSourceByFile = /* @__PURE__ */ new Map();
|
|
3400
|
+
const moduleIds = /* @__PURE__ */ new Set();
|
|
3401
|
+
const normalizeSourceFile = (id) => resolveViteModuleIdentity(id).key;
|
|
3402
|
+
const rememberModule = (id) => {
|
|
3403
|
+
if (!options.shouldOwnTailwindGeneration || typeof id !== "string" || id.length === 0) return;
|
|
3404
|
+
moduleIds.add(id);
|
|
3405
|
+
const identity = resolveViteModuleIdentity(id);
|
|
3406
|
+
if (require_v4_generation_core.isSourceStyleRequest(identity.cleanId)) for (const moduleId of identity.lookupIds) moduleIds.add(moduleId);
|
|
3407
|
+
};
|
|
3408
|
+
const register = async (id, code) => {
|
|
3409
|
+
rememberModule(id);
|
|
3410
|
+
const hotSource = hotSourceByFile.get(normalizeSourceFile(id));
|
|
3411
|
+
await options.registerAutoCssSource(id, hotSource ?? code);
|
|
3412
|
+
};
|
|
3413
|
+
const refreshSource = async (id, code) => {
|
|
3414
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
3415
|
+
if (!moduleIds.has(id) && !moduleIds.has(file) && !require_generator.hasTailwindRootDirectives(code, { importFallback: options.getImportFallback() })) return;
|
|
3416
|
+
hotSourceByFile.set(normalizeSourceFile(id), code);
|
|
3417
|
+
await register(id, code);
|
|
3418
|
+
options.sourceScanSession.invalidate();
|
|
3419
|
+
await options.refreshRuntimeState(true);
|
|
3420
|
+
await options.sourceScanSession.sync({ force: true });
|
|
3421
|
+
};
|
|
3422
|
+
return {
|
|
3423
|
+
refreshSource,
|
|
3424
|
+
register,
|
|
3425
|
+
rememberModule,
|
|
3426
|
+
moduleIds
|
|
3427
|
+
};
|
|
3428
|
+
}
|
|
3429
|
+
//#endregion
|
|
3430
|
+
//#region src/style-injector/vite-web.ts
|
|
3431
|
+
function getHandler(hook) {
|
|
3432
|
+
if (typeof hook === "function") return hook;
|
|
3433
|
+
if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
|
|
3434
|
+
}
|
|
3435
|
+
/** Generic Web 专用 style injector,避免引入其他构建器和框架适配。 */
|
|
3436
|
+
function createBuiltinViteWebStyleInjectorPlugins(options) {
|
|
3437
|
+
const normalized = require_source_candidate_scan_signature.normalizeStyleInjectorOptions(options);
|
|
3438
|
+
if (!normalized) return [];
|
|
3439
|
+
const injector = (0, weapp_style_injector_vite.weappStyleInjector)(normalized);
|
|
3440
|
+
const transform = getHandler(injector.transform);
|
|
3441
|
+
const generateBundle = getHandler(injector.generateBundle);
|
|
3442
|
+
return [{
|
|
3443
|
+
name: "weapp-tailwindcss:web-style-injector-pre",
|
|
3444
|
+
apply: "build",
|
|
3445
|
+
enforce: "pre",
|
|
3446
|
+
configResolved(config) {
|
|
3447
|
+
injector.configResolved?.(config);
|
|
3448
|
+
},
|
|
3449
|
+
async buildStart() {
|
|
3450
|
+
await injector.buildStart?.call(this, {});
|
|
3451
|
+
},
|
|
3452
|
+
async transform(code, id, options2) {
|
|
3453
|
+
return transform?.call(this, code, id, options2);
|
|
3454
|
+
}
|
|
3455
|
+
}, {
|
|
3456
|
+
name: "weapp-tailwindcss:web-style-injector",
|
|
3457
|
+
apply: "build",
|
|
3458
|
+
enforce: "post",
|
|
3459
|
+
configResolved(config) {
|
|
3460
|
+
injector.configResolved?.(config);
|
|
3461
|
+
},
|
|
3462
|
+
async generateBundle(outputOptions, bundle, isWrite) {
|
|
3463
|
+
await generateBundle?.call(this, outputOptions, bundle, isWrite);
|
|
3464
|
+
}
|
|
3465
|
+
}];
|
|
3466
|
+
}
|
|
3467
|
+
//#endregion
|
|
3468
|
+
//#region src/bundlers/vite/shared/create-css-only-plugins-runtime.ts
|
|
3469
|
+
const debug = require_compiler.createDebug();
|
|
3470
|
+
function resolveWebGeneratorOptions(opts) {
|
|
3471
|
+
return require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
3472
|
+
appType: void 0,
|
|
3473
|
+
platform: "web",
|
|
3474
|
+
tailwindcssMajorVersion: opts.tailwindRuntime.majorVersion,
|
|
3475
|
+
uniAppX: false
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
/** 创建不含 JS/template、分包和小程序 bundle 处理的 Generic Web Vite 插件。 */
|
|
3479
|
+
function createCssOnlyVitePlugins(options = {}) {
|
|
3480
|
+
const rawOptions = options;
|
|
3481
|
+
const opts = "tailwindRuntime" in options ? options : require_compiler.getCompilerContext({
|
|
3482
|
+
...rawOptions,
|
|
3483
|
+
appType: void 0,
|
|
3484
|
+
platform: "web",
|
|
3485
|
+
generator: rawOptions.generator && typeof rawOptions.generator === "object" ? {
|
|
3486
|
+
...rawOptions.generator,
|
|
3487
|
+
target: "web"
|
|
3488
|
+
} : { target: "web" },
|
|
3489
|
+
__internalDeferMissingCssEntriesWarning: true,
|
|
3490
|
+
__internalViteDeferRuntimeLogs: true
|
|
3491
|
+
});
|
|
3492
|
+
const disabled = opts.disabled === true || typeof opts.disabled === "object" && opts.disabled.plugin === true;
|
|
3493
|
+
const shouldGenerate = !disabled && resolveWebGeneratorOptions(opts).enabled;
|
|
3494
|
+
const sourceCandidateCollector = require_v4_generation_core.createSourceCandidateCollector({
|
|
3495
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
3496
|
+
customAttributesEntities: opts.customAttributesEntities,
|
|
3497
|
+
disabledDefaultTemplateHandler: opts.disabledDefaultTemplateHandler
|
|
3498
|
+
});
|
|
3499
|
+
const cssMemory = createViteCssMemory({
|
|
3500
|
+
debug,
|
|
3501
|
+
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file)
|
|
3502
|
+
});
|
|
3503
|
+
const hmrCssModuleVersions = createViteHmrCssModuleVersionTracker();
|
|
3504
|
+
const hmrTimingRecorder = require_hmr_timing.createHmrTimingRecorder("vite");
|
|
3505
|
+
const { runtimeState, ensureRuntimeClassSet, refreshRuntimeState } = createViteRuntimeClassSet({
|
|
3506
|
+
opts,
|
|
3507
|
+
initialTailwindRuntime: opts.tailwindRuntime,
|
|
3508
|
+
refreshTailwindcssRuntime: opts.refreshTailwindcssRuntime,
|
|
3509
|
+
uniAppXEnabled: false,
|
|
3510
|
+
customAttributesEntities: opts.customAttributesEntities,
|
|
3511
|
+
disabledDefaultTemplateHandler: opts.disabledDefaultTemplateHandler,
|
|
3512
|
+
debug
|
|
3513
|
+
});
|
|
3514
|
+
const hmrCandidateState = createViteHmrCandidateState({
|
|
3515
|
+
cleanGeneratedCssByFile: /* @__PURE__ */ new Map(),
|
|
3516
|
+
generatedClassSetByFile: /* @__PURE__ */ new Map(),
|
|
3517
|
+
getCommand: () => resolvedConfig?.command,
|
|
3518
|
+
getGeneratorOptions: () => resolveWebGeneratorOptions(opts),
|
|
3519
|
+
isRuntimeAffectingSource: () => false
|
|
3520
|
+
});
|
|
3521
|
+
let resolvedConfig;
|
|
3522
|
+
let recordedCandidates;
|
|
3523
|
+
const processedCssRegistry = createFrameworkProcessedCssRegistry();
|
|
3524
|
+
const processedCssAssets = /* @__PURE__ */ new WeakSet();
|
|
3525
|
+
const tailwindRootCssModuleIds = /* @__PURE__ */ new Set();
|
|
3526
|
+
const sourceScanSession = createFrameworkSourceScanSession({
|
|
3527
|
+
cssMemory,
|
|
3528
|
+
debug,
|
|
3529
|
+
getResolvedConfig: () => resolvedConfig,
|
|
3530
|
+
hmrCandidateState,
|
|
3531
|
+
isCandidateRequest: require_v4_generation_core.isSourceCandidateRequest,
|
|
3532
|
+
isWatchLikeBuild: () => resolvedConfig?.command === "serve" || resolvedConfig?.build.watch != null,
|
|
3533
|
+
opts,
|
|
3534
|
+
runtimeState,
|
|
3535
|
+
shouldOwnTailwindGeneration: shouldGenerate,
|
|
3536
|
+
sourceCandidateCollector
|
|
3537
|
+
});
|
|
3538
|
+
const { refreshSource: refreshTailwindRootCssSource, register: registerTailwindRootCss, rememberModule: rememberTailwindRootCssModule } = createFrameworkTailwindRootCss({
|
|
3539
|
+
getImportFallback: () => resolveWebGeneratorOptions(opts).importFallback,
|
|
3540
|
+
refreshRuntimeState: async () => {
|
|
3541
|
+
await refreshRuntimeState(true);
|
|
3542
|
+
},
|
|
3543
|
+
registerAutoCssSource: async (id, css) => {
|
|
3544
|
+
cssMemory.refreshRememberedCssSourceBySourceFile(id, require_generator.normalizeTailwindSourceForGenerator(require_generator.normalizeTailwindConfigDirectives(css, node_path.default.dirname((0, _weapp_tailwindcss_shared.cleanUrl)(id))), { importFallback: true }));
|
|
3545
|
+
},
|
|
3546
|
+
shouldOwnTailwindGeneration: shouldGenerate,
|
|
3547
|
+
sourceScanSession
|
|
3548
|
+
});
|
|
3549
|
+
const cssHandlerOptions = createCssHandlerOptionsCache({
|
|
3550
|
+
getAppType: () => void 0,
|
|
3551
|
+
mainCssChunkMatcher: opts.mainCssChunkMatcher,
|
|
3552
|
+
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
3553
|
+
getOutputRoot: () => resolvedConfig?.root
|
|
3554
|
+
});
|
|
3555
|
+
const generatedCssByFile = /* @__PURE__ */ new Map();
|
|
3556
|
+
const generateCss = createFrameworkCssGenerationQueue((id) => (0, _weapp_tailwindcss_shared.cleanUrl)(id), async (id, code, hookContext) => {
|
|
3557
|
+
if (!shouldGenerate || !isCSSRequest(id)) return;
|
|
3558
|
+
await runtimeState.readyPromise;
|
|
3559
|
+
await sourceScanSession.waitForPendingSyncs();
|
|
3560
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
3561
|
+
const outputFile = resolveViteCssPipelineOutputFile(file, opts, resolvedConfig?.root ?? node_process.default.cwd(), true, false, void 0);
|
|
3562
|
+
const runtime = hookContext?.sourceCandidates ? new Set(hookContext.sourceCandidates) : await ensureRuntimeClassSet();
|
|
3563
|
+
const generated = await require_v4_generation_core.generateTailwindV4Css({
|
|
3564
|
+
opts,
|
|
3565
|
+
runtimeState,
|
|
3566
|
+
runtime,
|
|
3567
|
+
compilerMode: "legacy",
|
|
3568
|
+
rawSource: require_generator.normalizeEmptyTailwindCustomVariants(code),
|
|
3569
|
+
file,
|
|
3570
|
+
outputFile,
|
|
3571
|
+
cssHandlerOptions: cssHandlerOptions.getCssHandlerOptions(file),
|
|
3572
|
+
cssUserHandlerOptions: cssHandlerOptions.getCssUserHandlerOptions(file),
|
|
3573
|
+
getSourceCandidatesForEntries: (entries) => sourceCandidateCollector.valuesForEntries(entries),
|
|
3574
|
+
generatorPlatform: "web",
|
|
3575
|
+
styleHandler: opts.styleHandler,
|
|
3576
|
+
debug,
|
|
3577
|
+
cssStage: hookContext?.cssStage
|
|
3578
|
+
});
|
|
3579
|
+
if (!generated) return;
|
|
3580
|
+
const tracedCss = require_v4_generation_core.annotateCssSourceTrace(generated.css, {
|
|
3581
|
+
opts,
|
|
3582
|
+
tokenSources: require_v4_generation_core.isCssSourceTraceEnabled(opts) ? require_v4_generation_core.createCssTokenSourceMap(sourceCandidateCollector.sourcesForEntries(void 0), opts) : void 0
|
|
3583
|
+
});
|
|
3584
|
+
generatedCssByFile.set(file, tracedCss);
|
|
3585
|
+
processedCssRegistry.record(file, tracedCss, {
|
|
3586
|
+
injectIntoMain: opts.mainCssChunkMatcher(outputFile, void 0),
|
|
3587
|
+
outputFile
|
|
3588
|
+
});
|
|
3589
|
+
processedCssRegistry.markSource(file);
|
|
3590
|
+
recordedCandidates = new Set(runtime);
|
|
3591
|
+
for (const dependency of generated.dependencies) hookContext?.addWatchFile?.(dependency);
|
|
3592
|
+
return `${require_v4_generation_core.createBundlerGeneratedCssMarker("vite", file)}\n${tracedCss}`;
|
|
3593
|
+
});
|
|
3594
|
+
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
3595
|
+
getAppType: () => void 0,
|
|
3596
|
+
generateTailwindCss: generateCss,
|
|
3597
|
+
rootImport: `${node_path.default.join(require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss"), "generator-placeholder.css").replaceAll(node_path.default.sep, "/")}`,
|
|
3598
|
+
onTailwindRootCss: registerTailwindRootCss,
|
|
3599
|
+
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
3600
|
+
shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
|
|
3601
|
+
shouldDeferGeneration: () => false,
|
|
3602
|
+
shouldOwnTailwindGeneration: shouldGenerate,
|
|
3603
|
+
shouldRewrite: opts.rewriteCssImports === true,
|
|
3604
|
+
weappTailwindcssDirPosix: node_path.default.dirname(node_path.default.resolve(node_process.default.cwd(), "generator-placeholder.css")).replaceAll(node_path.default.sep, "/")
|
|
3605
|
+
});
|
|
3606
|
+
if (disabled) return rewritePlugins;
|
|
3607
|
+
const sourceCandidatesPlugin = createFrameworkSourceCandidatesPluginForCssOnly({
|
|
3608
|
+
cssMemory,
|
|
3609
|
+
hmrCandidateState,
|
|
3610
|
+
hmrCssModuleVersions,
|
|
3611
|
+
hmrTimingRecorder,
|
|
3612
|
+
invalidateRecordedGeneratorCandidates: () => {
|
|
3613
|
+
recordedCandidates = void 0;
|
|
3614
|
+
},
|
|
3615
|
+
prepareTailwindGeneration: () => sourceScanSession.sync(),
|
|
3616
|
+
refreshRuntimeStateForAutoCssSources: async () => {
|
|
3617
|
+
await refreshRuntimeState(true);
|
|
3618
|
+
},
|
|
3619
|
+
refreshTailwindRootCssSource,
|
|
3620
|
+
rememberTailwindRootCssModule,
|
|
3621
|
+
resolveCurrentGeneratorBranch: () => require_generator.resolveGeneratorRuntimeBranch(resolveWebGeneratorOptions(opts), {
|
|
3622
|
+
appType: void 0,
|
|
3623
|
+
platform: "web",
|
|
3624
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
3625
|
+
uniAppX: false
|
|
3626
|
+
}),
|
|
3627
|
+
resolveCurrentGeneratorOptions: () => resolveWebGeneratorOptions(opts),
|
|
3628
|
+
runtimeState,
|
|
3629
|
+
sourceCandidateCollector,
|
|
3630
|
+
sourceScanSession,
|
|
3631
|
+
tailwindRootCssModuleIds,
|
|
3632
|
+
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
3633
|
+
});
|
|
3634
|
+
const postPlugin = createFrameworkPostPlugin({
|
|
3635
|
+
debug,
|
|
3636
|
+
generateBundleHook: void 0,
|
|
3637
|
+
generatorPlaceholderCssFile: node_path.default.join(require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss"), "generator-placeholder.css"),
|
|
3638
|
+
hasExplicitTailwindcssBasedir: false,
|
|
3639
|
+
hasExplicitGeneratorTarget: true,
|
|
3640
|
+
frameworkName: "generic",
|
|
3641
|
+
hmrTimingRecorder,
|
|
3642
|
+
opts,
|
|
3643
|
+
resolveViteStylePlatform: () => "web",
|
|
3644
|
+
refreshRuntimeState: async () => {
|
|
3645
|
+
await refreshRuntimeState(true);
|
|
3646
|
+
},
|
|
3647
|
+
setResolvedConfig: (config) => {
|
|
3648
|
+
resolvedConfig = config;
|
|
3649
|
+
},
|
|
3650
|
+
shouldInferAppType: false,
|
|
3651
|
+
shouldOwnTailwindGeneration: shouldGenerate,
|
|
3652
|
+
syncCssEntriesFromAnchor: () => false
|
|
3653
|
+
});
|
|
3654
|
+
const finalizer = createViteWebCssFinalizerOutputPlugin({
|
|
3655
|
+
opts,
|
|
3656
|
+
runtimeState,
|
|
3657
|
+
ensureRuntimeClassSet,
|
|
3658
|
+
debug,
|
|
3659
|
+
frameworkName: "generic",
|
|
3660
|
+
getResolvedConfig: () => resolvedConfig,
|
|
3661
|
+
markCssAssetProcessed: (asset) => {
|
|
3662
|
+
processedCssAssets.add(asset);
|
|
3663
|
+
},
|
|
3664
|
+
isCssAssetProcessed: (asset) => processedCssAssets.has(asset),
|
|
3665
|
+
isViteProcessedCssAsset: () => true,
|
|
3666
|
+
resolveCssAssetIdentity: createViteCssAssetIdentityResolver({
|
|
3667
|
+
generatorPlaceholderFile: node_path.default.join(require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss"), "generator-placeholder.css"),
|
|
3668
|
+
isKnownProcessedSource: processedCssRegistry.matchesIdentity
|
|
3669
|
+
}),
|
|
3670
|
+
recordCssAssetResult: (file, css) => {
|
|
3671
|
+
generatedCssByFile.set(file, css);
|
|
3672
|
+
},
|
|
3673
|
+
recordViteProcessedCssAssetResult: processedCssRegistry.record,
|
|
3674
|
+
getViteProcessedCssAssetResults: processedCssRegistry.entries,
|
|
3675
|
+
getRecordedGeneratorCandidates: () => recordedCandidates,
|
|
3676
|
+
getSourceCandidates: () => sourceCandidateCollector.values(),
|
|
3677
|
+
getSourceCandidatesForEntries: (entries) => sourceCandidateCollector.valuesForEntries(entries),
|
|
3678
|
+
getSourceCandidateSourcesForEntries: (entries) => sourceCandidateCollector.sourcesForEntries(entries),
|
|
3679
|
+
waitForSourceCandidateSyncs: sourceScanSession.waitForPendingSyncs,
|
|
3680
|
+
hmrTimingRecorder
|
|
3681
|
+
});
|
|
3682
|
+
const plugins = [
|
|
3683
|
+
...rewritePlugins,
|
|
3684
|
+
sourceCandidatesPlugin,
|
|
3685
|
+
...createViteCssGenerationPlugins({
|
|
3686
|
+
generateCss,
|
|
3687
|
+
getCommand: () => resolvedConfig?.command,
|
|
3688
|
+
onTailwindRootCss: registerTailwindRootCss,
|
|
3689
|
+
shouldGenerate: () => shouldGenerate,
|
|
3690
|
+
shouldGenerateBuild: () => true
|
|
3691
|
+
}),
|
|
3692
|
+
postPlugin,
|
|
3693
|
+
finalizer,
|
|
3694
|
+
createViteHmrCssModuleVersionFilterPlugin(hmrCssModuleVersions)
|
|
3695
|
+
];
|
|
3696
|
+
const styleInjectorFactory = options.__internalViteWebStyleInjectorFactory;
|
|
3697
|
+
if (opts.styleInjector !== void 0 && typeof styleInjectorFactory === "function") plugins.push(...styleInjectorFactory(opts.styleInjector));
|
|
3698
|
+
return plugins;
|
|
3699
|
+
}
|
|
3700
|
+
function createFrameworkSourceCandidatesPluginForCssOnly(options) {
|
|
3701
|
+
return {
|
|
3702
|
+
name: `${require_compiler.vitePluginName}:source-candidates`,
|
|
3703
|
+
enforce: "pre",
|
|
3704
|
+
async transform(code, id) {
|
|
3705
|
+
if (!options.sourceCandidateCollector || !require_v4_generation_core.isSourceCandidateRequest(id)) return;
|
|
3706
|
+
options.cssMemory.rememberKnownSfcSource(id, code);
|
|
3707
|
+
if (isCSSRequest(id) && require_generator.hasUserCssLayerBlocks(code)) options.rememberTailwindRootCssModule(id);
|
|
3708
|
+
await options.sourceCandidateCollector.merge(id, code);
|
|
3709
|
+
},
|
|
3710
|
+
async watchChange(id) {
|
|
3711
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
3712
|
+
options.sourceScanSession.invalidate();
|
|
3713
|
+
await options.sourceScanSession.syncChangedFile(id);
|
|
3714
|
+
},
|
|
3715
|
+
async handleHotUpdate(ctx) {
|
|
3716
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
3717
|
+
await options.sourceScanSession.syncChangedFile(ctx.file, await ctx.read?.());
|
|
3718
|
+
await options.sourceScanSession.waitForPendingSyncs();
|
|
3719
|
+
await options.refreshRuntimeStateForAutoCssSources(true);
|
|
3720
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
3721
|
+
const cssModules = await resolveHotTailwindCssModules(ctx, options.tailwindRootCssModuleIds, (modules) => options.hmrCssModuleVersions.filterModules(modules, ctx.timestamp, root));
|
|
3722
|
+
return cssModules.length > 0 ? mergeHotModulesByIdentity(root, ctx.modules, cssModules) : void 0;
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
//#endregion
|
|
3727
|
+
//#region src/bundlers/vite/frameworks/generic/web.ts
|
|
3728
|
+
/** Generic Web CSS-only profile,供 `vite/web` 入口直接使用。 */
|
|
3729
|
+
function createGenericWebVitePlugins(options = {}) {
|
|
3730
|
+
const capability = createGenericWebViteCapabilityProfile(options);
|
|
3731
|
+
const owner = createViteSourceOutputRelationOwner();
|
|
3732
|
+
const plugins = withViteSourceOutputRelationOwner(owner, () => createCssOnlyVitePlugins({
|
|
3733
|
+
...options,
|
|
3734
|
+
__internalViteCapabilityProfile: capability,
|
|
3735
|
+
__internalViteWebStyleInjectorFactory: createBuiltinViteWebStyleInjectorPlugins
|
|
3736
|
+
}));
|
|
3737
|
+
if (!plugins) {
|
|
3738
|
+
owner.dispose();
|
|
3739
|
+
return;
|
|
3740
|
+
}
|
|
3741
|
+
return plugins.map((plugin) => {
|
|
3742
|
+
const wrapped = { ...plugin };
|
|
3743
|
+
if (plugin.watchChange) {
|
|
3744
|
+
const hook = plugin.watchChange;
|
|
3745
|
+
wrapped.watchChange = async function(...args) {
|
|
3746
|
+
const id = args[0];
|
|
3747
|
+
if (args[1]?.event === "delete") owner.removeSource(id);
|
|
3748
|
+
else if (typeof id === "string") owner.observeSource(id);
|
|
3749
|
+
return typeof hook === "function" ? hook.apply(this, args) : hook.handler?.apply(this, args);
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
if (plugin.handleHotUpdate) {
|
|
3753
|
+
const hook = plugin.handleHotUpdate;
|
|
3754
|
+
wrapped.handleHotUpdate = async function(...args) {
|
|
3755
|
+
const file = args[0]?.file;
|
|
3756
|
+
if (typeof file === "string") owner.observeSource(file);
|
|
3757
|
+
return typeof hook === "function" ? hook.apply(this, args) : hook.handler?.apply(this, args);
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3760
|
+
if (plugin.closeBundle) {
|
|
3761
|
+
const hook = plugin.closeBundle;
|
|
3762
|
+
wrapped.closeBundle = async function(...args) {
|
|
3763
|
+
try {
|
|
3764
|
+
return typeof hook === "function" ? await hook.apply(this, args) : await hook.handler?.apply(this, args);
|
|
3765
|
+
} finally {
|
|
3766
|
+
owner.dispose();
|
|
3767
|
+
}
|
|
3768
|
+
};
|
|
3769
|
+
}
|
|
3770
|
+
return wrapped;
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3773
|
+
//#endregion
|
|
3774
|
+
Object.defineProperty(exports, "CSS_SOURCE_OUTPUT_EXT_RE", {
|
|
3775
|
+
enumerable: true,
|
|
3776
|
+
get: function() {
|
|
3777
|
+
return CSS_SOURCE_OUTPUT_EXT_RE;
|
|
3778
|
+
}
|
|
3779
|
+
});
|
|
3780
|
+
Object.defineProperty(exports, "SOURCE_STYLE_OUTPUT_EXT_RE", {
|
|
3781
|
+
enumerable: true,
|
|
3782
|
+
get: function() {
|
|
3783
|
+
return SOURCE_STYLE_OUTPUT_EXT_RE;
|
|
3784
|
+
}
|
|
3785
|
+
});
|
|
3786
|
+
Object.defineProperty(exports, "appendCss", {
|
|
3787
|
+
enumerable: true,
|
|
3788
|
+
get: function() {
|
|
3789
|
+
return appendCss;
|
|
3790
|
+
}
|
|
3791
|
+
});
|
|
3792
|
+
Object.defineProperty(exports, "canProcessViteSourceStyleAsCss", {
|
|
3793
|
+
enumerable: true,
|
|
3794
|
+
get: function() {
|
|
3795
|
+
return canProcessViteSourceStyleAsCss;
|
|
3796
|
+
}
|
|
3797
|
+
});
|
|
3798
|
+
Object.defineProperty(exports, "clearAssetSource", {
|
|
3799
|
+
enumerable: true,
|
|
3800
|
+
get: function() {
|
|
3801
|
+
return clearAssetSource;
|
|
3802
|
+
}
|
|
3803
|
+
});
|
|
3804
|
+
Object.defineProperty(exports, "collectChunkModuleIds", {
|
|
3805
|
+
enumerable: true,
|
|
3806
|
+
get: function() {
|
|
3807
|
+
return collectChunkModuleIds;
|
|
3808
|
+
}
|
|
3809
|
+
});
|
|
3810
|
+
Object.defineProperty(exports, "collectImportedStyleFiles", {
|
|
3811
|
+
enumerable: true,
|
|
3812
|
+
get: function() {
|
|
3813
|
+
return collectImportedStyleFiles;
|
|
3814
|
+
}
|
|
3815
|
+
});
|
|
3816
|
+
Object.defineProperty(exports, "collectMatchingGeneratedCssMarkerFiles", {
|
|
3817
|
+
enumerable: true,
|
|
3818
|
+
get: function() {
|
|
3819
|
+
return collectMatchingGeneratedCssMarkerFiles;
|
|
3820
|
+
}
|
|
3821
|
+
});
|
|
3822
|
+
Object.defineProperty(exports, "collectRootStyleBundleCssSources", {
|
|
3823
|
+
enumerable: true,
|
|
3824
|
+
get: function() {
|
|
3825
|
+
return collectRootStyleBundleCssSources;
|
|
3826
|
+
}
|
|
3827
|
+
});
|
|
3828
|
+
Object.defineProperty(exports, "collectViteProcessedCssSources", {
|
|
3829
|
+
enumerable: true,
|
|
3830
|
+
get: function() {
|
|
3831
|
+
return collectViteProcessedCssSources;
|
|
3832
|
+
}
|
|
3833
|
+
});
|
|
3834
|
+
Object.defineProperty(exports, "createCssAssetPipelineContext", {
|
|
3835
|
+
enumerable: true,
|
|
3836
|
+
get: function() {
|
|
3837
|
+
return createCssAssetPipelineContext;
|
|
3838
|
+
}
|
|
3839
|
+
});
|
|
3840
|
+
Object.defineProperty(exports, "createCssHandlerOptions", {
|
|
3841
|
+
enumerable: true,
|
|
3842
|
+
get: function() {
|
|
3843
|
+
return createCssHandlerOptions;
|
|
3844
|
+
}
|
|
3845
|
+
});
|
|
3846
|
+
Object.defineProperty(exports, "createCssHandlerOptionsCache", {
|
|
3847
|
+
enumerable: true,
|
|
3848
|
+
get: function() {
|
|
3849
|
+
return createCssHandlerOptionsCache;
|
|
3850
|
+
}
|
|
3851
|
+
});
|
|
3852
|
+
Object.defineProperty(exports, "createFrameworkCssGenerationQueue", {
|
|
3853
|
+
enumerable: true,
|
|
3854
|
+
get: function() {
|
|
3855
|
+
return createFrameworkCssGenerationQueue;
|
|
3856
|
+
}
|
|
3857
|
+
});
|
|
3858
|
+
Object.defineProperty(exports, "createFrameworkPostPlugin", {
|
|
3859
|
+
enumerable: true,
|
|
3860
|
+
get: function() {
|
|
3861
|
+
return createFrameworkPostPlugin;
|
|
3862
|
+
}
|
|
3863
|
+
});
|
|
3864
|
+
Object.defineProperty(exports, "createFrameworkProcessedCssRegistry", {
|
|
3865
|
+
enumerable: true,
|
|
3866
|
+
get: function() {
|
|
3867
|
+
return createFrameworkProcessedCssRegistry;
|
|
3868
|
+
}
|
|
3869
|
+
});
|
|
3870
|
+
Object.defineProperty(exports, "createFrameworkSourceScanSession", {
|
|
3871
|
+
enumerable: true,
|
|
3872
|
+
get: function() {
|
|
3873
|
+
return createFrameworkSourceScanSession;
|
|
3874
|
+
}
|
|
3875
|
+
});
|
|
3876
|
+
Object.defineProperty(exports, "createFrameworkTailwindRootCss", {
|
|
3877
|
+
enumerable: true,
|
|
3878
|
+
get: function() {
|
|
3879
|
+
return createFrameworkTailwindRootCss;
|
|
3880
|
+
}
|
|
3881
|
+
});
|
|
3882
|
+
Object.defineProperty(exports, "createGenericWebProductionBundleHooks", {
|
|
3883
|
+
enumerable: true,
|
|
3884
|
+
get: function() {
|
|
3885
|
+
return createGenericWebProductionBundleHooks;
|
|
3886
|
+
}
|
|
3887
|
+
});
|
|
3888
|
+
Object.defineProperty(exports, "createGenericWebProductionSourceCandidatesApply", {
|
|
3889
|
+
enumerable: true,
|
|
3890
|
+
get: function() {
|
|
3891
|
+
return createGenericWebProductionSourceCandidatesApply;
|
|
3892
|
+
}
|
|
3893
|
+
});
|
|
3894
|
+
Object.defineProperty(exports, "createGenericWebViteCapabilityProfile", {
|
|
3895
|
+
enumerable: true,
|
|
3896
|
+
get: function() {
|
|
3897
|
+
return createGenericWebViteCapabilityProfile;
|
|
3898
|
+
}
|
|
3899
|
+
});
|
|
3900
|
+
Object.defineProperty(exports, "createGenericWebVitePlugins", {
|
|
3901
|
+
enumerable: true,
|
|
3902
|
+
get: function() {
|
|
3903
|
+
return createGenericWebVitePlugins;
|
|
3904
|
+
}
|
|
3905
|
+
});
|
|
3906
|
+
Object.defineProperty(exports, "createRewriteCssImportsPlugins", {
|
|
3907
|
+
enumerable: true,
|
|
3908
|
+
get: function() {
|
|
3909
|
+
return createRewriteCssImportsPlugins;
|
|
3910
|
+
}
|
|
3911
|
+
});
|
|
3912
|
+
Object.defineProperty(exports, "createViteCssAssetIdentityResolver", {
|
|
3913
|
+
enumerable: true,
|
|
3914
|
+
get: function() {
|
|
3915
|
+
return createViteCssAssetIdentityResolver;
|
|
3916
|
+
}
|
|
3917
|
+
});
|
|
3918
|
+
Object.defineProperty(exports, "createViteCssGenerationPlugins", {
|
|
3919
|
+
enumerable: true,
|
|
3920
|
+
get: function() {
|
|
3921
|
+
return createViteCssGenerationPlugins;
|
|
3922
|
+
}
|
|
3923
|
+
});
|
|
3924
|
+
Object.defineProperty(exports, "createViteCssMemory", {
|
|
3925
|
+
enumerable: true,
|
|
3926
|
+
get: function() {
|
|
3927
|
+
return createViteCssMemory;
|
|
3928
|
+
}
|
|
3929
|
+
});
|
|
3930
|
+
Object.defineProperty(exports, "createViteHmrCandidateState", {
|
|
3931
|
+
enumerable: true,
|
|
3932
|
+
get: function() {
|
|
3933
|
+
return createViteHmrCandidateState;
|
|
3934
|
+
}
|
|
3935
|
+
});
|
|
3936
|
+
Object.defineProperty(exports, "createViteHmrCssModuleVersionFilterPlugin", {
|
|
3937
|
+
enumerable: true,
|
|
3938
|
+
get: function() {
|
|
3939
|
+
return createViteHmrCssModuleVersionFilterPlugin;
|
|
3940
|
+
}
|
|
3941
|
+
});
|
|
3942
|
+
Object.defineProperty(exports, "createViteHmrCssModuleVersionTracker", {
|
|
3943
|
+
enumerable: true,
|
|
3944
|
+
get: function() {
|
|
3945
|
+
return createViteHmrCssModuleVersionTracker;
|
|
3946
|
+
}
|
|
3947
|
+
});
|
|
3948
|
+
Object.defineProperty(exports, "createViteRuntimeClassSet", {
|
|
3949
|
+
enumerable: true,
|
|
3950
|
+
get: function() {
|
|
3951
|
+
return createViteRuntimeClassSet;
|
|
3952
|
+
}
|
|
3953
|
+
});
|
|
3954
|
+
Object.defineProperty(exports, "createViteSourceOutputRelationOwner", {
|
|
3955
|
+
enumerable: true,
|
|
3956
|
+
get: function() {
|
|
3957
|
+
return createViteSourceOutputRelationOwner;
|
|
3958
|
+
}
|
|
3959
|
+
});
|
|
3960
|
+
Object.defineProperty(exports, "createViteWebCssFinalizerOutputPlugin", {
|
|
3961
|
+
enumerable: true,
|
|
3962
|
+
get: function() {
|
|
3963
|
+
return createViteWebCssFinalizerOutputPlugin;
|
|
3964
|
+
}
|
|
3965
|
+
});
|
|
3966
|
+
Object.defineProperty(exports, "dedupeViteCssResults", {
|
|
3967
|
+
enumerable: true,
|
|
3968
|
+
get: function() {
|
|
3969
|
+
return dedupeViteCssResults;
|
|
3970
|
+
}
|
|
3971
|
+
});
|
|
3972
|
+
Object.defineProperty(exports, "extractSfcStyleBlocks", {
|
|
3973
|
+
enumerable: true,
|
|
3974
|
+
get: function() {
|
|
3975
|
+
return extractSfcStyleBlocks;
|
|
3976
|
+
}
|
|
3977
|
+
});
|
|
3978
|
+
Object.defineProperty(exports, "finalizeWebCss", {
|
|
3979
|
+
enumerable: true,
|
|
3980
|
+
get: function() {
|
|
3981
|
+
return finalizeWebCss;
|
|
3982
|
+
}
|
|
3983
|
+
});
|
|
3984
|
+
Object.defineProperty(exports, "formatPostcssSourceMap", {
|
|
3985
|
+
enumerable: true,
|
|
3986
|
+
get: function() {
|
|
3987
|
+
return formatPostcssSourceMap;
|
|
3988
|
+
}
|
|
3989
|
+
});
|
|
3990
|
+
Object.defineProperty(exports, "frameworkViteCapabilityProfile", {
|
|
3991
|
+
enumerable: true,
|
|
3992
|
+
get: function() {
|
|
3993
|
+
return frameworkViteCapabilityProfile;
|
|
3994
|
+
}
|
|
3995
|
+
});
|
|
3996
|
+
Object.defineProperty(exports, "getActiveViteSourceOutputRelationOwner", {
|
|
3997
|
+
enumerable: true,
|
|
3998
|
+
get: function() {
|
|
3999
|
+
return getActiveViteSourceOutputRelationOwner;
|
|
4000
|
+
}
|
|
4001
|
+
});
|
|
4002
|
+
Object.defineProperty(exports, "getAssetFile", {
|
|
4003
|
+
enumerable: true,
|
|
4004
|
+
get: function() {
|
|
4005
|
+
return getAssetFile;
|
|
4006
|
+
}
|
|
4007
|
+
});
|
|
4008
|
+
Object.defineProperty(exports, "hasMatchingStyleFileBase", {
|
|
4009
|
+
enumerable: true,
|
|
4010
|
+
get: function() {
|
|
4011
|
+
return hasMatchingStyleFileBase;
|
|
4012
|
+
}
|
|
4013
|
+
});
|
|
4014
|
+
Object.defineProperty(exports, "hasNonCommentCss", {
|
|
4015
|
+
enumerable: true,
|
|
4016
|
+
get: function() {
|
|
4017
|
+
return hasNonCommentCss;
|
|
4018
|
+
}
|
|
4019
|
+
});
|
|
4020
|
+
Object.defineProperty(exports, "hasSelfAcceptingNonStyleHotModule", {
|
|
4021
|
+
enumerable: true,
|
|
4022
|
+
get: function() {
|
|
4023
|
+
return hasSelfAcceptingNonStyleHotModule;
|
|
4024
|
+
}
|
|
4025
|
+
});
|
|
4026
|
+
Object.defineProperty(exports, "hasSfcStyleSources", {
|
|
4027
|
+
enumerable: true,
|
|
4028
|
+
get: function() {
|
|
4029
|
+
return hasSfcStyleSources;
|
|
4030
|
+
}
|
|
4031
|
+
});
|
|
4032
|
+
Object.defineProperty(exports, "hasTailwindGenerationSource", {
|
|
4033
|
+
enumerable: true,
|
|
4034
|
+
get: function() {
|
|
4035
|
+
return hasTailwindGenerationSource;
|
|
4036
|
+
}
|
|
4037
|
+
});
|
|
4038
|
+
Object.defineProperty(exports, "hasVitePipelineTailwindGenerationDirective", {
|
|
4039
|
+
enumerable: true,
|
|
4040
|
+
get: function() {
|
|
4041
|
+
return hasVitePipelineTailwindGenerationDirective;
|
|
4042
|
+
}
|
|
4043
|
+
});
|
|
4044
|
+
Object.defineProperty(exports, "inferPlatformFromViteOutDir", {
|
|
4045
|
+
enumerable: true,
|
|
4046
|
+
get: function() {
|
|
4047
|
+
return inferPlatformFromViteOutDir;
|
|
4048
|
+
}
|
|
4049
|
+
});
|
|
4050
|
+
Object.defineProperty(exports, "isCSSRequest", {
|
|
4051
|
+
enumerable: true,
|
|
4052
|
+
get: function() {
|
|
4053
|
+
return isCSSRequest;
|
|
4054
|
+
}
|
|
4055
|
+
});
|
|
4056
|
+
Object.defineProperty(exports, "isCssOutputFile", {
|
|
4057
|
+
enumerable: true,
|
|
4058
|
+
get: function() {
|
|
4059
|
+
return isCssOutputFile;
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
Object.defineProperty(exports, "isHTMLRequest", {
|
|
4063
|
+
enumerable: true,
|
|
4064
|
+
get: function() {
|
|
4065
|
+
return isHTMLRequest;
|
|
4066
|
+
}
|
|
4067
|
+
});
|
|
4068
|
+
Object.defineProperty(exports, "isMatchingCssSourceFile", {
|
|
4069
|
+
enumerable: true,
|
|
4070
|
+
get: function() {
|
|
4071
|
+
return isMatchingCssSourceFile;
|
|
4072
|
+
}
|
|
4073
|
+
});
|
|
4074
|
+
Object.defineProperty(exports, "isMatchingGeneratedCssMarkerFile", {
|
|
4075
|
+
enumerable: true,
|
|
4076
|
+
get: function() {
|
|
4077
|
+
return isMatchingGeneratedCssMarkerFile;
|
|
4078
|
+
}
|
|
4079
|
+
});
|
|
4080
|
+
Object.defineProperty(exports, "isMiniProgramStyleOutputFile", {
|
|
4081
|
+
enumerable: true,
|
|
4082
|
+
get: function() {
|
|
4083
|
+
return isMiniProgramStyleOutputFile;
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
Object.defineProperty(exports, "isMissingInternalCssSource", {
|
|
4087
|
+
enumerable: true,
|
|
4088
|
+
get: function() {
|
|
4089
|
+
return isMissingInternalCssSource;
|
|
4090
|
+
}
|
|
4091
|
+
});
|
|
4092
|
+
Object.defineProperty(exports, "isRootStyleOutputFile", {
|
|
4093
|
+
enumerable: true,
|
|
4094
|
+
get: function() {
|
|
4095
|
+
return isRootStyleOutputFile;
|
|
4096
|
+
}
|
|
4097
|
+
});
|
|
4098
|
+
Object.defineProperty(exports, "isSfcStyleSourceFile", {
|
|
4099
|
+
enumerable: true,
|
|
4100
|
+
get: function() {
|
|
4101
|
+
return isSfcStyleSourceFile;
|
|
4102
|
+
}
|
|
4103
|
+
});
|
|
4104
|
+
Object.defineProperty(exports, "isStyleImportRequest", {
|
|
4105
|
+
enumerable: true,
|
|
4106
|
+
get: function() {
|
|
4107
|
+
return isStyleImportRequest;
|
|
4108
|
+
}
|
|
4109
|
+
});
|
|
4110
|
+
Object.defineProperty(exports, "mergeHotModulesByIdentity", {
|
|
4111
|
+
enumerable: true,
|
|
4112
|
+
get: function() {
|
|
4113
|
+
return mergeHotModulesByIdentity;
|
|
4114
|
+
}
|
|
4115
|
+
});
|
|
4116
|
+
Object.defineProperty(exports, "normalizeCssSourceForCompare", {
|
|
4117
|
+
enumerable: true,
|
|
4118
|
+
get: function() {
|
|
4119
|
+
return normalizeCssSourceForCompare;
|
|
4120
|
+
}
|
|
4121
|
+
});
|
|
4122
|
+
Object.defineProperty(exports, "normalizeInjectableCssForTarget", {
|
|
4123
|
+
enumerable: true,
|
|
4124
|
+
get: function() {
|
|
4125
|
+
return normalizeInjectableCssForTarget;
|
|
4126
|
+
}
|
|
4127
|
+
});
|
|
4128
|
+
Object.defineProperty(exports, "normalizeInjectableCssForTargetWithImports", {
|
|
4129
|
+
enumerable: true,
|
|
4130
|
+
get: function() {
|
|
4131
|
+
return normalizeInjectableCssForTargetWithImports;
|
|
4132
|
+
}
|
|
4133
|
+
});
|
|
4134
|
+
Object.defineProperty(exports, "normalizeMarkerOutputFile", {
|
|
4135
|
+
enumerable: true,
|
|
4136
|
+
get: function() {
|
|
4137
|
+
return normalizeMarkerOutputFile;
|
|
4138
|
+
}
|
|
4139
|
+
});
|
|
4140
|
+
Object.defineProperty(exports, "normalizePath", {
|
|
4141
|
+
enumerable: true,
|
|
4142
|
+
get: function() {
|
|
4143
|
+
return normalizePath;
|
|
4144
|
+
}
|
|
4145
|
+
});
|
|
4146
|
+
Object.defineProperty(exports, "normalizeSfcSourceFileForCompare", {
|
|
4147
|
+
enumerable: true,
|
|
4148
|
+
get: function() {
|
|
4149
|
+
return normalizeSfcSourceFileForCompare;
|
|
4150
|
+
}
|
|
4151
|
+
});
|
|
4152
|
+
Object.defineProperty(exports, "normalizeVitePersistentCacheKey", {
|
|
4153
|
+
enumerable: true,
|
|
4154
|
+
get: function() {
|
|
4155
|
+
return normalizeVitePersistentCacheKey;
|
|
4156
|
+
}
|
|
4157
|
+
});
|
|
4158
|
+
Object.defineProperty(exports, "parseVueRequest", {
|
|
4159
|
+
enumerable: true,
|
|
4160
|
+
get: function() {
|
|
4161
|
+
return parseVueRequest;
|
|
4162
|
+
}
|
|
4163
|
+
});
|
|
4164
|
+
Object.defineProperty(exports, "posix", {
|
|
4165
|
+
enumerable: true,
|
|
4166
|
+
get: function() {
|
|
4167
|
+
return posix;
|
|
4168
|
+
}
|
|
4169
|
+
});
|
|
4170
|
+
Object.defineProperty(exports, "readAssetSource", {
|
|
4171
|
+
enumerable: true,
|
|
4172
|
+
get: function() {
|
|
4173
|
+
return readAssetSource$1;
|
|
4174
|
+
}
|
|
4175
|
+
});
|
|
4176
|
+
Object.defineProperty(exports, "registerGeneratorDependencies", {
|
|
4177
|
+
enumerable: true,
|
|
4178
|
+
get: function() {
|
|
4179
|
+
return registerGeneratorDependencies;
|
|
4180
|
+
}
|
|
4181
|
+
});
|
|
4182
|
+
Object.defineProperty(exports, "removeDuplicateUnlinkedRootCssAssetsReferencedByHtml", {
|
|
4183
|
+
enumerable: true,
|
|
4184
|
+
get: function() {
|
|
4185
|
+
return removeDuplicateUnlinkedRootCssAssetsReferencedByHtml;
|
|
4186
|
+
}
|
|
4187
|
+
});
|
|
4188
|
+
Object.defineProperty(exports, "removeTailwindEntryDirectivesFromCss", {
|
|
4189
|
+
enumerable: true,
|
|
4190
|
+
get: function() {
|
|
4191
|
+
return removeTailwindEntryDirectivesFromCss;
|
|
4192
|
+
}
|
|
4193
|
+
});
|
|
4194
|
+
Object.defineProperty(exports, "resolveHotSourceModules", {
|
|
4195
|
+
enumerable: true,
|
|
4196
|
+
get: function() {
|
|
4197
|
+
return resolveHotSourceModules;
|
|
4198
|
+
}
|
|
4199
|
+
});
|
|
4200
|
+
Object.defineProperty(exports, "resolveHotSourceModulesByIds", {
|
|
4201
|
+
enumerable: true,
|
|
4202
|
+
get: function() {
|
|
4203
|
+
return resolveHotSourceModulesByIds;
|
|
4204
|
+
}
|
|
4205
|
+
});
|
|
4206
|
+
Object.defineProperty(exports, "resolveHotTailwindCssModules", {
|
|
4207
|
+
enumerable: true,
|
|
4208
|
+
get: function() {
|
|
4209
|
+
return resolveHotTailwindCssModules;
|
|
4210
|
+
}
|
|
4211
|
+
});
|
|
4212
|
+
Object.defineProperty(exports, "resolveMiniProgramStyleOutputExtension", {
|
|
4213
|
+
enumerable: true,
|
|
4214
|
+
get: function() {
|
|
4215
|
+
return resolveMiniProgramStyleOutputExtension;
|
|
4216
|
+
}
|
|
4217
|
+
});
|
|
4218
|
+
Object.defineProperty(exports, "resolveReplayCssOutputFile", {
|
|
4219
|
+
enumerable: true,
|
|
4220
|
+
get: function() {
|
|
4221
|
+
return resolveReplayCssOutputFile;
|
|
4222
|
+
}
|
|
4223
|
+
});
|
|
4224
|
+
Object.defineProperty(exports, "resolveSfcStyleRequestFromKnownSource", {
|
|
4225
|
+
enumerable: true,
|
|
4226
|
+
get: function() {
|
|
4227
|
+
return resolveSfcStyleRequestFromKnownSource;
|
|
4228
|
+
}
|
|
4229
|
+
});
|
|
4230
|
+
Object.defineProperty(exports, "resolveSfcStyleSourceFromOutputFile", {
|
|
4231
|
+
enumerable: true,
|
|
4232
|
+
get: function() {
|
|
4233
|
+
return resolveSfcStyleSourceFromOutputFile;
|
|
4234
|
+
}
|
|
4235
|
+
});
|
|
4236
|
+
Object.defineProperty(exports, "resolveSourceStyleSourceFromOutputFile", {
|
|
4237
|
+
enumerable: true,
|
|
4238
|
+
get: function() {
|
|
4239
|
+
return resolveSourceStyleSourceFromOutputFile;
|
|
4240
|
+
}
|
|
4241
|
+
});
|
|
4242
|
+
Object.defineProperty(exports, "resolveViteCssHandlerExtraOptions", {
|
|
4243
|
+
enumerable: true,
|
|
4244
|
+
get: function() {
|
|
4245
|
+
return resolveViteCssHandlerExtraOptions;
|
|
4246
|
+
}
|
|
4247
|
+
});
|
|
4248
|
+
Object.defineProperty(exports, "resolveViteCssOutputFile", {
|
|
4249
|
+
enumerable: true,
|
|
4250
|
+
get: function() {
|
|
4251
|
+
return resolveViteCssOutputFile;
|
|
4252
|
+
}
|
|
4253
|
+
});
|
|
4254
|
+
Object.defineProperty(exports, "resolveViteCssPipelineOutputFile", {
|
|
4255
|
+
enumerable: true,
|
|
4256
|
+
get: function() {
|
|
4257
|
+
return resolveViteCssPipelineOutputFile;
|
|
4258
|
+
}
|
|
4259
|
+
});
|
|
4260
|
+
Object.defineProperty(exports, "resolveViteCssPipelineOutputFileFromSourceFile", {
|
|
4261
|
+
enumerable: true,
|
|
4262
|
+
get: function() {
|
|
4263
|
+
return resolveViteCssPipelineOutputFileFromSourceFile;
|
|
4264
|
+
}
|
|
4265
|
+
});
|
|
4266
|
+
Object.defineProperty(exports, "resolveViteCssPipelineRequestFile", {
|
|
4267
|
+
enumerable: true,
|
|
4268
|
+
get: function() {
|
|
4269
|
+
return resolveViteCssPipelineRequestFile;
|
|
4270
|
+
}
|
|
4271
|
+
});
|
|
4272
|
+
Object.defineProperty(exports, "resolveViteModuleIdentity", {
|
|
4273
|
+
enumerable: true,
|
|
4274
|
+
get: function() {
|
|
4275
|
+
return resolveViteModuleIdentity;
|
|
4276
|
+
}
|
|
4277
|
+
});
|
|
4278
|
+
Object.defineProperty(exports, "resolveViteProcessedCssAssetSource", {
|
|
4279
|
+
enumerable: true,
|
|
4280
|
+
get: function() {
|
|
4281
|
+
return resolveViteProcessedCssAssetSource;
|
|
4282
|
+
}
|
|
4283
|
+
});
|
|
4284
|
+
Object.defineProperty(exports, "resolveViteWebCssCompatOptions", {
|
|
4285
|
+
enumerable: true,
|
|
4286
|
+
get: function() {
|
|
4287
|
+
return resolveViteWebCssCompatOptions;
|
|
4288
|
+
}
|
|
4289
|
+
});
|
|
4290
|
+
Object.defineProperty(exports, "sendFullReloadForUnresolvedHotUpdate", {
|
|
4291
|
+
enumerable: true,
|
|
4292
|
+
get: function() {
|
|
4293
|
+
return sendFullReloadForUnresolvedHotUpdate;
|
|
4294
|
+
}
|
|
4295
|
+
});
|
|
4296
|
+
Object.defineProperty(exports, "sendSupplementalCssHotUpdates", {
|
|
4297
|
+
enumerable: true,
|
|
4298
|
+
get: function() {
|
|
4299
|
+
return sendSupplementalCssHotUpdates;
|
|
4300
|
+
}
|
|
4301
|
+
});
|
|
4302
|
+
Object.defineProperty(exports, "shouldApplyViteWebCssCompat", {
|
|
4303
|
+
enumerable: true,
|
|
4304
|
+
get: function() {
|
|
4305
|
+
return shouldApplyViteWebCssCompat;
|
|
4306
|
+
}
|
|
4307
|
+
});
|
|
4308
|
+
Object.defineProperty(exports, "shouldCollectTransformedSourceCandidates", {
|
|
4309
|
+
enumerable: true,
|
|
4310
|
+
get: function() {
|
|
4311
|
+
return shouldCollectTransformedSourceCandidates;
|
|
4312
|
+
}
|
|
4313
|
+
});
|
|
4314
|
+
Object.defineProperty(exports, "shouldGenerateCssByGenerator", {
|
|
4315
|
+
enumerable: true,
|
|
4316
|
+
get: function() {
|
|
4317
|
+
return shouldGenerateCssByGenerator;
|
|
4318
|
+
}
|
|
4319
|
+
});
|
|
4320
|
+
Object.defineProperty(exports, "shouldSkipGenericWebProductionSourceCandidates", {
|
|
4321
|
+
enumerable: true,
|
|
4322
|
+
get: function() {
|
|
4323
|
+
return shouldSkipGenericWebProductionSourceCandidates;
|
|
4324
|
+
}
|
|
4325
|
+
});
|
|
4326
|
+
Object.defineProperty(exports, "slash", {
|
|
4327
|
+
enumerable: true,
|
|
4328
|
+
get: function() {
|
|
4329
|
+
return slash;
|
|
4330
|
+
}
|
|
4331
|
+
});
|
|
4332
|
+
Object.defineProperty(exports, "summarizeStringCache", {
|
|
4333
|
+
enumerable: true,
|
|
4334
|
+
get: function() {
|
|
4335
|
+
return summarizeStringCache;
|
|
4336
|
+
}
|
|
4337
|
+
});
|
|
4338
|
+
Object.defineProperty(exports, "syncFrameworkSourceCandidatesForHotUpdate", {
|
|
4339
|
+
enumerable: true,
|
|
4340
|
+
get: function() {
|
|
4341
|
+
return syncFrameworkSourceCandidatesForHotUpdate;
|
|
4342
|
+
}
|
|
4343
|
+
});
|
|
4344
|
+
Object.defineProperty(exports, "touchMapEntry", {
|
|
4345
|
+
enumerable: true,
|
|
4346
|
+
get: function() {
|
|
4347
|
+
return touchMapEntry;
|
|
4348
|
+
}
|
|
4349
|
+
});
|
|
4350
|
+
Object.defineProperty(exports, "tryFinalizeGenericWebCss", {
|
|
4351
|
+
enumerable: true,
|
|
4352
|
+
get: function() {
|
|
4353
|
+
return tryFinalizeGenericWebCss;
|
|
4354
|
+
}
|
|
4355
|
+
});
|
|
4356
|
+
Object.defineProperty(exports, "withViteSourceOutputRelationOwner", {
|
|
4357
|
+
enumerable: true,
|
|
4358
|
+
get: function() {
|
|
4359
|
+
return withViteSourceOutputRelationOwner;
|
|
4360
|
+
}
|
|
4361
|
+
});
|