weapp-tailwindcss 5.3.0 → 5.3.2
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/generator-css/types.d.ts +1 -0
- package/dist/{component-local-style-CFL4ClhS.js → component-local-style-C2wC8o9F.js} +1 -0
- package/dist/{component-local-style-BirkN5f8.cjs → component-local-style-CNhEhd2B.cjs} +1 -0
- package/dist/{context-vWlNv-Cf.cjs → context-CB4Ef9U0.cjs} +4 -4
- package/dist/{context-CKQKq4Mv.js → context-Kvr3lLEC.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{generator-BXrWA7Sj.cjs → generator-DKiYbTFR.cjs} +11 -1
- package/dist/{generator-BP4WmgIo.js → generator-EnTXLBlK.js} +1 -1
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-B0qcNiuP.cjs → gulp-QJ_oz-06.cjs} +7 -7
- package/dist/{gulp-D1vDx4H1.js → gulp-vz36-uQP.js} +4 -4
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Dq1_msos.js → hmr-timing-HGlM4hX3.js} +4 -4
- package/dist/{hmr-timing-pF6k35pP.cjs → hmr-timing-W3kro20F.cjs} +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-DbYws6lr.cjs → options-CKZW99r4.cjs} +1 -1
- package/dist/{pipeline-helpers-DA5-EzbO.cjs → pipeline-helpers-t95KPu4O.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- 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-DSsjYtlq.js → source-candidate-scan-signature-BHCPQVoD.js} +3 -3
- package/dist/{source-candidate-scan-signature-DGQufJk3.cjs → source-candidate-scan-signature-BSad7bMQ.cjs} +3 -3
- package/dist/{style-options-Cta1OP3i.cjs → style-options-PCgz2ywM.cjs} +2 -2
- package/dist/{tailwindcss-C2K-vjJv.js → tailwindcss-BSEdWieh.js} +1 -1
- package/dist/{tailwindcss-D1M2xj5O.cjs → tailwindcss-jKzY37Sk.cjs} +2 -2
- package/dist/{transform-BYhgJszj.cjs → transform-CgohToUV.cjs} +1 -1
- package/dist/{transform-Ck31voUU.js → transform-DSRPiBWz.js} +1 -1
- package/dist/uni-app-x/style-asset/harmony-global.d.ts +9 -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/{v4-generation-core-BEYGV4eB.cjs → v4-generation-core-BfeXEc6R.cjs} +4 -4
- package/dist/{vite-DBgbFsei.js → vite-CVr0vIgh.js} +120 -90
- package/dist/{vite-jftHIupF.cjs → vite-Dy6THt54.cjs} +123 -93
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +28 -10
- package/dist/{webpack-DhwW2cva.cjs → webpack-Cf5RnhXt.cjs} +9 -9
- package/dist/{webpack-BSIWFzAA.js → webpack-DwtdWqwr.js} +5 -5
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
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-
|
|
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-BSEdWieh.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-HGlM4hX3.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-Kvr3lLEC.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-BHCPQVoD.js";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
|
-
import { r as shouldEnablePageLocalStyle } from "./component-local-style-
|
|
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";
|
|
@@ -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,88 +470,34 @@ 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
|
-
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
490
|
-
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
491
|
-
return applyStyleSources.map((source) => {
|
|
492
|
-
let root;
|
|
493
|
-
try {
|
|
494
|
-
root = postcss.parse(source);
|
|
495
|
-
} catch {
|
|
496
|
-
return source;
|
|
497
|
-
}
|
|
498
|
-
root.walkAtRules("reference", (rule) => {
|
|
499
|
-
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
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];
|
|
537
|
-
}
|
|
538
501
|
function resolveStyleAssetFile(file) {
|
|
539
502
|
if (!UVUE_TS_RE.test(file)) return;
|
|
540
503
|
return file.replace(/\.uvue\.ts$/, ".uvue");
|
|
@@ -605,19 +568,19 @@ function resolveCssFallbackFiles(styleAssetFiles = []) {
|
|
|
605
568
|
function resolveStyleAssetFilesForChunk(file, styleAssetFiles) {
|
|
606
569
|
return typeof styleAssetFiles === "function" ? styleAssetFiles(file) : styleAssetFiles;
|
|
607
570
|
}
|
|
608
|
-
function resolveSourceMapFiles(file) {
|
|
571
|
+
function resolveSourceMapFiles$1(file) {
|
|
609
572
|
return [
|
|
610
573
|
`${file}.map`,
|
|
611
574
|
file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
|
|
612
575
|
file.startsWith("assets/") ? void 0 : `assets/${file}.map`
|
|
613
576
|
].filter((item) => typeof item === "string");
|
|
614
577
|
}
|
|
615
|
-
function createStyleValueFromBundleSources(file,
|
|
578
|
+
function createStyleValueFromBundleSources(file, getBundleSource, options = {}) {
|
|
616
579
|
const cssStyles = mergeStyleValues(...[...options.cssSources ?? []].map((source) => source ? cssSourceToStyleValue(source) : void 0), ...resolveCssFallbackFiles(resolveStyleAssetFilesForChunk(file, options.styleAssetFiles)).map((cssFile) => {
|
|
617
580
|
const source = getBundleSource?.(cssFile);
|
|
618
581
|
return source ? cssSourceToStyleValue(source) : void 0;
|
|
619
582
|
}));
|
|
620
|
-
return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
583
|
+
return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles$1(file).flatMap((mapFile) => {
|
|
621
584
|
const source = getBundleSource?.(mapFile);
|
|
622
585
|
return source ? parseSourceMapSourcesContent(source) : [];
|
|
623
586
|
})].filter((source) => typeof source === "string"), cssStyles));
|
|
@@ -636,21 +599,8 @@ function injectStyleOption(code, styleVarName) {
|
|
|
636
599
|
if (fileOptionIndex < 0) return code;
|
|
637
600
|
return `${code.slice(0, fileOptionIndex)}["styles", [${styleVarName}]], ${code.slice(fileOptionIndex)}`;
|
|
638
601
|
}
|
|
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
602
|
function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options = {}) {
|
|
653
|
-
if (!JS_RE.test(file) || APP_JS_RE.test(file)) return code;
|
|
603
|
+
if (!JS_RE.test(file) || APP_JS_RE$1.test(file)) return code;
|
|
654
604
|
if (options.excludeComponents && COMPONENT_JS_RE.test(file)) return code;
|
|
655
605
|
const appSource = getBundleSource?.("assets/App.js") ?? getBundleSource?.("App.js");
|
|
656
606
|
const appStyle = appSource ? mergeStyleValues(...findStyleObjectDecls(appSource).map((decl) => parseStyleObject(decl.objectText))) : void 0;
|
|
@@ -661,7 +611,7 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
|
|
|
661
611
|
style
|
|
662
612
|
}] : [];
|
|
663
613
|
});
|
|
664
|
-
const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file,
|
|
614
|
+
const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file, getBundleSource, options), appStyle);
|
|
665
615
|
if (!styleSource) return code;
|
|
666
616
|
const mergedStyles = createMergedStyleValues(code, parseableLocalStyles.map((item) => item.style), styleSource);
|
|
667
617
|
if (mergedStyles) {
|
|
@@ -678,7 +628,87 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
|
|
|
678
628
|
const exportMatch = code.match(EXPORT_SFC_RE);
|
|
679
629
|
if (!exportMatch || exportMatch.index === void 0) return code;
|
|
680
630
|
const styleVarName = "_style_wt";
|
|
681
|
-
|
|
631
|
+
const statementStart = code.lastIndexOf("\n", exportMatch.index);
|
|
632
|
+
const insertPos = statementStart === -1 ? 0 : statementStart + 1;
|
|
633
|
+
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);
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/uni-app-x/style-asset.ts
|
|
637
|
+
const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
|
|
638
|
+
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
639
|
+
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
640
|
+
"import/app-service.ets",
|
|
641
|
+
"import/dynamic.ets",
|
|
642
|
+
"uni_modules/oh-package.json5"
|
|
643
|
+
]);
|
|
644
|
+
function resolveSourceMapFiles(file) {
|
|
645
|
+
return [
|
|
646
|
+
`${file}.map`,
|
|
647
|
+
file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
|
|
648
|
+
file.startsWith("assets/") ? void 0 : `assets/${file}.map`
|
|
649
|
+
].filter((item) => typeof item === "string");
|
|
650
|
+
}
|
|
651
|
+
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
652
|
+
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
653
|
+
return applyStyleSources.map((source) => {
|
|
654
|
+
let root;
|
|
655
|
+
try {
|
|
656
|
+
root = postcss.parse(source);
|
|
657
|
+
} catch {
|
|
658
|
+
return source;
|
|
659
|
+
}
|
|
660
|
+
root.walkAtRules("reference", (rule) => {
|
|
661
|
+
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
662
|
+
});
|
|
663
|
+
return root.toString();
|
|
664
|
+
}).join("\n");
|
|
665
|
+
}
|
|
666
|
+
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
667
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
668
|
+
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
669
|
+
for (const [file, item] of Object.entries(bundle)) {
|
|
670
|
+
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
671
|
+
const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
672
|
+
const source = getBundleSource(mapFile);
|
|
673
|
+
return source ? parseSourceMapSourcesContent(source) : [];
|
|
674
|
+
}));
|
|
675
|
+
for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
676
|
+
}
|
|
677
|
+
return utilities;
|
|
678
|
+
}
|
|
679
|
+
function collectUniAppXHarmonyApplyStyleSources(bundle) {
|
|
680
|
+
const sources = /* @__PURE__ */ new Set();
|
|
681
|
+
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
682
|
+
const addSource = (source) => {
|
|
683
|
+
for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
|
|
684
|
+
};
|
|
685
|
+
for (const [file, item] of Object.entries(bundle)) {
|
|
686
|
+
if (item.type === "asset" && file.endsWith(".uvue")) {
|
|
687
|
+
addSource(String(item.source));
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
691
|
+
for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
|
|
692
|
+
for (const mapFile of resolveSourceMapFiles(file)) {
|
|
693
|
+
const source = getBundleSource(mapFile);
|
|
694
|
+
if (!source) continue;
|
|
695
|
+
for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return [...sources];
|
|
699
|
+
}
|
|
700
|
+
function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
|
|
701
|
+
const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
|
|
702
|
+
const stylesName = match?.[1] ?? match?.[2];
|
|
703
|
+
if (!stylesName) return code;
|
|
704
|
+
if (!resolveStyleAssetFile(file)) return code;
|
|
705
|
+
const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
|
|
706
|
+
const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
|
|
707
|
+
const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
|
|
708
|
+
const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
|
|
709
|
+
if (styleArrays.length === 0) return code;
|
|
710
|
+
const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
|
|
711
|
+
return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
|
|
682
712
|
}
|
|
683
713
|
function injectUniAppXHarmonyBundleStyles(bundle, options = {}) {
|
|
684
714
|
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
@@ -6276,7 +6306,7 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6276
6306
|
//#region src/uni-app-x/vite.ts
|
|
6277
6307
|
let transformUVuePromise;
|
|
6278
6308
|
function loadTransformUVue() {
|
|
6279
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
6309
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-DSRPiBWz.js").then((mod) => mod.transformUVue));
|
|
6280
6310
|
return transformUVuePromise;
|
|
6281
6311
|
}
|
|
6282
6312
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -1,18 +1,18 @@
|
|
|
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-
|
|
3
|
+
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
4
4
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
5
|
+
const require_options = require("./options-CKZW99r4.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
7
|
+
const require_v4_generation_core = require("./v4-generation-core-BfeXEc6R.cjs");
|
|
8
8
|
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_context = require("./context-
|
|
11
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
12
|
-
const require_style_options = require("./style-options-
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-W3kro20F.cjs");
|
|
10
|
+
const require_context = require("./context-CB4Ef9U0.cjs");
|
|
11
|
+
const require_tailwindcss = require("./tailwindcss-jKzY37Sk.cjs");
|
|
12
|
+
const require_style_options = require("./style-options-PCgz2ywM.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BSad7bMQ.cjs");
|
|
14
14
|
require("./logger-TlKT3xmR.cjs");
|
|
15
|
-
const require_component_local_style = require("./component-local-style-
|
|
15
|
+
const require_component_local_style = require("./component-local-style-CNhEhd2B.cjs");
|
|
16
16
|
const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
|
|
17
17
|
let node_fs = require("node:fs");
|
|
18
18
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
@@ -243,6 +243,20 @@ const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
|
|
|
243
243
|
const SFC_STYLE_BLOCK_RE$2 = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
244
244
|
const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
|
|
245
245
|
const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
|
|
246
|
+
function cloneStyleEntry(entry) {
|
|
247
|
+
return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
|
|
248
|
+
}
|
|
249
|
+
function mergeStyleEntry(local, generated) {
|
|
250
|
+
const merged = local ? cloneStyleEntry(local) : {};
|
|
251
|
+
for (const [state, declarations] of Object.entries(generated)) merged[state] = {
|
|
252
|
+
...merged[state] ?? {},
|
|
253
|
+
...declarations
|
|
254
|
+
};
|
|
255
|
+
return merged;
|
|
256
|
+
}
|
|
257
|
+
function cloneStyleValue(style) {
|
|
258
|
+
return Object.fromEntries(Object.entries(style).map(([className, entry]) => [className, cloneStyleEntry(entry)]));
|
|
259
|
+
}
|
|
246
260
|
function toCamelCase(prop) {
|
|
247
261
|
return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
248
262
|
}
|
|
@@ -449,11 +463,14 @@ function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
|
449
463
|
function createMergedStyleValue(code, localStyle, appStyle) {
|
|
450
464
|
const used = collectUsedStyleKeys(code, appStyle);
|
|
451
465
|
if (used.size === 0) return;
|
|
452
|
-
const merged =
|
|
466
|
+
const merged = localStyle ? cloneStyleValue(localStyle) : {};
|
|
453
467
|
let changed = false;
|
|
454
468
|
for (const className of used) {
|
|
455
|
-
|
|
456
|
-
|
|
469
|
+
const generatedStyle = appStyle[className];
|
|
470
|
+
if (!generatedStyle) continue;
|
|
471
|
+
const next = mergeStyleEntry(merged[className], generatedStyle);
|
|
472
|
+
if (JSON.stringify(next) === JSON.stringify(merged[className])) continue;
|
|
473
|
+
merged[className] = next;
|
|
457
474
|
changed = true;
|
|
458
475
|
}
|
|
459
476
|
return changed ? merged : void 0;
|
|
@@ -462,88 +479,34 @@ function createMergedStyleValues(code, localStyles, appStyle) {
|
|
|
462
479
|
if (localStyles.length === 0) return;
|
|
463
480
|
const used = collectUsedStyleKeys(code, appStyle);
|
|
464
481
|
if (used.size === 0) return;
|
|
465
|
-
const merged = localStyles.map(
|
|
482
|
+
const merged = localStyles.map(cloneStyleValue);
|
|
466
483
|
let changed = false;
|
|
467
484
|
for (const className of used) {
|
|
468
485
|
const generatedStyle = appStyle[className];
|
|
469
486
|
if (!generatedStyle) continue;
|
|
470
487
|
const indexes = merged.flatMap((style, index) => style[className] ? [index] : []);
|
|
471
488
|
if (indexes.length === 0) {
|
|
472
|
-
merged[0][className] = generatedStyle;
|
|
489
|
+
merged[0][className] = mergeStyleEntry(void 0, generatedStyle);
|
|
473
490
|
changed = true;
|
|
474
491
|
continue;
|
|
475
492
|
}
|
|
476
493
|
for (const index of indexes) {
|
|
477
|
-
|
|
478
|
-
merged[index][className]
|
|
494
|
+
const next = mergeStyleEntry(merged[index][className], generatedStyle);
|
|
495
|
+
if (JSON.stringify(merged[index][className]) === JSON.stringify(next)) continue;
|
|
496
|
+
merged[index][className] = next;
|
|
479
497
|
changed = true;
|
|
480
498
|
}
|
|
481
499
|
}
|
|
482
500
|
return changed ? merged : void 0;
|
|
483
501
|
}
|
|
484
502
|
//#endregion
|
|
485
|
-
//#region src/uni-app-x/style-asset.ts
|
|
486
|
-
const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
|
|
503
|
+
//#region src/uni-app-x/style-asset/harmony-global.ts
|
|
487
504
|
const UVUE_TS_RE = /\.uvue\.ts$/;
|
|
488
505
|
const JS_RE = /\.js$/;
|
|
489
|
-
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
506
|
+
const APP_JS_RE$1 = /(?:^|\/)App\.js$/;
|
|
490
507
|
const COMPONENT_JS_RE = /(?:^|\/)components\/.+\.js$/;
|
|
491
|
-
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
492
|
-
"import/app-service.ets",
|
|
493
|
-
"import/dynamic.ets",
|
|
494
|
-
"uni_modules/oh-package.json5"
|
|
495
|
-
]);
|
|
496
508
|
const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
|
|
497
509
|
const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
|
|
498
|
-
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
499
|
-
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
500
|
-
return applyStyleSources.map((source) => {
|
|
501
|
-
let root;
|
|
502
|
-
try {
|
|
503
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
504
|
-
} catch {
|
|
505
|
-
return source;
|
|
506
|
-
}
|
|
507
|
-
root.walkAtRules("reference", (rule) => {
|
|
508
|
-
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
509
|
-
});
|
|
510
|
-
return root.toString();
|
|
511
|
-
}).join("\n");
|
|
512
|
-
}
|
|
513
|
-
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
514
|
-
const utilities = /* @__PURE__ */ new Set();
|
|
515
|
-
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
516
|
-
for (const [file, item] of Object.entries(bundle)) {
|
|
517
|
-
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
518
|
-
const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
519
|
-
const source = getBundleSource(mapFile);
|
|
520
|
-
return source ? parseSourceMapSourcesContent(source) : [];
|
|
521
|
-
}));
|
|
522
|
-
for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
523
|
-
}
|
|
524
|
-
return utilities;
|
|
525
|
-
}
|
|
526
|
-
function collectUniAppXHarmonyApplyStyleSources(bundle) {
|
|
527
|
-
const sources = /* @__PURE__ */ new Set();
|
|
528
|
-
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
529
|
-
const addSource = (source) => {
|
|
530
|
-
for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
|
|
531
|
-
};
|
|
532
|
-
for (const [file, item] of Object.entries(bundle)) {
|
|
533
|
-
if (item.type === "asset" && file.endsWith(".uvue")) {
|
|
534
|
-
addSource(String(item.source));
|
|
535
|
-
continue;
|
|
536
|
-
}
|
|
537
|
-
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
538
|
-
for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
|
|
539
|
-
for (const mapFile of resolveSourceMapFiles(file)) {
|
|
540
|
-
const source = getBundleSource(mapFile);
|
|
541
|
-
if (!source) continue;
|
|
542
|
-
for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
return [...sources];
|
|
546
|
-
}
|
|
547
510
|
function resolveStyleAssetFile(file) {
|
|
548
511
|
if (!UVUE_TS_RE.test(file)) return;
|
|
549
512
|
return file.replace(/\.uvue\.ts$/, ".uvue");
|
|
@@ -614,19 +577,19 @@ function resolveCssFallbackFiles(styleAssetFiles = []) {
|
|
|
614
577
|
function resolveStyleAssetFilesForChunk(file, styleAssetFiles) {
|
|
615
578
|
return typeof styleAssetFiles === "function" ? styleAssetFiles(file) : styleAssetFiles;
|
|
616
579
|
}
|
|
617
|
-
function resolveSourceMapFiles(file) {
|
|
580
|
+
function resolveSourceMapFiles$1(file) {
|
|
618
581
|
return [
|
|
619
582
|
`${file}.map`,
|
|
620
583
|
file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
|
|
621
584
|
file.startsWith("assets/") ? void 0 : `assets/${file}.map`
|
|
622
585
|
].filter((item) => typeof item === "string");
|
|
623
586
|
}
|
|
624
|
-
function createStyleValueFromBundleSources(file,
|
|
587
|
+
function createStyleValueFromBundleSources(file, getBundleSource, options = {}) {
|
|
625
588
|
const cssStyles = mergeStyleValues(...[...options.cssSources ?? []].map((source) => source ? cssSourceToStyleValue(source) : void 0), ...resolveCssFallbackFiles(resolveStyleAssetFilesForChunk(file, options.styleAssetFiles)).map((cssFile) => {
|
|
626
589
|
const source = getBundleSource?.(cssFile);
|
|
627
590
|
return source ? cssSourceToStyleValue(source) : void 0;
|
|
628
591
|
}));
|
|
629
|
-
return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
592
|
+
return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles$1(file).flatMap((mapFile) => {
|
|
630
593
|
const source = getBundleSource?.(mapFile);
|
|
631
594
|
return source ? parseSourceMapSourcesContent(source) : [];
|
|
632
595
|
})].filter((source) => typeof source === "string"), cssStyles));
|
|
@@ -645,21 +608,8 @@ function injectStyleOption(code, styleVarName) {
|
|
|
645
608
|
if (fileOptionIndex < 0) return code;
|
|
646
609
|
return `${code.slice(0, fileOptionIndex)}["styles", [${styleVarName}]], ${code.slice(fileOptionIndex)}`;
|
|
647
610
|
}
|
|
648
|
-
function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
|
|
649
|
-
const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
|
|
650
|
-
const stylesName = match?.[1] ?? match?.[2];
|
|
651
|
-
if (!stylesName) return code;
|
|
652
|
-
if (!resolveStyleAssetFile(file)) return code;
|
|
653
|
-
const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
|
|
654
|
-
const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
|
|
655
|
-
const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
|
|
656
|
-
const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
|
|
657
|
-
if (styleArrays.length === 0) return code;
|
|
658
|
-
const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
|
|
659
|
-
return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
|
|
660
|
-
}
|
|
661
611
|
function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options = {}) {
|
|
662
|
-
if (!JS_RE.test(file) || APP_JS_RE.test(file)) return code;
|
|
612
|
+
if (!JS_RE.test(file) || APP_JS_RE$1.test(file)) return code;
|
|
663
613
|
if (options.excludeComponents && COMPONENT_JS_RE.test(file)) return code;
|
|
664
614
|
const appSource = getBundleSource?.("assets/App.js") ?? getBundleSource?.("App.js");
|
|
665
615
|
const appStyle = appSource ? mergeStyleValues(...findStyleObjectDecls(appSource).map((decl) => parseStyleObject(decl.objectText))) : void 0;
|
|
@@ -670,7 +620,7 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
|
|
|
670
620
|
style
|
|
671
621
|
}] : [];
|
|
672
622
|
});
|
|
673
|
-
const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file,
|
|
623
|
+
const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file, getBundleSource, options), appStyle);
|
|
674
624
|
if (!styleSource) return code;
|
|
675
625
|
const mergedStyles = createMergedStyleValues(code, parseableLocalStyles.map((item) => item.style), styleSource);
|
|
676
626
|
if (mergedStyles) {
|
|
@@ -687,7 +637,87 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
|
|
|
687
637
|
const exportMatch = code.match(EXPORT_SFC_RE);
|
|
688
638
|
if (!exportMatch || exportMatch.index === void 0) return code;
|
|
689
639
|
const styleVarName = "_style_wt";
|
|
690
|
-
|
|
640
|
+
const statementStart = code.lastIndexOf("\n", exportMatch.index);
|
|
641
|
+
const insertPos = statementStart === -1 ? 0 : statementStart + 1;
|
|
642
|
+
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);
|
|
643
|
+
}
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/uni-app-x/style-asset.ts
|
|
646
|
+
const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
|
|
647
|
+
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
648
|
+
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
649
|
+
"import/app-service.ets",
|
|
650
|
+
"import/dynamic.ets",
|
|
651
|
+
"uni_modules/oh-package.json5"
|
|
652
|
+
]);
|
|
653
|
+
function resolveSourceMapFiles(file) {
|
|
654
|
+
return [
|
|
655
|
+
`${file}.map`,
|
|
656
|
+
file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
|
|
657
|
+
file.startsWith("assets/") ? void 0 : `assets/${file}.map`
|
|
658
|
+
].filter((item) => typeof item === "string");
|
|
659
|
+
}
|
|
660
|
+
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
661
|
+
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
662
|
+
return applyStyleSources.map((source) => {
|
|
663
|
+
let root;
|
|
664
|
+
try {
|
|
665
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
666
|
+
} catch {
|
|
667
|
+
return source;
|
|
668
|
+
}
|
|
669
|
+
root.walkAtRules("reference", (rule) => {
|
|
670
|
+
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
671
|
+
});
|
|
672
|
+
return root.toString();
|
|
673
|
+
}).join("\n");
|
|
674
|
+
}
|
|
675
|
+
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
676
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
677
|
+
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
678
|
+
for (const [file, item] of Object.entries(bundle)) {
|
|
679
|
+
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
680
|
+
const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
|
|
681
|
+
const source = getBundleSource(mapFile);
|
|
682
|
+
return source ? parseSourceMapSourcesContent(source) : [];
|
|
683
|
+
}));
|
|
684
|
+
for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
685
|
+
}
|
|
686
|
+
return utilities;
|
|
687
|
+
}
|
|
688
|
+
function collectUniAppXHarmonyApplyStyleSources(bundle) {
|
|
689
|
+
const sources = /* @__PURE__ */ new Set();
|
|
690
|
+
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
691
|
+
const addSource = (source) => {
|
|
692
|
+
for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
|
|
693
|
+
};
|
|
694
|
+
for (const [file, item] of Object.entries(bundle)) {
|
|
695
|
+
if (item.type === "asset" && file.endsWith(".uvue")) {
|
|
696
|
+
addSource(String(item.source));
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
|
|
700
|
+
for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
|
|
701
|
+
for (const mapFile of resolveSourceMapFiles(file)) {
|
|
702
|
+
const source = getBundleSource(mapFile);
|
|
703
|
+
if (!source) continue;
|
|
704
|
+
for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return [...sources];
|
|
708
|
+
}
|
|
709
|
+
function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
|
|
710
|
+
const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
|
|
711
|
+
const stylesName = match?.[1] ?? match?.[2];
|
|
712
|
+
if (!stylesName) return code;
|
|
713
|
+
if (!resolveStyleAssetFile(file)) return code;
|
|
714
|
+
const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
|
|
715
|
+
const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
|
|
716
|
+
const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
|
|
717
|
+
const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
|
|
718
|
+
if (styleArrays.length === 0) return code;
|
|
719
|
+
const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
|
|
720
|
+
return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
|
|
691
721
|
}
|
|
692
722
|
function injectUniAppXHarmonyBundleStyles(bundle, options = {}) {
|
|
693
723
|
const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
@@ -6285,7 +6315,7 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6285
6315
|
//#region src/uni-app-x/vite.ts
|
|
6286
6316
|
let transformUVuePromise;
|
|
6287
6317
|
function loadTransformUVue() {
|
|
6288
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
6318
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-CgohToUV.cjs")).then((mod) => mod.transformUVue));
|
|
6289
6319
|
return transformUVuePromise;
|
|
6290
6320
|
}
|
|
6291
6321
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
package/dist/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-Dy6THt54.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-CVr0vIgh.js";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_generator = require("./generator-
|
|
1
|
+
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
2
2
|
const require_weapp_tw_css_import_rewrite_loader = require("./weapp-tw-css-import-rewrite-loader.cjs");
|
|
3
3
|
let node_buffer = require("node:buffer");
|
|
4
4
|
//#region src/bundlers/webpack/loaders/weapp-tw-css-generation-loader.ts
|