@dcloudio/uni-cli-shared 3.0.0-alpha-3041020220513001 → 3.0.0-alpha-3041020220516004
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.
|
@@ -6,7 +6,7 @@ export declare function getComponentJsonFilenames(): string[];
|
|
|
6
6
|
export declare function findJsonFile(filename: string): Record<string, any> | undefined;
|
|
7
7
|
export declare function findUsingComponents(filename: string): UsingComponents | undefined;
|
|
8
8
|
export declare function normalizeJsonFilename(filename: string): string;
|
|
9
|
-
export declare function findChangedJsonFiles(): Map<string, string>;
|
|
9
|
+
export declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean): Map<string, string>;
|
|
10
10
|
export declare function addMiniProgramAppJson(appJson: Record<string, any>): void;
|
|
11
11
|
export declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void;
|
|
12
12
|
export declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void;
|
package/dist/json/mp/jsonFile.js
CHANGED
|
@@ -50,24 +50,35 @@ function normalizeJsonFilename(filename) {
|
|
|
50
50
|
return (0, utils_1.normalizeNodeModules)(filename);
|
|
51
51
|
}
|
|
52
52
|
exports.normalizeJsonFilename = normalizeJsonFilename;
|
|
53
|
-
function findChangedJsonFiles() {
|
|
53
|
+
function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
54
54
|
const changedJsonFiles = new Map();
|
|
55
55
|
function findChangedFile(filename, json) {
|
|
56
|
+
var _a;
|
|
56
57
|
const newJson = JSON.parse(JSON.stringify(json));
|
|
57
58
|
if (!newJson.usingComponents) {
|
|
58
59
|
newJson.usingComponents = {};
|
|
59
60
|
}
|
|
60
61
|
(0, shared_1.extend)(newJson.usingComponents, jsonUsingComponentsCache.get(filename));
|
|
61
|
-
const usingComponents = newJson.usingComponents;
|
|
62
62
|
// 格式化为相对路径,这样作为分包也可以直接运行
|
|
63
63
|
// app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
|
|
64
64
|
if (filename !== 'app') {
|
|
65
|
+
let usingComponents = newJson.usingComponents;
|
|
66
|
+
const globalUsingComponents = (_a = appJsonCache === null || appJsonCache === void 0 ? void 0 : appJsonCache.usingComponents) !== null && _a !== void 0 ? _a : {};
|
|
67
|
+
// 如果小程序不支持 global 的 usingComponents
|
|
68
|
+
if (!supportGlobalUsingComponents) {
|
|
69
|
+
// 从 appJsonCache 中读取全局的 usingComponents 并补充到子组件 usingComponents 中
|
|
70
|
+
usingComponents = {
|
|
71
|
+
...globalUsingComponents,
|
|
72
|
+
...newJson.usingComponents,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
65
75
|
Object.keys(usingComponents).forEach((name) => {
|
|
66
76
|
const componentFilename = usingComponents[name];
|
|
67
77
|
if (componentFilename.startsWith('/')) {
|
|
68
78
|
usingComponents[name] = (0, resolve_1.relativeFile)(filename, componentFilename.slice(1));
|
|
69
79
|
}
|
|
70
80
|
});
|
|
81
|
+
newJson.usingComponents = usingComponents;
|
|
71
82
|
}
|
|
72
83
|
const jsonStr = JSON.stringify(newJson, null, 2);
|
|
73
84
|
if (jsonFilesCache.get(filename) !== jsonStr) {
|
|
@@ -40,6 +40,8 @@ export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename
|
|
|
40
40
|
}): Plugin;
|
|
41
41
|
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): ExistingRawSourceMap;
|
|
42
42
|
export declare const cssUrlRE: RegExp;
|
|
43
|
+
export declare const cssDataUriRE: RegExp;
|
|
44
|
+
export declare const importCssRE: RegExp;
|
|
43
45
|
export declare function minifyCSS(css: string, config: ResolvedConfig): Promise<string>;
|
|
44
46
|
export declare function hoistAtRules(css: string): Promise<string>;
|
|
45
47
|
export interface StylePreprocessorResults {
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.hoistAtRules = exports.minifyCSS = exports.cssUrlRE = exports.formatPostcssSourceMap = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.commonjsProxyRE = exports.cssLangRE = void 0;
|
|
29
|
+
exports.hoistAtRules = exports.minifyCSS = exports.importCssRE = exports.cssDataUriRE = exports.cssUrlRE = exports.formatPostcssSourceMap = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.commonjsProxyRE = exports.cssLangRE = void 0;
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
@@ -516,6 +516,8 @@ async function resolvePostcssConfig(config) {
|
|
|
516
516
|
}
|
|
517
517
|
// https://drafts.csswg.org/css-syntax-3/#identifier-code-point
|
|
518
518
|
exports.cssUrlRE = /(?<=^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
|
|
519
|
+
exports.cssDataUriRE = /(?<=^|[^\w\-\u0080-\uffff])data-uri\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
|
|
520
|
+
exports.importCssRE = /@import ('[^']+\.css'|"[^"]+\.css"|[^'")]+\.css)/;
|
|
519
521
|
const cssImageSetRE = /(?<=image-set\()((?:[\w\-]+\([^\)]*\)|[^)])*)(?=\))/;
|
|
520
522
|
const UrlRewritePostcssPlugin = (opts) => {
|
|
521
523
|
if (!opts) {
|
|
@@ -550,26 +552,44 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
|
550
552
|
};
|
|
551
553
|
UrlRewritePostcssPlugin.postcss = true;
|
|
552
554
|
function rewriteCssUrls(css, replacer) {
|
|
553
|
-
return (0, utils_1.asyncReplace)(css,
|
|
555
|
+
return (0, utils_1.asyncReplace)(css, exports.cssUrlRE, async (match) => {
|
|
556
|
+
const [matched, rawUrl] = match;
|
|
557
|
+
return await doUrlReplace(rawUrl, matched, replacer);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
function rewriteCssDataUris(css, replacer) {
|
|
561
|
+
return (0, utils_1.asyncReplace)(css, exports.cssDataUriRE, async (match) => {
|
|
562
|
+
const [matched, rawUrl] = match;
|
|
563
|
+
return await doUrlReplace(rawUrl, matched, replacer, 'data-uri');
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function rewriteImportCss(css, replacer) {
|
|
567
|
+
return (0, utils_1.asyncReplace)(css, exports.importCssRE, async (match) => {
|
|
568
|
+
const [matched, rawUrl] = match;
|
|
569
|
+
return await doImportCSSReplace(rawUrl, matched, replacer);
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
// TODO: image and cross-fade could contain a "url" that needs to be processed
|
|
573
|
+
// https://drafts.csswg.org/css-images-4/#image-notation
|
|
574
|
+
// https://drafts.csswg.org/css-images-4/#cross-fade-function
|
|
575
|
+
const cssNotProcessedRE = /(gradient|element|cross-fade|image)\(/;
|
|
576
|
+
async function rewriteCssImageSet(css, replacer) {
|
|
577
|
+
return await (0, utils_1.asyncReplace)(css, cssImageSetRE, async (match) => {
|
|
554
578
|
const [, rawUrl] = match;
|
|
555
579
|
const url = await (0, utils_1.processSrcSet)(rawUrl, async ({ url }) => {
|
|
556
580
|
// the url maybe url(...)
|
|
557
581
|
if (exports.cssUrlRE.test(url)) {
|
|
558
582
|
return await rewriteCssUrls(url, replacer);
|
|
559
583
|
}
|
|
560
|
-
|
|
584
|
+
if (!cssNotProcessedRE.test(url)) {
|
|
585
|
+
return await doUrlReplace(url, url, replacer);
|
|
586
|
+
}
|
|
587
|
+
return url;
|
|
561
588
|
});
|
|
562
589
|
return url;
|
|
563
590
|
});
|
|
564
591
|
}
|
|
565
|
-
function
|
|
566
|
-
return (0, utils_1.asyncReplace)(css, cssImageSetRE, async (match) => {
|
|
567
|
-
const [matched, rawUrl] = match;
|
|
568
|
-
const url = await (0, utils_1.processSrcSet)(rawUrl, ({ url }) => doUrlReplace(url, matched, replacer));
|
|
569
|
-
return `image-set(${url})`;
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
async function doUrlReplace(rawUrl, matched, replacer) {
|
|
592
|
+
async function doUrlReplace(rawUrl, matched, replacer, funcName = 'url') {
|
|
573
593
|
let wrap = '';
|
|
574
594
|
const first = rawUrl[0];
|
|
575
595
|
if (first === `"` || first === `'`) {
|
|
@@ -582,7 +602,24 @@ async function doUrlReplace(rawUrl, matched, replacer) {
|
|
|
582
602
|
varRE.test(rawUrl)) {
|
|
583
603
|
return matched;
|
|
584
604
|
}
|
|
585
|
-
|
|
605
|
+
const newUrl = await replacer(rawUrl);
|
|
606
|
+
if (wrap === '' && newUrl !== encodeURI(newUrl)) {
|
|
607
|
+
// The new url might need wrapping even if the original did not have it, e.g. if a space was added during replacement
|
|
608
|
+
wrap = "'";
|
|
609
|
+
}
|
|
610
|
+
return `${funcName}(${wrap}${newUrl}${wrap})`;
|
|
611
|
+
}
|
|
612
|
+
async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
613
|
+
let wrap = '';
|
|
614
|
+
const first = rawUrl[0];
|
|
615
|
+
if (first === `"` || first === `'`) {
|
|
616
|
+
wrap = first;
|
|
617
|
+
rawUrl = rawUrl.slice(1, -1);
|
|
618
|
+
}
|
|
619
|
+
if ((0, utils_1.isExternalUrl)(rawUrl) || (0, utils_1.isDataUrl)(rawUrl) || rawUrl.startsWith('#')) {
|
|
620
|
+
return matched;
|
|
621
|
+
}
|
|
622
|
+
return `@import ${wrap}${await replacer(rawUrl)}${wrap}`;
|
|
586
623
|
}
|
|
587
624
|
async function minifyCSS(css, config) {
|
|
588
625
|
try {
|
|
@@ -734,8 +771,8 @@ function preprocessCss(content, isNVue = false) {
|
|
|
734
771
|
*/
|
|
735
772
|
async function rebaseUrls(file, rootFile, alias, isNVue = false) {
|
|
736
773
|
file = path_1.default.resolve(file); // ensure os-specific flashes
|
|
737
|
-
// 条件编译
|
|
738
|
-
|
|
774
|
+
// fixed by xxxxxx 条件编译
|
|
775
|
+
let contents = preprocessCss(fs_1.default.readFileSync(file, 'utf-8'), isNVue);
|
|
739
776
|
// in the same dir, no need to rebase
|
|
740
777
|
const fileDir = path_1.default.dirname(file);
|
|
741
778
|
const rootDir = path_1.default.dirname(rootFile);
|
|
@@ -743,10 +780,16 @@ async function rebaseUrls(file, rootFile, alias, isNVue = false) {
|
|
|
743
780
|
return { file, contents };
|
|
744
781
|
}
|
|
745
782
|
// no url()
|
|
746
|
-
|
|
783
|
+
const hasUrls = exports.cssUrlRE.test(contents);
|
|
784
|
+
// data-uri() calls
|
|
785
|
+
const hasDataUris = exports.cssDataUriRE.test(contents);
|
|
786
|
+
// no @import xxx.css
|
|
787
|
+
const hasImportCss = exports.importCssRE.test(contents);
|
|
788
|
+
if (!hasUrls && !hasDataUris && !hasImportCss) {
|
|
747
789
|
return { file, contents };
|
|
748
790
|
}
|
|
749
|
-
|
|
791
|
+
let rebased;
|
|
792
|
+
const rebaseFn = (url) => {
|
|
750
793
|
if (url.startsWith('/'))
|
|
751
794
|
return url;
|
|
752
795
|
// match alias, no need to rewrite
|
|
@@ -759,10 +802,20 @@ async function rebaseUrls(file, rootFile, alias, isNVue = false) {
|
|
|
759
802
|
const absolute = path_1.default.resolve(fileDir, url);
|
|
760
803
|
const relative = path_1.default.relative(rootDir, absolute);
|
|
761
804
|
return (0, utils_1.normalizePath)(relative);
|
|
762
|
-
}
|
|
805
|
+
};
|
|
806
|
+
// fix css imports in less such as `@import "foo.css"`
|
|
807
|
+
if (hasImportCss) {
|
|
808
|
+
contents = await rewriteImportCss(contents, rebaseFn);
|
|
809
|
+
}
|
|
810
|
+
if (hasUrls) {
|
|
811
|
+
contents = await rewriteCssUrls(rebased || contents, rebaseFn);
|
|
812
|
+
}
|
|
813
|
+
if (hasDataUris) {
|
|
814
|
+
contents = await rewriteCssDataUris(rebased || contents, rebaseFn);
|
|
815
|
+
}
|
|
763
816
|
return {
|
|
764
817
|
file,
|
|
765
|
-
contents
|
|
818
|
+
contents,
|
|
766
819
|
};
|
|
767
820
|
}
|
|
768
821
|
// .less
|
package/dist/vue/parse.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.parseWxsCode = exports.parseWxsNodes = exports.parseBlockCode = exports.
|
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
8
|
const ast_1 = require("../vite/utils/ast");
|
|
9
9
|
const BLOCK_RE = /<\/block>/;
|
|
10
|
-
const WXS_LANG_RE = /lang=["|'](renderjs|wxs)["|']/;
|
|
11
|
-
const WXS_ATTRS = ['wxs', 'renderjs'];
|
|
10
|
+
const WXS_LANG_RE = /lang=["|'](renderjs|wxs|sjs)["|']/;
|
|
11
|
+
const WXS_ATTRS = ['wxs', 'renderjs', 'sjs'];
|
|
12
12
|
function parseVueCode(code, isNVue = false) {
|
|
13
13
|
const hasBlock = BLOCK_RE.test(code);
|
|
14
14
|
const hasWxs = WXS_LANG_RE.test(code);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3041020220516004",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@babel/core": "^7.17.9",
|
|
23
23
|
"@babel/parser": "^7.17.9",
|
|
24
24
|
"@babel/types": "^7.17.0",
|
|
25
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
26
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
25
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3041020220516004",
|
|
26
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3041020220516004",
|
|
27
27
|
"@intlify/core-base": "9.1.9",
|
|
28
28
|
"@intlify/shared": "9.1.9",
|
|
29
29
|
"@intlify/vue-devtools": "9.1.9",
|