weapp-tailwindcss 5.3.1 → 5.3.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/source-candidates/types-and-cache.d.ts +3 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +15 -0
- package/dist/{context-Kvr3lLEC.js → context-4ittVpgt.js} +1 -1
- package/dist/{context-CB4Ef9U0.cjs → context-Ulhcd5lF.cjs} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{gulp-vz36-uQP.js → gulp-8V2aiU52.js} +3 -3
- package/dist/{gulp-QJ_oz-06.cjs → gulp-CsssU4xB.cjs} +6 -6
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-HGlM4hX3.js → hmr-timing-CTpjCpQh.js} +42 -13
- package/dist/{hmr-timing-W3kro20F.cjs → hmr-timing-DyiiYupC.cjs} +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/local-style-matcher-DRpFEu1s.cjs +34 -0
- package/dist/local-style-matcher-DsiI2wIc.js +17 -0
- package/dist/{options-CKZW99r4.cjs → options-BJrtIQbH.cjs} +3 -1
- package/dist/{pipeline-helpers-t95KPu4O.cjs → pipeline-helpers-Cda0Ox3K.cjs} +2 -2
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{source-candidate-scan-signature-BHCPQVoD.js → source-candidate-scan-signature--r31NK5J.js} +2 -2
- package/dist/{source-candidate-scan-signature-BSad7bMQ.cjs → source-candidate-scan-signature-bJFr7L8T.cjs} +2 -2
- package/dist/{style-options-PCgz2ywM.cjs → style-options-DW30H5PV.cjs} +1 -1
- package/dist/{tailwindcss-jKzY37Sk.cjs → tailwindcss-CexDJBhx.cjs} +1 -1
- package/dist/{tailwindcss-BSEdWieh.js → tailwindcss-ChnpCv25.js} +3 -1
- package/dist/{component-local-style-CNhEhd2B.cjs → transform-BQjg2T2T.cjs} +201 -27
- package/dist/{component-local-style-C2wC8o9F.js → transform-Cp4KybBy.js} +207 -16
- package/dist/types/user-defined-options/important.d.ts +2 -0
- package/dist/uni-app-x/component-local-style.d.ts +6 -4
- package/dist/uni-app-x/local-style-matcher.d.ts +4 -0
- package/dist/uni-app-x/options.d.ts +2 -0
- package/dist/uni-app-x/style-asset/harmony-global.d.ts +11 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +1 -3
- package/dist/uni-app-x/style-asset.d.ts +3 -8
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +1 -0
- package/dist/{v4-generation-core-BfeXEc6R.cjs → v4-generation-core-8YMXikPd.cjs} +42 -13
- package/dist/{vite-CtmGLZXy.cjs → vite-CeyMHgzQ.cjs} +180 -97
- package/dist/{vite-Crz1mQR4.js → vite-kY-WXrd6.js} +233 -150
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +4 -4
- package/dist/{webpack-DwtdWqwr.js → webpack-BN2kLWW_.js} +4 -4
- package/dist/{webpack-Cf5RnhXt.cjs → webpack-Bfj63Wt1.cjs} +8 -8
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +3 -3
- package/dist/transform-CgohToUV.cjs +0 -200
- package/dist/transform-DSRPiBWz.js +0 -201
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
2
2
|
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Ot as resolveSourceScanPath, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, lt as hasTailwindGeneratedCss, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-EnTXLBlK.js";
|
|
3
3
|
import { t as omitUndefined } from "./object-B-8IHefx.js";
|
|
4
|
-
import { a as findTailwindConfig, f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-
|
|
4
|
+
import { a as findTailwindConfig, f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-ChnpCv25.js";
|
|
5
5
|
import "./utils-MVwpU07P.js";
|
|
6
|
-
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, st as createSourceCandidateEligibilityMatcher, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-
|
|
6
|
+
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, st as createSourceCandidateEligibilityMatcher, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-CTpjCpQh.js";
|
|
7
7
|
import { m as createDebug, p as replaceWxml } from "./wxml-B7OAVpXJ.js";
|
|
8
|
-
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-
|
|
9
|
-
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature
|
|
8
|
+
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-4ittVpgt.js";
|
|
9
|
+
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature--r31NK5J.js";
|
|
10
|
+
import { n as shouldEnableComponentLocalStyle, r as shouldEnablePageLocalStyle, t as normalizeUniAppXLocalStyleId } from "./local-style-matcher-DsiI2wIc.js";
|
|
10
11
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
|
-
import { r as shouldEnablePageLocalStyle } from "./component-local-style-C2wC8o9F.js";
|
|
12
12
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import process$1 from "node:process";
|
|
@@ -17,7 +17,7 @@ import { collectCssImportRequestsRoot, compileCssMacroConditionalComments, conta
|
|
|
17
17
|
import { LRUCache } from "lru-cache";
|
|
18
18
|
import { readFile } from "node:fs/promises";
|
|
19
19
|
import micromatch from "micromatch";
|
|
20
|
-
import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
|
|
20
|
+
import { cleanUrl as cleanUrl$1, ensurePosix } from "@weapp-tailwindcss/shared";
|
|
21
21
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
import { Buffer } from "node:buffer";
|
|
@@ -234,6 +234,20 @@ const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
|
|
|
234
234
|
const SFC_STYLE_BLOCK_RE$2 = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
235
235
|
const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
|
|
236
236
|
const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
|
|
237
|
+
function cloneStyleEntry(entry) {
|
|
238
|
+
return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
|
|
239
|
+
}
|
|
240
|
+
function mergeStyleEntry(local, generated) {
|
|
241
|
+
const merged = local ? cloneStyleEntry(local) : {};
|
|
242
|
+
for (const [state, declarations] of Object.entries(generated)) merged[state] = {
|
|
243
|
+
...merged[state] ?? {},
|
|
244
|
+
...declarations
|
|
245
|
+
};
|
|
246
|
+
return merged;
|
|
247
|
+
}
|
|
248
|
+
function cloneStyleValue(style) {
|
|
249
|
+
return Object.fromEntries(Object.entries(style).map(([className, entry]) => [className, cloneStyleEntry(entry)]));
|
|
250
|
+
}
|
|
237
251
|
function toCamelCase(prop) {
|
|
238
252
|
return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
239
253
|
}
|
|
@@ -440,11 +454,14 @@ function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
|
440
454
|
function createMergedStyleValue(code, localStyle, appStyle) {
|
|
441
455
|
const used = collectUsedStyleKeys(code, appStyle);
|
|
442
456
|
if (used.size === 0) return;
|
|
443
|
-
const merged =
|
|
457
|
+
const merged = localStyle ? cloneStyleValue(localStyle) : {};
|
|
444
458
|
let changed = false;
|
|
445
459
|
for (const className of used) {
|
|
446
|
-
|
|
447
|
-
|
|
460
|
+
const generatedStyle = appStyle[className];
|
|
461
|
+
if (!generatedStyle) continue;
|
|
462
|
+
const next = mergeStyleEntry(merged[className], generatedStyle);
|
|
463
|
+
if (JSON.stringify(next) === JSON.stringify(merged[className])) continue;
|
|
464
|
+
merged[className] = next;
|
|
448
465
|
changed = true;
|
|
449
466
|
}
|
|
450
467
|
return changed ? merged : void 0;
|
|
@@ -453,87 +470,45 @@ function createMergedStyleValues(code, localStyles, appStyle) {
|
|
|
453
470
|
if (localStyles.length === 0) return;
|
|
454
471
|
const used = collectUsedStyleKeys(code, appStyle);
|
|
455
472
|
if (used.size === 0) return;
|
|
456
|
-
const merged = localStyles.map(
|
|
473
|
+
const merged = localStyles.map(cloneStyleValue);
|
|
457
474
|
let changed = false;
|
|
458
475
|
for (const className of used) {
|
|
459
476
|
const generatedStyle = appStyle[className];
|
|
460
477
|
if (!generatedStyle) continue;
|
|
461
478
|
const indexes = merged.flatMap((style, index) => style[className] ? [index] : []);
|
|
462
479
|
if (indexes.length === 0) {
|
|
463
|
-
merged[0][className] = generatedStyle;
|
|
480
|
+
merged[0][className] = mergeStyleEntry(void 0, generatedStyle);
|
|
464
481
|
changed = true;
|
|
465
482
|
continue;
|
|
466
483
|
}
|
|
467
484
|
for (const index of indexes) {
|
|
468
|
-
|
|
469
|
-
merged[index][className]
|
|
485
|
+
const next = mergeStyleEntry(merged[index][className], generatedStyle);
|
|
486
|
+
if (JSON.stringify(merged[index][className]) === JSON.stringify(next)) continue;
|
|
487
|
+
merged[index][className] = next;
|
|
470
488
|
changed = true;
|
|
471
489
|
}
|
|
472
490
|
}
|
|
473
491
|
return changed ? merged : void 0;
|
|
474
492
|
}
|
|
475
493
|
//#endregion
|
|
476
|
-
//#region src/uni-app-x/style-asset.ts
|
|
477
|
-
const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
|
|
494
|
+
//#region src/uni-app-x/style-asset/harmony-global.ts
|
|
478
495
|
const UVUE_TS_RE = /\.uvue\.ts$/;
|
|
479
496
|
const JS_RE = /\.js$/;
|
|
480
|
-
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
497
|
+
const APP_JS_RE$1 = /(?:^|\/)App\.js$/;
|
|
481
498
|
const COMPONENT_JS_RE = /(?:^|\/)components\/.+\.js$/;
|
|
482
|
-
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
483
|
-
"import/app-service.ets",
|
|
484
|
-
"import/dynamic.ets",
|
|
485
|
-
"uni_modules/oh-package.json5"
|
|
486
|
-
]);
|
|
487
499
|
const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
|
|
488
500
|
const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
return
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
});
|
|
501
|
-
return root.toString();
|
|
502
|
-
}).join("\n");
|
|
503
|
-
}
|
|
504
|
-
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
505
|
-
const utilities = /* @__PURE__ */ new Set();
|
|
506
|
-
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
507
|
-
for (const [file, item] of Object.entries(bundle)) {
|
|
508
|
-
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
509
|
-
const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
510
|
-
const source = getBundleSource(mapFile);
|
|
511
|
-
return source ? parseSourceMapSourcesContent(source) : [];
|
|
512
|
-
}));
|
|
513
|
-
for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
514
|
-
}
|
|
515
|
-
return utilities;
|
|
516
|
-
}
|
|
517
|
-
function collectUniAppXHarmonyApplyStyleSources(bundle) {
|
|
518
|
-
const sources = /* @__PURE__ */ new Set();
|
|
519
|
-
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
520
|
-
const addSource = (source) => {
|
|
521
|
-
for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
|
|
522
|
-
};
|
|
523
|
-
for (const [file, item] of Object.entries(bundle)) {
|
|
524
|
-
if (item.type === "asset" && file.endsWith(".uvue")) {
|
|
525
|
-
addSource(String(item.source));
|
|
526
|
-
continue;
|
|
527
|
-
}
|
|
528
|
-
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
529
|
-
for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
|
|
530
|
-
for (const mapFile of resolveSourceMapFiles(file)) {
|
|
531
|
-
const source = getBundleSource(mapFile);
|
|
532
|
-
if (!source) continue;
|
|
533
|
-
for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
return [...sources];
|
|
501
|
+
function resolveSfcSourceId(code) {
|
|
502
|
+
const match = code.match(/\[\s*["']__file["']\s*,\s*(["'])(.*?)\1\s*\]/);
|
|
503
|
+
return match?.[2] ? normalizeUniAppXLocalStyleId(match[2]) : void 0;
|
|
504
|
+
}
|
|
505
|
+
function shouldExcludeComponent(file, code, options) {
|
|
506
|
+
if (!options.excludeComponents) return false;
|
|
507
|
+
const sourceId = resolveSfcSourceId(code);
|
|
508
|
+
if (sourceId) return shouldEnableComponentLocalStyle(sourceId, options.componentMatcher);
|
|
509
|
+
const normalizedFile = normalizeUniAppXLocalStyleId(file);
|
|
510
|
+
if (options.componentMatcher?.(normalizedFile)) return true;
|
|
511
|
+
return COMPONENT_JS_RE.test(normalizedFile);
|
|
537
512
|
}
|
|
538
513
|
function resolveStyleAssetFile(file) {
|
|
539
514
|
if (!UVUE_TS_RE.test(file)) return;
|
|
@@ -605,19 +580,19 @@ function resolveCssFallbackFiles(styleAssetFiles = []) {
|
|
|
605
580
|
function resolveStyleAssetFilesForChunk(file, styleAssetFiles) {
|
|
606
581
|
return typeof styleAssetFiles === "function" ? styleAssetFiles(file) : styleAssetFiles;
|
|
607
582
|
}
|
|
608
|
-
function resolveSourceMapFiles(file) {
|
|
583
|
+
function resolveSourceMapFiles$1(file) {
|
|
609
584
|
return [
|
|
610
585
|
`${file}.map`,
|
|
611
586
|
file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
|
|
612
587
|
file.startsWith("assets/") ? void 0 : `assets/${file}.map`
|
|
613
588
|
].filter((item) => typeof item === "string");
|
|
614
589
|
}
|
|
615
|
-
function createStyleValueFromBundleSources(file,
|
|
590
|
+
function createStyleValueFromBundleSources(file, getBundleSource, options = {}) {
|
|
616
591
|
const cssStyles = mergeStyleValues(...[...options.cssSources ?? []].map((source) => source ? cssSourceToStyleValue(source) : void 0), ...resolveCssFallbackFiles(resolveStyleAssetFilesForChunk(file, options.styleAssetFiles)).map((cssFile) => {
|
|
617
592
|
const source = getBundleSource?.(cssFile);
|
|
618
593
|
return source ? cssSourceToStyleValue(source) : void 0;
|
|
619
594
|
}));
|
|
620
|
-
return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
595
|
+
return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles$1(file).flatMap((mapFile) => {
|
|
621
596
|
const source = getBundleSource?.(mapFile);
|
|
622
597
|
return source ? parseSourceMapSourcesContent(source) : [];
|
|
623
598
|
})].filter((source) => typeof source === "string"), cssStyles));
|
|
@@ -636,22 +611,9 @@ function injectStyleOption(code, styleVarName) {
|
|
|
636
611
|
if (fileOptionIndex < 0) return code;
|
|
637
612
|
return `${code.slice(0, fileOptionIndex)}["styles", [${styleVarName}]], ${code.slice(fileOptionIndex)}`;
|
|
638
613
|
}
|
|
639
|
-
function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
|
|
640
|
-
const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
|
|
641
|
-
const stylesName = match?.[1] ?? match?.[2];
|
|
642
|
-
if (!stylesName) return code;
|
|
643
|
-
if (!resolveStyleAssetFile(file)) return code;
|
|
644
|
-
const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
|
|
645
|
-
const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
|
|
646
|
-
const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
|
|
647
|
-
const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
|
|
648
|
-
if (styleArrays.length === 0) return code;
|
|
649
|
-
const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
|
|
650
|
-
return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
|
|
651
|
-
}
|
|
652
614
|
function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options = {}) {
|
|
653
|
-
if (!JS_RE.test(file) || APP_JS_RE.test(file)) return code;
|
|
654
|
-
if (
|
|
615
|
+
if (!JS_RE.test(file) || APP_JS_RE$1.test(file)) return code;
|
|
616
|
+
if (shouldExcludeComponent(file, code, options)) return code;
|
|
655
617
|
const appSource = getBundleSource?.("assets/App.js") ?? getBundleSource?.("App.js");
|
|
656
618
|
const appStyle = appSource ? mergeStyleValues(...findStyleObjectDecls(appSource).map((decl) => parseStyleObject(decl.objectText))) : void 0;
|
|
657
619
|
const parseableLocalStyles = findStyleObjectDecls(code).flatMap((decl) => {
|
|
@@ -661,7 +623,7 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
|
|
|
661
623
|
style
|
|
662
624
|
}] : [];
|
|
663
625
|
});
|
|
664
|
-
const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file,
|
|
626
|
+
const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file, getBundleSource, options), appStyle);
|
|
665
627
|
if (!styleSource) return code;
|
|
666
628
|
const mergedStyles = createMergedStyleValues(code, parseableLocalStyles.map((item) => item.style), styleSource);
|
|
667
629
|
if (mergedStyles) {
|
|
@@ -678,7 +640,87 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
|
|
|
678
640
|
const exportMatch = code.match(EXPORT_SFC_RE);
|
|
679
641
|
if (!exportMatch || exportMatch.index === void 0) return code;
|
|
680
642
|
const styleVarName = "_style_wt";
|
|
681
|
-
|
|
643
|
+
const statementStart = code.lastIndexOf("\n", exportMatch.index);
|
|
644
|
+
const insertPos = statementStart === -1 ? 0 : statementStart + 1;
|
|
645
|
+
return injectStyleOption(new RegExp(`\\b(?:const|let|var)\\s+${styleVarName}\\s*=`).test(code) ? code : `${code.slice(0, insertPos)}const ${styleVarName} = ${JSON.stringify(newStyle)};\n${code.slice(insertPos)}`, styleVarName);
|
|
646
|
+
}
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/uni-app-x/style-asset.ts
|
|
649
|
+
const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
|
|
650
|
+
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
651
|
+
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
652
|
+
"import/app-service.ets",
|
|
653
|
+
"import/dynamic.ets",
|
|
654
|
+
"uni_modules/oh-package.json5"
|
|
655
|
+
]);
|
|
656
|
+
function resolveSourceMapFiles(file) {
|
|
657
|
+
return [
|
|
658
|
+
`${file}.map`,
|
|
659
|
+
file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
|
|
660
|
+
file.startsWith("assets/") ? void 0 : `assets/${file}.map`
|
|
661
|
+
].filter((item) => typeof item === "string");
|
|
662
|
+
}
|
|
663
|
+
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
664
|
+
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
665
|
+
return applyStyleSources.map((source) => {
|
|
666
|
+
let root;
|
|
667
|
+
try {
|
|
668
|
+
root = postcss.parse(source);
|
|
669
|
+
} catch {
|
|
670
|
+
return source;
|
|
671
|
+
}
|
|
672
|
+
root.walkAtRules("reference", (rule) => {
|
|
673
|
+
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
674
|
+
});
|
|
675
|
+
return root.toString();
|
|
676
|
+
}).join("\n");
|
|
677
|
+
}
|
|
678
|
+
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
679
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
680
|
+
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
681
|
+
for (const [file, item] of Object.entries(bundle)) {
|
|
682
|
+
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
683
|
+
const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
684
|
+
const source = getBundleSource(mapFile);
|
|
685
|
+
return source ? parseSourceMapSourcesContent(source) : [];
|
|
686
|
+
}));
|
|
687
|
+
for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
688
|
+
}
|
|
689
|
+
return utilities;
|
|
690
|
+
}
|
|
691
|
+
function collectUniAppXHarmonyApplyStyleSources(bundle) {
|
|
692
|
+
const sources = /* @__PURE__ */ new Set();
|
|
693
|
+
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
694
|
+
const addSource = (source) => {
|
|
695
|
+
for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
|
|
696
|
+
};
|
|
697
|
+
for (const [file, item] of Object.entries(bundle)) {
|
|
698
|
+
if (item.type === "asset" && file.endsWith(".uvue")) {
|
|
699
|
+
addSource(String(item.source));
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
703
|
+
for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
|
|
704
|
+
for (const mapFile of resolveSourceMapFiles(file)) {
|
|
705
|
+
const source = getBundleSource(mapFile);
|
|
706
|
+
if (!source) continue;
|
|
707
|
+
for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return [...sources];
|
|
711
|
+
}
|
|
712
|
+
function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
|
|
713
|
+
const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
|
|
714
|
+
const stylesName = match?.[1] ?? match?.[2];
|
|
715
|
+
if (!stylesName) return code;
|
|
716
|
+
if (!resolveStyleAssetFile(file)) return code;
|
|
717
|
+
const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
|
|
718
|
+
const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
|
|
719
|
+
const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
|
|
720
|
+
const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
|
|
721
|
+
if (styleArrays.length === 0) return code;
|
|
722
|
+
const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
|
|
723
|
+
return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
|
|
682
724
|
}
|
|
683
725
|
function injectUniAppXHarmonyBundleStyles(bundle, options = {}) {
|
|
684
726
|
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
@@ -1754,7 +1796,7 @@ function isWeappViteSidecarRequest(request) {
|
|
|
1754
1796
|
return new URLSearchParams(query).has("weapp-vite-sidecar");
|
|
1755
1797
|
}
|
|
1756
1798
|
function resolveViteCssPipelineRequestFile(request) {
|
|
1757
|
-
return isWeappViteSidecarRequest(request) ? cleanUrl(request) : request;
|
|
1799
|
+
return isWeappViteSidecarRequest(request) ? cleanUrl$1(request) : request;
|
|
1758
1800
|
}
|
|
1759
1801
|
function isHTMLRequest(request) {
|
|
1760
1802
|
return htmlLangRE.test(request);
|
|
@@ -1765,7 +1807,7 @@ function normalizePath(id) {
|
|
|
1765
1807
|
async function formatPostcssSourceMap(rawMap, file) {
|
|
1766
1808
|
const inputFileDir = path.dirname(file);
|
|
1767
1809
|
const sources = rawMap.sources.map((source) => {
|
|
1768
|
-
const cleanSource = cleanUrl(decodeURIComponent(source));
|
|
1810
|
+
const cleanSource = cleanUrl$1(decodeURIComponent(source));
|
|
1769
1811
|
if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
|
|
1770
1812
|
return normalizePath(path.resolve(inputFileDir, cleanSource));
|
|
1771
1813
|
});
|
|
@@ -3274,7 +3316,7 @@ function toArray(value) {
|
|
|
3274
3316
|
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
3275
3317
|
}
|
|
3276
3318
|
function normalizeSourceId(id) {
|
|
3277
|
-
const file = cleanUrl(id);
|
|
3319
|
+
const file = cleanUrl$1(id);
|
|
3278
3320
|
return path.isAbsolute(file) ? path.resolve(file) : void 0;
|
|
3279
3321
|
}
|
|
3280
3322
|
function collectChunkModuleIds(chunk) {
|
|
@@ -3295,7 +3337,7 @@ function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
|
3295
3337
|
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
3296
3338
|
for (const candidate of candidates) {
|
|
3297
3339
|
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
3298
|
-
const cleanCandidate = cleanUrl(candidate);
|
|
3340
|
+
const cleanCandidate = cleanUrl$1(candidate);
|
|
3299
3341
|
const resolved = path.isAbsolute(cleanCandidate) ? path.resolve(cleanCandidate) : path.resolve(rootDir, cleanCandidate);
|
|
3300
3342
|
ids.add(resolved);
|
|
3301
3343
|
}
|
|
@@ -5803,7 +5845,7 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5803
5845
|
const utilities = /* @__PURE__ */ new Set();
|
|
5804
5846
|
function rememberSource(code, id, authoritative = false) {
|
|
5805
5847
|
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5806
|
-
const sourceKey = normalizePath(cleanUrl(id));
|
|
5848
|
+
const sourceKey = normalizePath(cleanUrl$1(id));
|
|
5807
5849
|
const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
|
|
5808
5850
|
for (const source of sources) {
|
|
5809
5851
|
styleSources.add(source);
|
|
@@ -5820,7 +5862,7 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5820
5862
|
}
|
|
5821
5863
|
function prepareStyles(code, id) {
|
|
5822
5864
|
if (!code.includes("@apply") || code.includes("@reference")) return code;
|
|
5823
|
-
const references = referenceBySourceId.get(normalizePath(cleanUrl(id)));
|
|
5865
|
+
const references = referenceBySourceId.get(normalizePath(cleanUrl$1(id)));
|
|
5824
5866
|
if (references?.size !== 1) return code;
|
|
5825
5867
|
return `${references.values().next().value}\n${code}`;
|
|
5826
5868
|
}
|
|
@@ -5829,7 +5871,7 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5829
5871
|
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(prepareStyles(code, id), id);
|
|
5830
5872
|
const sourceUtilities = collectUniAppXHarmonyApplyUtilitiesFromSources(sources);
|
|
5831
5873
|
if (sources.length === 0 || sourceUtilities.size === 0) return code;
|
|
5832
|
-
const cssFile = path.resolve(options.getResolvedConfig()?.root ?? process$1.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath(cleanUrl(id)))}.css`);
|
|
5874
|
+
const cssFile = path.resolve(options.getResolvedConfig()?.root ?? process$1.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath(cleanUrl$1(id)))}.css`);
|
|
5833
5875
|
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
5834
5876
|
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
5835
5877
|
addWatchFile: hookContext.addWatchFile?.bind(hookContext),
|
|
@@ -5916,8 +5958,8 @@ function normalizeIdentityKey(file) {
|
|
|
5916
5958
|
* 将 Vite URL、文件路径和 Windows 的等价路径收敛为同一个模块身份。
|
|
5917
5959
|
*/
|
|
5918
5960
|
function resolveViteModuleIdentity(id, root = process$1.cwd()) {
|
|
5919
|
-
const cleanId = decodeFileId(cleanUrl(id));
|
|
5920
|
-
const decodedRoot = decodeFileId(cleanUrl(root));
|
|
5961
|
+
const cleanId = decodeFileId(cleanUrl$1(id));
|
|
5962
|
+
const decodedRoot = decodeFileId(cleanUrl$1(root));
|
|
5921
5963
|
const normalizedRoot = isWindowsFile(decodedRoot) ? normalizeWindowsFile(decodedRoot) : slash(path.resolve(decodedRoot));
|
|
5922
5964
|
const unwrappedId = stripFileProtocol(stripViteFsPrefix(cleanId));
|
|
5923
5965
|
const file = unwrappedId.startsWith("\0") ? void 0 : normalizeFile(unwrappedId, normalizedRoot);
|
|
@@ -5978,7 +6020,7 @@ async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
|
5978
6020
|
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
5979
6021
|
const isHotSourceStyleModule = (id) => {
|
|
5980
6022
|
if (!isSourceStyleRequest(id)) return false;
|
|
5981
|
-
const file = cleanUrl(id);
|
|
6023
|
+
const file = cleanUrl$1(id);
|
|
5982
6024
|
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5983
6025
|
if (outDir) {
|
|
5984
6026
|
const identity = resolveViteModuleIdentity(file, root);
|
|
@@ -6007,7 +6049,7 @@ async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
|
6007
6049
|
for (const id of ids) {
|
|
6008
6050
|
if (typeof id !== "string" || !/\.(?:uvue|nvue|vue|tsx?|jsx?)(?:$|[?#])/i.test(id)) continue;
|
|
6009
6051
|
const identity = resolveViteModuleIdentity(id, root);
|
|
6010
|
-
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${cleanUrl(lookupId)}?import`);
|
|
6052
|
+
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${cleanUrl$1(lookupId)}?import`);
|
|
6011
6053
|
}
|
|
6012
6054
|
return resolveHotModulesByIds(ctx, sourceIds, (mod) => {
|
|
6013
6055
|
const modId = mod.id ?? mod.url;
|
|
@@ -6064,7 +6106,7 @@ function isRootMiniProgramStyleUrl(file) {
|
|
|
6064
6106
|
}
|
|
6065
6107
|
function resolveCssHotUrl(id, root) {
|
|
6066
6108
|
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
6067
|
-
const cleanId = cleanUrl(id);
|
|
6109
|
+
const cleanId = cleanUrl$1(id);
|
|
6068
6110
|
if (/^\/(?!@fs\/|[A-Z]:)/i.test(cleanId) && !cleanId.startsWith(slash(root))) {
|
|
6069
6111
|
if (isRootMiniProgramStyleUrl(cleanId)) return;
|
|
6070
6112
|
return `${cleanId}${suffix}`;
|
|
@@ -6221,14 +6263,14 @@ function isPreprocessorRequest(id, lang) {
|
|
|
6221
6263
|
return PREPROCESSOR_EXT_RE.test(id);
|
|
6222
6264
|
}
|
|
6223
6265
|
function resolveUniAppXCssTarget(id) {
|
|
6224
|
-
return UVUE_NVUE_RE$1.test(cleanUrl(id)) ? "uvue" : void 0;
|
|
6266
|
+
return UVUE_NVUE_RE$1.test(cleanUrl$1(id)) ? "uvue" : void 0;
|
|
6225
6267
|
}
|
|
6226
6268
|
function isCssModuleExport(code) {
|
|
6227
6269
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
6228
6270
|
}
|
|
6229
6271
|
function normalizeRelativeTailwindReferences(code, id) {
|
|
6230
6272
|
if (!code.includes("@reference")) return code;
|
|
6231
|
-
const sourceFile = cleanUrl(id);
|
|
6273
|
+
const sourceFile = cleanUrl$1(id);
|
|
6232
6274
|
const pathApi = WINDOWS_ABSOLUTE_PATH_RE.test(sourceFile) ? path.win32 : path;
|
|
6233
6275
|
const sourceDir = pathApi.dirname(sourceFile);
|
|
6234
6276
|
return code.replace(RELATIVE_REFERENCE_RE, (_full, quote, request) => {
|
|
@@ -6257,18 +6299,18 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6257
6299
|
return {
|
|
6258
6300
|
appendToStyle(code, id) {
|
|
6259
6301
|
if (!isEnabled()) return code;
|
|
6260
|
-
const rules = rulesByFile.get(cleanUrl(id));
|
|
6302
|
+
const rules = rulesByFile.get(cleanUrl$1(id));
|
|
6261
6303
|
return rules ? `${code}\n${rules}` : code;
|
|
6262
6304
|
},
|
|
6263
6305
|
handleHotUpdate(ctx) {
|
|
6264
|
-
if (!isEnabled() || !/\.(?:uvue|nvue)$/i.test(cleanUrl(ctx.file))) return;
|
|
6306
|
+
if (!isEnabled() || !/\.(?:uvue|nvue)$/i.test(cleanUrl$1(ctx.file))) return;
|
|
6265
6307
|
const styleModules = [...ctx.server.moduleGraph.getModulesByFile?.(ctx.file) ?? []].filter(isStyleModule);
|
|
6266
6308
|
if (styleModules.length === 0) return;
|
|
6267
6309
|
for (const mod of styleModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
6268
6310
|
return [.../* @__PURE__ */ new Set([...ctx.modules, ...styleModules])];
|
|
6269
6311
|
},
|
|
6270
6312
|
remember(id, rules) {
|
|
6271
|
-
rulesByFile.set(cleanUrl(id), rules);
|
|
6313
|
+
rulesByFile.set(cleanUrl$1(id), rules);
|
|
6272
6314
|
}
|
|
6273
6315
|
};
|
|
6274
6316
|
}
|
|
@@ -6276,7 +6318,7 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6276
6318
|
//#region src/uni-app-x/vite.ts
|
|
6277
6319
|
let transformUVuePromise;
|
|
6278
6320
|
function loadTransformUVue() {
|
|
6279
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
6321
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-Cp4KybBy.js").then((mod) => mod.transformUVue));
|
|
6280
6322
|
return transformUVuePromise;
|
|
6281
6323
|
}
|
|
6282
6324
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -6285,7 +6327,7 @@ function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
|
6285
6327
|
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
6286
6328
|
}
|
|
6287
6329
|
function createUniAppXPlugins(options) {
|
|
6288
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6330
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6289
6331
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
6290
6332
|
const utsPlatform = resolveUniUtsPlatform();
|
|
6291
6333
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
@@ -6317,7 +6359,7 @@ function createUniAppXPlugins(options) {
|
|
|
6317
6359
|
return componentLocalStyleEnabled;
|
|
6318
6360
|
}
|
|
6319
6361
|
function shouldEnablePageLocalStyleForFile(id) {
|
|
6320
|
-
return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) || shouldEnablePageLocalStyle(id));
|
|
6362
|
+
return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) || shouldEnablePageLocalStyle(id, resolvedUniAppXOptions.componentLocalStyles.pageMatcher));
|
|
6321
6363
|
}
|
|
6322
6364
|
function isHarmonyBuildTarget() {
|
|
6323
6365
|
if (resolveUniUtsPlatform().isAppHarmony) return true;
|
|
@@ -6372,7 +6414,7 @@ function createUniAppXPlugins(options) {
|
|
|
6372
6414
|
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
6373
6415
|
const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
|
|
6374
6416
|
reportStyleWarnings(postcssResult);
|
|
6375
|
-
const postcssMap = await formatPostcssSourceMap(postcssResult.map.toJSON(), normalizePath(cleanUrl(id)));
|
|
6417
|
+
const postcssMap = await formatPostcssSourceMap(postcssResult.map.toJSON(), normalizePath(cleanUrl$1(id)));
|
|
6376
6418
|
return {
|
|
6377
6419
|
code: postcssResult.css,
|
|
6378
6420
|
map: postcssMap
|
|
@@ -6419,21 +6461,25 @@ function createUniAppXPlugins(options) {
|
|
|
6419
6461
|
async function transformSfc(code, id, context) {
|
|
6420
6462
|
if (isNativeAppBuildTarget(id)) {
|
|
6421
6463
|
nativeLocalStyleModuleIds.add(id);
|
|
6422
|
-
nativeLocalStyleModuleIds.add(cleanUrl(id));
|
|
6464
|
+
nativeLocalStyleModuleIds.add(cleanUrl$1(id));
|
|
6423
6465
|
}
|
|
6424
6466
|
harmonyApply.rememberSource(code, id, true);
|
|
6467
|
+
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6468
|
+
const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
|
|
6425
6469
|
const resolvedConfig = getResolvedConfig();
|
|
6426
6470
|
const shouldForceRefresh = resolvedConfig?.command === "serve" || resolvedConfig?.command === "build";
|
|
6427
|
-
const
|
|
6471
|
+
const moduleGraphCandidates = enableComponentLocalStyle || enablePageLocalStyle ? await registerModuleGraphCandidates?.(id, code) : void 0;
|
|
6472
|
+
const runtimeSet = await ensureRuntimeClassSet(shouldForceRefresh);
|
|
6473
|
+
const currentRuntimeSet = moduleGraphCandidates?.size ? /* @__PURE__ */ new Set([...runtimeSet, ...moduleGraphCandidates]) : runtimeSet;
|
|
6428
6474
|
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6429
6475
|
const transformUVue = await loadTransformUVue();
|
|
6430
|
-
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6431
|
-
const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
|
|
6432
6476
|
const transformOptions = omitUndefined({
|
|
6477
|
+
componentMatcher: resolvedUniAppXOptions.componentLocalStyles.componentMatcher,
|
|
6433
6478
|
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6434
6479
|
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6435
6480
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6436
6481
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
6482
|
+
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
6437
6483
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
6438
6484
|
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => webLocalStyle.remember(id, rules) } : {}
|
|
6439
6485
|
});
|
|
@@ -6506,6 +6552,7 @@ function createUniAppXPlugins(options) {
|
|
|
6506
6552
|
}
|
|
6507
6553
|
injectUniAppXHarmonyBundleStyles(bundle, {
|
|
6508
6554
|
cssSources,
|
|
6555
|
+
componentMatcher: resolvedUniAppXOptions.componentLocalStyles.componentMatcher,
|
|
6509
6556
|
excludeComponents: shouldEnableComponentLocalStyle()
|
|
6510
6557
|
});
|
|
6511
6558
|
}
|
|
@@ -8718,12 +8765,12 @@ function extractSfcStyleSource(source, index) {
|
|
|
8718
8765
|
return styleSources.length > 0 ? styleSources.join("\n") : void 0;
|
|
8719
8766
|
}
|
|
8720
8767
|
function normalizeKnownSfcSourceKey(file) {
|
|
8721
|
-
return normalizeOutputPathKey(path.resolve(cleanUrl(file)));
|
|
8768
|
+
return normalizeOutputPathKey(path.resolve(cleanUrl$1(file)));
|
|
8722
8769
|
}
|
|
8723
8770
|
function shouldCollectTransformedSourceCandidates(id) {
|
|
8724
8771
|
if (isWeappViteSidecarRequest(id)) return false;
|
|
8725
8772
|
if (id.search(/[?#]/) < 0) return true;
|
|
8726
|
-
const file = cleanUrl(id);
|
|
8773
|
+
const file = cleanUrl$1(id);
|
|
8727
8774
|
return !SFC_COMPONENT_FILE_RE.test(file);
|
|
8728
8775
|
}
|
|
8729
8776
|
function createViteCssMemory(options) {
|
|
@@ -8733,7 +8780,7 @@ function createViteCssMemory(options) {
|
|
|
8733
8780
|
const knownSfcSources = /* @__PURE__ */ new Map();
|
|
8734
8781
|
const rememberKnownSfcSource = (id, code) => {
|
|
8735
8782
|
if (id.search(/[?#]/) >= 0) return;
|
|
8736
|
-
const file = cleanUrl(id);
|
|
8783
|
+
const file = cleanUrl$1(id);
|
|
8737
8784
|
if (!SFC_COMPONENT_FILE_RE.test(file)) return;
|
|
8738
8785
|
if (!hasSfcStyleBlocks(code)) return;
|
|
8739
8786
|
touchMapEntry(knownSfcSources, normalizeKnownSfcSourceKey(file), code);
|
|
@@ -8794,23 +8841,23 @@ function createViteCssMemory(options) {
|
|
|
8794
8841
|
for (const [rememberedKey, remembered] of relatedRememberedEntries) refreshRememberedCssSourceEntry(rememberedKey, remembered, sourceFile, rawSource);
|
|
8795
8842
|
};
|
|
8796
8843
|
const resolveCachedStyleSource = (sourceFile) => {
|
|
8797
|
-
const file = cleanUrl(stripRequestQuery(sourceFile));
|
|
8844
|
+
const file = cleanUrl$1(stripRequestQuery(sourceFile));
|
|
8798
8845
|
if (SFC_COMPONENT_FILE_RE.test(file)) return getKnownSfcSource(file);
|
|
8799
8846
|
if (isSourceStyleRequest(file)) return options.getSourceCandidateSource(file);
|
|
8800
8847
|
};
|
|
8801
8848
|
const resolveCurrentStyleSource = (sourceFile) => {
|
|
8802
8849
|
const cached = resolveCachedStyleSource(sourceFile);
|
|
8803
8850
|
if (cached != null) return cached;
|
|
8804
|
-
const file = cleanUrl(stripRequestQuery(sourceFile));
|
|
8851
|
+
const file = cleanUrl$1(stripRequestQuery(sourceFile));
|
|
8805
8852
|
const knownSource = knownCssSources.get(normalizeCssSourceIdentity(sourceFile));
|
|
8806
8853
|
if (knownSource != null) return knownSource;
|
|
8807
8854
|
const candidateSource = options.getSourceCandidateSource(file);
|
|
8808
8855
|
if (candidateSource != null) return candidateSource;
|
|
8809
8856
|
};
|
|
8810
8857
|
const refreshRememberedCssSourceByCurrentFile = async (sourceFile) => {
|
|
8811
|
-
const file = cleanUrl(sourceFile);
|
|
8858
|
+
const file = cleanUrl$1(sourceFile);
|
|
8812
8859
|
const normalizedSourceFile = normalizeOutputPathKey(file);
|
|
8813
|
-
const matchedRememberedSources = [...rememberedCssSources.values()].filter((remembered) => normalizeOutputPathKey(stripRequestQuery(cleanUrl(remembered.sourceFile))) === normalizedSourceFile);
|
|
8860
|
+
const matchedRememberedSources = [...rememberedCssSources.values()].filter((remembered) => normalizeOutputPathKey(stripRequestQuery(cleanUrl$1(remembered.sourceFile))) === normalizedSourceFile);
|
|
8814
8861
|
if (matchedRememberedSources.length === 0) return;
|
|
8815
8862
|
const source = await resolveCurrentStyleSource(file);
|
|
8816
8863
|
if (source == null) {
|
|
@@ -8937,7 +8984,7 @@ function joinPosixPath(base, subpath) {
|
|
|
8937
8984
|
}
|
|
8938
8985
|
function isCssLikeImporter(importer) {
|
|
8939
8986
|
if (!importer) return false;
|
|
8940
|
-
const normalized = cleanUrl(importer);
|
|
8987
|
+
const normalized = cleanUrl$1(importer);
|
|
8941
8988
|
return isSourceStyleRequest(importer) || isCSSRequest(normalized) || normalized.endsWith("/*");
|
|
8942
8989
|
}
|
|
8943
8990
|
function stripTailwindConfigDirectives(code) {
|
|
@@ -8963,7 +9010,7 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
8963
9010
|
},
|
|
8964
9011
|
async transform(code, id) {
|
|
8965
9012
|
if (!isCSSRequest(id)) return null;
|
|
8966
|
-
const file = cleanUrl(id);
|
|
9013
|
+
const file = cleanUrl$1(id);
|
|
8967
9014
|
const normalizedCode = hasTailwindRootDirectives(code) || code.includes("@config") ? normalizeTailwindConfigDirectives(code, path.dirname(file)) : code;
|
|
8968
9015
|
await options.onCssSourceTransform?.(id, normalizedCode);
|
|
8969
9016
|
const hasTailwindRoot = hasTailwindRootDirectives(normalizedCode, { importFallback: true });
|
|
@@ -9331,7 +9378,7 @@ function createViteHmrCandidateState(options) {
|
|
|
9331
9378
|
let pendingCssTargetFiles;
|
|
9332
9379
|
let pendingTargetsArmed = false;
|
|
9333
9380
|
let pendingFullRegeneration = false;
|
|
9334
|
-
const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey(cleanUrl(file));
|
|
9381
|
+
const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey(cleanUrl$1(file));
|
|
9335
9382
|
const clear = () => {
|
|
9336
9383
|
pendingChange = void 0;
|
|
9337
9384
|
pendingCssTargetFiles = void 0;
|
|
@@ -9465,6 +9512,29 @@ function createViteHmrCandidateState(options) {
|
|
|
9465
9512
|
};
|
|
9466
9513
|
}
|
|
9467
9514
|
//#endregion
|
|
9515
|
+
//#region src/bundlers/vite/shared/framework-module-candidates.ts
|
|
9516
|
+
function createFrameworkModuleCandidateRegistrar(options) {
|
|
9517
|
+
return async (id, source) => {
|
|
9518
|
+
await options.runtimeState.readyPromise;
|
|
9519
|
+
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
|
|
9520
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
9521
|
+
options.cacheCurrent();
|
|
9522
|
+
const cssHandlerOptions = options.getCssHandlerOptions(id);
|
|
9523
|
+
return validateCandidatesByGenerator({
|
|
9524
|
+
candidates,
|
|
9525
|
+
cssHandlerOptions,
|
|
9526
|
+
cssUserHandlerOptions: cssHandlerOptions,
|
|
9527
|
+
debug: options.debug,
|
|
9528
|
+
file: cleanUrl$1(id),
|
|
9529
|
+
generatorPlatform: options.getGeneratorPlatform(),
|
|
9530
|
+
opts: options.opts,
|
|
9531
|
+
rawSource: "",
|
|
9532
|
+
runtimeState: options.runtimeState,
|
|
9533
|
+
styleHandler: options.styleHandler
|
|
9534
|
+
});
|
|
9535
|
+
};
|
|
9536
|
+
}
|
|
9537
|
+
//#endregion
|
|
9468
9538
|
//#region src/bundlers/vite/shared/framework-plugin-order.ts
|
|
9469
9539
|
function orderFrameworkSourceCandidatePlugins(extraPlugins, rewritePlugins, sourceCandidatesPlugin, beforeExtraPlugin) {
|
|
9470
9540
|
const anchor = beforeExtraPlugin ? extraPlugins.findIndex(beforeExtraPlugin) : -1;
|
|
@@ -9635,7 +9705,7 @@ function createFrameworkProcessedCssRegistry() {
|
|
|
9635
9705
|
const results = /* @__PURE__ */ new Map();
|
|
9636
9706
|
const sourceFiles = /* @__PURE__ */ new Set();
|
|
9637
9707
|
const markSource = (file) => {
|
|
9638
|
-
sourceFiles.add(path.resolve(cleanUrl(file)));
|
|
9708
|
+
sourceFiles.add(path.resolve(cleanUrl$1(file)));
|
|
9639
9709
|
};
|
|
9640
9710
|
const record = (file, css, options = {}) => {
|
|
9641
9711
|
const key = normalizeVitePersistentCacheKey(file);
|
|
@@ -9649,7 +9719,7 @@ function createFrameworkProcessedCssRegistry() {
|
|
|
9649
9719
|
};
|
|
9650
9720
|
const get = (file) => results.get(normalizeVitePersistentCacheKey(file));
|
|
9651
9721
|
const matchesIdentity = (candidate) => {
|
|
9652
|
-
return sourceFiles.has(path.resolve(cleanUrl(candidate)));
|
|
9722
|
+
return sourceFiles.has(path.resolve(cleanUrl$1(candidate)));
|
|
9653
9723
|
};
|
|
9654
9724
|
const prune = (activeFiles) => {
|
|
9655
9725
|
for (const [key, result] of results) {
|
|
@@ -9714,7 +9784,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9714
9784
|
enforce: "pre",
|
|
9715
9785
|
async load(id) {
|
|
9716
9786
|
if (!options.shouldOwnTailwindGeneration || options.isWebOrNativeAppPlatform(options.resolveViteStylePlatform()) || !isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
|
|
9717
|
-
const file = cleanUrl(id);
|
|
9787
|
+
const file = cleanUrl$1(id);
|
|
9718
9788
|
const rawCode = await readFile(file, "utf8").catch(() => void 0);
|
|
9719
9789
|
if (typeof rawCode !== "string") return;
|
|
9720
9790
|
options.rememberOriginalCssLayerSource(id, rawCode);
|
|
@@ -9740,7 +9810,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9740
9810
|
} : void 0;
|
|
9741
9811
|
return options.hmrTimingRecorder.measure("sourceCandidates.transform", async () => {
|
|
9742
9812
|
options.invalidateRecordedGeneratorCandidates();
|
|
9743
|
-
const file = cleanUrl(id);
|
|
9813
|
+
const file = cleanUrl$1(id);
|
|
9744
9814
|
if (!options.sourceScanSession.matches(file)) {
|
|
9745
9815
|
options.sourceCandidateCollector.remove(file);
|
|
9746
9816
|
options.sourceScanSession.cacheCurrent();
|
|
@@ -9759,18 +9829,18 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9759
9829
|
}
|
|
9760
9830
|
},
|
|
9761
9831
|
async watchChange(id, change) {
|
|
9762
|
-
recordCompilationDependencyChanges(options.runtimeState, createCompilationDependencyChanges([path.resolve(cleanUrl(id))]));
|
|
9832
|
+
recordCompilationDependencyChanges(options.runtimeState, createCompilationDependencyChanges([path.resolve(cleanUrl$1(id))]));
|
|
9763
9833
|
await options.hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
9764
9834
|
if (options.shouldOwnTailwindGeneration && isSourceCandidateRequest(id)) options.invalidateRecordedGeneratorCandidates();
|
|
9765
9835
|
if (options.sourceScanSession.isDependency(id)) options.sourceScanSession.invalidate();
|
|
9766
9836
|
if (change.event === "delete") {
|
|
9767
|
-
const file = cleanUrl(id);
|
|
9837
|
+
const file = cleanUrl$1(id);
|
|
9768
9838
|
const sourceCandidateChange = options.sourceCandidateCollector.remove(file);
|
|
9769
9839
|
options.sourceScanSession.cacheCurrent();
|
|
9770
9840
|
options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, sourceCandidateChange, { runtimeAffecting: options.sourceScanSession.isDependency(file) }));
|
|
9771
9841
|
return;
|
|
9772
9842
|
}
|
|
9773
|
-
const changedSource = options.shouldOwnTailwindGeneration && isSourceCandidateRequest(id) && isCSSRequest(id) ? await readFile(cleanUrl(id), "utf8").catch(() => void 0) : void 0;
|
|
9843
|
+
const changedSource = options.shouldOwnTailwindGeneration && isSourceCandidateRequest(id) && isCSSRequest(id) ? await readFile(cleanUrl$1(id), "utf8").catch(() => void 0) : void 0;
|
|
9774
9844
|
if (typeof changedSource === "string") {
|
|
9775
9845
|
options.rememberOriginalCssLayerSource(id, changedSource);
|
|
9776
9846
|
await options.refreshTailwindRootCssSource(id, changedSource);
|
|
@@ -9781,7 +9851,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9781
9851
|
handleHotUpdate: {
|
|
9782
9852
|
order: "post",
|
|
9783
9853
|
async handler(ctx) {
|
|
9784
|
-
recordCompilationDependencyChanges(options.runtimeState, createCompilationDependencyChanges([path.resolve(cleanUrl(ctx.file))]));
|
|
9854
|
+
recordCompilationDependencyChanges(options.runtimeState, createCompilationDependencyChanges([path.resolve(cleanUrl$1(ctx.file))]));
|
|
9785
9855
|
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
9786
9856
|
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && isSourceCandidateRequest(ctx.file);
|
|
9787
9857
|
if (isSourceCandidateHotUpdate && isSourceStyleRequest(ctx.file)) {
|
|
@@ -9821,7 +9891,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9821
9891
|
const hotRoot = ctx.server.config?.root ?? process$1.cwd();
|
|
9822
9892
|
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9823
9893
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) {
|
|
9824
|
-
if (!/\.(?:uvue|nvue)$/i.test(cleanUrl(ctx.file))) sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
9894
|
+
if (!/\.(?:uvue|nvue)$/i.test(cleanUrl$1(ctx.file))) sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
9825
9895
|
if (sourceModules.some((mod) => {
|
|
9826
9896
|
const id = mod.id ?? mod.url;
|
|
9827
9897
|
return typeof id === "string" && /[?&]macro=true(?:&|$)/.test(id) === false && typeof mod.url === "string" && mod.url.startsWith("/pages/") && /\.vue(?:$|[?#])/i.test(id);
|
|
@@ -9839,7 +9909,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9839
9909
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9840
9910
|
return [];
|
|
9841
9911
|
}
|
|
9842
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && /\.(?:uvue|nvue)$/i.test(cleanUrl(ctx.file)) && !hasTemplateHotSourceModule(sourceModules)) {
|
|
9912
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && /\.(?:uvue|nvue)$/i.test(cleanUrl$1(ctx.file)) && !hasTemplateHotSourceModule(sourceModules)) {
|
|
9843
9913
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9844
9914
|
return [];
|
|
9845
9915
|
}
|
|
@@ -9864,7 +9934,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9864
9934
|
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
9865
9935
|
function createFrameworkHmrRuntimeSignature(file, source) {
|
|
9866
9936
|
if (!source || !WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source)) return "";
|
|
9867
|
-
return (isSfcStyleSourceFile(cleanUrl(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
|
|
9937
|
+
return (isSfcStyleSourceFile(cleanUrl$1(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
|
|
9868
9938
|
}
|
|
9869
9939
|
function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
|
|
9870
9940
|
return createFrameworkHmrRuntimeSignature(file, previousSource) !== createFrameworkHmrRuntimeSignature(file, nextSource);
|
|
@@ -9895,7 +9965,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9895
9965
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
9896
9966
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
9897
9967
|
const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
|
|
9898
|
-
const normalizeDependency = (file) => path.normalize(path.resolve(cleanUrl(file)));
|
|
9968
|
+
const normalizeDependency = (file) => path.normalize(path.resolve(cleanUrl$1(file)));
|
|
9899
9969
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9900
9970
|
const invalidate = () => {
|
|
9901
9971
|
sourceCandidateScanInvalidated = true;
|
|
@@ -10045,7 +10115,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10045
10115
|
};
|
|
10046
10116
|
const syncChangedFile = async (id, sourceOverride) => {
|
|
10047
10117
|
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return;
|
|
10048
|
-
const file = cleanUrl(id);
|
|
10118
|
+
const file = cleanUrl$1(id);
|
|
10049
10119
|
const runtimeAffectingByDependency = isDependency(file);
|
|
10050
10120
|
if (runtimeAffectingByDependency) invalidate();
|
|
10051
10121
|
const resolvedFile = resolveSourceScanPath(file);
|
|
@@ -10086,7 +10156,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10086
10156
|
};
|
|
10087
10157
|
return {
|
|
10088
10158
|
cacheCurrent,
|
|
10089
|
-
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete(cleanUrl(id)),
|
|
10159
|
+
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete(cleanUrl$1(id)),
|
|
10090
10160
|
getStats: () => ({
|
|
10091
10161
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
|
|
10092
10162
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
@@ -10120,7 +10190,7 @@ function createFrameworkTailwindRootCss(options) {
|
|
|
10120
10190
|
await options.registerAutoCssSource(id, hotSource ?? code);
|
|
10121
10191
|
};
|
|
10122
10192
|
const refreshSource = async (id, code) => {
|
|
10123
|
-
const file = cleanUrl(id);
|
|
10193
|
+
const file = cleanUrl$1(id);
|
|
10124
10194
|
if (!moduleIds.has(id) && !moduleIds.has(file) && !hasTailwindRootDirectives(code, { importFallback: options.getImportFallback() })) return;
|
|
10125
10195
|
hotSourceByFile.set(normalizeSourceFile(id), code);
|
|
10126
10196
|
await register(id, code);
|
|
@@ -10261,13 +10331,13 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10261
10331
|
let autoCssSourcesRefresh;
|
|
10262
10332
|
let autoCssSourcesDiscovered = false;
|
|
10263
10333
|
const syncTailwindCssSourceCandidates = async (id, css) => {
|
|
10264
|
-
if (tailwindcssMajorVersion === 4 && isMissingInternalCssSource(cleanUrl(id), weappTailwindcssPackageDir)) return;
|
|
10334
|
+
if (tailwindcssMajorVersion === 4 && isMissingInternalCssSource(cleanUrl$1(id), weappTailwindcssPackageDir)) return;
|
|
10265
10335
|
await sourceCandidateCollector.syncCss(id, css);
|
|
10266
10336
|
sourceScanSession.cacheCurrent();
|
|
10267
10337
|
};
|
|
10268
10338
|
const registerAutoCssSource = async (id, css, options2 = {}) => {
|
|
10269
10339
|
if (!shouldOwnTailwindGeneration) return;
|
|
10270
|
-
const file = cleanUrl(id);
|
|
10340
|
+
const file = cleanUrl$1(id);
|
|
10271
10341
|
if (!path.isAbsolute(file)) return;
|
|
10272
10342
|
if (!isTailwindV4CssEntry(file)) return;
|
|
10273
10343
|
if (isMissingInternalCssSource(file, weappTailwindcssPackageDir)) return;
|
|
@@ -10339,7 +10409,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10339
10409
|
});
|
|
10340
10410
|
const originalCssLayerSourceByFile = new LRUCache({ max: 128 });
|
|
10341
10411
|
const rememberOriginalCssLayerSource = (id, code) => {
|
|
10342
|
-
const file = cleanUrl(id);
|
|
10412
|
+
const file = cleanUrl$1(id);
|
|
10343
10413
|
if (!isCSSRequest(file)) return;
|
|
10344
10414
|
if (!hasUserCssLayerBlocks(code)) {
|
|
10345
10415
|
originalCssLayerSourceByFile.delete(file);
|
|
@@ -10404,18 +10474,18 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10404
10474
|
};
|
|
10405
10475
|
const isNuxtPageHotModule = (id) => {
|
|
10406
10476
|
if (typeof id !== "string") return false;
|
|
10407
|
-
const cleanId = cleanUrl(id).replace(/%2F/gi, "/");
|
|
10477
|
+
const cleanId = cleanUrl$1(id).replace(/%2F/gi, "/");
|
|
10408
10478
|
if (cleanId.includes("virtual:nuxt:") && /(?:^|\/)routes\.mjs$/.test(cleanId)) return true;
|
|
10409
10479
|
if (!/[?&]macro=true(?:&|$)/.test(id)) return false;
|
|
10410
10480
|
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
10411
10481
|
};
|
|
10412
|
-
const normalizeGeneratedCssCacheFile = (file) => normalizeVitePersistentCacheKey(cleanUrl(file));
|
|
10482
|
+
const normalizeGeneratedCssCacheFile = (file) => normalizeVitePersistentCacheKey(cleanUrl$1(file));
|
|
10413
10483
|
const hmrCandidateState = createViteHmrCandidateState({
|
|
10414
10484
|
cleanGeneratedCssByFile,
|
|
10415
10485
|
generatedClassSetByFile,
|
|
10416
10486
|
getCommand: () => resolvedConfig?.command,
|
|
10417
10487
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
10418
|
-
isRuntimeAffectingSource: (file) => uniAppXEnabled && !resolveCurrentGeneratorBranch().isWeb && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
|
|
10488
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && !resolveCurrentGeneratorBranch().isWeb && /\.(?:uvue|nvue)$/i.test(cleanUrl$1(file))
|
|
10419
10489
|
});
|
|
10420
10490
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
10421
10491
|
cssMemory,
|
|
@@ -10460,7 +10530,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10460
10530
|
processedCssRegistry.prune(activeFiles);
|
|
10461
10531
|
cssMemory.prune(options2);
|
|
10462
10532
|
};
|
|
10463
|
-
const normalizeViteProcessedCssFile = (file) => path.resolve(cleanUrl(file));
|
|
10533
|
+
const normalizeViteProcessedCssFile = (file) => path.resolve(cleanUrl$1(file));
|
|
10464
10534
|
const markViteProcessedCssSource = processedCssRegistry.markSource;
|
|
10465
10535
|
const isUniViteProject = () => {
|
|
10466
10536
|
return resolvedConfig?.plugins?.some((plugin) => plugin.name.includes("uni")) ?? false;
|
|
@@ -10503,7 +10573,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10503
10573
|
if (!shouldOwnTailwindGeneration) return;
|
|
10504
10574
|
await runtimeState.readyPromise;
|
|
10505
10575
|
await sourceScanSession.waitForPendingSyncs();
|
|
10506
|
-
const file = cleanUrl(id);
|
|
10576
|
+
const file = cleanUrl$1(id);
|
|
10507
10577
|
const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
|
|
10508
10578
|
const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? resolveViteCssPipelineRequestFile(id) : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
10509
10579
|
if (!isCSSRequest(requestFile) || opts.htmlMatcher(file) || isHTMLRequest(file)) return;
|
|
@@ -10701,7 +10771,7 @@ ${tracedCss}`;
|
|
|
10701
10771
|
getSourceCandidates,
|
|
10702
10772
|
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file),
|
|
10703
10773
|
getSourceCandidateSources: () => sourceCandidateCollector.sources(),
|
|
10704
|
-
extractSourceCandidates: (file, source) => extractCandidatesFromSource(source, path.extname(cleanUrl(file)).slice(1) || "html", {
|
|
10774
|
+
extractSourceCandidates: (file, source) => extractCandidatesFromSource(source, path.extname(cleanUrl$1(file)).slice(1) || "html", {
|
|
10705
10775
|
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
10706
10776
|
customAttributesEntities,
|
|
10707
10777
|
disabledDefaultTemplateHandler
|
|
@@ -10715,7 +10785,7 @@ ${tracedCss}`;
|
|
|
10715
10785
|
setRememberedCssSignature: cssMemory.setRememberedCssSignature,
|
|
10716
10786
|
getKnownCssSource: cssMemory.getKnownCssSource,
|
|
10717
10787
|
getKnownSfcSource: cssMemory.getKnownSfcSource,
|
|
10718
|
-
getOriginalCssLayerSource: (file) => originalCssLayerSourceByFile.get(cleanUrl(file)),
|
|
10788
|
+
getOriginalCssLayerSource: (file) => originalCssLayerSourceByFile.get(cleanUrl$1(file)),
|
|
10719
10789
|
recordGeneratorCandidates,
|
|
10720
10790
|
pruneViteCssCaches,
|
|
10721
10791
|
getViteCssCacheStats,
|
|
@@ -10772,6 +10842,17 @@ ${tracedCss}`;
|
|
|
10772
10842
|
});
|
|
10773
10843
|
const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
|
|
10774
10844
|
const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
|
|
10845
|
+
const registerModuleGraphCandidates = createFrameworkModuleCandidateRegistrar({
|
|
10846
|
+
cacheCurrent: sourceScanSession.cacheCurrent,
|
|
10847
|
+
debug,
|
|
10848
|
+
getCssHandlerOptions: transformCssHandlerOptions.getCssHandlerOptions,
|
|
10849
|
+
getGeneratorPlatform: resolveGeneratorPlatform,
|
|
10850
|
+
invalidateRecordedGeneratorCandidates,
|
|
10851
|
+
opts,
|
|
10852
|
+
runtimeState,
|
|
10853
|
+
sourceCandidateCollector,
|
|
10854
|
+
styleHandler
|
|
10855
|
+
});
|
|
10775
10856
|
const prepareTailwindGeneration = async () => {
|
|
10776
10857
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
10777
10858
|
await sourceScanSession.sync();
|
|
@@ -10788,6 +10869,7 @@ ${tracedCss}`;
|
|
|
10788
10869
|
isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
10789
10870
|
jsHandler,
|
|
10790
10871
|
mainCssChunkMatcher,
|
|
10872
|
+
registerModuleGraphCandidates,
|
|
10791
10873
|
runtimeState,
|
|
10792
10874
|
styleHandler,
|
|
10793
10875
|
syncSourceCandidatesForHotUpdate,
|
|
@@ -10803,7 +10885,7 @@ ${tracedCss}`;
|
|
|
10803
10885
|
debug("preserve adapted generated css before uni-app watch cache: %s", id);
|
|
10804
10886
|
return css;
|
|
10805
10887
|
}
|
|
10806
|
-
const file = cleanUrl(id);
|
|
10888
|
+
const file = cleanUrl$1(id);
|
|
10807
10889
|
const styleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), css, id) : id;
|
|
10808
10890
|
const transformedCss = (await styleHandler(css, transformCssHandlerOptions.getCssHandlerOptions(styleRequest))).css;
|
|
10809
10891
|
debug("adapt css before uni-app watch cache: %s inputRaw=%s outputRaw=%s", id, css.includes("\\[") || css.includes("\\:"), transformedCss.includes("\\[") || transformedCss.includes("\\:"));
|
|
@@ -11209,6 +11291,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
11209
11291
|
isWebGeneratorTarget: context.isWebGeneratorTarget,
|
|
11210
11292
|
jsHandler: context.jsHandler,
|
|
11211
11293
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
11294
|
+
registerModuleGraphCandidates: context.registerModuleGraphCandidates,
|
|
11212
11295
|
runtimeState: context.runtimeState,
|
|
11213
11296
|
styleHandler: context.styleHandler,
|
|
11214
11297
|
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|