weapp-tailwindcss 5.5.5 → 5.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +5 -4
- package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -2
- package/dist/bundlers/shared/framework-css-composition.d.ts +1 -0
- package/dist/bundlers/shared/framework-postcss.d.ts +2 -1
- package/dist/bundlers/shared/framework-user-css.d.ts +1 -0
- package/dist/bundlers/shared/generated-css-marker.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +5 -7
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +4 -1
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -4
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +4 -2
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +6 -3
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/user-css/compile-functions.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +3 -1
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +3 -0
- package/dist/bundlers/shared/style-handler-options.d.ts +7 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +0 -1
- package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +3 -0
- package/dist/bundlers/vite/css-handler-options.d.ts +1 -1
- package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/sync-processed-css.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/framework-style-memory.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/web-css-module.d.ts +1 -0
- package/dist/bundlers/vite/plugin-hook.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +3 -1
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +3 -1
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +2 -1
- package/dist/bundlers/vite/shared/framework-runtime-configuration.d.ts +3 -0
- package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +9 -0
- package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +6 -5
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +3 -3
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +3 -1
- package/dist/bundlers/vite/shared/hmr-source.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +2 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +1 -1
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/semantic-css.d.ts +1 -1
- package/dist/compiler/types.d.ts +1 -1
- package/dist/{compiler-Cc0JXfbw.cjs → compiler-C8FqI-P3.cjs} +17378 -40552
- package/dist/{compiler-D_vxtEdw.js → compiler-D3GBwxoa.js} +32 -23
- package/dist/core/compiler/transforms.d.ts +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/{css-imports-FRZwX4P6.cjs → css-imports-XvtI1zCY.cjs} +2 -3
- package/dist/css-macro.cjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/{defaults-CKx-4LcW.js → defaults-AQuvJS-h.js} +4 -2
- package/dist/{defaults-CiGsr8Xq.cjs → defaults-CyX5iO9y.cjs} +4 -2
- package/dist/defaults.cjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/final-css-cleanup-CDTmVAye.cjs +1 -0
- package/dist/{final-css-cleanup-B0HUBtiE.js → final-css-cleanup-u_sI2p56.js} +1 -126
- package/dist/framework/index.d.ts +1 -1
- package/dist/framework/platform.d.ts +2 -2
- package/dist/{generator-BdSIvFEO.cjs → generator-Bvr4WmuF.cjs} +135 -149
- package/dist/{generator-CAOx1Sqm.js → generator-C0BJjyLM.js} +116 -130
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-Dnt8VL8D.cjs → gulp-BExe5RBF.cjs} +8 -8
- package/dist/{gulp-B1mPTMqw.js → gulp-BhkIIk7J.js} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-wAt0LavM.js → hmr-timing-B9Yt86-U.js} +299 -404
- package/dist/{hmr-timing-qpX410qU.cjs → hmr-timing-CoiJIqDu.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/js/NodePathWalker.d.ts +1 -1
- package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
- package/dist/js/node-path-walker/import-tokens.d.ts +1 -1
- package/dist/{pipeline-helpers-BHagysZY.cjs → pipeline-helpers-BOjTEmMi.cjs} +6 -6
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{scoped-generator-BqxVxNp9.js → scoped-generator-B6Y1bxzM.js} +46 -31
- package/dist/{scoped-generator-CtetE5rm.cjs → scoped-generator-BUBls_oM.cjs} +46 -31
- package/dist/{source-candidate-scan-signature-BDGB9nKZ.cjs → source-candidate-scan-signature-BtJZp28T.cjs} +32 -3
- package/dist/{source-candidate-scan-signature-Lm32zKVA.js → source-candidate-scan-signature-DNuGKTqf.js} +21 -4
- package/dist/style-injector/internal.d.ts +118 -8
- package/dist/style-injector/options.d.ts +5 -1
- package/dist/tailwindcss/runtime-options.d.ts +5 -0
- package/dist/tailwindcss/v4/preflight.d.ts +0 -1
- package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +1 -3
- package/dist/{tailwindcss-DTV9MoJT.js → tailwindcss-B_4E52WF.js} +7 -13
- package/dist/{tailwindcss-9e6ZuYgS.cjs → tailwindcss-CBYjzRmV.cjs} +4 -10
- package/dist/{transform-BbbZvFQq.js → transform-CkEnJYIP.js} +18 -12
- package/dist/{transform-D21f8Dm8.cjs → transform-FkqbTBJR.cjs} +17 -11
- package/dist/types/index.d.ts +3 -2
- package/dist/uni-app-x/border-preflight.d.ts +1 -2
- package/dist/uni-app-x/component-local-style.d.ts +2 -1
- package/dist/uni-app-x/transform.d.ts +4 -2
- package/dist/uni-app-x/vite/author-apply.d.ts +3 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +1 -1
- package/dist/uni-app-x/vite/style-result.d.ts +5 -0
- package/dist/{v4-generation-core-DJBWZ_D0.cjs → v4-generation-core-Cz1D7wm1.cjs} +313 -418
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-CaH7WjX6.cjs → vite-DxuKPZlp.cjs} +565 -592
- package/dist/{vite-CuYntLZP.js → vite-lP35OguX.js} +558 -578
- package/dist/vite-web.d.ts +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
- package/dist/{web-CdXkY_VO.js → web-Dfz_jpNj.js} +144 -107
- package/dist/{web-CYs2Kcaa.cjs → web-DhDxhlkq.cjs} +156 -107
- package/dist/{webpack-BnCSOUuu.js → webpack-D6jp1o3m.js} +18 -17
- package/dist/{webpack-BQNnpQPC.cjs → webpack-R2Sbggiy.cjs} +20 -20
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
- package/dist/wxml/utils/custom-template.d.ts +1 -1
- package/package.json +8 -10
- package/dist/final-css-cleanup-DSjczga3.cjs +0 -138
- package/dist/tailwindcss/v4-engine/css-import.d.ts +0 -14
- package/dist/uni-app-x/style-asset/source-parser.d.ts +0 -2
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
3
|
+
const require_generator = require("./generator-Bvr4WmuF.cjs");
|
|
4
|
+
const require_tailwindcss = require("./tailwindcss-CBYjzRmV.cjs");
|
|
5
5
|
require("./utils-CuKLf1Zv.cjs");
|
|
6
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
7
|
-
const require_compiler = require("./compiler-
|
|
6
|
+
const require_v4_generation_core = require("./v4-generation-core-Cz1D7wm1.cjs");
|
|
7
|
+
const require_compiler = require("./compiler-C8FqI-P3.cjs");
|
|
8
8
|
const require_cache = require("./cache-CBJFB1HN.cjs");
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
|
|
11
|
-
const require_scoped_generator = require("./scoped-generator-
|
|
12
|
-
const require_web = require("./web-
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-CoiJIqDu.cjs");
|
|
10
|
+
require("./final-css-cleanup-CDTmVAye.cjs");
|
|
11
|
+
const require_scoped_generator = require("./scoped-generator-BUBls_oM.cjs");
|
|
12
|
+
const require_web = require("./web-DhDxhlkq.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BtJZp28T.cjs");
|
|
14
14
|
require("./logger-TlKT3xmR.cjs");
|
|
15
15
|
let node_fs = require("node:fs");
|
|
16
16
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
@@ -28,22 +28,8 @@ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
|
28
28
|
let node_buffer = require("node:buffer");
|
|
29
29
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
30
30
|
let node_async_hooks = require("node:async_hooks");
|
|
31
|
-
let postcss_scss = require("postcss-scss");
|
|
32
|
-
postcss_scss = require_rolldown_runtime.__toESM(postcss_scss, 1);
|
|
33
31
|
let _vue_compiler_dom = require("@vue/compiler-dom");
|
|
34
32
|
let comment_json = require("comment-json");
|
|
35
|
-
//#region src/uni-app-x/style-asset/source-parser.ts
|
|
36
|
-
function parseUniAppXStyleSource(source) {
|
|
37
|
-
return postcss_scss.default.parse(source, { from: void 0 });
|
|
38
|
-
}
|
|
39
|
-
function isUniAppXStyleSourceEmpty(source) {
|
|
40
|
-
try {
|
|
41
|
-
return parseUniAppXStyleSource(source).nodes.every((node) => node.type === "comment");
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
33
|
//#region src/uni-app-x/style-asset/harmony-apply.ts
|
|
48
34
|
const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
|
|
49
35
|
function createGeneratedRuleMap(css) {
|
|
@@ -67,7 +53,7 @@ function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
|
|
|
67
53
|
if (!styleSource.includes("@apply")) return block;
|
|
68
54
|
let root;
|
|
69
55
|
try {
|
|
70
|
-
root = parseUniAppXStyleSource(styleSource);
|
|
56
|
+
root = (0, _weapp_tailwindcss_postcss.parseUniAppXStyleSource)(styleSource);
|
|
71
57
|
} catch {
|
|
72
58
|
return block;
|
|
73
59
|
}
|
|
@@ -81,7 +67,9 @@ function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
|
|
|
81
67
|
changed = true;
|
|
82
68
|
});
|
|
83
69
|
if (!changed) return block;
|
|
84
|
-
if (!root.toString().includes("@apply")) root.walkAtRules("reference", (rule) =>
|
|
70
|
+
if (!root.toString().includes("@apply")) root.walkAtRules("reference", (rule) => {
|
|
71
|
+
rule.remove();
|
|
72
|
+
});
|
|
85
73
|
return `${open}${root.toString()}${close}`;
|
|
86
74
|
});
|
|
87
75
|
}
|
|
@@ -115,7 +103,6 @@ const STYLE_ENTRY_RE = /\[\s*("((?:\\.|[^"\\])+)")\s*,\s*(_pS\(_uM\(\[[\s\S]*?\]
|
|
|
115
103
|
const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
|
|
116
104
|
const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
117
105
|
const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
|
|
118
|
-
const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
|
|
119
106
|
const STRING_STYLE_PROPERTIES = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
120
107
|
function cloneStyleEntry(entry) {
|
|
121
108
|
return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
|
|
@@ -143,9 +130,6 @@ function normalizeStyleValue(prop, value) {
|
|
|
143
130
|
if (typeof value === "number") return STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) ? String(value) : value;
|
|
144
131
|
return normalizeValue(prop, value);
|
|
145
132
|
}
|
|
146
|
-
function unescapeCssClassSelector(className) {
|
|
147
|
-
return className.replace(/\\([^\n\r\f0-9a-f])/gi, "$1");
|
|
148
|
-
}
|
|
149
133
|
function parseStyleExport(source) {
|
|
150
134
|
const json = source.replace(STYLE_EXPORT_PREFIX_RE, "").trim();
|
|
151
135
|
if (!json) return;
|
|
@@ -221,35 +205,8 @@ function createUtsStyleArrayFromAppStyles(code, appSource) {
|
|
|
221
205
|
if (used.size === 0) return;
|
|
222
206
|
return createUtsStyleArray([...used].map((className) => entries.get(className)).filter(Boolean));
|
|
223
207
|
}
|
|
224
|
-
function cssToStyleExport(source) {
|
|
225
|
-
let root;
|
|
226
|
-
try {
|
|
227
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
228
|
-
} catch {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const result = {};
|
|
232
|
-
root.walkRules((rule) => {
|
|
233
|
-
const selectors = rule.selectors ?? [];
|
|
234
|
-
for (const selector of selectors) {
|
|
235
|
-
const match = selector.trim().match(CLASS_SELECTOR_PREFIX_RE);
|
|
236
|
-
if (!match?.[1]) continue;
|
|
237
|
-
const declarations = {};
|
|
238
|
-
rule.walkDecls((decl) => {
|
|
239
|
-
declarations[toCamelCase(decl.prop)] = normalizeValue(decl.prop, decl.value);
|
|
240
|
-
});
|
|
241
|
-
if (Object.keys(declarations).length > 0) {
|
|
242
|
-
result[match[1]] = { "": declarations };
|
|
243
|
-
const className = unescapeCssClassSelector(match[1]);
|
|
244
|
-
result[className] = { "": declarations };
|
|
245
|
-
result[require_compiler.replaceWxml(className)] = { "": declarations };
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
250
|
-
}
|
|
251
208
|
function cssSourceToStyleValue(source) {
|
|
252
|
-
return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) :
|
|
209
|
+
return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) : (0, _weapp_tailwindcss_postcss.cssToClassStyleValue)(source);
|
|
253
210
|
}
|
|
254
211
|
function mergeStyleValues(...items) {
|
|
255
212
|
const result = {};
|
|
@@ -265,32 +222,9 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
265
222
|
for (const source of sources) {
|
|
266
223
|
const styleSources = source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE)].map((styleBlock) => styleBlock[1] ?? "") : [source];
|
|
267
224
|
for (const styleSource of styleSources) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
} catch {
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
root.walkRules((rule) => {
|
|
275
|
-
const applyRules = rule.nodes?.filter((node) => node.type === "atrule" && node.name === "apply") ?? [];
|
|
276
|
-
if (applyRules.length === 0) return;
|
|
277
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
278
|
-
for (const selector of selectors) {
|
|
279
|
-
const className = selector.trim().match(CLASS_SELECTOR_PREFIX_RE)?.[1];
|
|
280
|
-
if (!className) continue;
|
|
281
|
-
const declarations = {};
|
|
282
|
-
for (const applyRule of applyRules) for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(applyRule.params)) {
|
|
283
|
-
const utilityDeclarations = utilityStyles[utility]?.[""] ?? utilityStyles[require_compiler.replaceWxml(utility)]?.[""];
|
|
284
|
-
if (utilityDeclarations) Object.assign(declarations, utilityDeclarations);
|
|
285
|
-
}
|
|
286
|
-
if (Object.keys(declarations).length > 0) {
|
|
287
|
-
const unescapedClassName = unescapeCssClassSelector(className);
|
|
288
|
-
result[className] = { "": declarations };
|
|
289
|
-
result[unescapedClassName] = { "": declarations };
|
|
290
|
-
result[require_compiler.replaceWxml(unescapedClassName)] = { "": declarations };
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
225
|
+
const applied = (0, _weapp_tailwindcss_postcss.expandCssApplySourcesToStyleValue)(styleSource, utilityStyles);
|
|
226
|
+
if (!applied) continue;
|
|
227
|
+
Object.assign(result, applied);
|
|
294
228
|
}
|
|
295
229
|
}
|
|
296
230
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
@@ -298,7 +232,7 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
298
232
|
function resolveReferencePaths(styleSource, sourceId) {
|
|
299
233
|
let root;
|
|
300
234
|
try {
|
|
301
|
-
root = parseUniAppXStyleSource(styleSource);
|
|
235
|
+
root = (0, _weapp_tailwindcss_postcss.parseUniAppXStyleSource)(styleSource);
|
|
302
236
|
} catch {
|
|
303
237
|
return styleSource;
|
|
304
238
|
}
|
|
@@ -320,17 +254,7 @@ function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
|
|
|
320
254
|
}
|
|
321
255
|
function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
322
256
|
const utilities = /* @__PURE__ */ new Set();
|
|
323
|
-
for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source))
|
|
324
|
-
let root;
|
|
325
|
-
try {
|
|
326
|
-
root = parseUniAppXStyleSource(styleSource);
|
|
327
|
-
} catch {
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
root.walkAtRules("apply", (rule) => {
|
|
331
|
-
for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
332
|
-
});
|
|
333
|
-
}
|
|
257
|
+
for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) for (const utility of (0, _weapp_tailwindcss_postcss.collectCssApplyUtilities)(styleSource)) utilities.add(utility);
|
|
334
258
|
return utilities;
|
|
335
259
|
}
|
|
336
260
|
function createMergedStyleValue(code, localStyle, appStyle) {
|
|
@@ -547,7 +471,7 @@ function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtili
|
|
|
547
471
|
return applyStyleSources.map((source) => {
|
|
548
472
|
let root;
|
|
549
473
|
try {
|
|
550
|
-
root = parseUniAppXStyleSource(source);
|
|
474
|
+
root = (0, _weapp_tailwindcss_postcss.parseUniAppXStyleSource)(source);
|
|
551
475
|
} catch {
|
|
552
476
|
return source;
|
|
553
477
|
}
|
|
@@ -832,6 +756,204 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
|
|
|
832
756
|
}
|
|
833
757
|
}
|
|
834
758
|
//#endregion
|
|
759
|
+
//#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
|
|
760
|
+
function applyViteAssetEmissionPlan(plan, options) {
|
|
761
|
+
for (const operation of plan.operations()) {
|
|
762
|
+
if (operation.kind === "delete") {
|
|
763
|
+
delete options.bundle[operation.assetId];
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
const writeTarget = options.writeTargets?.get(operation.assetId);
|
|
767
|
+
const existing = options.bundle[operation.assetId];
|
|
768
|
+
const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
|
|
769
|
+
if (asset) {
|
|
770
|
+
asset.source = operation.source;
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
|
|
774
|
+
if (replayAsset) options.bundle[operation.assetId] = replayAsset;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/bundlers/vite/generate-bundle/root-style-output.ts
|
|
779
|
+
function isRootMiniProgramStyleOutputFile$1(file) {
|
|
780
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
781
|
+
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
782
|
+
}
|
|
783
|
+
function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
784
|
+
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
785
|
+
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
786
|
+
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
787
|
+
const baseDir = targetDir === "." ? "" : targetDir;
|
|
788
|
+
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
789
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
790
|
+
}
|
|
791
|
+
function createCssImportShell$1(targetFile, importedFile) {
|
|
792
|
+
return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
|
|
793
|
+
}
|
|
794
|
+
function resolveSingleCssImportOutputFile(targetFile, css) {
|
|
795
|
+
let importedFile;
|
|
796
|
+
try {
|
|
797
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("import", (atRule) => {
|
|
798
|
+
if (importedFile !== void 0) return;
|
|
799
|
+
const request = require_generator.parseImportRequest(atRule.params);
|
|
800
|
+
if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
|
|
801
|
+
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
802
|
+
if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
|
|
803
|
+
const targetDir = node_path.default.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
804
|
+
importedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
805
|
+
});
|
|
806
|
+
} catch {}
|
|
807
|
+
return importedFile;
|
|
808
|
+
}
|
|
809
|
+
function createRootMiniProgramOriginStyleOutputFile(file) {
|
|
810
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
811
|
+
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
|
|
812
|
+
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
813
|
+
}
|
|
814
|
+
function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
|
|
815
|
+
return enabled === true;
|
|
816
|
+
}
|
|
817
|
+
function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
|
|
818
|
+
return !options.isWebGeneratorTarget && options.matchesCss && require_web.isRootStyleOutputFile(options.file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
|
|
819
|
+
}
|
|
820
|
+
function resolveFrameworkRootImportShellPlan(options) {
|
|
821
|
+
const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
822
|
+
css: options.rawSource,
|
|
823
|
+
file: options.rootImportShellOutputFile,
|
|
824
|
+
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
825
|
+
matchesCss: options.matchesCss,
|
|
826
|
+
shouldKeep: options.shouldKeep
|
|
827
|
+
});
|
|
828
|
+
if (isCurrentImportShell) {
|
|
829
|
+
const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
|
|
830
|
+
return {
|
|
831
|
+
isCurrentImportShell,
|
|
832
|
+
reusableTarget: options.rememberedTarget,
|
|
833
|
+
targetToRemember: importedFile && require_web.isRootStyleOutputFile(importedFile) ? importedFile : void 0
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
if (options.rememberedTarget) return {
|
|
837
|
+
isCurrentImportShell,
|
|
838
|
+
reusableTarget: options.rememberedTarget,
|
|
839
|
+
targetToRemember: void 0
|
|
840
|
+
};
|
|
841
|
+
if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(options.assetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
|
|
842
|
+
isCurrentImportShell,
|
|
843
|
+
reusableTarget: void 0,
|
|
844
|
+
targetToRemember: void 0
|
|
845
|
+
};
|
|
846
|
+
const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(options.rootImportShellOutputFile)));
|
|
847
|
+
const target = targets.size === 1 ? [...targets][0] : void 0;
|
|
848
|
+
return {
|
|
849
|
+
isCurrentImportShell,
|
|
850
|
+
reusableTarget: target,
|
|
851
|
+
targetToRemember: target
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
855
|
+
if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
|
|
856
|
+
const plan = new require_compiler.AssetEmissionPlan();
|
|
857
|
+
const writeTargets = /* @__PURE__ */ new Map();
|
|
858
|
+
let restored = 0;
|
|
859
|
+
for (const [sourceFile, targetFile] of options.targetByFile) {
|
|
860
|
+
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !require_web.isRootStyleOutputFile(sourceFile) || !require_web.isRootStyleOutputFile(targetFile) || require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile)) continue;
|
|
861
|
+
const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(candidate.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile))?.[1];
|
|
862
|
+
if (output?.type !== "asset") continue;
|
|
863
|
+
const rawSource = output.source.toString();
|
|
864
|
+
if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
|
|
865
|
+
const nextSource = createCssImportShell$1(sourceFile, targetFile);
|
|
866
|
+
if (rawSource === nextSource) continue;
|
|
867
|
+
plan.write(sourceFile, nextSource);
|
|
868
|
+
writeTargets.set(sourceFile, output);
|
|
869
|
+
options.recordCssAssetResult?.(sourceFile, nextSource);
|
|
870
|
+
options.onUpdate?.(sourceFile, rawSource, nextSource);
|
|
871
|
+
options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
|
|
872
|
+
restored++;
|
|
873
|
+
}
|
|
874
|
+
applyViteAssetEmissionPlan(plan, {
|
|
875
|
+
bundle,
|
|
876
|
+
writeTargets
|
|
877
|
+
});
|
|
878
|
+
return restored;
|
|
879
|
+
}
|
|
880
|
+
function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
|
|
881
|
+
const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
882
|
+
if (output.type !== "chunk") return [];
|
|
883
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
884
|
+
if (file.includes("/")) return [];
|
|
885
|
+
return [{
|
|
886
|
+
file,
|
|
887
|
+
isEntry: output.isEntry === true
|
|
888
|
+
}];
|
|
889
|
+
});
|
|
890
|
+
const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
|
|
891
|
+
const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => node_path.default.posix.parse(chunk.file).name));
|
|
892
|
+
const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
893
|
+
if (output.type !== "asset") return [];
|
|
894
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
895
|
+
return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(node_path.default.posix.parse(file).name) ? [file] : [];
|
|
896
|
+
});
|
|
897
|
+
return candidates.length === 1 ? candidates[0] : void 0;
|
|
898
|
+
}
|
|
899
|
+
function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
|
|
900
|
+
if (options.targetByFile.size === 0) return 0;
|
|
901
|
+
const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
|
|
902
|
+
if (!runtimeRootFile) return 0;
|
|
903
|
+
const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
|
|
904
|
+
if (frameworkRootFiles.length !== 1) return 0;
|
|
905
|
+
const frameworkRootFile = frameworkRootFiles[0];
|
|
906
|
+
const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile))?.[1];
|
|
907
|
+
const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(frameworkRootFile))?.[1];
|
|
908
|
+
if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
|
|
909
|
+
const runtimeSource = runtimeOutput.source.toString();
|
|
910
|
+
const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
|
|
911
|
+
if (importedRuntimeFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedRuntimeFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(frameworkRootFile)) return 0;
|
|
912
|
+
const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
|
|
913
|
+
if (importedFrameworkFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFrameworkFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile)) return 0;
|
|
914
|
+
const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
|
|
915
|
+
runtimeOutput.source = nextSource;
|
|
916
|
+
options.recordCssAssetResult?.(runtimeRootFile, nextSource);
|
|
917
|
+
options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
|
|
918
|
+
options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
|
|
919
|
+
return 1;
|
|
920
|
+
}
|
|
921
|
+
function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
|
|
922
|
+
return enabled === true;
|
|
923
|
+
}
|
|
924
|
+
//#endregion
|
|
925
|
+
//#region src/bundlers/vite/generate-bundle/framework-style-memory.ts
|
|
926
|
+
function createFrameworkStyleMemory(targetByFile) {
|
|
927
|
+
const sources = /* @__PURE__ */ new Map();
|
|
928
|
+
return { prepare(bundle, removedFiles) {
|
|
929
|
+
for (const file of removedFiles) {
|
|
930
|
+
const key = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
931
|
+
sources.delete(key);
|
|
932
|
+
for (const [source, target] of targetByFile) if (require_source_candidate_scan_signature.normalizeOutputPathKey(source) === key || require_source_candidate_scan_signature.normalizeOutputPathKey(target) === key) {
|
|
933
|
+
sources.delete(require_source_candidate_scan_signature.normalizeOutputPathKey(source));
|
|
934
|
+
targetByFile.delete(source);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
const currentFiles = new Set(Object.entries(bundle).map(([file, asset]) => require_source_candidate_scan_signature.normalizeOutputPathKey(asset.fileName || file)));
|
|
938
|
+
for (const [file, asset] of sources) if (!currentFiles.has(file)) bundle[file] = { ...asset };
|
|
939
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
940
|
+
for (const [file, asset] of Object.entries(bundle)) {
|
|
941
|
+
if (asset.type !== "asset" || !isRootMiniProgramStyleOutputFile$1(asset.fileName || file)) continue;
|
|
942
|
+
const source = typeof asset.source === "string" ? asset.source : node_buffer.Buffer.from(asset.source).toString();
|
|
943
|
+
if (require_v4_generation_core.hasBundlerGeneratedCssMarker(source)) sources.delete(require_source_candidate_scan_signature.normalizeOutputPathKey(asset.fileName || file));
|
|
944
|
+
else inputs.set(require_source_candidate_scan_signature.normalizeOutputPathKey(asset.fileName || file), {
|
|
945
|
+
...asset,
|
|
946
|
+
source
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
return () => {
|
|
950
|
+
const mappedFiles = new Set([...targetByFile.keys()].map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
951
|
+
for (const file of sources.keys()) if (!mappedFiles.has(file)) sources.delete(file);
|
|
952
|
+
for (const [file, asset] of inputs) if (mappedFiles.has(file)) sources.set(file, asset);
|
|
953
|
+
};
|
|
954
|
+
} };
|
|
955
|
+
}
|
|
956
|
+
//#endregion
|
|
835
957
|
//#region src/bundlers/vite/processed-css-assets/cleanup.ts
|
|
836
958
|
function collectCssImportAtRuleCss(css) {
|
|
837
959
|
if (!css.includes("@import")) return [];
|
|
@@ -869,7 +991,7 @@ function restoreCssImportAtRules(source, filtered, file) {
|
|
|
869
991
|
return require_web.appendCss(missingImports.join("\n"), filtered);
|
|
870
992
|
}
|
|
871
993
|
function removeCommentOnlyAtRules(css) {
|
|
872
|
-
if (!
|
|
994
|
+
if (!(0, _weapp_tailwindcss_postcss.hasEmptyCssBlockCandidate)(css)) return css;
|
|
873
995
|
try {
|
|
874
996
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
875
997
|
let changed = false;
|
|
@@ -1294,7 +1416,7 @@ function isRuleCoveredByRootCss(rule, coverage) {
|
|
|
1294
1416
|
return rootDeclarations != null && declarationKeys.every((declaration) => rootDeclarations.has(declaration));
|
|
1295
1417
|
});
|
|
1296
1418
|
}
|
|
1297
|
-
function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
1419
|
+
function removeScopedCssCoveredByRootStyleSources(css, rootSources, preserveRuntimeProperties = false) {
|
|
1298
1420
|
if (!hasVueScopedAttr(css)) return css;
|
|
1299
1421
|
const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
|
|
1300
1422
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
@@ -1308,13 +1430,14 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
|
1308
1430
|
}
|
|
1309
1431
|
});
|
|
1310
1432
|
root.walkRules((rule) => {
|
|
1433
|
+
if (preserveRuntimeProperties && (0, _weapp_tailwindcss_postcss.isTailwindRuntimePropertyRule)(rule)) return;
|
|
1311
1434
|
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule)) {
|
|
1312
1435
|
rule.remove();
|
|
1313
1436
|
changed = true;
|
|
1314
1437
|
}
|
|
1315
1438
|
});
|
|
1316
1439
|
root.walkAtRules((atRule) => {
|
|
1317
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
1440
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || !preserveRuntimeProperties && isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
1318
1441
|
atRule.remove();
|
|
1319
1442
|
changed = true;
|
|
1320
1443
|
return;
|
|
@@ -1329,8 +1452,8 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
|
1329
1452
|
return css;
|
|
1330
1453
|
}
|
|
1331
1454
|
}
|
|
1332
|
-
function removeScopedTailwindPreflightCss(css) {
|
|
1333
|
-
return removeScopedCssCoveredByRootStyleSources(css, []);
|
|
1455
|
+
function removeScopedTailwindPreflightCss(css, options) {
|
|
1456
|
+
return removeScopedCssCoveredByRootStyleSources(css, [], options?.preserveRuntimeProperties);
|
|
1334
1457
|
}
|
|
1335
1458
|
function collectSingleViteGeneratedCssMarkerFile(rawSource) {
|
|
1336
1459
|
const blocks = require_v4_generation_core.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
@@ -1359,237 +1482,74 @@ function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
|
1359
1482
|
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule))) {
|
|
1360
1483
|
rule.remove();
|
|
1361
1484
|
changed = true;
|
|
1362
|
-
}
|
|
1363
|
-
});
|
|
1364
|
-
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
1365
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
1366
|
-
atRule.remove();
|
|
1367
|
-
changed = true;
|
|
1368
|
-
return;
|
|
1369
|
-
}
|
|
1370
|
-
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
1371
|
-
atRule.remove();
|
|
1372
|
-
changed = true;
|
|
1373
|
-
}
|
|
1374
|
-
});
|
|
1375
|
-
root.walkComments((comment) => {
|
|
1376
|
-
if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
|
|
1377
|
-
comment.remove();
|
|
1378
|
-
changed = true;
|
|
1379
|
-
return;
|
|
1380
|
-
}
|
|
1381
|
-
if (!comment.text.trim().startsWith("tokens:")) return;
|
|
1382
|
-
const next = comment.next();
|
|
1383
|
-
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
1384
|
-
comment.remove();
|
|
1385
|
-
changed = true;
|
|
1386
|
-
});
|
|
1387
|
-
if (changed)
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
try {
|
|
1394
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1395
|
-
let changed = false;
|
|
1396
|
-
root.each((node) => {
|
|
1397
|
-
if (node.type !== "comment" || !node.text.trim().startsWith("tokens:")) return;
|
|
1398
|
-
const next = node.next();
|
|
1399
|
-
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
1400
|
-
node.remove();
|
|
1401
|
-
changed = true;
|
|
1402
|
-
});
|
|
1403
|
-
return changed ? root.toString().trim() : css;
|
|
1404
|
-
} catch {
|
|
1405
|
-
return css;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
1409
|
-
let updated = 0;
|
|
1410
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1411
|
-
if (output.type !== "asset") continue;
|
|
1412
|
-
const file = require_web.getAssetFile(bundleFile, output);
|
|
1413
|
-
const rawSource = require_web.readAssetSource(output);
|
|
1414
|
-
const hasScopedCss = hasVueScopedAttr(rawSource);
|
|
1415
|
-
const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
|
|
1416
|
-
const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && require_web.isCssOutputFile(file) && !require_web.isMiniProgramStyleOutputFile(file);
|
|
1417
|
-
if (!(options.cssMatcher(file) || hasScopedCss && require_web.isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || require_web.isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
|
|
1418
|
-
const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
|
|
1419
|
-
if (nextCss === rawSource) continue;
|
|
1420
|
-
output.source = nextCss;
|
|
1421
|
-
options.recordCssAssetResult?.(file, nextCss);
|
|
1422
|
-
options.onUpdate?.(file, rawSource, nextCss);
|
|
1423
|
-
options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
|
|
1424
|
-
updated++;
|
|
1425
|
-
}
|
|
1426
|
-
return updated;
|
|
1427
|
-
}
|
|
1428
|
-
//#endregion
|
|
1429
|
-
//#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
|
|
1430
|
-
function applyViteAssetEmissionPlan(plan, options) {
|
|
1431
|
-
for (const operation of plan.operations()) {
|
|
1432
|
-
if (operation.kind === "delete") {
|
|
1433
|
-
delete options.bundle[operation.assetId];
|
|
1434
|
-
continue;
|
|
1435
|
-
}
|
|
1436
|
-
const writeTarget = options.writeTargets?.get(operation.assetId);
|
|
1437
|
-
const existing = options.bundle[operation.assetId];
|
|
1438
|
-
const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
|
|
1439
|
-
if (asset) {
|
|
1440
|
-
asset.source = operation.source;
|
|
1441
|
-
continue;
|
|
1442
|
-
}
|
|
1443
|
-
const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
|
|
1444
|
-
if (replayAsset) options.bundle[operation.assetId] = replayAsset;
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
//#endregion
|
|
1448
|
-
//#region src/bundlers/vite/generate-bundle/root-style-output.ts
|
|
1449
|
-
function isRootMiniProgramStyleOutputFile$1(file) {
|
|
1450
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1451
|
-
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
1452
|
-
}
|
|
1453
|
-
function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
1454
|
-
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
1455
|
-
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
1456
|
-
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
1457
|
-
const baseDir = targetDir === "." ? "" : targetDir;
|
|
1458
|
-
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
1459
|
-
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
1460
|
-
}
|
|
1461
|
-
function createCssImportShell$1(targetFile, importedFile) {
|
|
1462
|
-
return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
|
|
1463
|
-
}
|
|
1464
|
-
function resolveSingleCssImportOutputFile(targetFile, css) {
|
|
1465
|
-
let importedFile;
|
|
1466
|
-
try {
|
|
1467
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("import", (atRule) => {
|
|
1468
|
-
if (importedFile !== void 0) return;
|
|
1469
|
-
const request = require_generator.parseImportRequest(atRule.params);
|
|
1470
|
-
if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
|
|
1471
|
-
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
1472
|
-
if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
|
|
1473
|
-
const targetDir = node_path.default.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
1474
|
-
importedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
1475
|
-
});
|
|
1476
|
-
} catch {}
|
|
1477
|
-
return importedFile;
|
|
1478
|
-
}
|
|
1479
|
-
function createRootMiniProgramOriginStyleOutputFile(file) {
|
|
1480
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1481
|
-
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
|
|
1482
|
-
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
1483
|
-
}
|
|
1484
|
-
function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
|
|
1485
|
-
return enabled === true;
|
|
1486
|
-
}
|
|
1487
|
-
function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
|
|
1488
|
-
return !options.isWebGeneratorTarget && options.matchesCss && require_web.isRootStyleOutputFile(options.file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
|
|
1489
|
-
}
|
|
1490
|
-
function resolveFrameworkRootImportShellPlan(options) {
|
|
1491
|
-
const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
1492
|
-
css: options.rawSource,
|
|
1493
|
-
file: options.rootImportShellOutputFile,
|
|
1494
|
-
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
1495
|
-
matchesCss: options.matchesCss,
|
|
1496
|
-
shouldKeep: options.shouldKeep
|
|
1497
|
-
});
|
|
1498
|
-
if (isCurrentImportShell) {
|
|
1499
|
-
const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
|
|
1500
|
-
return {
|
|
1501
|
-
isCurrentImportShell,
|
|
1502
|
-
reusableTarget: options.rememberedTarget,
|
|
1503
|
-
targetToRemember: importedFile && require_web.isRootStyleOutputFile(importedFile) ? importedFile : void 0
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
if (options.rememberedTarget) return {
|
|
1507
|
-
isCurrentImportShell,
|
|
1508
|
-
reusableTarget: options.rememberedTarget,
|
|
1509
|
-
targetToRemember: void 0
|
|
1510
|
-
};
|
|
1511
|
-
if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(options.assetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
|
|
1512
|
-
isCurrentImportShell,
|
|
1513
|
-
reusableTarget: void 0,
|
|
1514
|
-
targetToRemember: void 0
|
|
1515
|
-
};
|
|
1516
|
-
const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(options.rootImportShellOutputFile)));
|
|
1517
|
-
const target = targets.size === 1 ? [...targets][0] : void 0;
|
|
1518
|
-
return {
|
|
1519
|
-
isCurrentImportShell,
|
|
1520
|
-
reusableTarget: target,
|
|
1521
|
-
targetToRemember: target
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
1525
|
-
if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
|
|
1526
|
-
const plan = new require_compiler.AssetEmissionPlan();
|
|
1527
|
-
const writeTargets = /* @__PURE__ */ new Map();
|
|
1528
|
-
let restored = 0;
|
|
1529
|
-
for (const [sourceFile, targetFile] of options.targetByFile) {
|
|
1530
|
-
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !require_web.isRootStyleOutputFile(sourceFile) || !require_web.isRootStyleOutputFile(targetFile) || require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile)) continue;
|
|
1531
|
-
const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(candidate.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile))?.[1];
|
|
1532
|
-
if (output?.type !== "asset") continue;
|
|
1533
|
-
const rawSource = output.source.toString();
|
|
1534
|
-
if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
|
|
1535
|
-
const nextSource = createCssImportShell$1(sourceFile, targetFile);
|
|
1536
|
-
if (rawSource === nextSource) continue;
|
|
1537
|
-
plan.write(sourceFile, nextSource);
|
|
1538
|
-
writeTargets.set(sourceFile, output);
|
|
1539
|
-
options.recordCssAssetResult?.(sourceFile, nextSource);
|
|
1540
|
-
options.onUpdate?.(sourceFile, rawSource, nextSource);
|
|
1541
|
-
options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
|
|
1542
|
-
restored++;
|
|
1543
|
-
}
|
|
1544
|
-
applyViteAssetEmissionPlan(plan, {
|
|
1545
|
-
bundle,
|
|
1546
|
-
writeTargets
|
|
1547
|
-
});
|
|
1548
|
-
return restored;
|
|
1549
|
-
}
|
|
1550
|
-
function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
|
|
1551
|
-
const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
1552
|
-
if (output.type !== "chunk") return [];
|
|
1553
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
1554
|
-
if (file.includes("/")) return [];
|
|
1555
|
-
return [{
|
|
1556
|
-
file,
|
|
1557
|
-
isEntry: output.isEntry === true
|
|
1558
|
-
}];
|
|
1559
|
-
});
|
|
1560
|
-
const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
|
|
1561
|
-
const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => node_path.default.posix.parse(chunk.file).name));
|
|
1562
|
-
const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
1563
|
-
if (output.type !== "asset") return [];
|
|
1564
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
1565
|
-
return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(node_path.default.posix.parse(file).name) ? [file] : [];
|
|
1566
|
-
});
|
|
1567
|
-
return candidates.length === 1 ? candidates[0] : void 0;
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
1488
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
1489
|
+
atRule.remove();
|
|
1490
|
+
changed = true;
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
1494
|
+
atRule.remove();
|
|
1495
|
+
changed = true;
|
|
1496
|
+
}
|
|
1497
|
+
});
|
|
1498
|
+
root.walkComments((comment) => {
|
|
1499
|
+
if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
|
|
1500
|
+
comment.remove();
|
|
1501
|
+
changed = true;
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
if (!comment.text.trim().startsWith("tokens:")) return;
|
|
1505
|
+
const next = comment.next();
|
|
1506
|
+
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
1507
|
+
comment.remove();
|
|
1508
|
+
changed = true;
|
|
1509
|
+
});
|
|
1510
|
+
if (changed) {
|
|
1511
|
+
(0, _weapp_tailwindcss_postcss.removeUnusedMiniProgramContentInit)(root);
|
|
1512
|
+
nextCss = root.toString().trim();
|
|
1513
|
+
}
|
|
1514
|
+
} catch {}
|
|
1515
|
+
return require_web.hasNonCommentCss(nextCss) ? nextCss : "";
|
|
1568
1516
|
}
|
|
1569
|
-
function
|
|
1570
|
-
if (
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
runtimeOutput.source = nextSource;
|
|
1586
|
-
options.recordCssAssetResult?.(runtimeRootFile, nextSource);
|
|
1587
|
-
options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
|
|
1588
|
-
options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
|
|
1589
|
-
return 1;
|
|
1517
|
+
function removeDanglingCssSourceTraceComments(css) {
|
|
1518
|
+
if (!css.includes("/* tokens:")) return css;
|
|
1519
|
+
try {
|
|
1520
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1521
|
+
let changed = false;
|
|
1522
|
+
root.each((node) => {
|
|
1523
|
+
if (node.type !== "comment" || !node.text.trim().startsWith("tokens:")) return;
|
|
1524
|
+
const next = node.next();
|
|
1525
|
+
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
1526
|
+
node.remove();
|
|
1527
|
+
changed = true;
|
|
1528
|
+
});
|
|
1529
|
+
return changed ? root.toString().trim() : css;
|
|
1530
|
+
} catch {
|
|
1531
|
+
return css;
|
|
1532
|
+
}
|
|
1590
1533
|
}
|
|
1591
|
-
function
|
|
1592
|
-
|
|
1534
|
+
function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
1535
|
+
let updated = 0;
|
|
1536
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1537
|
+
if (output.type !== "asset") continue;
|
|
1538
|
+
const file = require_web.getAssetFile(bundleFile, output);
|
|
1539
|
+
const rawSource = require_web.readAssetSource(output);
|
|
1540
|
+
const hasScopedCss = hasVueScopedAttr(rawSource);
|
|
1541
|
+
const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
|
|
1542
|
+
const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && require_web.isCssOutputFile(file) && !require_web.isMiniProgramStyleOutputFile(file);
|
|
1543
|
+
if (!(options.cssMatcher(file) || hasScopedCss && require_web.isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || require_web.isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
|
|
1544
|
+
const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
|
|
1545
|
+
if (nextCss === rawSource) continue;
|
|
1546
|
+
output.source = nextCss;
|
|
1547
|
+
options.recordCssAssetResult?.(file, nextCss);
|
|
1548
|
+
options.onUpdate?.(file, rawSource, nextCss);
|
|
1549
|
+
options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
|
|
1550
|
+
updated++;
|
|
1551
|
+
}
|
|
1552
|
+
return updated;
|
|
1593
1553
|
}
|
|
1594
1554
|
//#endregion
|
|
1595
1555
|
//#region src/bundlers/vite/processed-css-assets/injection-plan.ts
|
|
@@ -1743,10 +1703,15 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
1743
1703
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1744
1704
|
if (output.type !== "asset") continue;
|
|
1745
1705
|
const file = require_web.getAssetFile(bundleFile, output);
|
|
1746
|
-
if (!require_web.isCssOutputFile(file)
|
|
1706
|
+
if (!require_web.isCssOutputFile(file)) continue;
|
|
1747
1707
|
const rawSource = require_web.readAssetSource(output);
|
|
1748
|
-
let nextCss = require_web.resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
1749
1708
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
1709
|
+
if (singleMarkerFile) {
|
|
1710
|
+
require_web.getActiveViteSourceOutputRelationOwner()?.recordOwnedOutput(singleMarkerFile, file);
|
|
1711
|
+
options.debug?.("css marker ownership: %s -> %s", singleMarkerFile, file);
|
|
1712
|
+
}
|
|
1713
|
+
if (!options.isViteProcessedCssAsset?.(output, file)) continue;
|
|
1714
|
+
let nextCss = require_web.resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
1750
1715
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
1751
1716
|
nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
|
|
1752
1717
|
if (nextCss !== rawSource) {
|
|
@@ -1858,7 +1823,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
1858
1823
|
}
|
|
1859
1824
|
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
1860
1825
|
const mainFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
1861
|
-
const normalizedOriginalCss = measure("normalizeTarget", () => require_web.normalizeInjectableCssForTargetWithImports(transformCss(require_web.removeTailwindEntryDirectivesFromCss(originalSource), file), file));
|
|
1826
|
+
const normalizedOriginalCss = measure("normalizeTarget", () => require_web.normalizeInjectableCssForTargetWithImports(transformCss(require_web.removeTailwindEntryDirectivesFromCss(originalSource, options.createCssPipelineContext?.(file)?.currentGeneratorBranch?.isWeb === true), file), file));
|
|
1862
1827
|
let nextCss = normalizedOriginalCss.css;
|
|
1863
1828
|
const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
|
|
1864
1829
|
const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
|
|
@@ -2156,7 +2121,7 @@ function createCssAssetEmitter(context, bundle) {
|
|
|
2156
2121
|
return (fileName, source) => {
|
|
2157
2122
|
const fileNameKey = require_source_candidate_scan_signature.normalizeOutputPathKey(fileName);
|
|
2158
2123
|
const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
|
|
2159
|
-
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
|
|
2124
|
+
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset" && "source" in existing) {
|
|
2160
2125
|
existing.source = source;
|
|
2161
2126
|
return existing;
|
|
2162
2127
|
}
|
|
@@ -2264,6 +2229,10 @@ function processViteCssCacheTask(options) {
|
|
|
2264
2229
|
function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash) {
|
|
2265
2230
|
return `${cssRuntimeSignature}:${cssRuntimeAffectingHash}`;
|
|
2266
2231
|
}
|
|
2232
|
+
/** 入口重放的干净生成结果,避免和已合并框架贡献的产物缓存混用。 */
|
|
2233
|
+
function createGeneratedReplayCacheKey(outputFile) {
|
|
2234
|
+
return `${require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile)}::__generated_replay__`;
|
|
2235
|
+
}
|
|
2267
2236
|
function normalizeRememberedSourceIdentity(file) {
|
|
2268
2237
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2269
2238
|
}
|
|
@@ -2303,9 +2272,23 @@ function mergeRememberedCssSources(sources, outputFile) {
|
|
|
2303
2272
|
}
|
|
2304
2273
|
function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
2305
2274
|
const groups = /* @__PURE__ */ new Map();
|
|
2275
|
+
const outputFiles = [...styleOutputFiles ?? []];
|
|
2276
|
+
const currentOutputs = new Set(outputFiles.map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
2277
|
+
const relationOwner = require_web.getActiveViteSourceOutputRelationOwner();
|
|
2306
2278
|
for (const [key, remembered] of sources ?? []) {
|
|
2279
|
+
const ownedOutputs = [...relationOwner?.getOwnedOutputs(remembered.sourceFile) ?? []].filter((file) => currentOutputs.has(require_source_candidate_scan_signature.normalizeOutputPathKey(file)) && opts.cssMatcher(file));
|
|
2280
|
+
if (ownedOutputs.length === 1) {
|
|
2281
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(ownedOutputs[0]);
|
|
2282
|
+
const group = groups.get(outputKey) ?? [];
|
|
2283
|
+
group.push({
|
|
2284
|
+
key,
|
|
2285
|
+
remembered
|
|
2286
|
+
});
|
|
2287
|
+
groups.set(outputKey, group);
|
|
2288
|
+
continue;
|
|
2289
|
+
}
|
|
2307
2290
|
const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
|
|
2308
|
-
const resolvedOutputFile = require_web.CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? require_web.resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension,
|
|
2291
|
+
const resolvedOutputFile = require_web.CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? require_web.resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles) : require_web.resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles);
|
|
2309
2292
|
const rememberedOutputFile = remembered.outputFile.replace(/[?#].*$/, "");
|
|
2310
2293
|
const outputFile = opts.cssMatcher(rememberedOutputFile) && !require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedOutputFile).includes("/") && require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedOutputFile.replace(/[?#].*$/, "")) ? remembered.outputFile : resolvedOutputFile;
|
|
2311
2294
|
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
@@ -2901,6 +2884,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2901
2884
|
runtimeAffectingSignatureByFile: snapshot.runtimeAffectingSignatureByFile
|
|
2902
2885
|
}) : "";
|
|
2903
2886
|
const { cssCacheKey, cssHashKey, cssSharedCacheKey, cssTaskHash, rememberedCssRuntimeSignature } = resolveViteCssTransformCachePlan({
|
|
2887
|
+
cssBundleSourceHash: isWebGeneratorTarget ? cache.computeHash(rawSource) : void 0,
|
|
2904
2888
|
cssIsMainChunk: cssHandlerOptions2.isMainChunk === true,
|
|
2905
2889
|
cssRuntimeAffectingHash,
|
|
2906
2890
|
cssShareScope,
|
|
@@ -3506,13 +3490,15 @@ function resolveViteCssTransformCachePlan(options) {
|
|
|
3506
3490
|
options.cssIsMainChunk ? "1" : "0",
|
|
3507
3491
|
options.cssRuntimeAffectingHash,
|
|
3508
3492
|
options.scopedGeneratorCandidateSignature,
|
|
3509
|
-
options.sourceTraceSignature
|
|
3493
|
+
options.sourceTraceSignature,
|
|
3494
|
+
...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
|
|
3510
3495
|
].join(":"),
|
|
3511
3496
|
cssTaskHash: [
|
|
3512
3497
|
options.cssRuntimeAffectingHash,
|
|
3513
3498
|
options.scopedGeneratorCandidateSignature,
|
|
3514
3499
|
options.sourceTraceSignature,
|
|
3515
|
-
options.linkedImpactSignature
|
|
3500
|
+
options.linkedImpactSignature,
|
|
3501
|
+
...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
|
|
3516
3502
|
].join(":"),
|
|
3517
3503
|
rememberedCssRuntimeSignature
|
|
3518
3504
|
};
|
|
@@ -3544,6 +3530,27 @@ function applyViteCssTransformTaskResult(options) {
|
|
|
3544
3530
|
return result.css;
|
|
3545
3531
|
}
|
|
3546
3532
|
//#endregion
|
|
3533
|
+
//#region src/bundlers/vite/generate-bundle/web-css-module.ts
|
|
3534
|
+
/** 仅替换 transform 阶段标记的模块区间,保留 bundler 合并的前后样式及其层叠顺序。 */
|
|
3535
|
+
function replaceWebCssModule(source, sourceFile, generated) {
|
|
3536
|
+
const markers = [...source.matchAll(/\/\*!?\s*weapp-tailwindcss vite-generated-css(-end)?\s*:\s*([^\s*]+)\s*\*\//gi)];
|
|
3537
|
+
const sourceKey = require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, ""));
|
|
3538
|
+
let cursor = 0;
|
|
3539
|
+
let result = "";
|
|
3540
|
+
let replaced = false;
|
|
3541
|
+
for (let index = 0; index < markers.length; index++) {
|
|
3542
|
+
const start = markers[index];
|
|
3543
|
+
const end = markers[index + 1];
|
|
3544
|
+
if (start[1] || !end?.[1] || start[2] !== end[2]) continue;
|
|
3545
|
+
if (require_source_candidate_scan_signature.normalizeOutputPathKey(decodeURIComponent(start[2])) !== sourceKey) continue;
|
|
3546
|
+
result += source.slice(cursor, start.index) + generated;
|
|
3547
|
+
cursor = end.index + end[0].length;
|
|
3548
|
+
replaced = true;
|
|
3549
|
+
index++;
|
|
3550
|
+
}
|
|
3551
|
+
return replaced ? result + source.slice(cursor) : void 0;
|
|
3552
|
+
}
|
|
3553
|
+
//#endregion
|
|
3547
3554
|
//#region src/bundlers/vite/generate-bundle/css-transform-task.ts
|
|
3548
3555
|
function resolveBundleUserRawSource(options) {
|
|
3549
3556
|
return options.vitePipelineCssAsset && !require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource) && require_web.normalizeCssSourceForCompare(options.rawSource) !== require_web.normalizeCssSourceForCompare(options.generatorRawSource) ? options.normalizeMiniProgramGeneratorRawSource(options.normalizeGeneratorUserRawSource(options.rawSource, options.generatorSourceFile, options.assetSourceFile), options.outputFile) : void 0;
|
|
@@ -3551,7 +3558,7 @@ function resolveBundleUserRawSource(options) {
|
|
|
3551
3558
|
async function executeViteCssTransformTask(options) {
|
|
3552
3559
|
await options.runtimeState.readyPromise;
|
|
3553
3560
|
const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
|
|
3554
|
-
if (require_web.hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget && require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource)) {
|
|
3561
|
+
if (require_web.hasTailwindGenerationSource(options.generatorRawSource) && (!options.isWebGeneratorTarget || !require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource) || require_generator.hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true })) || !options.isWebGeneratorTarget && require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource)) {
|
|
3555
3562
|
const bundleUserRawSource = resolveBundleUserRawSource(options);
|
|
3556
3563
|
const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
3557
3564
|
const generated = await (options.generateCss ?? require_v4_generation_core.generateTailwindV4Css)({
|
|
@@ -3575,7 +3582,7 @@ async function executeViteCssTransformTask(options) {
|
|
|
3575
3582
|
userRawSource: generatorUserRawSource || void 0
|
|
3576
3583
|
});
|
|
3577
3584
|
if (generated) {
|
|
3578
|
-
const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(generated.css)));
|
|
3585
|
+
const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(options.isWebGeneratorTarget ? replaceWebCssModule(options.rawSource, options.generatorSourceFile, generated.css) ?? generated.css : generated.css)));
|
|
3579
3586
|
return {
|
|
3580
3587
|
classSet: generated.classSet,
|
|
3581
3588
|
css,
|
|
@@ -3645,7 +3652,7 @@ function finalizeMiniProgramCssAssetStructures(bundle, options) {
|
|
|
3645
3652
|
const file = output.fileName || bundleFile;
|
|
3646
3653
|
if (!options.cssMatcher(file) || options.files && !options.files.has(file)) continue;
|
|
3647
3654
|
const rawSource = readAssetSource$1(output);
|
|
3648
|
-
const outputCss =
|
|
3655
|
+
const outputCss = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCssStructure)(rawSource);
|
|
3649
3656
|
if (outputCss === rawSource) continue;
|
|
3650
3657
|
plan.write(file, outputCss);
|
|
3651
3658
|
writeTargets.set(file, output);
|
|
@@ -3672,7 +3679,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
3672
3679
|
const rawSource = readAssetSource$1(output);
|
|
3673
3680
|
if (rawSource.trim().length === 0) continue;
|
|
3674
3681
|
if (options.lastCssResultByFile?.has(file)) {
|
|
3675
|
-
const structurallyCleanSource =
|
|
3682
|
+
const structurallyCleanSource = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCssStructure)(rawSource);
|
|
3676
3683
|
const outputCss = (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(structurallyCleanSource);
|
|
3677
3684
|
if (outputCss !== rawSource) {
|
|
3678
3685
|
plan.write(file, outputCss);
|
|
@@ -3685,7 +3692,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
3685
3692
|
continue;
|
|
3686
3693
|
}
|
|
3687
3694
|
if (!shouldFinalizeMiniProgramCssAsset(rawSource)) {
|
|
3688
|
-
const structurallyCleanSource =
|
|
3695
|
+
const structurallyCleanSource = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCssStructure)(rawSource);
|
|
3689
3696
|
if (structurallyCleanSource !== rawSource) {
|
|
3690
3697
|
plan.write(file, structurallyCleanSource);
|
|
3691
3698
|
writeTargets.set(file, output);
|
|
@@ -3707,7 +3714,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
3707
3714
|
},
|
|
3708
3715
|
cssPresetEnv: {}
|
|
3709
3716
|
});
|
|
3710
|
-
const structurallyCleanCss =
|
|
3717
|
+
const structurallyCleanCss = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCssStructure)(css);
|
|
3711
3718
|
const outputCss = (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(structurallyCleanCss);
|
|
3712
3719
|
if (outputCss === rawSource) continue;
|
|
3713
3720
|
plan.write(file, outputCss);
|
|
@@ -4016,9 +4023,58 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
4016
4023
|
return updated;
|
|
4017
4024
|
}
|
|
4018
4025
|
//#endregion
|
|
4026
|
+
//#region src/bundlers/vite/generate-bundle/finalize/sync-processed-css.ts
|
|
4027
|
+
function syncProcessedCss(options) {
|
|
4028
|
+
const { bundle, opts, cssPipelineStrategy, createCssPipelineContext, isViteProcessedCssAsset, markCssAssetProcessed, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles, transformWebTargetCss, debug, recordTimingDetail, getViteProcessedCssAssetResults, onUpdate, pendingRememberedCssReplayUpdates } = options;
|
|
4029
|
+
const collectStartedAt = performance.now();
|
|
4030
|
+
collectViteProcessedCssAssetResults(bundle, {
|
|
4031
|
+
opts,
|
|
4032
|
+
cssPipelineStrategy,
|
|
4033
|
+
createCssPipelineContext,
|
|
4034
|
+
isViteProcessedCssAsset,
|
|
4035
|
+
markCssAssetProcessed,
|
|
4036
|
+
recordCssAssetResult,
|
|
4037
|
+
recordViteProcessedCssAssetResult,
|
|
4038
|
+
resolveViteProcessedCssOutputFile: (file) => require_web.resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
|
|
4039
|
+
subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
|
|
4040
|
+
transformCss: transformWebTargetCss,
|
|
4041
|
+
debug
|
|
4042
|
+
});
|
|
4043
|
+
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
4044
|
+
const injectStartedAt = performance.now();
|
|
4045
|
+
const currentResults = new Map([...getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => [require_source_candidate_scan_signature.normalizeOutputPathKey(file), [file, record]]));
|
|
4046
|
+
for (const update of pendingRememberedCssReplayUpdates) {
|
|
4047
|
+
recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
4048
|
+
currentResults.set(require_source_candidate_scan_signature.normalizeOutputPathKey(update.file), [update.file, {
|
|
4049
|
+
css: update.css,
|
|
4050
|
+
injectIntoMain: update.injectIntoMain,
|
|
4051
|
+
outputFile: update.outputFile
|
|
4052
|
+
}]);
|
|
4053
|
+
}
|
|
4054
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
4055
|
+
opts,
|
|
4056
|
+
cssPipelineStrategy,
|
|
4057
|
+
createCssPipelineContext,
|
|
4058
|
+
getViteProcessedCssAssetResults: () => currentResults.values(),
|
|
4059
|
+
markCssAssetProcessed,
|
|
4060
|
+
recordCssAssetResult,
|
|
4061
|
+
transformCss: transformWebTargetCss,
|
|
4062
|
+
shouldRemoveInjectedSourceAsset: (targetFile, record) => {
|
|
4063
|
+
if (record.injectIntoMain === false) return false;
|
|
4064
|
+
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
4065
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
4066
|
+
},
|
|
4067
|
+
debug,
|
|
4068
|
+
onUpdate,
|
|
4069
|
+
recordTimingDetail
|
|
4070
|
+
});
|
|
4071
|
+
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
4072
|
+
return injected;
|
|
4073
|
+
}
|
|
4074
|
+
//#endregion
|
|
4019
4075
|
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
4020
4076
|
async function finalizeGenerateBundle(options) {
|
|
4021
|
-
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug,
|
|
4077
|
+
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, runtime, runtimeState, snapshot, sourceCandidates, state, styleHandler, tasks, timingDetails, transformRuntime, useIncrementalMode } = options;
|
|
4022
4078
|
const tasksStart = performance.now();
|
|
4023
4079
|
if (cssTaskFactories.length > 0) {
|
|
4024
4080
|
const cssConcurrency = resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion);
|
|
@@ -4049,68 +4105,11 @@ async function finalizeGenerateBundle(options) {
|
|
|
4049
4105
|
styleHandler
|
|
4050
4106
|
});
|
|
4051
4107
|
recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
|
|
4052
|
-
const syncViteProcessedCssIntoMainCssAssets = () => {
|
|
4053
|
-
const collectStartedAt = performance.now();
|
|
4054
|
-
collectViteProcessedCssAssetResults(bundle, {
|
|
4055
|
-
opts,
|
|
4056
|
-
cssPipelineStrategy,
|
|
4057
|
-
createCssPipelineContext,
|
|
4058
|
-
isViteProcessedCssAsset,
|
|
4059
|
-
markCssAssetProcessed,
|
|
4060
|
-
recordCssAssetResult,
|
|
4061
|
-
recordViteProcessedCssAssetResult,
|
|
4062
|
-
resolveViteProcessedCssOutputFile: (file) => require_web.resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
|
|
4063
|
-
subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
|
|
4064
|
-
transformCss: transformWebTargetCss,
|
|
4065
|
-
debug
|
|
4066
|
-
});
|
|
4067
|
-
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
4068
|
-
const injectStartedAt = performance.now();
|
|
4069
|
-
let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
4070
|
-
opts,
|
|
4071
|
-
cssPipelineStrategy,
|
|
4072
|
-
createCssPipelineContext,
|
|
4073
|
-
getViteProcessedCssAssetResults,
|
|
4074
|
-
markCssAssetProcessed,
|
|
4075
|
-
recordCssAssetResult,
|
|
4076
|
-
transformCss: transformWebTargetCss,
|
|
4077
|
-
shouldRemoveInjectedSourceAsset: (targetFile, record) => {
|
|
4078
|
-
if (record.injectIntoMain === false) return false;
|
|
4079
|
-
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
4080
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
4081
|
-
},
|
|
4082
|
-
debug,
|
|
4083
|
-
onUpdate,
|
|
4084
|
-
recordTimingDetail
|
|
4085
|
-
});
|
|
4086
|
-
if (pendingRememberedCssReplayUpdates.length > 0) {
|
|
4087
|
-
for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
4088
|
-
injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
4089
|
-
opts,
|
|
4090
|
-
cssPipelineStrategy,
|
|
4091
|
-
createCssPipelineContext,
|
|
4092
|
-
getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
|
|
4093
|
-
css: update.css,
|
|
4094
|
-
injectIntoMain: update.injectIntoMain,
|
|
4095
|
-
outputFile: update.outputFile
|
|
4096
|
-
}]),
|
|
4097
|
-
markCssAssetProcessed,
|
|
4098
|
-
recordCssAssetResult,
|
|
4099
|
-
transformCss: transformWebTargetCss,
|
|
4100
|
-
debug,
|
|
4101
|
-
onUpdate,
|
|
4102
|
-
recordTimingDetail
|
|
4103
|
-
});
|
|
4104
|
-
debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
|
|
4105
|
-
}
|
|
4106
|
-
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
4107
|
-
return injected;
|
|
4108
|
-
};
|
|
4109
4108
|
const processedCssStartedAt = performance.now();
|
|
4110
|
-
|
|
4109
|
+
syncProcessedCss(options);
|
|
4111
4110
|
if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
|
|
4112
4111
|
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
|
|
4113
|
-
|
|
4112
|
+
syncProcessedCss(options);
|
|
4114
4113
|
}
|
|
4115
4114
|
recordTimingDetail("finalize.processedCss", processedCssStartedAt);
|
|
4116
4115
|
const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
|
|
@@ -4341,6 +4340,16 @@ function createJsEntryResolver(jsEntries) {
|
|
|
4341
4340
|
function resolveUniAppXJsTransformEnabled$1(uniAppX) {
|
|
4342
4341
|
return uniAppX === void 0 ? true : require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
4343
4342
|
}
|
|
4343
|
+
/**
|
|
4344
|
+
* generateBundle 里每个 chunk 都会独立转译。
|
|
4345
|
+
* 生产构建再走 moduleGraph 只会把已在产物里的 JS 再 Babel 一遍;增量模式才需要它更新被跳过的 clean chunk。
|
|
4346
|
+
*/
|
|
4347
|
+
function resolveGenerateBundleJsFastPath(options) {
|
|
4348
|
+
return {
|
|
4349
|
+
experimentalJsFastPath: options.experimentalJsFastPath ?? "oxc",
|
|
4350
|
+
moduleGraphEnabled: options.useIncrementalMode
|
|
4351
|
+
};
|
|
4352
|
+
}
|
|
4344
4353
|
function createJsHandlerOptionsFactory(options) {
|
|
4345
4354
|
return (absoluteFilename, extra) => ({
|
|
4346
4355
|
...extra,
|
|
@@ -4394,30 +4403,9 @@ function isUniAppXNativeAppOutDir(outDir) {
|
|
|
4394
4403
|
}
|
|
4395
4404
|
//#endregion
|
|
4396
4405
|
//#region src/uni-app-x/border-preflight.ts
|
|
4397
|
-
const BORDER_PREFLIGHT_CLASS =
|
|
4398
|
-
/** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
|
|
4399
|
-
function hoistUniAppXBorderPreflight(css) {
|
|
4400
|
-
if (!css.includes("weapp-tw-border")) return css;
|
|
4401
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
4402
|
-
const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
|
|
4403
|
-
const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
|
|
4404
|
-
if (!anchor || resets.length === 0) return css;
|
|
4405
|
-
for (const reset of resets) {
|
|
4406
|
-
reset.remove();
|
|
4407
|
-
root.insertBefore(anchor, reset);
|
|
4408
|
-
}
|
|
4409
|
-
return root.toString();
|
|
4410
|
-
}
|
|
4411
|
-
/** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
|
|
4412
|
-
function createUniAppXBorderPreflight(options) {
|
|
4413
|
-
const declarations = (0, _weapp_tailwindcss_postcss.createInjectPreflight)(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
|
|
4414
|
-
if (declarations.length === 0) return;
|
|
4415
|
-
const rule = _weapp_tailwindcss_postcss.postcss.rule({ selector: `.${BORDER_PREFLIGHT_CLASS}` });
|
|
4416
|
-
for (const declaration of declarations) rule.append(_weapp_tailwindcss_postcss.postcss.decl(declaration));
|
|
4417
|
-
return rule.toString();
|
|
4418
|
-
}
|
|
4406
|
+
const BORDER_PREFLIGHT_CLASS = _weapp_tailwindcss_postcss.UNI_APP_X_BORDER_PREFLIGHT_CLASS;
|
|
4419
4407
|
function resolveUniAppXBorderPreflightOptions(options, isWeb) {
|
|
4420
|
-
const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
|
|
4408
|
+
const borderPreflight = isWeb ? void 0 : (0, _weapp_tailwindcss_postcss.createUniAppXBorderPreflight)(options.cssPreflight);
|
|
4421
4409
|
return borderPreflight ? {
|
|
4422
4410
|
borderPreflight,
|
|
4423
4411
|
borderPreflightRange: options.cssPreflightRange
|
|
@@ -4435,7 +4423,7 @@ function injectBorderPreflightClass(ms, node, offset) {
|
|
|
4435
4423
|
const attribute = node.props.find((prop) => prop.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE && prop.name === "class");
|
|
4436
4424
|
if (attribute?.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE) {
|
|
4437
4425
|
if (attribute.value) {
|
|
4438
|
-
if (attribute.value.content.split(/\s+/).includes(
|
|
4426
|
+
if (attribute.value.content.split(/\s+/).includes(BORDER_PREFLIGHT_CLASS)) return;
|
|
4439
4427
|
const start = offset + attribute.value.loc.start.offset;
|
|
4440
4428
|
if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
|
|
4441
4429
|
else {
|
|
@@ -4468,50 +4456,8 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
4468
4456
|
}
|
|
4469
4457
|
//#endregion
|
|
4470
4458
|
//#region src/uni-app-x/vite/author-apply.ts
|
|
4471
|
-
function
|
|
4472
|
-
return
|
|
4473
|
-
}
|
|
4474
|
-
function atRuleKey(name, params) {
|
|
4475
|
-
return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
|
|
4476
|
-
}
|
|
4477
|
-
/**
|
|
4478
|
-
* `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
|
|
4479
|
-
* utilities 和 property 注册复制进 scoped style 模块。
|
|
4480
|
-
*/
|
|
4481
|
-
function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
|
|
4482
|
-
try {
|
|
4483
|
-
const authorRoot = _weapp_tailwindcss_postcss.postcss.parse(require_generator.removeTailwindSourceDirectives(authorCss, { importFallback: true }));
|
|
4484
|
-
const authorSelectors = /* @__PURE__ */ new Set();
|
|
4485
|
-
const authorAtRules = /* @__PURE__ */ new Set();
|
|
4486
|
-
authorRoot.walkRules((rule) => {
|
|
4487
|
-
for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
|
|
4488
|
-
});
|
|
4489
|
-
authorRoot.walkAtRules((atRule) => {
|
|
4490
|
-
if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
|
|
4491
|
-
});
|
|
4492
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(generatedCss);
|
|
4493
|
-
let changed = false;
|
|
4494
|
-
root.walkRules((rule) => {
|
|
4495
|
-
if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
|
|
4496
|
-
rule.remove();
|
|
4497
|
-
changed = true;
|
|
4498
|
-
});
|
|
4499
|
-
root.walkAtRules((atRule) => {
|
|
4500
|
-
if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
|
|
4501
|
-
if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
|
|
4502
|
-
atRule.remove();
|
|
4503
|
-
changed = true;
|
|
4504
|
-
});
|
|
4505
|
-
root.walkComments((comment) => {
|
|
4506
|
-
if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
|
|
4507
|
-
comment.remove();
|
|
4508
|
-
changed = true;
|
|
4509
|
-
}
|
|
4510
|
-
});
|
|
4511
|
-
return changed ? root.toString().trim() : generatedCss;
|
|
4512
|
-
} catch {
|
|
4513
|
-
return generatedCss;
|
|
4514
|
-
}
|
|
4459
|
+
function retainUniAppXAuthorApplyCss(generatedCss, authorCss, options) {
|
|
4460
|
+
return (0, _weapp_tailwindcss_postcss.retainUniAppXAuthorApplyCss)(generatedCss, require_generator.removeTailwindSourceDirectives(authorCss, { importFallback: true }), options);
|
|
4515
4461
|
}
|
|
4516
4462
|
//#endregion
|
|
4517
4463
|
//#region src/uni-app-x/vite/harmony-apply.ts
|
|
@@ -4558,7 +4504,7 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
4558
4504
|
const cssFile = node_path.default.resolve(options.getResolvedConfig()?.root ?? node_process.default.cwd(), `uni-app-x-harmony-apply-${createStableHash(require_web.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)))}.css`);
|
|
4559
4505
|
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
4560
4506
|
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
4561
|
-
addWatchFile: hookContext.addWatchFile
|
|
4507
|
+
...hookContext.addWatchFile ? { addWatchFile: hookContext.addWatchFile.bind(hookContext) } : {},
|
|
4562
4508
|
disableSourceScan: true,
|
|
4563
4509
|
sourceCandidates: [],
|
|
4564
4510
|
transient: true
|
|
@@ -4661,6 +4607,18 @@ function reportStyleWarnings(result) {
|
|
|
4661
4607
|
for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
|
|
4662
4608
|
}
|
|
4663
4609
|
//#endregion
|
|
4610
|
+
//#region src/uni-app-x/vite/style-result.ts
|
|
4611
|
+
/** 将样式处理结果和源码映射统一转换为 Vite 模块结果。 */
|
|
4612
|
+
async function createUniAppXStyleResult(id, result) {
|
|
4613
|
+
reportStyleWarnings(result);
|
|
4614
|
+
const rawPostcssMap = result.map.toJSON();
|
|
4615
|
+
const map = await require_web.formatPostcssSourceMap(rawPostcssMap, require_web.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
4616
|
+
return {
|
|
4617
|
+
code: result.css,
|
|
4618
|
+
map: JSON.stringify(map)
|
|
4619
|
+
};
|
|
4620
|
+
}
|
|
4621
|
+
//#endregion
|
|
4664
4622
|
//#region src/uni-app-x/vite/style-source.ts
|
|
4665
4623
|
const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
|
|
4666
4624
|
function createUniAppXSfcStyleSources() {
|
|
@@ -4829,7 +4787,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
4829
4787
|
//#region src/uni-app-x/vite.ts
|
|
4830
4788
|
let transformUVuePromise;
|
|
4831
4789
|
function loadTransformUVue() {
|
|
4832
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
4790
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-FkqbTBJR.cjs")).then((mod) => mod.transformUVue));
|
|
4833
4791
|
return transformUVuePromise;
|
|
4834
4792
|
}
|
|
4835
4793
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -4921,19 +4879,12 @@ function createUniAppXPlugins(options) {
|
|
|
4921
4879
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(sourceCode, id) : sourceCode, {
|
|
4922
4880
|
...hookContext,
|
|
4923
4881
|
disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
|
|
4924
|
-
|
|
4882
|
+
...isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? { sourceCandidates: [] } : {},
|
|
4925
4883
|
transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
|
|
4926
4884
|
}) : void 0;
|
|
4927
|
-
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode) : generatedCss : sourceCode;
|
|
4885
|
+
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode, { preserveRuntimeProperties: isWebGeneratorTarget() }) : generatedCss : sourceCode;
|
|
4928
4886
|
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
4929
|
-
|
|
4930
|
-
reportStyleWarnings(postcssResult);
|
|
4931
|
-
const rawPostcssMap = postcssResult.map.toJSON();
|
|
4932
|
-
const postcssMap = await require_web.formatPostcssSourceMap(rawPostcssMap, require_web.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
4933
|
-
return {
|
|
4934
|
-
code: postcssResult.css,
|
|
4935
|
-
map: postcssMap
|
|
4936
|
-
};
|
|
4887
|
+
return createUniAppXStyleResult(id, isWebGeneratorTarget() && typeof generatedCss === "string" && generatedCss.trim().length > 0 ? await (0, _weapp_tailwindcss_postcss.postcss)().process(styleCode, styleHandlerOptions.postcssOptions.options) : await styleHandler(styleCode, styleHandlerOptions));
|
|
4937
4888
|
}
|
|
4938
4889
|
}
|
|
4939
4890
|
const harmonyApply = createUniAppXHarmonyApplyExpander({
|
|
@@ -5017,6 +4968,7 @@ function createUniAppXPlugins(options) {
|
|
|
5017
4968
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
5018
4969
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
5019
4970
|
native: true,
|
|
4971
|
+
localStyleVariants: !isNativeAppBuildTarget(id) && !isWebGeneratorTarget() ? true : void 0,
|
|
5020
4972
|
...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
|
|
5021
4973
|
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
5022
4974
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
@@ -5327,6 +5279,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5327
5279
|
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
5328
5280
|
if (!rememberedCssSource) continue;
|
|
5329
5281
|
const { sourceFile } = rememberedCssSource;
|
|
5282
|
+
if (normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedOutputFile)) || normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile)) || bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
5330
5283
|
const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : require_v4_generation_core.normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
|
|
5331
5284
|
cssOnly: true,
|
|
5332
5285
|
outputFile,
|
|
@@ -5354,21 +5307,11 @@ async function processRememberedCssReplay(options) {
|
|
|
5354
5307
|
const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
|
|
5355
5308
|
const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
|
|
5356
5309
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
5357
|
-
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
|
|
5363
|
-
if (cachedCss != null) {
|
|
5364
|
-
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
|
|
5365
|
-
metrics.css.cacheHits++;
|
|
5366
|
-
debug("css replay cached result into framework root target: %s", outputFile);
|
|
5367
|
-
continue;
|
|
5368
|
-
}
|
|
5369
|
-
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
5370
|
-
}
|
|
5371
|
-
}
|
|
5310
|
+
const shouldMergeReplayIntoFrameworkRootTarget = [...frameworkRootImportShellTargetByFile ?? []].some(([file, target]) => require_source_candidate_scan_signature.normalizeOutputPathKey(target) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) && normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(file))) || outputFile !== rememberedOutputFile && normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile));
|
|
5311
|
+
const generatedReplayKey = createGeneratedReplayCacheKey(outputFile);
|
|
5312
|
+
activeViteCssCacheFiles.add(generatedReplayKey);
|
|
5313
|
+
const cachedGeneratedReplayCss = allRememberedSignaturesFresh && shouldMergeReplayIntoFrameworkRootTarget ? lastCssResultByFile.get(generatedReplayKey) : void 0;
|
|
5314
|
+
if (allRememberedSignaturesFresh && !shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
5372
5315
|
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await require_scoped_generator.createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
5373
5316
|
const sourceTraceTokenSources = sourceTraceSources ? require_v4_generation_core.createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
5374
5317
|
const annotateCss = (css) => require_v4_generation_core.annotateCssSourceTrace(css, {
|
|
@@ -5418,6 +5361,20 @@ async function processRememberedCssReplay(options) {
|
|
|
5418
5361
|
}));
|
|
5419
5362
|
continue;
|
|
5420
5363
|
}
|
|
5364
|
+
if (cachedGeneratedReplayCss) {
|
|
5365
|
+
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
5366
|
+
const start = performance.now();
|
|
5367
|
+
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
5368
|
+
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
5369
|
+
recordCssAssetResult?.(outputFile, cachedGeneratedReplayCss);
|
|
5370
|
+
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedGeneratedReplayCss, sourceFile, outputFile, true));
|
|
5371
|
+
metrics.css.elapsed += measureElapsed(start);
|
|
5372
|
+
metrics.css.cacheHits++;
|
|
5373
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, cachedGeneratedReplayCss);
|
|
5374
|
+
debug("css replay reuse generated cache: %s bytes=%d", outputFile, cachedGeneratedReplayCss.length);
|
|
5375
|
+
}));
|
|
5376
|
+
continue;
|
|
5377
|
+
}
|
|
5421
5378
|
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
5422
5379
|
const start = performance.now();
|
|
5423
5380
|
const generated = await require_v4_generation_core.generateTailwindV4Css({
|
|
@@ -5434,11 +5391,12 @@ async function processRememberedCssReplay(options) {
|
|
|
5434
5391
|
generatorPlatform,
|
|
5435
5392
|
styleHandler,
|
|
5436
5393
|
debug,
|
|
5437
|
-
previousCss
|
|
5394
|
+
previousCss: shouldMergeReplayIntoFrameworkRootTarget ? void 0 : previousCss
|
|
5438
5395
|
});
|
|
5439
5396
|
const css = annotateCss(generated?.css ?? (await styleHandler(generatorRawSource, cssHandlerOptions)).css);
|
|
5440
5397
|
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
5441
5398
|
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
|
|
5399
|
+
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, generatedReplayKey, css, cssRuntimeAffectingHash);
|
|
5442
5400
|
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
5443
5401
|
if (generated) {
|
|
5444
5402
|
registerGeneratorDependencies({ addWatchFile }, generated.dependencies);
|
|
@@ -5498,7 +5456,7 @@ function createConfiguredCssSourceRegistry(options) {
|
|
|
5498
5456
|
return {
|
|
5499
5457
|
explicitCssEntryFiles,
|
|
5500
5458
|
getSourceEntries,
|
|
5501
|
-
normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || fallbackFile, options.outDir, options.opts),
|
|
5459
|
+
normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || (fallbackFile ?? ""), options.outDir, options.opts),
|
|
5502
5460
|
resolveMatchedSourceOutputFile: (sourceFile) => resolveOutputFileFromMatchedCssSource({
|
|
5503
5461
|
bundleFiles: options.bundleFiles,
|
|
5504
5462
|
defaultStyleOutputExtension: options.defaultStyleOutputExtension,
|
|
@@ -6208,7 +6166,11 @@ function createGenerateBundleHook$1(context) {
|
|
|
6208
6166
|
const jsEntries = snapshot.jsEntries;
|
|
6209
6167
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
6210
6168
|
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
6211
|
-
const
|
|
6169
|
+
const jsFastPath = resolveGenerateBundleJsFastPath({
|
|
6170
|
+
experimentalJsFastPath: opts.experimentalJsFastPath,
|
|
6171
|
+
useIncrementalMode
|
|
6172
|
+
});
|
|
6173
|
+
const moduleGraphOptions = jsFastPath.moduleGraphEnabled ? createBundleModuleGraphOptions(outDir, jsEntries) : void 0;
|
|
6212
6174
|
const hasRuntimeAffectingChanges = require_scoped_generator.hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
6213
6175
|
const runtimeStart = performance.now();
|
|
6214
6176
|
const forceV4RuntimeRefreshBySource = forceRuntimeRefreshBySource;
|
|
@@ -6318,7 +6280,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
6318
6280
|
debug
|
|
6319
6281
|
});
|
|
6320
6282
|
const createBaseHandlerOptions = createJsHandlerOptionsFactory({
|
|
6321
|
-
getExperimentalJsFastPath: () =>
|
|
6283
|
+
getExperimentalJsFastPath: () => jsFastPath.experimentalJsFastPath,
|
|
6322
6284
|
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
6323
6285
|
moduleGraph: moduleGraphOptions
|
|
6324
6286
|
});
|
|
@@ -6691,8 +6653,11 @@ function createGenerateBundleHook(context) {
|
|
|
6691
6653
|
const relationOwner = require_web.getActiveViteSourceOutputRelationOwner();
|
|
6692
6654
|
const removalConsumer = relationOwner?.createRemovalConsumer();
|
|
6693
6655
|
const rememberCssSource = context.rememberCssSource;
|
|
6656
|
+
const frameworkRootImportShellTargetByFile = context.frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map();
|
|
6657
|
+
const frameworkStyleMemory = createFrameworkStyleMemory(frameworkRootImportShellTargetByFile);
|
|
6694
6658
|
const runtimeHandler = createGenerateBundleHook$1({
|
|
6695
6659
|
...context,
|
|
6660
|
+
frameworkRootImportShellTargetByFile,
|
|
6696
6661
|
rememberCssSource: rememberCssSource ? (entry, cssRuntimeSignature) => {
|
|
6697
6662
|
relationOwner?.recordOwnedOutput(entry.sourceFile, entry.outputFile);
|
|
6698
6663
|
rememberCssSource(entry, cssRuntimeSignature);
|
|
@@ -6701,9 +6666,11 @@ function createGenerateBundleHook(context) {
|
|
|
6701
6666
|
return async function generateBundle(options, bundle) {
|
|
6702
6667
|
relationOwner?.recordBundle(bundle);
|
|
6703
6668
|
const removedFiles = removalConsumer?.consume(Object.keys(bundle)) ?? [];
|
|
6669
|
+
const rememberFrameworkStyles = frameworkStyleMemory.prepare(bundle, removedFiles);
|
|
6704
6670
|
require_compiler.beginCompilerShadowRun(context.runtimeState);
|
|
6705
6671
|
const runRuntime = () => runWithRemovedBundleFiles(removedFiles, () => runtimeHandler.call(this, options, bundle));
|
|
6706
6672
|
await (relationOwner ? require_web.withViteSourceOutputRelationOwner(relationOwner, runRuntime) : runRuntime());
|
|
6673
|
+
rememberFrameworkStyles();
|
|
6707
6674
|
};
|
|
6708
6675
|
}
|
|
6709
6676
|
//#endregion
|
|
@@ -6715,7 +6682,7 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6715
6682
|
if (!options.matchesCss(file)) continue;
|
|
6716
6683
|
const targets = /* @__PURE__ */ new Set();
|
|
6717
6684
|
_weapp_tailwindcss_postcss.postcss.parse(asset.source.toString()).walkAtRules("import", (rule) => {
|
|
6718
|
-
const request =
|
|
6685
|
+
const request = (0, _weapp_tailwindcss_postcss.parseCssImportSpecifier)(rule.params)?.specifier;
|
|
6719
6686
|
if (request && !/^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i.test(request)) {
|
|
6720
6687
|
const target = node_path.default.posix.normalize(node_path.default.posix.join(node_path.default.posix.dirname(file), request));
|
|
6721
6688
|
if (assets.has(target)) targets.add(target);
|
|
@@ -6746,7 +6713,7 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6746
6713
|
if (!target || !imports.has(target) || reaches(file, target) || reaches(target, file)) continue;
|
|
6747
6714
|
imports.get(file).add(target);
|
|
6748
6715
|
const relative = node_path.default.posix.relative(node_path.default.posix.dirname(file), target);
|
|
6749
|
-
requests.push(`@import ${
|
|
6716
|
+
requests.push(`@import ${(0, _weapp_tailwindcss_postcss.quoteCssImportSpecifier)(relative.startsWith(".") ? relative : `./${relative}`)};\n`);
|
|
6750
6717
|
}
|
|
6751
6718
|
if (requests.length > 0) {
|
|
6752
6719
|
const next = requests.join("") + original;
|
|
@@ -6756,6 +6723,20 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6756
6723
|
}
|
|
6757
6724
|
}
|
|
6758
6725
|
//#endregion
|
|
6726
|
+
//#region src/bundlers/vite/css-finalizer/final-assets.ts
|
|
6727
|
+
/** 按生成目标统一收尾已组装的 CSS 资产,供空资产和常规分支复用。 */
|
|
6728
|
+
function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
|
|
6729
|
+
if (isWebGeneratorTarget) return require_web.finalizeWebCssCalc(bundle, context);
|
|
6730
|
+
finalizeMiniProgramCssAssetStructures(bundle, {
|
|
6731
|
+
cssMatcher: context.opts.cssMatcher,
|
|
6732
|
+
debug: context.debug,
|
|
6733
|
+
files,
|
|
6734
|
+
isWebGeneratorTarget,
|
|
6735
|
+
onUpdate: context.opts.onUpdate,
|
|
6736
|
+
recordCssAssetResult: context.recordCssAssetResult
|
|
6737
|
+
});
|
|
6738
|
+
}
|
|
6739
|
+
//#endregion
|
|
6759
6740
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
6760
6741
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
6761
6742
|
return {
|
|
@@ -6833,6 +6814,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6833
6814
|
rootDir,
|
|
6834
6815
|
sourceRoot
|
|
6835
6816
|
})) {
|
|
6817
|
+
await require_web.finalizeWebCssCalc(bundle, context);
|
|
6836
6818
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
6837
6819
|
finishTiming();
|
|
6838
6820
|
return;
|
|
@@ -6956,7 +6938,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6956
6938
|
const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
|
|
6957
6939
|
recordTiming("assets.enumerate", enumerateStartedAt);
|
|
6958
6940
|
if (entries.length === 0) {
|
|
6959
|
-
await injectHarmonyBundleStyles(
|
|
6941
|
+
await injectHarmonyBundleStyles();
|
|
6960
6942
|
collectViteProcessedCssAssets();
|
|
6961
6943
|
injectViteProcessedCssIntoMainCss();
|
|
6962
6944
|
linkEntryStyles();
|
|
@@ -6967,14 +6949,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6967
6949
|
onUpdate: trackFinalCssAssetUpdate,
|
|
6968
6950
|
recordCssAssetResult
|
|
6969
6951
|
});
|
|
6970
|
-
|
|
6971
|
-
cssMatcher: opts.cssMatcher,
|
|
6972
|
-
debug,
|
|
6973
|
-
files: finalCssAssetFiles,
|
|
6974
|
-
isWebGeneratorTarget,
|
|
6975
|
-
onUpdate: opts.onUpdate,
|
|
6976
|
-
recordCssAssetResult
|
|
6977
|
-
});
|
|
6952
|
+
await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
|
|
6978
6953
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
6979
6954
|
finishTiming();
|
|
6980
6955
|
return;
|
|
@@ -7092,14 +7067,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7092
7067
|
onUpdate: trackFinalCssAssetUpdate,
|
|
7093
7068
|
recordCssAssetResult
|
|
7094
7069
|
});
|
|
7095
|
-
|
|
7096
|
-
cssMatcher: opts.cssMatcher,
|
|
7097
|
-
debug,
|
|
7098
|
-
files: finalCssAssetFiles,
|
|
7099
|
-
isWebGeneratorTarget,
|
|
7100
|
-
onUpdate: opts.onUpdate,
|
|
7101
|
-
recordCssAssetResult
|
|
7102
|
-
});
|
|
7070
|
+
await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
|
|
7103
7071
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
7104
7072
|
recordTiming("assets.write", writeStartedAt);
|
|
7105
7073
|
finishTiming();
|
|
@@ -7325,7 +7293,7 @@ function isWebOrNativeAppPlatform(platform) {
|
|
|
7325
7293
|
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
7326
7294
|
}
|
|
7327
7295
|
function isInternalUserDefinedOptions(options) {
|
|
7328
|
-
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
7296
|
+
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && "tailwindRuntime" in options && typeof options.tailwindRuntime === "object" && "refreshTailwindcssRuntime" in options && typeof options.refreshTailwindcssRuntime === "function";
|
|
7329
7297
|
}
|
|
7330
7298
|
function isNuxtPageHotModule(id) {
|
|
7331
7299
|
if (typeof id !== "string") return false;
|
|
@@ -7335,6 +7303,41 @@ function isNuxtPageHotModule(id) {
|
|
|
7335
7303
|
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
7336
7304
|
}
|
|
7337
7305
|
//#endregion
|
|
7306
|
+
//#region src/bundlers/vite/shared/framework-runtime-configuration.ts
|
|
7307
|
+
const ENV_PLATFORM_KEYS = [
|
|
7308
|
+
"UNI_PLATFORM",
|
|
7309
|
+
"UNI_UTS_PLATFORM",
|
|
7310
|
+
"TARO_ENV",
|
|
7311
|
+
"MPX_CURRENT_TARGET_MODE",
|
|
7312
|
+
"MPX_CLI_MODE"
|
|
7313
|
+
];
|
|
7314
|
+
/** 在配置基准确定后同步显式 CSS 入口,保留运行时与用户选项的一致性。 */
|
|
7315
|
+
function createFrameworkCssEntrySync(opts, rawCssEntries) {
|
|
7316
|
+
return (anchor) => {
|
|
7317
|
+
var _opts$tailwindcss;
|
|
7318
|
+
const entries = require_generator.normalizeCssEntries(rawCssEntries, anchor ?? node_process.default.cwd());
|
|
7319
|
+
if (!entries) return false;
|
|
7320
|
+
const changed = !sameStringList(opts.cssEntries, entries);
|
|
7321
|
+
opts.cssEntries = entries;
|
|
7322
|
+
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
7323
|
+
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
7324
|
+
opts.tailwindcss.v4.cssEntries = entries;
|
|
7325
|
+
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = entries;
|
|
7326
|
+
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = entries;
|
|
7327
|
+
return changed;
|
|
7328
|
+
};
|
|
7329
|
+
}
|
|
7330
|
+
/** 按显式配置、框架环境与输出目录顺序解析当前样式平台。 */
|
|
7331
|
+
function resolveFrameworkStylePlatform(opts, outDir) {
|
|
7332
|
+
const explicit = require_compiler.normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
7333
|
+
if (explicit) return explicit;
|
|
7334
|
+
for (const key of ENV_PLATFORM_KEYS) {
|
|
7335
|
+
const platform = require_compiler.normalizeFrameworkStylePlatform(node_process.default.env[key], opts.appType);
|
|
7336
|
+
if (platform) return platform;
|
|
7337
|
+
}
|
|
7338
|
+
return inferPlatformFromOutDir(outDir);
|
|
7339
|
+
}
|
|
7340
|
+
//#endregion
|
|
7338
7341
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
7339
7342
|
function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
7340
7343
|
const shouldSkipSourceCandidateState = () => options.shouldSkipSourceCandidateState?.() === true;
|
|
@@ -7368,7 +7371,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7368
7371
|
};
|
|
7369
7372
|
return {
|
|
7370
7373
|
name: `${require_compiler.vitePluginName}:source-candidates`,
|
|
7371
|
-
apply,
|
|
7374
|
+
...apply === void 0 ? {} : { apply },
|
|
7372
7375
|
enforce: "pre",
|
|
7373
7376
|
async load(id) {
|
|
7374
7377
|
if (!options.shouldOwnTailwindGeneration || shouldSkipSourceCandidateState() || options.isWebOrNativeAppPlatform(options.resolveViteStylePlatform()) || !require_web.isCSSRequest(id) || !require_web.shouldCollectTransformedSourceCandidates(id)) return;
|
|
@@ -7467,7 +7470,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7467
7470
|
mod.file
|
|
7468
7471
|
]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
|
|
7469
7472
|
}
|
|
7470
|
-
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await
|
|
7473
|
+
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await require_web.readViteHmrSource(ctx) : void 0;
|
|
7471
7474
|
if (typeof hotSource === "string" && require_web.isCSSRequest(ctx.file)) {
|
|
7472
7475
|
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
7473
7476
|
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
@@ -7554,13 +7557,6 @@ const debug = require_compiler.createDebug();
|
|
|
7554
7557
|
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
7555
7558
|
const weappTailwindcssDirPosix = require_web.slash(weappTailwindcssPackageDir);
|
|
7556
7559
|
const generatorPlaceholderCssFile = node_path.default.join(weappTailwindcssPackageDir, "generator-placeholder.css");
|
|
7557
|
-
const ENV_PLATFORM_KEYS = [
|
|
7558
|
-
"UNI_PLATFORM",
|
|
7559
|
-
"UNI_UTS_PLATFORM",
|
|
7560
|
-
"TARO_ENV",
|
|
7561
|
-
"MPX_CURRENT_TARGET_MODE",
|
|
7562
|
-
"MPX_CLI_MODE"
|
|
7563
|
-
];
|
|
7564
7560
|
function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
7565
7561
|
debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
|
|
7566
7562
|
const capability = options.__internalViteCapabilityProfile ?? require_web.frameworkViteCapabilityProfile;
|
|
@@ -7568,23 +7564,12 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7568
7564
|
const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
7569
7565
|
const hasExplicitTailwindcssBasedir = typeof options.__internalViteRawExplicitTailwindcssBasedir === "boolean" ? options.__internalViteRawExplicitTailwindcssBasedir : typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
7570
7566
|
const rawCssEntries = collectConfiguredCssEntries(rawOptions);
|
|
7571
|
-
const
|
|
7567
|
+
const deferredOptions = {
|
|
7572
7568
|
...options,
|
|
7573
7569
|
__internalDeferMissingCssEntriesWarning: true
|
|
7574
|
-
});
|
|
7575
|
-
const syncCssEntriesFromAnchor = (anchor) => {
|
|
7576
|
-
var _opts$tailwindcss;
|
|
7577
|
-
const normalizedCssEntries = require_generator.normalizeCssEntries(rawCssEntries, anchor ?? node_process.default.cwd());
|
|
7578
|
-
if (!normalizedCssEntries) return false;
|
|
7579
|
-
const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
|
|
7580
|
-
opts.cssEntries = normalizedCssEntries;
|
|
7581
|
-
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
7582
|
-
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
7583
|
-
opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
7584
|
-
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
7585
|
-
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
7586
|
-
return changed;
|
|
7587
7570
|
};
|
|
7571
|
+
const opts = isInternalUserDefinedOptions(options) ? options : require_compiler.getCompilerContext(deferredOptions);
|
|
7572
|
+
const syncCssEntriesFromAnchor = createFrameworkCssEntrySync(opts, rawCssEntries);
|
|
7588
7573
|
syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
|
|
7589
7574
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler, styleInjector } = opts;
|
|
7590
7575
|
const initialTailwindRuntime = tailwindRuntime;
|
|
@@ -7603,15 +7588,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7603
7588
|
isWeb: () => resolveCurrentGeneratorBranch().isWeb
|
|
7604
7589
|
});
|
|
7605
7590
|
const hmrCssModuleVersions = require_web.createViteHmrCssModuleVersionTracker();
|
|
7606
|
-
const resolveViteStylePlatform = () =>
|
|
7607
|
-
const explicit = require_compiler.normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
7608
|
-
if (explicit) return explicit;
|
|
7609
|
-
for (const key of ENV_PLATFORM_KEYS) {
|
|
7610
|
-
const envPlatform = require_compiler.normalizeFrameworkStylePlatform(node_process.default.env[key], opts.appType);
|
|
7611
|
-
if (envPlatform) return envPlatform;
|
|
7612
|
-
}
|
|
7613
|
-
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
7614
|
-
};
|
|
7591
|
+
const resolveViteStylePlatform = () => resolveFrameworkStylePlatform(opts, resolvedConfig?.build?.outDir);
|
|
7615
7592
|
const resolveGeneratorPlatform = () => opts.cssOptions?.platform ?? opts.platform ?? resolveViteStylePlatform();
|
|
7616
7593
|
const resolveCurrentGeneratorOptions = () => require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
7617
7594
|
appType: opts.appType,
|
|
@@ -7639,7 +7616,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7639
7616
|
const platform = resolveViteStylePlatform();
|
|
7640
7617
|
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb)) return code;
|
|
7641
7618
|
let transformedCode = code;
|
|
7642
|
-
if (transformedCode.includes("#if")) transformedCode = (0, _weapp_tailwindcss_postcss.compileCssMacroConditionalComments)(transformedCode, { platform:
|
|
7619
|
+
if (transformedCode.includes("#if")) transformedCode = (0, _weapp_tailwindcss_postcss.compileCssMacroConditionalComments)(transformedCode, { ...platform ? { platform } : {} });
|
|
7643
7620
|
if (transformedCode.includes("@layer")) transformedCode = (0, _weapp_tailwindcss_postcss.unwrapUnsupportedCascadeLayers)(transformedCode);
|
|
7644
7621
|
return transformedCode;
|
|
7645
7622
|
};
|
|
@@ -8068,7 +8045,7 @@ ${previousTracedCss}`;
|
|
|
8068
8045
|
});
|
|
8069
8046
|
debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
|
|
8070
8047
|
return `${require_v4_generation_core.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8071
|
-
${tracedCss}`;
|
|
8048
|
+
${tracedCss}${currentGeneratorBranch.isWeb ? `\n${require_v4_generation_core.createBundlerGeneratedCssEndMarker("vite", normalizeViteProcessedCssFile(file))}` : ""}`;
|
|
8072
8049
|
};
|
|
8073
8050
|
const generateTailwindCssForVitePipeline = require_web.createFrameworkCssGenerationQueue(normalizeGeneratedCssCacheFile, generateTailwindCssForVitePipelineNow);
|
|
8074
8051
|
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
@@ -8336,13 +8313,16 @@ function wrapPluginHook(hook, before) {
|
|
|
8336
8313
|
before(...args);
|
|
8337
8314
|
return hook.apply(this, args);
|
|
8338
8315
|
};
|
|
8339
|
-
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function")
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8316
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
|
|
8317
|
+
const handler = hook.handler;
|
|
8318
|
+
return {
|
|
8319
|
+
...hook,
|
|
8320
|
+
handler(...args) {
|
|
8321
|
+
before(...args);
|
|
8322
|
+
return handler.apply(this, args);
|
|
8323
|
+
}
|
|
8324
|
+
};
|
|
8325
|
+
}
|
|
8346
8326
|
return hook;
|
|
8347
8327
|
}
|
|
8348
8328
|
function wrapPluginCloseBundle(hook, dispose) {
|
|
@@ -8353,16 +8333,19 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8353
8333
|
dispose.call(this);
|
|
8354
8334
|
}
|
|
8355
8335
|
};
|
|
8356
|
-
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function")
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8336
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
|
|
8337
|
+
const handler = hook.handler;
|
|
8338
|
+
return {
|
|
8339
|
+
...hook,
|
|
8340
|
+
async handler(...args) {
|
|
8341
|
+
try {
|
|
8342
|
+
return await handler.apply(this, args);
|
|
8343
|
+
} finally {
|
|
8344
|
+
dispose.call(this);
|
|
8345
|
+
}
|
|
8363
8346
|
}
|
|
8364
|
-
}
|
|
8365
|
-
}
|
|
8347
|
+
};
|
|
8348
|
+
}
|
|
8366
8349
|
return dispose;
|
|
8367
8350
|
}
|
|
8368
8351
|
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
@@ -8374,11 +8357,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8374
8357
|
}
|
|
8375
8358
|
const wrappedPlugins = plugins.map((plugin) => ({
|
|
8376
8359
|
...plugin,
|
|
8377
|
-
watchChange: wrapPluginHook(plugin
|
|
8360
|
+
watchChange: wrapPluginHook(plugin["watchChange"], (id, change) => {
|
|
8378
8361
|
if (change?.event === "delete") relationOwner.removeSource(id);
|
|
8379
8362
|
else relationOwner.observeSource(id);
|
|
8380
8363
|
}),
|
|
8381
|
-
handleHotUpdate: wrapPluginHook(plugin
|
|
8364
|
+
handleHotUpdate: wrapPluginHook(plugin["handleHotUpdate"], (context) => {
|
|
8382
8365
|
if (context?.file) relationOwner.observeSource(context.file);
|
|
8383
8366
|
})
|
|
8384
8367
|
}));
|
|
@@ -8417,12 +8400,8 @@ function createTaroAlipayBrowserslistAssetPlugin() {
|
|
|
8417
8400
|
name: "weapp-tailwindcss:taro-alipay-browserslist-asset",
|
|
8418
8401
|
enforce: "pre",
|
|
8419
8402
|
generateBundle(_options, bundle) {
|
|
8420
|
-
if (node_process.default.env
|
|
8421
|
-
bundle[".browserslistrc"] =
|
|
8422
|
-
type: "asset",
|
|
8423
|
-
fileName: ".browserslistrc",
|
|
8424
|
-
source: "defaults and fully supports es6-module"
|
|
8425
|
-
};
|
|
8403
|
+
if (node_process.default.env["TARO_ENV"] !== "alipay") return;
|
|
8404
|
+
bundle[".browserslistrc"] = createReplayCssAsset(".browserslistrc", "defaults and fully supports es6-module");
|
|
8426
8405
|
}
|
|
8427
8406
|
};
|
|
8428
8407
|
}
|
|
@@ -8628,8 +8607,8 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8628
8607
|
},
|
|
8629
8608
|
transformGeneratedCss(css, context) {
|
|
8630
8609
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
8631
|
-
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
8632
|
-
return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
|
|
8610
|
+
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss, { preserveRuntimeProperties: context.currentGeneratorBranch.isWeb }), context.currentGeneratorBranch.isWeb);
|
|
8611
|
+
return context.currentGeneratorBranch.isWeb ? output : (0, _weapp_tailwindcss_postcss.hoistUniAppXBorderPreflight)(output);
|
|
8633
8612
|
}
|
|
8634
8613
|
};
|
|
8635
8614
|
function createUniAppXVitePlugins(options = {}) {
|
|
@@ -8752,7 +8731,7 @@ function resolveViteProfile(options, config, environmentName) {
|
|
|
8752
8731
|
}
|
|
8753
8732
|
const family = platformFamily(selectedPlatform ?? (config.build?.outDir ? node_path.default.basename(node_path.default.normalize(config.build.outDir)) : void 0));
|
|
8754
8733
|
if (!explicitAppType && !(rawTarget !== "web" && family !== "web")) appType = void 0;
|
|
8755
|
-
const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" &&
|
|
8734
|
+
const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" && family !== "mini-program";
|
|
8756
8735
|
const cssOnlyGenericWeb = isGenericWeb && (forceGenericWeb || rawTarget === void 0 && explicitAppType === void 0 && selectedPlatform === void 0);
|
|
8757
8736
|
const capability = isGenericWeb ? {
|
|
8758
8737
|
...require_web.createGenericWebViteCapabilityProfile(options),
|
|
@@ -8777,8 +8756,8 @@ function resolveViteProfile(options, config, environmentName) {
|
|
|
8777
8756
|
}
|
|
8778
8757
|
function invokeHook(plugin, hookName, thisArg, args) {
|
|
8779
8758
|
const hook = plugin?.[hookName];
|
|
8780
|
-
if (typeof hook === "function") return
|
|
8781
|
-
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return hook.handler
|
|
8759
|
+
if (typeof hook === "function") return Reflect.apply(hook, thisArg, args);
|
|
8760
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return Reflect.apply(hook.handler, thisArg, args);
|
|
8782
8761
|
}
|
|
8783
8762
|
function emitDeferredRuntimeLogs(opts, profile, rawOptions) {
|
|
8784
8763
|
const hasExplicitLogLevel = Object.hasOwn(rawOptions, "logLevel");
|
|
@@ -8887,7 +8866,7 @@ function createDispatcher(options) {
|
|
|
8887
8866
|
opts.appType = profile.appType;
|
|
8888
8867
|
_weapp_tailwindcss_logger.logger.debug("根据 Vite 项目根目录自动推断 appType -> %s", profile.appType);
|
|
8889
8868
|
}
|
|
8890
|
-
if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) &&
|
|
8869
|
+
if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) && !options.platform && !options.cssOptions?.platform && !node_process.default.env["UNI_PLATFORM"] && !node_process.default.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
|
|
8891
8870
|
const capability = opts.__internalViteCapabilityProfile;
|
|
8892
8871
|
if (capability) Object.assign(capability, profile.capability);
|
|
8893
8872
|
else opts.__internalViteCapabilityProfile = profile.capability;
|
|
@@ -8935,12 +8914,6 @@ Object.defineProperty(exports, "injectBorderPreflightClass", {
|
|
|
8935
8914
|
return injectBorderPreflightClass;
|
|
8936
8915
|
}
|
|
8937
8916
|
});
|
|
8938
|
-
Object.defineProperty(exports, "isUniAppXStyleSourceEmpty", {
|
|
8939
|
-
enumerable: true,
|
|
8940
|
-
get: function() {
|
|
8941
|
-
return isUniAppXStyleSourceEmpty;
|
|
8942
|
-
}
|
|
8943
|
-
});
|
|
8944
8917
|
Object.defineProperty(exports, "shouldEnableComponentLocalStyle", {
|
|
8945
8918
|
enumerable: true,
|
|
8946
8919
|
get: function() {
|