@dcloudio/uni-cli-shared 3.0.0-alpha-3040220220310006 → 3.0.0-alpha-3040320220324001
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/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/env/provide.d.ts +2 -0
- package/dist/env/provide.js +2 -0
- package/dist/esbuild.d.ts +1 -0
- package/dist/esbuild.js +7 -1
- package/dist/json/app/pages/code.d.ts +1 -1
- package/dist/json/app/pages/code.js +1 -2
- package/dist/json/app/pages/definePage.d.ts +1 -0
- package/dist/json/app/pages/definePage.js +15 -1
- package/dist/json/app/pages/index.d.ts +1 -0
- package/dist/json/app/pages/index.js +6 -1
- package/dist/json/manifest.d.ts +1 -1
- package/dist/json/manifest.js +10 -5
- package/dist/json/pages.js +23 -2
- package/dist/logs/format.d.ts +4 -1
- package/dist/logs/format.js +26 -1
- package/dist/logs/index.d.ts +2 -0
- package/dist/logs/index.js +13 -1
- package/dist/preprocess/context.js +1 -1
- package/dist/vite/index.d.ts +2 -1
- package/dist/vite/plugins/cssScoped.d.ts +1 -0
- package/dist/vite/plugins/cssScoped.js +23 -1
- package/dist/vite/plugins/dynamicImportPolyfill.d.ts +2 -0
- package/dist/vite/plugins/dynamicImportPolyfill.js +15 -0
- package/dist/vite/plugins/index.d.ts +3 -1
- package/dist/vite/plugins/index.js +6 -1
- package/dist/vite/plugins/inject.d.ts +1 -1
- package/dist/vite/plugins/inject.js +2 -2
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +5 -5
- package/dist/vite/utils/plugin.d.ts +1 -4
- package/dist/vite/utils/plugin.js +1 -5
- package/dist/vue/utils.d.ts +1 -0
- package/dist/vue/utils.js +16 -1
- package/package.json +3 -3
package/dist/constants.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare const JSON_JS_MAP: {
|
|
|
15
15
|
};
|
|
16
16
|
export declare const ASSETS_INLINE_LIMIT: number;
|
|
17
17
|
export declare const APP_SERVICE_FILENAME = "app-service.js";
|
|
18
|
+
export declare const APP_CONFIG = "app-config.js";
|
|
19
|
+
export declare const APP_CONFIG_SERVICE = "app-config-service.js";
|
|
18
20
|
export declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
|
|
19
21
|
export declare const PAGE_EXTNAME_APP: string[];
|
|
20
22
|
export declare const PAGE_EXTNAME: string[];
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
3
|
+
exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
4
4
|
exports.PUBLIC_DIR = 'static';
|
|
5
5
|
exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
|
|
6
6
|
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
@@ -25,6 +25,8 @@ exports.JSON_JS_MAP = {
|
|
|
25
25
|
};
|
|
26
26
|
exports.ASSETS_INLINE_LIMIT = 40 * 1024;
|
|
27
27
|
exports.APP_SERVICE_FILENAME = 'app-service.js';
|
|
28
|
+
exports.APP_CONFIG = 'app-config.js';
|
|
29
|
+
exports.APP_CONFIG_SERVICE = 'app-config-service.js';
|
|
28
30
|
exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
|
|
29
31
|
// APP 平台解析页面后缀的优先级
|
|
30
32
|
exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
|
package/dist/env/provide.d.ts
CHANGED
package/dist/env/provide.js
CHANGED
|
@@ -13,6 +13,8 @@ function initAppProvide() {
|
|
|
13
13
|
crypto: cryptoDefine,
|
|
14
14
|
'window.crypto': cryptoDefine,
|
|
15
15
|
'global.crypto': cryptoDefine,
|
|
16
|
+
'uni.getCurrentSubNVue': ['@dcloudio/uni-app', 'getCurrentSubNVue'],
|
|
17
|
+
'uni.requireNativePlugin': ['@dcloudio/uni-app', 'requireNativePlugin'],
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
exports.initAppProvide = initAppProvide;
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { BuildOptions } from 'esbuild';
|
|
2
2
|
export declare function transformWithEsbuild(code: string, filename: string, options: BuildOptions): Promise<import("esbuild").BuildResult>;
|
|
3
|
+
export declare function esbuild(options: BuildOptions): Promise<import("esbuild").BuildResult>;
|
package/dist/esbuild.js
CHANGED
|
@@ -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.transformWithEsbuild = void 0;
|
|
29
|
+
exports.esbuild = exports.transformWithEsbuild = void 0;
|
|
30
30
|
const path_1 = __importDefault(require("path"));
|
|
31
31
|
function transformWithEsbuild(code, filename, options) {
|
|
32
32
|
options.stdin = {
|
|
@@ -38,3 +38,9 @@ function transformWithEsbuild(code, filename, options) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
exports.transformWithEsbuild = transformWithEsbuild;
|
|
41
|
+
function esbuild(options) {
|
|
42
|
+
return Promise.resolve().then(() => __importStar(require('esbuild'))).then((esbuild) => {
|
|
43
|
+
return esbuild.build(options);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.esbuild = esbuild;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const polyfillCode = "\nif (typeof Promise !== 'undefined' && !Promise.prototype.finally) {\n Promise.prototype.finally = function(callback) {\n const promise = this.constructor\n return this.then(\n value => promise.resolve(callback()).then(() => value),\n reason => promise.resolve(callback()).then(() => {\n throw reason\n })\n )\n }\n}\nif(uni&&uni.base64ToArrayBuffer){\n ArrayBuffer = uni.base64ToArrayBuffer('').constructor\n}\n";
|
|
2
|
-
export declare const restoreGlobalCode = "\
|
|
2
|
+
export declare const restoreGlobalCode = "\nif(uni.restoreGlobal){\n uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)\n}\n";
|
|
3
3
|
export declare const globalCode: string;
|
|
@@ -18,9 +18,8 @@ if(uni&&uni.base64ToArrayBuffer){
|
|
|
18
18
|
}
|
|
19
19
|
`;
|
|
20
20
|
exports.restoreGlobalCode = `
|
|
21
|
-
import * as vue from 'vue'
|
|
22
21
|
if(uni.restoreGlobal){
|
|
23
|
-
uni.restoreGlobal(
|
|
22
|
+
uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
|
|
24
23
|
}
|
|
25
24
|
`;
|
|
26
25
|
const GLOBALS = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.definePageCode = void 0;
|
|
3
|
+
exports.defineNVuePageCode = exports.definePageCode = void 0;
|
|
4
4
|
const utils_1 = require("../../../utils");
|
|
5
5
|
function definePageCode(pagesJson) {
|
|
6
6
|
const importPagesCode = [];
|
|
@@ -26,3 +26,17 @@ function definePageCode(pagesJson) {
|
|
|
26
26
|
return importPagesCode.join('\n') + '\n' + definePagesCode.join('\n');
|
|
27
27
|
}
|
|
28
28
|
exports.definePageCode = definePageCode;
|
|
29
|
+
function defineNVuePageCode(pagesJson) {
|
|
30
|
+
const importNVuePagesCode = [];
|
|
31
|
+
pagesJson.pages.forEach((page) => {
|
|
32
|
+
if (!page.style.isNVue) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
|
|
36
|
+
if (pagePathWithExtname) {
|
|
37
|
+
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then(()=>{})`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return importNVuePagesCode.join('\n');
|
|
41
|
+
}
|
|
42
|
+
exports.defineNVuePageCode = defineNVuePageCode;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function normalizeAppPagesJson(pagesJson: Record<string, any>): string;
|
|
2
|
+
export declare function normalizeAppNVuePagesJson(pagesJson: Record<string, any>): string;
|
|
2
3
|
export declare function normalizeAppConfigService(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeAppConfigService = exports.normalizeAppPagesJson = void 0;
|
|
3
|
+
exports.normalizeAppConfigService = exports.normalizeAppNVuePagesJson = exports.normalizeAppPagesJson = void 0;
|
|
4
4
|
const code_1 = require("./code");
|
|
5
5
|
const definePage_1 = require("./definePage");
|
|
6
6
|
const uniConfig_1 = require("./uniConfig");
|
|
@@ -9,12 +9,17 @@ function normalizeAppPagesJson(pagesJson) {
|
|
|
9
9
|
return code_1.polyfillCode + code_1.restoreGlobalCode + (0, definePage_1.definePageCode)(pagesJson);
|
|
10
10
|
}
|
|
11
11
|
exports.normalizeAppPagesJson = normalizeAppPagesJson;
|
|
12
|
+
function normalizeAppNVuePagesJson(pagesJson) {
|
|
13
|
+
return (0, definePage_1.defineNVuePageCode)(pagesJson);
|
|
14
|
+
}
|
|
15
|
+
exports.normalizeAppNVuePagesJson = normalizeAppNVuePagesJson;
|
|
12
16
|
function normalizeAppConfigService(pagesJson, manifestJson) {
|
|
13
17
|
return `
|
|
14
18
|
;(function(){
|
|
15
19
|
let u=void 0,isReady=false,onReadyCallbacks=[],isServiceReady=false,onServiceReadyCallbacks=[];
|
|
16
20
|
const __uniConfig = ${(0, uniConfig_1.normalizeAppUniConfig)(pagesJson, manifestJson)};
|
|
17
21
|
const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
|
|
22
|
+
__uniConfig.styles=${process.env.UNI_NVUE_APP_STYLES || '[]'};//styles
|
|
18
23
|
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
|
19
24
|
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
|
20
25
|
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:16})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,${code_1.globalCode}}}}});
|
package/dist/json/manifest.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function normalizeNetworkTimeout(networkTimeout?: Partial<typeof
|
|
|
19
19
|
downloadFile: number;
|
|
20
20
|
};
|
|
21
21
|
export declare function getUniStatistics(inputDir: string, platform: UniApp.PLATFORM): any;
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function isEnableUniPushV2(inputDir: string, platform: UniApp.PLATFORM): boolean;
|
|
23
23
|
export declare function isUniPushOffline(inputDir: string): boolean;
|
|
24
24
|
export declare function getRouterOptions(manifestJson: Record<string, any>): {
|
|
25
25
|
mode?: 'history' | 'hash';
|
package/dist/json/manifest.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.
|
|
6
|
+
exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.isEnableUniPushV2 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -47,15 +47,20 @@ function getUniStatistics(inputDir, platform) {
|
|
|
47
47
|
return (0, shared_1.extend)({}, manifest.uniStatistics, manifest[platform] && manifest[platform].uniStatistics);
|
|
48
48
|
}
|
|
49
49
|
exports.getUniStatistics = getUniStatistics;
|
|
50
|
-
function
|
|
50
|
+
function isEnableUniPushV2(inputDir, platform) {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
52
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
52
|
-
|
|
53
|
+
if (platform === 'app') {
|
|
54
|
+
return (((_e = (_d = (_c = (_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.distribute) === null || _b === void 0 ? void 0 : _b.sdkConfigs) === null || _c === void 0 ? void 0 : _c.push) === null || _d === void 0 ? void 0 : _d.unipush) === null || _e === void 0 ? void 0 : _e.version) ==
|
|
55
|
+
'2');
|
|
56
|
+
}
|
|
57
|
+
return ((_g = (_f = manifest[platform]) === null || _f === void 0 ? void 0 : _f.unipush) === null || _g === void 0 ? void 0 : _g.enable) === true;
|
|
53
58
|
}
|
|
54
|
-
exports.
|
|
59
|
+
exports.isEnableUniPushV2 = isEnableUniPushV2;
|
|
55
60
|
function isUniPushOffline(inputDir) {
|
|
56
61
|
var _a, _b, _c, _d, _e;
|
|
57
62
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
58
|
-
return (((_e = (_d = (_c = (_b = (_a = manifest
|
|
63
|
+
return (((_e = (_d = (_c = (_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.distribute) === null || _b === void 0 ? void 0 : _b.sdkConfigs) === null || _c === void 0 ? void 0 : _c.push) === null || _d === void 0 ? void 0 : _d.unipush) === null || _e === void 0 ? void 0 : _e.offline) ===
|
|
59
64
|
true);
|
|
60
65
|
}
|
|
61
66
|
exports.isUniPushOffline = isUniPushOffline;
|
package/dist/json/pages.js
CHANGED
|
@@ -113,9 +113,30 @@ function validatePages(pagesJson, jsonStr) {
|
|
|
113
113
|
}
|
|
114
114
|
exports.validatePages = validatePages;
|
|
115
115
|
function normalizePages(pages, platform) {
|
|
116
|
-
|
|
116
|
+
pages.forEach((page) => {
|
|
117
117
|
page.style = normalizePageStyle(page.path, page.style, platform);
|
|
118
118
|
});
|
|
119
|
+
if (platform !== 'app') {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const subNVuePages = [];
|
|
123
|
+
// subNVues
|
|
124
|
+
pages.forEach(({ style: { subNVues } }) => {
|
|
125
|
+
if (!(0, shared_1.isArray)(subNVues)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
subNVues.forEach((subNVue) => {
|
|
129
|
+
if (subNVue && subNVue.path) {
|
|
130
|
+
subNVuePages.push({
|
|
131
|
+
path: subNVue.path,
|
|
132
|
+
style: { isSubNVue: true, isNVue: true, navigationBar: {} },
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
if (subNVuePages.length) {
|
|
138
|
+
pages.push(...subNVuePages);
|
|
139
|
+
}
|
|
119
140
|
}
|
|
120
141
|
function normalizeSubpackages(subpackages) {
|
|
121
142
|
const pages = [];
|
|
@@ -137,7 +158,7 @@ function normalizeSubpackageSubNVues(root, style = { navigationBar: {} }) {
|
|
|
137
158
|
if (!platformStyle) {
|
|
138
159
|
return style;
|
|
139
160
|
}
|
|
140
|
-
if (
|
|
161
|
+
if ((0, shared_1.isArray)(platformStyle.subNVues)) {
|
|
141
162
|
platformStyle.subNVues.forEach((subNVue) => {
|
|
142
163
|
if (subNVue.path) {
|
|
143
164
|
subNVue.path = (0, utils_1.normalizePath)(path_1.default.join(root, subNVue.path));
|
package/dist/logs/format.d.ts
CHANGED
|
@@ -4,5 +4,8 @@ export interface Formatter<T extends LogOptions = LogOptions> {
|
|
|
4
4
|
format: (msg: string, options?: T) => string;
|
|
5
5
|
}
|
|
6
6
|
export declare function formatErrMsg(msg: string, options?: LogErrorOptions): string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare const removeNVueInfoFormatter: Formatter;
|
|
8
|
+
export declare function formatInfoMsg(msg: string, options?: LogOptions & {
|
|
9
|
+
nvue?: boolean;
|
|
10
|
+
}): string;
|
|
8
11
|
export declare function formatWarnMsg(msg: string, options?: LogOptions): string;
|
package/dist/logs/format.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatWarnMsg = exports.formatInfoMsg = exports.formatErrMsg = void 0;
|
|
3
|
+
exports.formatWarnMsg = exports.formatInfoMsg = exports.removeNVueInfoFormatter = exports.formatErrMsg = void 0;
|
|
4
4
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
5
5
|
const env_1 = require("../hbx/env");
|
|
6
6
|
const alias_1 = require("../hbx/alias");
|
|
@@ -37,12 +37,37 @@ function formatErrMsg(msg, options) {
|
|
|
37
37
|
return msg;
|
|
38
38
|
}
|
|
39
39
|
exports.formatErrMsg = formatErrMsg;
|
|
40
|
+
const REMOVED_NVUE_MSGS = [
|
|
41
|
+
(msg) => {
|
|
42
|
+
// vite v2.7.10 building for development... (x2)
|
|
43
|
+
return msg.includes('vite v') && msg.includes('building ');
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
exports.removeNVueInfoFormatter = {
|
|
47
|
+
test(msg) {
|
|
48
|
+
return !!REMOVED_NVUE_MSGS.find((m) => typeof m === 'string' ? msg.includes(m) : m(msg));
|
|
49
|
+
},
|
|
50
|
+
format() {
|
|
51
|
+
return '';
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const nvueInfoFormatters = [];
|
|
55
|
+
const initNVueInfoFormattersOnce = (0, uni_shared_1.once)(() => {
|
|
56
|
+
nvueInfoFormatters.push(exports.removeNVueInfoFormatter);
|
|
57
|
+
});
|
|
40
58
|
function formatInfoMsg(msg, options) {
|
|
41
59
|
initInfoFormattersOnce();
|
|
42
60
|
const formatter = infoFormatters.find(({ test }) => test(msg, options));
|
|
43
61
|
if (formatter) {
|
|
44
62
|
return formatter.format(msg, options);
|
|
45
63
|
}
|
|
64
|
+
if (options === null || options === void 0 ? void 0 : options.nvue) {
|
|
65
|
+
initNVueInfoFormattersOnce();
|
|
66
|
+
const formatter = nvueInfoFormatters.find(({ test }) => test(msg, options));
|
|
67
|
+
if (formatter) {
|
|
68
|
+
return formatter.format(msg, options);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
46
71
|
return msg;
|
|
47
72
|
}
|
|
48
73
|
exports.formatInfoMsg = formatInfoMsg;
|
package/dist/logs/index.d.ts
CHANGED
package/dist/logs/index.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatWarnMsg = exports.formatInfoMsg = exports.formatErrMsg = void 0;
|
|
3
|
+
exports.output = exports.formatWarnMsg = exports.formatInfoMsg = exports.formatErrMsg = void 0;
|
|
4
4
|
var format_1 = require("./format");
|
|
5
5
|
Object.defineProperty(exports, "formatErrMsg", { enumerable: true, get: function () { return format_1.formatErrMsg; } });
|
|
6
6
|
Object.defineProperty(exports, "formatInfoMsg", { enumerable: true, get: function () { return format_1.formatInfoMsg; } });
|
|
7
7
|
Object.defineProperty(exports, "formatWarnMsg", { enumerable: true, get: function () { return format_1.formatWarnMsg; } });
|
|
8
|
+
let lastType;
|
|
9
|
+
let lastMsg;
|
|
10
|
+
function output(type, msg) {
|
|
11
|
+
if (type === lastType && msg === lastMsg) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
lastMsg = msg;
|
|
15
|
+
lastType = type;
|
|
16
|
+
const method = type === 'info' ? 'log' : type;
|
|
17
|
+
console[method](msg);
|
|
18
|
+
}
|
|
19
|
+
exports.output = output;
|
|
@@ -45,7 +45,7 @@ function initPreContext(platform, userPreContext) {
|
|
|
45
45
|
});
|
|
46
46
|
defaultContext[normalizeKey(platform)] = true;
|
|
47
47
|
vueContext.VUE3 = true;
|
|
48
|
-
nvueContext.
|
|
48
|
+
nvueContext.VUE3 = true;
|
|
49
49
|
if (platform === 'app' || platform === 'app-plus') {
|
|
50
50
|
defaultContext.APP = true;
|
|
51
51
|
defaultContext.APP_PLUS = true;
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import type { EmittedAsset } from 'rollup';
|
|
3
3
|
import type { ParserOptions } from '@vue/compiler-core';
|
|
4
|
-
import type { CompilerOptions, TemplateCompiler } from '@vue/compiler-sfc';
|
|
4
|
+
import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
|
|
5
5
|
import { UniViteCopyPluginOptions } from './plugins/copy';
|
|
6
6
|
export declare const cssTarget = "chrome53";
|
|
7
7
|
export interface CopyOptions {
|
|
@@ -13,6 +13,7 @@ export interface CopyOptions {
|
|
|
13
13
|
}
|
|
14
14
|
interface UniVitePluginUniOptions {
|
|
15
15
|
compiler?: TemplateCompiler;
|
|
16
|
+
styleOptions?: Pick<SFCStyleCompileOptions, 'postcssPlugins'>;
|
|
16
17
|
compilerOptions?: {
|
|
17
18
|
miniProgram?: {
|
|
18
19
|
emitFile?: (emittedFile: EmittedAsset) => string;
|
|
@@ -2,5 +2,6 @@ import type { Plugin } from 'vite';
|
|
|
2
2
|
interface UniCssScopedPluginOptions {
|
|
3
3
|
filter: (id: string) => boolean;
|
|
4
4
|
}
|
|
5
|
+
export declare function uniRemoveCssScopedPlugin({ filter }?: UniCssScopedPluginOptions): Plugin;
|
|
5
6
|
export declare function uniCssScopedPlugin({ filter }?: UniCssScopedPluginOptions): Plugin;
|
|
6
7
|
export {};
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uniCssScopedPlugin = void 0;
|
|
6
|
+
exports.uniCssScopedPlugin = exports.uniRemoveCssScopedPlugin = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
9
|
const constants_1 = require("../../constants");
|
|
@@ -17,6 +17,28 @@ function addScoped(code) {
|
|
|
17
17
|
}
|
|
18
18
|
return code.replace(/(<style\b[^><]*)>/gi, '$1 scoped>');
|
|
19
19
|
}
|
|
20
|
+
function removeScoped(code) {
|
|
21
|
+
if (!SCOPED_RE.test(code)) {
|
|
22
|
+
return code;
|
|
23
|
+
}
|
|
24
|
+
return code.replace(/(<style.*)scoped(.*>)/gi, '$1$2');
|
|
25
|
+
}
|
|
26
|
+
function uniRemoveCssScopedPlugin({ filter } = { filter: () => false }) {
|
|
27
|
+
return {
|
|
28
|
+
name: 'uni:css-remove-scoped',
|
|
29
|
+
enforce: 'pre',
|
|
30
|
+
transform(code, id) {
|
|
31
|
+
if (!filter(id))
|
|
32
|
+
return null;
|
|
33
|
+
debugScoped(id);
|
|
34
|
+
return {
|
|
35
|
+
code: removeScoped(code),
|
|
36
|
+
map: null,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.uniRemoveCssScopedPlugin = uniRemoveCssScopedPlugin;
|
|
20
42
|
function uniCssScopedPlugin({ filter } = { filter: () => false }) {
|
|
21
43
|
return {
|
|
22
44
|
name: 'uni:css-scoped',
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicImportPolyfill = void 0;
|
|
4
|
+
function dynamicImportPolyfill(promise = false) {
|
|
5
|
+
return {
|
|
6
|
+
name: 'dynamic-import-polyfill',
|
|
7
|
+
renderDynamicImport() {
|
|
8
|
+
return {
|
|
9
|
+
left: promise ? 'Promise.resolve(' : '(',
|
|
10
|
+
right: ')',
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.dynamicImportPolyfill = dynamicImportPolyfill;
|
|
@@ -4,5 +4,7 @@ export * from './inject';
|
|
|
4
4
|
export * from './mainJs';
|
|
5
5
|
export * from './jsonJs';
|
|
6
6
|
export * from './console';
|
|
7
|
+
export * from './dynamicImportPolyfill';
|
|
7
8
|
export { assetPlugin, getAssetHash } from './vitejs/plugins/asset';
|
|
8
|
-
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, } from './vitejs/plugins/css';
|
|
9
|
+
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
|
|
10
|
+
export { generateCodeFrame } from './vitejs/utils';
|
|
@@ -14,13 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin = void 0;
|
|
17
|
+
exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin = void 0;
|
|
18
18
|
__exportStar(require("./cssScoped"), exports);
|
|
19
19
|
__exportStar(require("./copy"), exports);
|
|
20
20
|
__exportStar(require("./inject"), exports);
|
|
21
21
|
__exportStar(require("./mainJs"), exports);
|
|
22
22
|
__exportStar(require("./jsonJs"), exports);
|
|
23
23
|
__exportStar(require("./console"), exports);
|
|
24
|
+
__exportStar(require("./dynamicImportPolyfill"), exports);
|
|
24
25
|
var asset_1 = require("./vitejs/plugins/asset");
|
|
25
26
|
Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
|
|
26
27
|
Object.defineProperty(exports, "getAssetHash", { enumerable: true, get: function () { return asset_1.getAssetHash; } });
|
|
@@ -29,3 +30,7 @@ Object.defineProperty(exports, "isCSSRequest", { enumerable: true, get: function
|
|
|
29
30
|
Object.defineProperty(exports, "cssPlugin", { enumerable: true, get: function () { return css_1.cssPlugin; } });
|
|
30
31
|
Object.defineProperty(exports, "cssPostPlugin", { enumerable: true, get: function () { return css_1.cssPostPlugin; } });
|
|
31
32
|
Object.defineProperty(exports, "minifyCSS", { enumerable: true, get: function () { return css_1.minifyCSS; } });
|
|
33
|
+
Object.defineProperty(exports, "cssLangRE", { enumerable: true, get: function () { return css_1.cssLangRE; } });
|
|
34
|
+
Object.defineProperty(exports, "commonjsProxyRE", { enumerable: true, get: function () { return css_1.commonjsProxyRE; } });
|
|
35
|
+
var utils_1 = require("./vitejs/utils");
|
|
36
|
+
Object.defineProperty(exports, "generateCodeFrame", { enumerable: true, get: function () { return utils_1.generateCodeFrame; } });
|
|
@@ -8,5 +8,5 @@ export interface InjectOptions {
|
|
|
8
8
|
exclude?: FilterPattern;
|
|
9
9
|
[str: string]: Injectment | FilterPattern | Boolean | Function | undefined;
|
|
10
10
|
}
|
|
11
|
-
export declare function uniViteInjectPlugin(options: InjectOptions): Plugin;
|
|
11
|
+
export declare function uniViteInjectPlugin(name: string, options: InjectOptions): Plugin;
|
|
12
12
|
export {};
|
|
@@ -13,7 +13,7 @@ const magic_string_1 = __importDefault(require("magic-string"));
|
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const debugInject = (0, debug_1.default)('uni:inject');
|
|
15
15
|
const debugInjectTry = (0, debug_1.default)('uni:inject-try');
|
|
16
|
-
function uniViteInjectPlugin(options) {
|
|
16
|
+
function uniViteInjectPlugin(name, options) {
|
|
17
17
|
if (!options)
|
|
18
18
|
throw new Error('Missing options');
|
|
19
19
|
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
@@ -41,7 +41,7 @@ function uniViteInjectPlugin(options) {
|
|
|
41
41
|
const sourceMap = options.sourceMap !== false;
|
|
42
42
|
const callback = options.callback;
|
|
43
43
|
return {
|
|
44
|
-
name
|
|
44
|
+
name,
|
|
45
45
|
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
|
|
46
46
|
enforce: 'post',
|
|
47
47
|
transform(code, id) {
|
|
@@ -24,6 +24,7 @@ export interface CSSModulesOptions {
|
|
|
24
24
|
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | null;
|
|
25
25
|
}
|
|
26
26
|
export declare const cssLangRE: RegExp;
|
|
27
|
+
export declare const commonjsProxyRE: RegExp;
|
|
27
28
|
export declare const isCSSRequest: (request: string) => boolean;
|
|
28
29
|
export declare const isDirectCSSRequest: (request: string) => boolean;
|
|
29
30
|
/**
|
|
@@ -35,7 +36,7 @@ export declare function cssPlugin(config: ResolvedConfig): Plugin;
|
|
|
35
36
|
*/
|
|
36
37
|
export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
37
38
|
chunkCssFilename: (id: string) => string | void;
|
|
38
|
-
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
39
|
+
chunkCssCode: (filename: string, cssCode: string) => Promise<string> | string;
|
|
39
40
|
}): Plugin;
|
|
40
41
|
export declare const cssUrlRE: RegExp;
|
|
41
42
|
export declare function minifyCSS(css: string, config: ResolvedConfig): Promise<string>;
|
|
@@ -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.minifyCSS = exports.cssUrlRE = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.cssLangRE = void 0;
|
|
29
|
+
exports.minifyCSS = exports.cssUrlRE = 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"));
|
|
@@ -42,7 +42,7 @@ const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
|
42
42
|
exports.cssLangRE = new RegExp(cssLangs);
|
|
43
43
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
44
44
|
const directRequestRE = /(\?|&)direct\b/;
|
|
45
|
-
|
|
45
|
+
exports.commonjsProxyRE = /\?commonjs-proxy/;
|
|
46
46
|
const isCSSRequest = (request) => exports.cssLangRE.test(request) && !directRequestRE.test(request);
|
|
47
47
|
exports.isCSSRequest = isCSSRequest;
|
|
48
48
|
const isDirectCSSRequest = (request) => exports.cssLangRE.test(request) && directRequestRE.test(request);
|
|
@@ -72,7 +72,7 @@ function cssPlugin(config) {
|
|
|
72
72
|
cssModulesCache.set(config, moduleCache);
|
|
73
73
|
},
|
|
74
74
|
async transform(raw, id) {
|
|
75
|
-
if (!exports.cssLangRE.test(id) || commonjsProxyRE.test(id)) {
|
|
75
|
+
if (!exports.cssLangRE.test(id) || exports.commonjsProxyRE.test(id)) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
const urlReplacer = async (url, importer) => {
|
|
@@ -123,7 +123,7 @@ function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
|
123
123
|
// 查询main.js时,需要忽略pages.json.js,否则会把所有页面样式加进来
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
if (exports.cssLangRE.test(id) && !commonjsProxyRE.test(id)) {
|
|
126
|
+
if (exports.cssLangRE.test(id) && !exports.commonjsProxyRE.test(id)) {
|
|
127
127
|
cssModuleIds.add(id);
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
@@ -146,7 +146,7 @@ function cssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
|
146
146
|
cssChunks = new Map();
|
|
147
147
|
},
|
|
148
148
|
async transform(css, id) {
|
|
149
|
-
if (!exports.cssLangRE.test(id) || commonjsProxyRE.test(id)) {
|
|
149
|
+
if (!exports.cssLangRE.test(id) || exports.commonjsProxyRE.test(id)) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
const modules = cssModulesCache.get(config).get(id);
|
|
@@ -6,9 +6,6 @@ export interface UniViteFilterPluginOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function injectAssetPlugin(config: ResolvedConfig): void;
|
|
8
8
|
export declare function injectCssPlugin(config: ResolvedConfig): void;
|
|
9
|
-
export declare function injectCssPostPlugin(config: ResolvedConfig,
|
|
10
|
-
chunkCssFilename: (id: string) => string | void;
|
|
11
|
-
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
12
|
-
}): void;
|
|
9
|
+
export declare function injectCssPostPlugin(config: ResolvedConfig, newCssPostPlugin: Plugin): void;
|
|
13
10
|
export declare function replacePlugins(plugins: Plugin[], config: ResolvedConfig): void;
|
|
14
11
|
export declare function removePlugins(plugins: string | string[], config: ResolvedConfig): void;
|
|
@@ -12,11 +12,7 @@ function injectCssPlugin(config) {
|
|
|
12
12
|
replacePlugins([(0, css_1.cssPlugin)(config)], config);
|
|
13
13
|
}
|
|
14
14
|
exports.injectCssPlugin = injectCssPlugin;
|
|
15
|
-
function injectCssPostPlugin(config,
|
|
16
|
-
const newCssPostPlugin = (0, css_1.cssPostPlugin)(config, {
|
|
17
|
-
chunkCssFilename,
|
|
18
|
-
chunkCssCode,
|
|
19
|
-
});
|
|
15
|
+
function injectCssPostPlugin(config, newCssPostPlugin) {
|
|
20
16
|
const oldCssPostPlugin = config.plugins.find((p) => p.name === newCssPostPlugin.name);
|
|
21
17
|
// 直接覆盖原有方法,不能删除,替换,因为 unocss 在 pre 阶段已经获取到了旧的 css-post 插件对象
|
|
22
18
|
if (oldCssPostPlugin) {
|
package/dist/vue/utils.d.ts
CHANGED
|
@@ -28,3 +28,4 @@ export declare function createUniVueTransformAssetUrls(base: string): {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
export declare function getBaseNodeTransforms(base: string): import("@vue/compiler-core").NodeTransform[];
|
|
31
|
+
export declare function renameProp(name: string, prop?: DirectiveNode | AttributeNode): void;
|
package/dist/vue/utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
3
|
+
exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
6
6
|
const compiler_core_1 = require("@vue/compiler-core");
|
|
7
7
|
const templateTransformAssetUrl_1 = require("./transforms/templateTransformAssetUrl");
|
|
8
8
|
const templateTransformSrcset_1 = require("./transforms/templateTransformSrcset");
|
|
9
|
+
const ast_1 = require("../vite/utils/ast");
|
|
9
10
|
const url_1 = require("../vite/utils/url");
|
|
10
11
|
const constants_1 = require("../constants");
|
|
11
12
|
exports.VUE_REF = 'r';
|
|
@@ -103,3 +104,17 @@ function getBaseNodeTransforms(base) {
|
|
|
103
104
|
];
|
|
104
105
|
}
|
|
105
106
|
exports.getBaseNodeTransforms = getBaseNodeTransforms;
|
|
107
|
+
function renameProp(name, prop) {
|
|
108
|
+
if (!prop) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if ((0, ast_1.isDirectiveNode)(prop)) {
|
|
112
|
+
if (prop.arg && (0, compiler_core_1.isStaticExp)(prop.arg)) {
|
|
113
|
+
prop.arg.content = name;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
prop.name = name;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.renameProp = renameProp;
|
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-3040320220324001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@babel/core": "^7.17.2",
|
|
22
22
|
"@babel/parser": "^7.16.4",
|
|
23
23
|
"@babel/types": "^7.16.8",
|
|
24
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
25
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
24
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3040320220324001",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3040320220324001",
|
|
26
26
|
"@rollup/pluginutils": "^4.1.2",
|
|
27
27
|
"@vue/compiler-core": "3.2.31",
|
|
28
28
|
"@vue/compiler-dom": "3.2.31",
|