weapp-tailwindcss 5.5.1 → 5.5.3
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/shared/css-imports.d.ts +1 -0
- package/dist/bundlers/shared/framework-user-css.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +6 -2
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -1
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
- package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +3 -2
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/entry-style-graph.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +1 -0
- package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +3 -1
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +1 -0
- package/dist/compiler/runtime-snapshot.d.ts +4 -1
- package/dist/{compiler-B0YSc0DY.js → compiler-C9X5Afn4.js} +3 -3
- package/dist/{compiler-D2ZJc3uA.cjs → compiler-DMPaUcH6.cjs} +6 -6
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-imports-BFMU7Hpd.cjs → css-imports-DXplvodk.cjs} +29 -0
- package/dist/{css-loader-runtime-CSv0lKqV.cjs → css-loader-runtime-DGqsWVua.cjs} +2 -1
- package/dist/{defaults-B5ep0ojb.js → defaults-CKx-4LcW.js} +1 -1
- package/dist/{defaults-BI9j1znS.cjs → defaults-CiGsr8Xq.cjs} +1 -1
- package/dist/defaults.cjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/{generator-DsrQ9txU.cjs → generator-BoZIiZD5.cjs} +130 -77
- package/dist/{generator-DyXTBPmE.js → generator-C2aWns8n.js} +119 -78
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DXeQfvVC.js → gulp-COAAztkm.js} +4 -4
- package/dist/{gulp-C9ENAx3f.cjs → gulp-D50z06nw.cjs} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-DNxQm-bN.js → hmr-timing-CTk1uZr9.js} +245 -183
- package/dist/{hmr-timing-Cz4IesEM.cjs → hmr-timing-DK0MJKpl.cjs} +5 -5
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-CSGnR5gh.cjs → pipeline-helpers-BzjYXNTa.cjs} +4 -4
- 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 +6 -3
- package/dist/rspack.js +6 -3
- package/dist/{scoped-generator-kRj_5Axx.js → scoped-generator-C21A7fis.js} +3 -3
- package/dist/{scoped-generator-TVjEaOeP.cjs → scoped-generator-CTkuf9Ae.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-B7cUxqqX.cjs → source-candidate-scan-signature-4mZDDaKT.cjs} +2 -2
- package/dist/{source-candidate-scan-signature-CsP4BQNa.js → source-candidate-scan-signature-BB5DfjO2.js} +2 -2
- package/dist/tailwindcss/v4-engine/css-import.d.ts +14 -0
- package/dist/{tailwindcss-C-jBBQfw.cjs → tailwindcss-Bji4u8In.cjs} +1 -1
- package/dist/{tailwindcss-BK9S7zuq.js → tailwindcss-c4PkOe1F.js} +1 -1
- package/dist/{transform-DUPOPZ54.cjs → transform-Cy0ddBWf.cjs} +14 -14
- package/dist/{transform-CfOzh007.js → transform-DmLonqPE.js} +14 -14
- package/dist/uni-app-x/border-preflight.d.ts +18 -0
- package/dist/uni-app-x/style-asset/source-parser.d.ts +2 -0
- package/dist/uni-app-x/style-reference-path.d.ts +1 -0
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +5 -0
- package/dist/uni-app-x/vite/style-source.d.ts +14 -4
- package/dist/uni-app-x/vite/web-sfc-hmr.d.ts +14 -0
- package/dist/{v4-generation-core-CRNUU_Rr.cjs → v4-generation-core-DQeiq-g1.cjs} +243 -181
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-BXe-axax.js → vite-CaUxtQx5.js} +340 -88
- package/dist/{vite-D_mAIfTU.cjs → vite-OG66oLpb.cjs} +356 -85
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/{watch-dependencies-DLZDrWdH.cjs → watch-dependencies-GbC14Rlt.cjs} +14 -11
- package/dist/weapp-tw-css-generation-loader.cjs +3 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +11 -10
- package/dist/weapp-tw-runtime-classset-loader.cjs +16 -11
- package/dist/{web-Cv7ualrU.js → web-Bd-9OHFE.js} +7 -6
- package/dist/{web-B2Ea9K4B.cjs → web-CZKIefdl.cjs} +9 -8
- package/dist/{webpack-7Um2GFtx.js → webpack-Cyvq3H7Z.js} +38 -23
- package/dist/{webpack-Ce04-btG.cjs → webpack-DJGgU27Y.cjs} +37 -23
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +7 -5
|
@@ -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-BoZIiZD5.cjs");
|
|
4
|
+
const require_tailwindcss = require("./tailwindcss-Bji4u8In.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-DQeiq-g1.cjs");
|
|
7
|
+
const require_compiler = require("./compiler-DMPaUcH6.cjs");
|
|
8
8
|
const require_cache = require("./cache-CBJFB1HN.cjs");
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-DK0MJKpl.cjs");
|
|
10
10
|
const require_final_css_cleanup = require("./final-css-cleanup-DSjczga3.cjs");
|
|
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-
|
|
11
|
+
const require_scoped_generator = require("./scoped-generator-CTkuf9Ae.cjs");
|
|
12
|
+
const require_web = require("./web-CZKIefdl.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-4mZDDaKT.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,7 +28,22 @@ 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
|
+
let _vue_compiler_dom = require("@vue/compiler-dom");
|
|
31
34
|
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
|
|
32
47
|
//#region src/uni-app-x/style-asset/harmony-apply.ts
|
|
33
48
|
const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
|
|
34
49
|
function createGeneratedRuleMap(css) {
|
|
@@ -52,7 +67,7 @@ function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
|
|
|
52
67
|
if (!styleSource.includes("@apply")) return block;
|
|
53
68
|
let root;
|
|
54
69
|
try {
|
|
55
|
-
root =
|
|
70
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
56
71
|
} catch {
|
|
57
72
|
return block;
|
|
58
73
|
}
|
|
@@ -86,6 +101,14 @@ function shouldEnablePageLocalStyle(id, matcher) {
|
|
|
86
101
|
return matcher ? matcher(normalizedId) : PAGE_RE.test(normalizedId);
|
|
87
102
|
}
|
|
88
103
|
//#endregion
|
|
104
|
+
//#region src/uni-app-x/style-reference-path.ts
|
|
105
|
+
const WINDOWS_SOURCE_RE = /^[a-z]:[\\/]|^[\\/]{2}[^\\/]/i;
|
|
106
|
+
/** 按来源文件的盘符或共享根目录解析,再在 CSS 引用边界统一分隔符。 */
|
|
107
|
+
function resolveStyleReferencePath(sourceFile, request) {
|
|
108
|
+
const paths = WINDOWS_SOURCE_RE.test(sourceFile) ? node_path.default.win32 : node_path.default;
|
|
109
|
+
return paths.resolve(paths.dirname(sourceFile), request).replaceAll("\\", "/");
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
89
112
|
//#region src/uni-app-x/style-asset/style-value.ts
|
|
90
113
|
const GEN_APP_STYLES_RE = /const\s+GenAppStyles\s*=\s*\[_uM\(\[([\s\S]*?)\]\)\]/;
|
|
91
114
|
const STYLE_ENTRY_RE = /\[\s*("((?:\\.|[^"\\])+)")\s*,\s*(_pS\(_uM\(\[[\s\S]*?\]\)\))\s*\]/g;
|
|
@@ -244,7 +267,7 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
244
267
|
for (const styleSource of styleSources) {
|
|
245
268
|
let root;
|
|
246
269
|
try {
|
|
247
|
-
root =
|
|
270
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
248
271
|
} catch {
|
|
249
272
|
continue;
|
|
250
273
|
}
|
|
@@ -273,15 +296,14 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
273
296
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
274
297
|
}
|
|
275
298
|
function resolveReferencePaths(styleSource, sourceId) {
|
|
276
|
-
if (!sourceId || !styleSource.includes("@reference")) return styleSource;
|
|
277
299
|
let root;
|
|
278
300
|
try {
|
|
279
|
-
root =
|
|
301
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
280
302
|
} catch {
|
|
281
303
|
return styleSource;
|
|
282
304
|
}
|
|
305
|
+
if (!sourceId || !styleSource.includes("@reference")) return root.toString();
|
|
283
306
|
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
284
|
-
const pathApi = /^[a-z]:[\\/]/i.test(cleanSourceId) ? node_path.default.win32 : node_path.default;
|
|
285
307
|
root.walkAtRules("reference", (rule) => {
|
|
286
308
|
const quote = rule.params[0];
|
|
287
309
|
if (quote !== "\"" && quote !== "'") return;
|
|
@@ -289,7 +311,7 @@ function resolveReferencePaths(styleSource, sourceId) {
|
|
|
289
311
|
if (closingQuoteIndex <= 1) return;
|
|
290
312
|
const referencePath = rule.params.slice(1, closingQuoteIndex);
|
|
291
313
|
if (!referencePath.startsWith(".")) return;
|
|
292
|
-
rule.params = `${quote}${
|
|
314
|
+
rule.params = `${quote}${resolveStyleReferencePath(cleanSourceId, referencePath)}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
|
|
293
315
|
});
|
|
294
316
|
return root.toString();
|
|
295
317
|
}
|
|
@@ -301,7 +323,7 @@ function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
|
301
323
|
for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) {
|
|
302
324
|
let root;
|
|
303
325
|
try {
|
|
304
|
-
root =
|
|
326
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
305
327
|
} catch {
|
|
306
328
|
continue;
|
|
307
329
|
}
|
|
@@ -525,7 +547,7 @@ function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtili
|
|
|
525
547
|
return applyStyleSources.map((source) => {
|
|
526
548
|
let root;
|
|
527
549
|
try {
|
|
528
|
-
root =
|
|
550
|
+
root = parseUniAppXStyleSource(source);
|
|
529
551
|
} catch {
|
|
530
552
|
return source;
|
|
531
553
|
}
|
|
@@ -1463,7 +1485,7 @@ function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
|
|
|
1463
1485
|
return enabled === true;
|
|
1464
1486
|
}
|
|
1465
1487
|
function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
|
|
1466
|
-
return !options.isWebGeneratorTarget && options.matchesCss &&
|
|
1488
|
+
return !options.isWebGeneratorTarget && options.matchesCss && require_web.isRootStyleOutputFile(options.file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
|
|
1467
1489
|
}
|
|
1468
1490
|
function resolveFrameworkRootImportShellPlan(options) {
|
|
1469
1491
|
const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
@@ -1478,7 +1500,7 @@ function resolveFrameworkRootImportShellPlan(options) {
|
|
|
1478
1500
|
return {
|
|
1479
1501
|
isCurrentImportShell,
|
|
1480
1502
|
reusableTarget: options.rememberedTarget,
|
|
1481
|
-
targetToRemember: importedFile &&
|
|
1503
|
+
targetToRemember: importedFile && require_web.isRootStyleOutputFile(importedFile) ? importedFile : void 0
|
|
1482
1504
|
};
|
|
1483
1505
|
}
|
|
1484
1506
|
if (options.rememberedTarget) return {
|
|
@@ -1505,7 +1527,7 @@ function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
1505
1527
|
const writeTargets = /* @__PURE__ */ new Map();
|
|
1506
1528
|
let restored = 0;
|
|
1507
1529
|
for (const [sourceFile, targetFile] of options.targetByFile) {
|
|
1508
|
-
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !
|
|
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;
|
|
1509
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];
|
|
1510
1532
|
if (output?.type !== "asset") continue;
|
|
1511
1533
|
const rawSource = output.source.toString();
|
|
@@ -1675,6 +1697,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1675
1697
|
if (removableRecords.length === 0) return 0;
|
|
1676
1698
|
const recordFileKeys = new Set(removableRecords.map((record) => require_source_candidate_scan_signature.normalizeOutputPathKey(record.file)));
|
|
1677
1699
|
const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
|
|
1700
|
+
const targetMatcher = (0, _weapp_tailwindcss_postcss.createCssRuleMatcher)(targetCss);
|
|
1678
1701
|
let removed = 0;
|
|
1679
1702
|
for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
|
|
1680
1703
|
if (candidateOutput.type !== "asset") continue;
|
|
@@ -1683,7 +1706,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1683
1706
|
const candidateIsRootWebStyle = require_web.isRootStyleOutputFile(candidateKey) && !require_web.isMiniProgramStyleOutputFile(candidateKey);
|
|
1684
1707
|
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
1685
1708
|
const candidateSource = require_web.readAssetSource(candidateOutput).trim();
|
|
1686
|
-
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) ||
|
|
1709
|
+
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || targetMatcher.contains(candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !require_web.hasNonCommentCss(targetMatcher.filter(candidateSource).trim())))) continue;
|
|
1687
1710
|
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
1688
1711
|
else require_web.clearAssetSource(candidateOutput);
|
|
1689
1712
|
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
@@ -2069,15 +2092,22 @@ function createTransformFilterSignature(options) {
|
|
|
2069
2092
|
//#region src/bundlers/vite/generate-bundle/bundle-markup-candidates.ts
|
|
2070
2093
|
async function collectBundleMarkupCandidates(options) {
|
|
2071
2094
|
const { extractSourceCandidates, previousCandidatesByFile, preserveMissingFiles, resolveSourceCandidateFile, rootDir, snapshot, transformFilter } = options;
|
|
2072
|
-
const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file,
|
|
2095
|
+
const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, entry]) => [file, {
|
|
2096
|
+
...entry,
|
|
2097
|
+
candidates: new Set(entry.candidates)
|
|
2098
|
+
}])) : /* @__PURE__ */ new Map();
|
|
2099
|
+
for (const file of snapshot.removedFiles) candidatesByFile.delete(file);
|
|
2073
2100
|
await Promise.all(snapshot.entries.map(async (entry) => {
|
|
2074
2101
|
if (!extractSourceCandidates || entry.type !== "html" || entry.output.type !== "asset" || shouldSkipViteAssetTransform(entry.output, entry.file, rootDir, transformFilter)) return;
|
|
2075
2102
|
const sourceFile = resolveSourceCandidateFile(entry.file) ?? node_path.default.resolve(rootDir, entry.file);
|
|
2076
|
-
candidatesByFile.set(
|
|
2103
|
+
candidatesByFile.set(entry.file, {
|
|
2104
|
+
sourceFile,
|
|
2105
|
+
candidates: await extractSourceCandidates(sourceFile, entry.source)
|
|
2106
|
+
});
|
|
2077
2107
|
}));
|
|
2078
2108
|
const valuesForEntries = (entries, filterOptions = {}) => {
|
|
2079
2109
|
const values = /* @__PURE__ */ new Set();
|
|
2080
|
-
for (const
|
|
2110
|
+
for (const { sourceFile: file, candidates } of candidatesByFile.values()) {
|
|
2081
2111
|
if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(file, entries)) continue;
|
|
2082
2112
|
if (filterOptions.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
|
|
2083
2113
|
for (const candidate of candidates) values.add(candidate);
|
|
@@ -2574,7 +2604,11 @@ async function processViteCssBundleEntry(options) {
|
|
|
2574
2604
|
const { activeViteCssCacheFiles, addWatchFile, annotateCssSourceTrace, applyCssResultToBundle, applyViteCssCacheResult, applyViteCssTransformTaskResult, bundle, bundleFiles, cache, collectedBundlerGeneratedCssFiles, configuredTailwindV4CssSourceFileKeysForScope, configuredTailwindV4ExplicitCssEntryFileKeysForScope, context, createCandidateSignature, createCssSourceTraceCacheSignature, createCssTokenSourceMap, createCssTransformShareScopeKey, createInitialCssPipelineContext, createRuntimeAffectingSourceSignature, createScopedGeneratorCandidateSignature, createScopedGeneratorRuntime, createScopedGeneratorSourceTraceMap, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, currentSubpackageRoots, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, envFlags, executeViteCssTransformTask, file, frameworkRootImportShellTargetByFile, generatorCandidatesChanged, generatorPlatform, generatorRuntime, getConfiguredTailwindV4CssSourceEntries, getCssHandlerOptions, getCssSource, getCssUserHandlerOptions, getLastCssResult, getOriginalCssLayerSource, getRememberedCssSources, getSfcSource, getSourceCandidateSources, getViteProcessedCssAssetResult, getViteProcessedCssAssetResults, hasExplicitConfiguredRootCssEntryForOutput, hasRuntimeAffectingChanges, hasViteProcessedCssResultForSource, isCssAssetProcessed, isCssImportOnlyBundleAsset, isMiniProgramStyleOutputFile, isRootMiniProgramStyleOutputFile, isSubpackageOutputFile, isTemporaryCssAssetFile, isViteProcessedCssAsset, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, measureElapsed, metrics, normalizeConfiguredTailwindV4CssEntryFileKey, normalizeGeneratorUserRawSource, normalizeMiniProgramGeneratorRawSource, normalizeOutputPathKey, normalizeRelativeCssConfigDirectives, normalizeViteCssCacheKey, onUpdate, opts, originalEntrySource, originalSource, outDir, processFiles, processViteCssCacheTask, recordCssAssetResult, recordViteProcessedCssAssetResult, rememberCssSource, rememberProcessCacheKey, removeCssCoveredByRootStyleBundleSources, resolveAssetSourceFile, resolveConfiguredCssEntryRootInjectionTarget, resolveConfiguredRootCssSourceStyle, resolveCssAssetIdentity, resolveCssAssetOutputPlan, resolveFrameworkRootImportShellPlan, resolveMatchedCssSourceOutputFile, resolveReplayCssOutputFile, resolveViteCssCompositionPlan, resolveViteCssLinkedImpactSignature, resolveViteCssPipelineOutputFile, resolveViteCssSourcePlan, resolveViteCssTransformCachePlan, resolveViteCssTransformDecisionPlan, rootDir, runtimeLinkedCssFiles, runtimeSignature, runtimeState, selectConfiguredRootCssSourceEntry, sharedCssResultCache, shouldExcludeSubpackageSourceCandidates, shouldGenerateWebCssByGenerator, shouldInjectCssIntoMainFromOutput, shouldKeepCurrentRootCssOutputForConfiguredSource, shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell, shouldKeepRootMiniProgramStyleAsImportShell, shouldMoveRootMiniProgramStyleToImportShellOrigin, shouldPreserveAppCssExtension, shouldProcessTailwindGeneration, shouldSkipRawRememberedCssSource, shouldSkipRawSourceStyleAsset, shouldSkipViteAssetTransform, snapshot, sourceRoot, state, styleHandler, temporaryCssAssetSourceResolver, timeTask, transformFilter, transformRuntime, transformWebTargetCss, useIncrementalMode, usedConfiguredTailwindV4CssSourceFiles } = options;
|
|
2575
2605
|
metrics.css.total++;
|
|
2576
2606
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
2577
|
-
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource
|
|
2607
|
+
const rawSource = normalizeRelativeCssConfigDirectives(isWebGeneratorTarget ? originalEntrySource : require_v4_generation_core.normalizeMiniProgramImportShell(originalEntrySource, {
|
|
2608
|
+
cssOnly: true,
|
|
2609
|
+
outputFile: originalSource.fileName || file,
|
|
2610
|
+
outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
|
|
2611
|
+
}), assetSourceFile, outDir, opts);
|
|
2578
2612
|
const currentRawSourceHasExplicitScanContext = rawSource.includes("@source") || rawSource.includes("@config");
|
|
2579
2613
|
const cssPipelineContext2 = {
|
|
2580
2614
|
...createInitialCssPipelineContext(file),
|
|
@@ -2633,7 +2667,10 @@ async function processViteCssBundleEntry(options) {
|
|
|
2633
2667
|
}))
|
|
2634
2668
|
});
|
|
2635
2669
|
let outputFile = cssAssetOutputPlan.outputFile;
|
|
2636
|
-
const resolveMatchedOutputFileForCurrentAsset =
|
|
2670
|
+
const resolveMatchedOutputFileForCurrentAsset = (sourceFile) => {
|
|
2671
|
+
const matched = cssAssetOutputPlan.resolveMatchedOutputFile(sourceFile);
|
|
2672
|
+
return matched ? frameworkRootImportShellTargetByFile.get(matched) ?? matched : matched;
|
|
2673
|
+
};
|
|
2637
2674
|
const resolvedFromConfiguredOriginalCssEntry = cssAssetOutputPlan.resolvedFromConfiguredOriginalCssEntry;
|
|
2638
2675
|
if (cssAssetOutputPlan.reusedRootImportShellTarget) debug("css reuse framework root import shell target: %s -> %s", rootImportShellOutputFile, outputFile);
|
|
2639
2676
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -2956,7 +2993,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2956
2993
|
function resolveCssBundleOutputFile(options) {
|
|
2957
2994
|
const { bundleFiles, defaultStyleOutputExtension, file, isWebGeneratorTarget, opts, pipelineContext, cssPipelineStrategy, shouldPreserveAppCssExtension } = options;
|
|
2958
2995
|
let outputFile = require_web.resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, shouldPreserveAppCssExtension, defaultStyleOutputExtension, bundleFiles);
|
|
2959
|
-
if (outputFile === file && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
2996
|
+
if (outputFile === file && require_source_candidate_scan_signature.normalizeOutputPathKey(options.assetOutputFile ?? file) === require_source_candidate_scan_signature.normalizeOutputPathKey(file) && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
2960
2997
|
...pipelineContext,
|
|
2961
2998
|
file
|
|
2962
2999
|
}))) outputFile = createRootMiniProgramOriginStyleOutputFile(file);
|
|
@@ -2993,7 +3030,10 @@ function createMatchedCssSourceOutputResolver(options) {
|
|
|
2993
3030
|
};
|
|
2994
3031
|
}
|
|
2995
3032
|
function resolveCssAssetOutputPlan(options) {
|
|
2996
|
-
let outputFile = resolveCssBundleOutputFile(
|
|
3033
|
+
let outputFile = resolveCssBundleOutputFile({
|
|
3034
|
+
...options,
|
|
3035
|
+
assetOutputFile: options.rootImportShellOutputFile
|
|
3036
|
+
});
|
|
2997
3037
|
const reusedRootImportShellTarget = Boolean(options.rootImportShellTarget && !options.isWebGeneratorTarget && (options.opts.cssMatcher(options.rootImportShellOutputFile) || options.opts.cssMatcher(options.file)) && options.shouldReuseRootImportShell());
|
|
2998
3038
|
if (reusedRootImportShellTarget && options.rootImportShellTarget) outputFile = options.rootImportShellTarget;
|
|
2999
3039
|
const resolveMatchedOutputFile = createMatchedCssSourceOutputResolver({
|
|
@@ -3505,21 +3545,22 @@ function applyViteCssTransformTaskResult(options) {
|
|
|
3505
3545
|
}
|
|
3506
3546
|
//#endregion
|
|
3507
3547
|
//#region src/bundlers/vite/generate-bundle/css-transform-task.ts
|
|
3508
|
-
function
|
|
3509
|
-
|
|
3510
|
-
return [options.generatorUserLayerRawSource, bundleUserRawSource].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
3548
|
+
function resolveBundleUserRawSource(options) {
|
|
3549
|
+
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;
|
|
3511
3550
|
}
|
|
3512
3551
|
async function executeViteCssTransformTask(options) {
|
|
3513
3552
|
await options.runtimeState.readyPromise;
|
|
3514
3553
|
const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
|
|
3515
3554
|
if (require_web.hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget && require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource)) {
|
|
3516
|
-
const
|
|
3555
|
+
const bundleUserRawSource = resolveBundleUserRawSource(options);
|
|
3556
|
+
const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
3517
3557
|
const generated = await (options.generateCss ?? require_v4_generation_core.generateTailwindV4Css)({
|
|
3518
3558
|
cssHandlerOptions: options.generatorCssHandlerOptions,
|
|
3519
3559
|
cssStage: "framework-processed",
|
|
3520
3560
|
cssUserHandlerOptions: options.cssUserHandlerOptions,
|
|
3521
3561
|
debug: options.debug,
|
|
3522
3562
|
file: options.generatorSourceFile,
|
|
3563
|
+
frameworkProcessedUserCss: options.isWebGeneratorTarget ? void 0 : bundleUserRawSource,
|
|
3523
3564
|
generatorPlatform: options.generatorPlatform,
|
|
3524
3565
|
getSourceCandidatesForEntries: options.getSourceCandidatesForEntries,
|
|
3525
3566
|
opts: options.opts,
|
|
@@ -4352,6 +4393,61 @@ function isUniAppXNativeAppOutDir(outDir) {
|
|
|
4352
4393
|
return typeof outDir === "string" && /(?:^|[/\\-])(?:\.uvue[/\\])?app-(?:android|ios|harmony)(?:[/\\-]|$)/.test(outDir);
|
|
4353
4394
|
}
|
|
4354
4395
|
//#endregion
|
|
4396
|
+
//#region src/uni-app-x/border-preflight.ts
|
|
4397
|
+
const BORDER_PREFLIGHT_CLASS = "weapp-tw-border";
|
|
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
|
+
}
|
|
4419
|
+
function resolveUniAppXBorderPreflightOptions(options, isWeb) {
|
|
4420
|
+
const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
|
|
4421
|
+
return borderPreflight ? {
|
|
4422
|
+
borderPreflight,
|
|
4423
|
+
borderPreflightRange: options.cssPreflightRange
|
|
4424
|
+
} : {};
|
|
4425
|
+
}
|
|
4426
|
+
function shouldInjectBorderPreflight(node, range) {
|
|
4427
|
+
return range === "all" ? ![
|
|
4428
|
+
"template",
|
|
4429
|
+
"slot",
|
|
4430
|
+
"block"
|
|
4431
|
+
].includes(node.tag) : node.tag === "view" || node.tag === "text";
|
|
4432
|
+
}
|
|
4433
|
+
/** 在既有 class 转换完成后插入基础类,保持 utility 与动态绑定的原始顺序。 */
|
|
4434
|
+
function injectBorderPreflightClass(ms, node, offset) {
|
|
4435
|
+
const attribute = node.props.find((prop) => prop.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE && prop.name === "class");
|
|
4436
|
+
if (attribute?.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE) {
|
|
4437
|
+
if (attribute.value) {
|
|
4438
|
+
if (attribute.value.content.split(/\s+/).includes("weapp-tw-border")) return;
|
|
4439
|
+
const start = offset + attribute.value.loc.start.offset;
|
|
4440
|
+
if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
|
|
4441
|
+
else {
|
|
4442
|
+
ms.prependRight(start, `"${BORDER_PREFLIGHT_CLASS} `);
|
|
4443
|
+
ms.appendLeft(offset + attribute.value.loc.end.offset, "\"");
|
|
4444
|
+
}
|
|
4445
|
+
} else ms.appendLeft(offset + attribute.loc.end.offset, `="${BORDER_PREFLIGHT_CLASS}"`);
|
|
4446
|
+
return;
|
|
4447
|
+
}
|
|
4448
|
+
ms.appendLeft(offset + node.loc.start.offset + node.tag.length + 1, ` class="${BORDER_PREFLIGHT_CLASS}"`);
|
|
4449
|
+
}
|
|
4450
|
+
//#endregion
|
|
4355
4451
|
//#region src/uni-app-x/style-isolation.ts
|
|
4356
4452
|
const manifestCache = /* @__PURE__ */ new Map();
|
|
4357
4453
|
function resolveUniAppXStyleIsolationEnabled(root) {
|
|
@@ -4533,7 +4629,6 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
4533
4629
|
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
4534
4630
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
4535
4631
|
const RELATIVE_REFERENCE_RE = /@reference\s+(["'])(\.\.?[\\/][^"']+)\1\s*;?/g;
|
|
4536
|
-
const WINDOWS_ABSOLUTE_PATH_RE$1 = /^[a-z]:[\\/]/i;
|
|
4537
4632
|
function isPreprocessorRequest(id, lang) {
|
|
4538
4633
|
return require_v4_generation_core.isSourcePreprocessorRequest(id, lang);
|
|
4539
4634
|
}
|
|
@@ -4546,10 +4641,8 @@ function isCssModuleExport(code) {
|
|
|
4546
4641
|
function normalizeRelativeTailwindReferences(code, id) {
|
|
4547
4642
|
if (!code.includes("@reference")) return code;
|
|
4548
4643
|
const sourceFile = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
4549
|
-
const pathApi = WINDOWS_ABSOLUTE_PATH_RE$1.test(sourceFile) ? node_path.default.win32 : node_path.default;
|
|
4550
|
-
const sourceDir = pathApi.dirname(sourceFile);
|
|
4551
4644
|
return code.replace(RELATIVE_REFERENCE_RE, (_full, quote, request) => {
|
|
4552
|
-
return `@reference ${quote}${
|
|
4645
|
+
return `@reference ${quote}${resolveStyleReferencePath(sourceFile, request)}${quote};`;
|
|
4553
4646
|
});
|
|
4554
4647
|
}
|
|
4555
4648
|
function resolvePreprocessorTransform(code, id, lang, options) {
|
|
@@ -4563,12 +4656,64 @@ function resolvePreprocessorTransform(code, id, lang, options) {
|
|
|
4563
4656
|
}
|
|
4564
4657
|
if (!options.isNativeAppStyleTarget) return { result: void 0 };
|
|
4565
4658
|
}
|
|
4659
|
+
function reportStyleWarnings(result) {
|
|
4660
|
+
const warnings = typeof result.warnings === "function" ? result.warnings() : [];
|
|
4661
|
+
for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
|
|
4662
|
+
}
|
|
4566
4663
|
//#endregion
|
|
4567
4664
|
//#region src/uni-app-x/vite/style-source.ts
|
|
4568
4665
|
const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
|
|
4569
|
-
function
|
|
4570
|
-
|
|
4666
|
+
function createUniAppXSfcStyleSources() {
|
|
4667
|
+
const authoredByFile = /* @__PURE__ */ new Map();
|
|
4668
|
+
const generatedByFile = /* @__PURE__ */ new Map();
|
|
4669
|
+
const generatedIndicesByFile = /* @__PURE__ */ new Map();
|
|
4670
|
+
function getGenerated(id, index) {
|
|
4671
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
4672
|
+
if (authoredByFile.get(file)?.[index]) return;
|
|
4673
|
+
return generatedByFile.get(file)?.get(index) ?? (generatedIndicesByFile.get(file)?.has(index) ? "" : void 0);
|
|
4674
|
+
}
|
|
4675
|
+
return {
|
|
4676
|
+
rememberSource(id, source) {
|
|
4677
|
+
authoredByFile.set((0, _weapp_tailwindcss_shared.cleanUrl)(id), require_web.extractSfcStyleBlocks(source));
|
|
4678
|
+
},
|
|
4679
|
+
rememberGenerated(id, source) {
|
|
4680
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
4681
|
+
const authoredCount = authoredByFile.get(file)?.length ?? 0;
|
|
4682
|
+
const generated = /* @__PURE__ */ new Map();
|
|
4683
|
+
const generatedIndices = generatedIndicesByFile.get(file) ?? /* @__PURE__ */ new Set();
|
|
4684
|
+
for (const [index, style] of require_web.extractSfcStyleBlocks(source).entries()) if (index >= authoredCount) {
|
|
4685
|
+
generated.set(index, style.source);
|
|
4686
|
+
generatedIndices.add(index);
|
|
4687
|
+
}
|
|
4688
|
+
generatedByFile.set(file, generated);
|
|
4689
|
+
generatedIndicesByFile.set(file, generatedIndices);
|
|
4690
|
+
},
|
|
4691
|
+
getGenerated,
|
|
4692
|
+
hasGenerated(id) {
|
|
4693
|
+
return Boolean(generatedByFile.get((0, _weapp_tailwindcss_shared.cleanUrl)(id))?.size);
|
|
4694
|
+
},
|
|
4695
|
+
load(id, index) {
|
|
4696
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
4697
|
+
const style = authoredByFile.get(file)?.[index];
|
|
4698
|
+
if (!style) {
|
|
4699
|
+
const generated = getGenerated(file, index);
|
|
4700
|
+
return generated === void 0 ? void 0 : {
|
|
4701
|
+
code: generated,
|
|
4702
|
+
map: null
|
|
4703
|
+
};
|
|
4704
|
+
}
|
|
4705
|
+
const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source);
|
|
4706
|
+
return normalized === style.source ? void 0 : {
|
|
4707
|
+
code: normalized,
|
|
4708
|
+
map: null
|
|
4709
|
+
};
|
|
4710
|
+
}
|
|
4711
|
+
};
|
|
4712
|
+
}
|
|
4713
|
+
function resolveUniAppXStyleSource(code, query, generatedSource) {
|
|
4571
4714
|
if (VITE_CSS_HMR_MODULE_RE.test(code)) return { skip: true };
|
|
4715
|
+
if (!query.vue || query.type !== "style") return { code };
|
|
4716
|
+
if (generatedSource !== void 0) return { code: generatedSource };
|
|
4572
4717
|
const styleBlocks = require_web.extractSfcStyleBlocks(code);
|
|
4573
4718
|
if (styleBlocks.length === 0) return { code };
|
|
4574
4719
|
const style = styleBlocks[query.index ?? 0];
|
|
@@ -4610,6 +4755,37 @@ function createUniAppXWebLocalStyleBridge(isEnabled, hmrCssModuleVersions) {
|
|
|
4610
4755
|
};
|
|
4611
4756
|
}
|
|
4612
4757
|
//#endregion
|
|
4758
|
+
//#region src/uni-app-x/vite/web-sfc-hmr.ts
|
|
4759
|
+
function createUniAppXWebSfcHmr(options) {
|
|
4760
|
+
const sources = /* @__PURE__ */ new WeakMap();
|
|
4761
|
+
function enabled(ctx) {
|
|
4762
|
+
return options.isEnabled() && /\.(?:uvue|nvue)$/.test(ctx.file) && typeof ctx.read === "function";
|
|
4763
|
+
}
|
|
4764
|
+
return {
|
|
4765
|
+
async prepare(ctx) {
|
|
4766
|
+
if (!enabled(ctx)) return;
|
|
4767
|
+
const source = await ctx.read();
|
|
4768
|
+
sources.set(ctx, source);
|
|
4769
|
+
const result = await options.transform(source, ctx.file);
|
|
4770
|
+
ctx.read = async () => result?.code ?? source;
|
|
4771
|
+
},
|
|
4772
|
+
async finish(ctx) {
|
|
4773
|
+
if (!enabled(ctx)) return false;
|
|
4774
|
+
options.hmrCssModuleVersions?.clear();
|
|
4775
|
+
const source = sources.get(ctx) ?? await ctx.read();
|
|
4776
|
+
if (hasUniAppXImportantApply(source, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)) {
|
|
4777
|
+
ctx.server.ws.send({
|
|
4778
|
+
type: "full-reload",
|
|
4779
|
+
path: ctx.file
|
|
4780
|
+
});
|
|
4781
|
+
return true;
|
|
4782
|
+
}
|
|
4783
|
+
if (!sources.has(ctx)) await options.transform(source, ctx.file);
|
|
4784
|
+
return false;
|
|
4785
|
+
}
|
|
4786
|
+
};
|
|
4787
|
+
}
|
|
4788
|
+
//#endregion
|
|
4613
4789
|
//#region src/uni-app-x/vite/asset-task.ts
|
|
4614
4790
|
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
4615
4791
|
return uniAppX === void 0 ? true : require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
@@ -4653,7 +4829,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
4653
4829
|
//#region src/uni-app-x/vite.ts
|
|
4654
4830
|
let transformUVuePromise;
|
|
4655
4831
|
function loadTransformUVue() {
|
|
4656
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
4832
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-Cy0ddBWf.cjs")).then((mod) => mod.transformUVue));
|
|
4657
4833
|
return transformUVuePromise;
|
|
4658
4834
|
}
|
|
4659
4835
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -4665,8 +4841,13 @@ function createUniAppXPlugins(options) {
|
|
|
4665
4841
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
4666
4842
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
4667
4843
|
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
4668
|
-
const
|
|
4844
|
+
const sfcStyleSources = createUniAppXSfcStyleSources();
|
|
4669
4845
|
const pendingSfcTransforms = /* @__PURE__ */ new Map();
|
|
4846
|
+
const webSfcHmr = createUniAppXWebSfcHmr({
|
|
4847
|
+
isEnabled: () => isEnabled() && isWebGeneratorTarget() && getResolvedConfig()?.command === "serve",
|
|
4848
|
+
transform: (source, id) => runTransformSfc(source, id, {}),
|
|
4849
|
+
hmrCssModuleVersions
|
|
4850
|
+
});
|
|
4670
4851
|
const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget, hmrCssModuleVersions);
|
|
4671
4852
|
let componentLocalStyleEnabled;
|
|
4672
4853
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
@@ -4722,10 +4903,6 @@ function createUniAppXPlugins(options) {
|
|
|
4722
4903
|
}
|
|
4723
4904
|
return styleHandlerOptions;
|
|
4724
4905
|
}
|
|
4725
|
-
function reportStyleWarnings(result) {
|
|
4726
|
-
const warnings = typeof result.warnings === "function" ? result.warnings() : [];
|
|
4727
|
-
for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
|
|
4728
|
-
}
|
|
4729
4906
|
async function transformStyle(code, id, query, hookContext) {
|
|
4730
4907
|
const isNativeStyle = isNativeAppBuildTarget(id);
|
|
4731
4908
|
const parsed = query ?? require_web.parseVueRequest(id).query;
|
|
@@ -4779,19 +4956,17 @@ function createUniAppXPlugins(options) {
|
|
|
4779
4956
|
}, {
|
|
4780
4957
|
name: "weapp-tailwindcss:uni-app-x:css:pre",
|
|
4781
4958
|
enforce: "pre",
|
|
4959
|
+
handleHotUpdate: {
|
|
4960
|
+
order: "pre",
|
|
4961
|
+
handler: (ctx) => webSfcHmr.prepare(ctx)
|
|
4962
|
+
},
|
|
4782
4963
|
load: {
|
|
4783
4964
|
order: "pre",
|
|
4784
4965
|
async handler(id) {
|
|
4785
4966
|
const { filename, query } = require_web.parseVueRequest(id);
|
|
4786
4967
|
if (!query.vue || query.type !== "style" || !UVUE_NVUE_RE.test(filename)) return;
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
if (!style) return;
|
|
4790
|
-
const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source);
|
|
4791
|
-
return normalized === style.source ? void 0 : {
|
|
4792
|
-
code: normalized,
|
|
4793
|
-
map: null
|
|
4794
|
-
};
|
|
4968
|
+
await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
|
|
4969
|
+
return sfcStyleSources.load(filename, query.index ?? 0);
|
|
4795
4970
|
}
|
|
4796
4971
|
},
|
|
4797
4972
|
async transform(code, id) {
|
|
@@ -4799,9 +4974,10 @@ function createUniAppXPlugins(options) {
|
|
|
4799
4974
|
await runtimeState.readyPromise;
|
|
4800
4975
|
const { filename, query } = require_web.parseVueRequest(id);
|
|
4801
4976
|
if (query.vue && query.type === "style") await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
|
|
4802
|
-
const
|
|
4977
|
+
const generatedSource = sfcStyleSources.getGenerated(filename, query.index ?? 0);
|
|
4978
|
+
const resolvedSource = resolveUniAppXStyleSource(code, query, generatedSource);
|
|
4803
4979
|
if (resolvedSource.skip) return;
|
|
4804
|
-
const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
|
|
4980
|
+
const styleCode = query.vue && query.type === "style" && generatedSource === void 0 && !sfcStyleSources.hasGenerated(filename) ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
|
|
4805
4981
|
const preprocessorCode = query.vue && query.type === "style" ? (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(styleCode) : styleCode;
|
|
4806
4982
|
const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
|
|
4807
4983
|
isIosPlatform,
|
|
@@ -4811,11 +4987,14 @@ function createUniAppXPlugins(options) {
|
|
|
4811
4987
|
code: preprocessorCode,
|
|
4812
4988
|
map: null
|
|
4813
4989
|
} : void 0);
|
|
4814
|
-
return transformStyle(preprocessorCode, id, query, this)
|
|
4990
|
+
return await transformStyle(preprocessorCode, id, query, this) ?? (preprocessorCode !== code ? {
|
|
4991
|
+
code: preprocessorCode,
|
|
4992
|
+
map: null
|
|
4993
|
+
} : void 0);
|
|
4815
4994
|
}
|
|
4816
4995
|
}];
|
|
4817
4996
|
async function transformSfc(code, id, context) {
|
|
4818
|
-
|
|
4997
|
+
sfcStyleSources.rememberSource(id, code);
|
|
4819
4998
|
if (isWebGeneratorTarget()) for (const style of require_web.extractSfcStyleBlocks(code)) webCssEntryDiagnostics?.observeSourceImports(style.source, id);
|
|
4820
4999
|
if (isNativeAppBuildTarget(id)) {
|
|
4821
5000
|
nativeLocalStyleModuleIds.add(id);
|
|
@@ -4838,6 +5017,7 @@ function createUniAppXPlugins(options) {
|
|
|
4838
5017
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
4839
5018
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
4840
5019
|
native: true,
|
|
5020
|
+
...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
|
|
4841
5021
|
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
4842
5022
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
4843
5023
|
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => {
|
|
@@ -4846,6 +5026,7 @@ function createUniAppXPlugins(options) {
|
|
|
4846
5026
|
} } : {}
|
|
4847
5027
|
});
|
|
4848
5028
|
const result = Object.keys(transformOptions).length > 0 ? transformUVue(code, id, jsHandler, currentRuntimeSet, transformOptions) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
5029
|
+
sfcStyleSources.rememberGenerated(id, isWebGeneratorTarget() ? result?.code ?? "" : "");
|
|
4849
5030
|
if (!result?.code) return result;
|
|
4850
5031
|
harmonyApply.rememberSource(result.code, id);
|
|
4851
5032
|
const expandedCode = await harmonyApply.expandStyles(result.code, id, context);
|
|
@@ -4874,7 +5055,9 @@ function createUniAppXPlugins(options) {
|
|
|
4874
5055
|
order: "pre",
|
|
4875
5056
|
async handler(code, id) {
|
|
4876
5057
|
if (!isEnabled()) return;
|
|
4877
|
-
|
|
5058
|
+
const { query } = require_web.parseVueRequest(id);
|
|
5059
|
+
if (!UVUE_NVUE_QUERY_RE.test(id) || query.vue && query.type === "style") return;
|
|
5060
|
+
if (isWebGeneratorTarget() && query.vue && query.type) return;
|
|
4878
5061
|
return runTransformSfc(code, id, this);
|
|
4879
5062
|
}
|
|
4880
5063
|
},
|
|
@@ -4883,17 +5066,7 @@ function createUniAppXPlugins(options) {
|
|
|
4883
5066
|
async handler(ctx) {
|
|
4884
5067
|
if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
|
|
4885
5068
|
if (!UVUE_NVUE_RE.test(ctx.file) && !require_web.isCSSRequest(ctx.file)) return;
|
|
4886
|
-
if (
|
|
4887
|
-
const source = await ctx.read();
|
|
4888
|
-
if (hasUniAppXImportantApply(source, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)) {
|
|
4889
|
-
ctx.server.ws.send({
|
|
4890
|
-
type: "full-reload",
|
|
4891
|
-
path: ctx.file
|
|
4892
|
-
});
|
|
4893
|
-
return [];
|
|
4894
|
-
}
|
|
4895
|
-
await runTransformSfc(source, ctx.file, this);
|
|
4896
|
-
}
|
|
5069
|
+
if (await webSfcHmr.finish(ctx)) return [];
|
|
4897
5070
|
return webLocalStyle.handleHotUpdate(ctx) ?? nativeHmrReloader.handleHotUpdate(ctx);
|
|
4898
5071
|
}
|
|
4899
5072
|
},
|
|
@@ -5153,8 +5326,13 @@ async function processRememberedCssReplay(options) {
|
|
|
5153
5326
|
const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
|
|
5154
5327
|
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
5155
5328
|
if (!rememberedCssSource) continue;
|
|
5156
|
-
const {
|
|
5157
|
-
const
|
|
5329
|
+
const { sourceFile } = rememberedCssSource;
|
|
5330
|
+
const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : require_v4_generation_core.normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
|
|
5331
|
+
cssOnly: true,
|
|
5332
|
+
outputFile,
|
|
5333
|
+
outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
|
|
5334
|
+
});
|
|
5335
|
+
const generatorRawSource = isWebGeneratorTarget ? rawSource : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(rawSource, outputFile, [...bundleFiles, ...lastCssResultByFile.keys()]);
|
|
5158
5336
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5159
5337
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
5160
5338
|
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
@@ -5235,7 +5413,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5235
5413
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
5236
5414
|
metrics.css.elapsed += measureElapsed(start);
|
|
5237
5415
|
metrics.css.transformed++;
|
|
5238
|
-
onUpdate(outputFile, rawSource, css);
|
|
5416
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, css);
|
|
5239
5417
|
debug("css replay preserve local import shell: %s", outputFile);
|
|
5240
5418
|
}));
|
|
5241
5419
|
continue;
|
|
@@ -5275,7 +5453,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5275
5453
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
5276
5454
|
metrics.css.elapsed += measureElapsed(start);
|
|
5277
5455
|
metrics.css.transformed++;
|
|
5278
|
-
onUpdate(outputFile, rawSource, css);
|
|
5456
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, css);
|
|
5279
5457
|
debug("css replay handle: %s", outputFile);
|
|
5280
5458
|
}));
|
|
5281
5459
|
}
|
|
@@ -5359,7 +5537,7 @@ function createConfiguredCssRootResolvers(options) {
|
|
|
5359
5537
|
if (matchedOriginalEntry && outputFile.replace(/[?#].*$/, "").endsWith(".css")) return matchedOriginalEntry;
|
|
5360
5538
|
const shouldRequireExplicitEntry = !options.cssPipelineContext.currentGeneratorBranch.isWeb && options.opts.cssMatcher(outputFile) && isRootStyleOutputFile(outputFile);
|
|
5361
5539
|
const generationEntries = entries.filter((entry) => require_web.hasTailwindGenerationSource(entry.source) && (!shouldRequireExplicitEntry || explicitFileKeys.has(normalizeEntryFile(entry.file))));
|
|
5362
|
-
const matchedOutputEntries = generationEntries.filter((entry) => require_source_candidate_scan_signature.normalizeOutputPathKey(resolveEntryOutputFile(entry.file).replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")));
|
|
5540
|
+
const matchedOutputEntries = generationEntries.filter((entry) => require_source_candidate_scan_signature.normalizeOutputPathKey(resolveEntryOutputFile(entry.file).replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")) || (originalFileNames?.length ?? 0) === 0 && require_source_candidate_scan_signature.normalizeOutputPathKey(options.rootImportShellTargets?.get(resolveEntryOutputFile(entry.file)) ?? "") === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")));
|
|
5363
5541
|
if (matchedOutputEntries.length === 1) return matchedOutputEntries[0];
|
|
5364
5542
|
if (!shouldSelectRootOutput(outputFile)) return;
|
|
5365
5543
|
if (generationEntries.length <= 1) return generationEntries[0];
|
|
@@ -5423,7 +5601,7 @@ function createConfiguredCssRootResolvers(options) {
|
|
|
5423
5601
|
}
|
|
5424
5602
|
//#endregion
|
|
5425
5603
|
//#region src/bundlers/vite/generate-bundle/runtime-linked-css.ts
|
|
5426
|
-
const MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE = /\.(?:wxml|axml|jxml|ksml|ttml|qml|tyml|xhsml|swan)$/i;
|
|
5604
|
+
const MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE = /\.(?:wxml|axml|jxml|ksml|ttml|qml|qxml|tyml|xhsml|swan)$/i;
|
|
5427
5605
|
const JS_STYLE_IMPORT_RE = /\b(?:import|require)\s*(?:\(\s*)?["']([^"']+\.(?:css|less|sass|scss|styl|stylus|pcss|postcss))(?:[?#][^"']*)?["']/g;
|
|
5428
5606
|
function addSiblingCssFile(files, file, extensionByStem, fallbackExtension) {
|
|
5429
5607
|
const templateMatch = file.replace(/[?#].*$/, "").match(MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE);
|
|
@@ -5904,7 +6082,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
5904
6082
|
const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
5905
6083
|
const defaultStyleOutputExtension = require_web.resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
|
|
5906
6084
|
const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
|
|
5907
|
-
return isWebGeneratorTarget ? source : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(source, outputFile);
|
|
6085
|
+
return isWebGeneratorTarget ? source : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(source, outputFile, [...Object.keys(bundle), ...lastCssResultByFile.keys()]);
|
|
5908
6086
|
};
|
|
5909
6087
|
await runtimeState.readyPromise;
|
|
5910
6088
|
debug("start");
|
|
@@ -5964,6 +6142,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
5964
6142
|
currentSubpackageRoots,
|
|
5965
6143
|
defaultStyleOutputExtension,
|
|
5966
6144
|
entries: configuredTailwindV4CssSourceEntriesForScope,
|
|
6145
|
+
rootImportShellTargets: frameworkRootImportShellTargetByFile,
|
|
5967
6146
|
explicitCssEntryFiles: configuredTailwindV4ExplicitCssEntryFiles,
|
|
5968
6147
|
isWebGeneratorTarget,
|
|
5969
6148
|
opts,
|
|
@@ -6528,6 +6707,55 @@ function createGenerateBundleHook(context) {
|
|
|
6528
6707
|
};
|
|
6529
6708
|
}
|
|
6530
6709
|
//#endregion
|
|
6710
|
+
//#region src/bundlers/vite/generate-bundle/entry-style-graph.ts
|
|
6711
|
+
function linkEntryChunkStyles(bundle, options) {
|
|
6712
|
+
const assets = new Map(Object.entries(bundle).flatMap(([key, output]) => output.type === "asset" ? [[require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || key), output]] : []));
|
|
6713
|
+
const imports = /* @__PURE__ */ new Map();
|
|
6714
|
+
for (const [file, asset] of assets) {
|
|
6715
|
+
if (!options.matchesCss(file)) continue;
|
|
6716
|
+
const targets = /* @__PURE__ */ new Set();
|
|
6717
|
+
_weapp_tailwindcss_postcss.postcss.parse(asset.source.toString()).walkAtRules("import", (rule) => {
|
|
6718
|
+
const request = require_generator.parseCssImportSpecifier(rule.params)?.specifier;
|
|
6719
|
+
if (request && !/^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i.test(request)) {
|
|
6720
|
+
const target = node_path.default.posix.normalize(node_path.default.posix.join(node_path.default.posix.dirname(file), request));
|
|
6721
|
+
if (assets.has(target)) targets.add(target);
|
|
6722
|
+
}
|
|
6723
|
+
});
|
|
6724
|
+
imports.set(file, targets);
|
|
6725
|
+
}
|
|
6726
|
+
const reaches = (from, target, visited = /* @__PURE__ */ new Set()) => {
|
|
6727
|
+
if (from === target) return true;
|
|
6728
|
+
if (visited.has(from)) return false;
|
|
6729
|
+
visited.add(from);
|
|
6730
|
+
return [...imports.get(from) ?? []].some((next) => reaches(next, target, visited));
|
|
6731
|
+
};
|
|
6732
|
+
for (const chunk of Object.values(bundle)) {
|
|
6733
|
+
if (chunk.type !== "chunk" || !chunk.isEntry) continue;
|
|
6734
|
+
const entry = node_path.default.posix.parse(require_source_candidate_scan_signature.normalizeOutputPathKey(chunk.fileName));
|
|
6735
|
+
const roots = [...assets].filter(([file]) => {
|
|
6736
|
+
const style = node_path.default.posix.parse(file);
|
|
6737
|
+
return options.matchesCss(file) && style.dir === entry.dir && style.name === entry.name;
|
|
6738
|
+
});
|
|
6739
|
+
if (roots.length !== 1) continue;
|
|
6740
|
+
const [file, asset] = roots[0];
|
|
6741
|
+
const original = asset.source.toString();
|
|
6742
|
+
const requests = [];
|
|
6743
|
+
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
6744
|
+
const output = options.resolveOutputFile(id);
|
|
6745
|
+
const target = output && require_source_candidate_scan_signature.normalizeOutputPathKey(output);
|
|
6746
|
+
if (!target || !imports.has(target) || reaches(file, target) || reaches(target, file)) continue;
|
|
6747
|
+
imports.get(file).add(target);
|
|
6748
|
+
const relative = node_path.default.posix.relative(node_path.default.posix.dirname(file), target);
|
|
6749
|
+
requests.push(`@import ${require_generator.quoteCssImportSpecifier(relative.startsWith(".") ? relative : `./${relative}`)};\n`);
|
|
6750
|
+
}
|
|
6751
|
+
if (requests.length > 0) {
|
|
6752
|
+
const next = requests.join("") + original;
|
|
6753
|
+
asset.source = next;
|
|
6754
|
+
options.onUpdate?.(file, original, next);
|
|
6755
|
+
}
|
|
6756
|
+
}
|
|
6757
|
+
}
|
|
6758
|
+
//#endregion
|
|
6531
6759
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
6532
6760
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
6533
6761
|
return {
|
|
@@ -6614,6 +6842,17 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6614
6842
|
finalCssAssetFiles.add(file);
|
|
6615
6843
|
opts.onUpdate(file, original, generated);
|
|
6616
6844
|
};
|
|
6845
|
+
const linkEntryStyles = () => {
|
|
6846
|
+
if (isWebGeneratorTarget) return;
|
|
6847
|
+
linkEntryChunkStyles(bundle, {
|
|
6848
|
+
matchesCss: opts.cssMatcher,
|
|
6849
|
+
onUpdate: trackFinalCssAssetUpdate,
|
|
6850
|
+
resolveOutputFile: (id) => {
|
|
6851
|
+
if (!opts.cssMatcher(id) || id.includes("?")) return;
|
|
6852
|
+
return require_web.resolveViteCssPipelineOutputFile(id, opts, rootDir, false, false, sourceRoot, require_web.resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle));
|
|
6853
|
+
}
|
|
6854
|
+
});
|
|
6855
|
+
};
|
|
6617
6856
|
restoreFrameworkRootMiniProgramImportShellAssets(bundle, {
|
|
6618
6857
|
debug,
|
|
6619
6858
|
isWebGeneratorTarget,
|
|
@@ -6720,6 +6959,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6720
6959
|
await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
|
|
6721
6960
|
collectViteProcessedCssAssets();
|
|
6722
6961
|
injectViteProcessedCssIntoMainCss();
|
|
6962
|
+
linkEntryStyles();
|
|
6723
6963
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
6724
6964
|
cssMatcher: opts.cssMatcher,
|
|
6725
6965
|
debug,
|
|
@@ -6844,6 +7084,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6844
7084
|
await injectHarmonyBundleStyles();
|
|
6845
7085
|
collectViteProcessedCssAssets();
|
|
6846
7086
|
injectViteProcessedCssIntoMainCss();
|
|
7087
|
+
linkEntryStyles();
|
|
6847
7088
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
6848
7089
|
cssMatcher: opts.cssMatcher,
|
|
6849
7090
|
debug,
|
|
@@ -6882,7 +7123,7 @@ function createViteServeJsTransformPlugin(options) {
|
|
|
6882
7123
|
if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
|
|
6883
7124
|
const handlerOptions = options.createHandlerOptions(id);
|
|
6884
7125
|
if (require_compiler.shouldSkipJsTransform(code, handlerOptions)) return;
|
|
6885
|
-
const runtime = await options.transformRuntime();
|
|
7126
|
+
const runtime = await options.transformRuntime(id, code);
|
|
6886
7127
|
const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
|
|
6887
7128
|
if (transformed === code) return;
|
|
6888
7129
|
return {
|
|
@@ -7020,9 +7261,9 @@ function createConfiguredCssEntryDiagnostics(options) {
|
|
|
7020
7261
|
//#endregion
|
|
7021
7262
|
//#region src/bundlers/vite/shared/framework-module-candidates.ts
|
|
7022
7263
|
function createFrameworkModuleCandidateRegistrar(options) {
|
|
7023
|
-
return async (id, source) => {
|
|
7264
|
+
return async (id, source, extension) => {
|
|
7024
7265
|
await options.runtimeState.readyPromise;
|
|
7025
|
-
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
|
|
7266
|
+
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source, extension);
|
|
7026
7267
|
options.invalidateRecordedGeneratorCandidates();
|
|
7027
7268
|
options.cacheCurrent();
|
|
7028
7269
|
const cssHandlerOptions = options.getCssHandlerOptions(id);
|
|
@@ -7761,7 +8002,7 @@ ${previousTracedCss}`;
|
|
|
7761
8002
|
previousCss: previousGeneratorCss,
|
|
7762
8003
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
7763
8004
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
7764
|
-
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
8005
|
+
deferCssAdaptation: resolvedConfig?.command === "build" && !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7765
8006
|
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
7766
8007
|
cssStage: hookContext?.cssStage,
|
|
7767
8008
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
@@ -7954,6 +8195,8 @@ ${tracedCss}`;
|
|
|
7954
8195
|
await sourceScanSession.sync();
|
|
7955
8196
|
};
|
|
7956
8197
|
const extraPlugins = capability.frameworkExtras ? frameworkBranch.createExtraPlugins?.({
|
|
8198
|
+
cssPreflight: opts.cssPreflight,
|
|
8199
|
+
cssPreflightRange: opts.cssPreflightRange,
|
|
7957
8200
|
customAttributesEntities,
|
|
7958
8201
|
disabledDefaultTemplateHandler,
|
|
7959
8202
|
ensureRuntimeClassSet,
|
|
@@ -8058,7 +8301,7 @@ ${tracedCss}`;
|
|
|
8058
8301
|
getCommand: () => resolvedConfig?.command,
|
|
8059
8302
|
jsHandler,
|
|
8060
8303
|
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
8061
|
-
transformRuntime:
|
|
8304
|
+
transformRuntime: (id, code) => registerModuleGraphCandidates(id, code, "js")
|
|
8062
8305
|
}) : void 0;
|
|
8063
8306
|
const plugins = [
|
|
8064
8307
|
...sourceAndRewritePlugins,
|
|
@@ -8107,7 +8350,7 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8107
8350
|
try {
|
|
8108
8351
|
return await hook.apply(this, args);
|
|
8109
8352
|
} finally {
|
|
8110
|
-
dispose();
|
|
8353
|
+
dispose.call(this);
|
|
8111
8354
|
}
|
|
8112
8355
|
};
|
|
8113
8356
|
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
|
|
@@ -8116,7 +8359,7 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8116
8359
|
try {
|
|
8117
8360
|
return await hook.handler.apply(this, args);
|
|
8118
8361
|
} finally {
|
|
8119
|
-
dispose();
|
|
8362
|
+
dispose.call(this);
|
|
8120
8363
|
}
|
|
8121
8364
|
}
|
|
8122
8365
|
};
|
|
@@ -8140,7 +8383,12 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8140
8383
|
})
|
|
8141
8384
|
}));
|
|
8142
8385
|
const cleanupPlugin = wrappedPlugins.at(-1);
|
|
8143
|
-
if (cleanupPlugin)
|
|
8386
|
+
if (cleanupPlugin) {
|
|
8387
|
+
cleanupPlugin.closeBundle = wrapPluginCloseBundle(cleanupPlugin.closeBundle, function() {
|
|
8388
|
+
if (!this.meta?.watchMode) relationOwner.dispose();
|
|
8389
|
+
});
|
|
8390
|
+
cleanupPlugin.closeWatcher = wrapPluginCloseBundle(cleanupPlugin.closeWatcher, relationOwner.dispose);
|
|
8391
|
+
}
|
|
8144
8392
|
return wrappedPlugins;
|
|
8145
8393
|
}
|
|
8146
8394
|
//#endregion
|
|
@@ -8179,11 +8427,13 @@ function createTaroAlipayBrowserslistAssetPlugin() {
|
|
|
8179
8427
|
};
|
|
8180
8428
|
}
|
|
8181
8429
|
function createTaroVitePlugins(options = {}) {
|
|
8182
|
-
|
|
8430
|
+
const plugins = createViteFrameworkPlugins(options, {
|
|
8183
8431
|
frameworkName: "taro",
|
|
8184
8432
|
cssPipelineStrategy: taroCssPipelineStrategy,
|
|
8185
8433
|
styleInjectorDelegate: require_scoped_generator.viteStyleInjectorDelegates.taro
|
|
8186
|
-
})
|
|
8434
|
+
});
|
|
8435
|
+
if (!plugins) return;
|
|
8436
|
+
return [createTaroAlipayBrowserslistAssetPlugin(), ...plugins];
|
|
8187
8437
|
}
|
|
8188
8438
|
//#endregion
|
|
8189
8439
|
//#region src/bundlers/vite/frameworks/uni-app/index.ts
|
|
@@ -8378,7 +8628,8 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8378
8628
|
},
|
|
8379
8629
|
transformGeneratedCss(css, context) {
|
|
8380
8630
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
8381
|
-
|
|
8631
|
+
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
8632
|
+
return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
|
|
8382
8633
|
}
|
|
8383
8634
|
};
|
|
8384
8635
|
function createUniAppXVitePlugins(options = {}) {
|
|
@@ -8392,6 +8643,8 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
8392
8643
|
sourceCandidatesBeforeExtraPlugin: (plugin) => plugin.name === "weapp-tailwindcss:uni-app-x:nvue",
|
|
8393
8644
|
createExtraPlugins: (context) => createUniAppXPlugins({
|
|
8394
8645
|
appType: "uni-app-x",
|
|
8646
|
+
cssPreflight: context.cssPreflight,
|
|
8647
|
+
cssPreflightRange: context.cssPreflightRange,
|
|
8395
8648
|
customAttributesEntities: context.customAttributesEntities,
|
|
8396
8649
|
disabledDefaultTemplateHandler: context.disabledDefaultTemplateHandler,
|
|
8397
8650
|
ensureRuntimeClassSet: context.ensureRuntimeClassSet,
|
|
@@ -8676,6 +8929,18 @@ Object.defineProperty(exports, "WeappTailwindcss", {
|
|
|
8676
8929
|
return WeappTailwindcss;
|
|
8677
8930
|
}
|
|
8678
8931
|
});
|
|
8932
|
+
Object.defineProperty(exports, "injectBorderPreflightClass", {
|
|
8933
|
+
enumerable: true,
|
|
8934
|
+
get: function() {
|
|
8935
|
+
return injectBorderPreflightClass;
|
|
8936
|
+
}
|
|
8937
|
+
});
|
|
8938
|
+
Object.defineProperty(exports, "isUniAppXStyleSourceEmpty", {
|
|
8939
|
+
enumerable: true,
|
|
8940
|
+
get: function() {
|
|
8941
|
+
return isUniAppXStyleSourceEmpty;
|
|
8942
|
+
}
|
|
8943
|
+
});
|
|
8679
8944
|
Object.defineProperty(exports, "shouldEnableComponentLocalStyle", {
|
|
8680
8945
|
enumerable: true,
|
|
8681
8946
|
get: function() {
|
|
@@ -8688,3 +8953,9 @@ Object.defineProperty(exports, "shouldEnablePageLocalStyle", {
|
|
|
8688
8953
|
return shouldEnablePageLocalStyle;
|
|
8689
8954
|
}
|
|
8690
8955
|
});
|
|
8956
|
+
Object.defineProperty(exports, "shouldInjectBorderPreflight", {
|
|
8957
|
+
enumerable: true,
|
|
8958
|
+
get: function() {
|
|
8959
|
+
return shouldInjectBorderPreflight;
|
|
8960
|
+
}
|
|
8961
|
+
});
|