weapp-tailwindcss 5.3.1 → 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/index.cjs +1 -1
- package/dist/index.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/{vite-Crz1mQR4.js → vite-CVr0vIgh.js} +113 -83
- package/dist/{vite-CtmGLZXy.cjs → vite-Dy6THt54.cjs} +113 -83
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const require_framework = require("./framework.cjs");
|
|
|
3
3
|
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
4
4
|
const require_gulp = require("./gulp-QJ_oz-06.cjs");
|
|
5
5
|
const require_postcss = require("./postcss.cjs");
|
|
6
|
-
const require_vite = require("./vite-
|
|
6
|
+
const require_vite = require("./vite-Dy6THt54.cjs");
|
|
7
7
|
const require_webpack = require("./webpack-Cf5RnhXt.cjs");
|
|
8
8
|
require("./webpack.cjs");
|
|
9
9
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMp
|
|
|
2
2
|
import { t as createWeappTailwindcssGenerator } from "./generator-EnTXLBlK.js";
|
|
3
3
|
import { t as createPlugins } from "./gulp-vz36-uQP.js";
|
|
4
4
|
import weappTailwindcssPostcssPlugin from "./postcss.js";
|
|
5
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
5
|
+
import { t as WeappTailwindcss } from "./vite-CVr0vIgh.js";
|
|
6
6
|
import { n as weappTailwindcssPackageDir } from "./webpack-DwtdWqwr.js";
|
|
7
7
|
import "./webpack.js";
|
|
8
8
|
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface HarmonyStyleInjectOptions {
|
|
2
|
+
cssSources?: Iterable<string | undefined> | undefined;
|
|
3
|
+
styleAssetFiles?: Iterable<string | undefined> | ((file: string) => Iterable<string | undefined>) | undefined;
|
|
4
|
+
excludeComponents?: boolean | undefined;
|
|
5
|
+
mapSources?: Iterable<string | undefined> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveStyleAssetFile(file: string): string | undefined;
|
|
8
|
+
export declare function resolveStylePlaceholderFallbackFiles(file: string): string[];
|
|
9
|
+
export declare function injectUniAppXHarmonyGlobalStyles(file: string, code: string, getBundleSource?: (file: string) => string | undefined, options?: HarmonyStyleInjectOptions): string;
|
|
@@ -13,7 +13,5 @@ export declare function createStyleValueFromApplySources(sources: string[], util
|
|
|
13
13
|
export declare function collectUniAppXHarmonyApplyStyleSourcesFromSource(source: string, sourceId?: string): string[];
|
|
14
14
|
export declare function collectUniAppXHarmonyApplyUtilitiesFromSources(sources: Iterable<string>): Set<string>;
|
|
15
15
|
export declare function createMergedStyleValue(code: string, localStyle: StyleValue | undefined, appStyle: StyleValue): StyleValue | undefined;
|
|
16
|
-
export declare function createMergedStyleValues(code: string, localStyles: StyleValue[], appStyle: StyleValue):
|
|
17
|
-
[x: string]: Record<string, StyleDeclarations>;
|
|
18
|
-
}[] | undefined;
|
|
16
|
+
export declare function createMergedStyleValues(code: string, localStyles: StyleValue[], appStyle: StyleValue): StyleValue[] | undefined;
|
|
19
17
|
export {};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import type { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
+
import type { HarmonyStyleInjectOptions } from './style-asset/harmony-global.js';
|
|
2
3
|
import { expandUniAppXHarmonyApplyStyles } from './style-asset/harmony-apply.js';
|
|
4
|
+
import { injectUniAppXHarmonyGlobalStyles } from './style-asset/harmony-global.js';
|
|
3
5
|
import { collectUniAppXHarmonyApplyStyleSourcesFromSource, collectUniAppXHarmonyApplyUtilitiesFromSources } from './style-asset/style-value.js';
|
|
4
6
|
export declare const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
5
7
|
type BundleItem = {
|
|
6
8
|
type: string;
|
|
7
9
|
} | OutputAsset | OutputChunk;
|
|
8
|
-
|
|
9
|
-
cssSources?: Iterable<string | undefined> | undefined;
|
|
10
|
-
styleAssetFiles?: Iterable<string | undefined> | ((file: string) => Iterable<string | undefined>) | undefined;
|
|
11
|
-
excludeComponents?: boolean | undefined;
|
|
12
|
-
mapSources?: Iterable<string | undefined> | undefined;
|
|
13
|
-
}
|
|
14
|
-
export { collectUniAppXHarmonyApplyStyleSourcesFromSource, collectUniAppXHarmonyApplyUtilitiesFromSources, expandUniAppXHarmonyApplyStyles, };
|
|
10
|
+
export { collectUniAppXHarmonyApplyStyleSourcesFromSource, collectUniAppXHarmonyApplyUtilitiesFromSources, expandUniAppXHarmonyApplyStyles, injectUniAppXHarmonyGlobalStyles, };
|
|
15
11
|
export declare function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources: string[], _applyUtilities: Iterable<string>): string;
|
|
16
12
|
export declare function collectUniAppXHarmonyApplyUtilities(bundle: Record<string, BundleItem>): Set<string>;
|
|
17
13
|
export declare function collectUniAppXHarmonyApplyStyleSources(bundle: Record<string, BundleItem>): string[];
|
|
18
14
|
export declare function injectUniAppXStylePlaceholder(file: string, code: string, getAssetSource?: (file: string) => string | undefined, cssSources?: Iterable<string | undefined>): string;
|
|
19
|
-
export declare function injectUniAppXHarmonyGlobalStyles(file: string, code: string, getBundleSource?: (file: string) => string | undefined, options?: HarmonyStyleInjectOptions): string;
|
|
20
15
|
export declare function injectUniAppXHarmonyBundleStyles(bundle: Record<string, BundleItem>, options?: HarmonyStyleInjectOptions): boolean;
|
|
21
16
|
export declare function isUniAppXHarmonyBundle(bundle: Record<string, BundleItem>): boolean;
|
|
22
17
|
export declare function createUniAppXBundleAssetSourceGetter(bundle: Record<string, BundleItem>): (file: string) => string | undefined;
|
|
@@ -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);
|
|
@@ -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);
|
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 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.2",
|
|
5
5
|
"description": "Bring Tailwind CSS to every platform! 把 Tailwind CSS 的原子化开发体验带到全端!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -211,8 +211,8 @@
|
|
|
211
211
|
"oxc-walker": "^1.1.1",
|
|
212
212
|
"semver": "~7.8.5",
|
|
213
213
|
"yaml": "^2.9.0",
|
|
214
|
-
"@weapp-tailwindcss/postcss": "3.2.11",
|
|
215
214
|
"@weapp-tailwindcss/logger": "2.0.2",
|
|
215
|
+
"@weapp-tailwindcss/postcss": "3.2.11",
|
|
216
216
|
"tailwindcss-config": "2.0.3",
|
|
217
217
|
"weapp-style-injector": "1.0.3",
|
|
218
218
|
"@weapp-tailwindcss/shared": "2.0.2",
|