@dcloudio/uni-cli-shared 3.0.0-4080720251210001 → 3.0.0-5000420260317001
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 +3 -0
- package/dist/constants.js +6 -1
- package/dist/deps.js +6 -1
- package/dist/dom2/index.d.ts +1 -0
- package/dist/dom2/index.js +17 -0
- package/dist/dom2/sharedData.d.ts +2 -0
- package/dist/dom2/sharedData.js +19 -0
- package/dist/easycom.js +34 -5
- package/dist/env/define.d.ts +3 -0
- package/dist/env/define.js +12 -0
- package/dist/hbx/alias.js +15 -17
- package/dist/hbx/index.d.ts +1 -1
- package/dist/hbx/index.js +4 -2
- package/dist/hbx/log.d.ts +5 -0
- package/dist/hbx/log.js +44 -1
- package/dist/i18n.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json/app/manifest/index.d.ts +1 -0
- package/dist/json/app/manifest/index.js +3 -1
- package/dist/json/mp/pages.js +0 -5
- package/dist/json/pages.d.ts +2 -2
- package/dist/json/pages.js +4 -1
- package/dist/json/uni-x/index.d.ts +1 -1
- package/dist/json/utils.js +31 -22
- package/dist/logs/console.js +1 -1
- package/dist/logs/index.d.ts +11 -0
- package/dist/logs/index.js +34 -1
- package/dist/messages/en.d.ts +6 -3
- package/dist/messages/en.js +6 -3
- package/dist/messages/index.d.ts +11 -5
- package/dist/messages/zh_CN.d.ts +5 -2
- package/dist/messages/zh_CN.js +5 -2
- package/dist/mp/assets.d.ts +1 -0
- package/dist/mp/assets.js +27 -1
- package/dist/mp/externalClasses.d.ts +38 -2
- package/dist/mp/externalClasses.js +90 -4
- package/dist/mp/index.d.ts +4 -3
- package/dist/mp/index.js +11 -1
- package/dist/mp/plugin.d.ts +1 -0
- package/dist/mp/plugin.js +14 -1
- package/dist/mp/style.d.ts +1 -0
- package/dist/mp/style.js +8 -1
- package/dist/mp/usingComponents.d.ts +1 -0
- package/dist/mp/usingComponents.js +17 -1
- package/dist/postcss/index.d.ts +2 -0
- package/dist/postcss/index.js +3 -1
- package/dist/postcss/plugins/stylePluginExternal.d.ts +17 -0
- package/dist/postcss/plugins/stylePluginExternal.js +127 -0
- package/dist/postcss/plugins/stylePluginScoped.js +30 -0
- package/dist/preprocess/context.js +2 -0
- package/dist/preprocess/index.d.ts +9 -6
- package/dist/preprocess/index.js +33 -8
- package/dist/resolve.js +5 -1
- package/dist/uni_modules.js +20 -4
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +9 -6
- package/dist/utsUtils.d.ts +1 -0
- package/dist/utsUtils.js +2 -1
- package/dist/vite/autoImport.js +91 -6
- package/dist/vite/plugins/console.js +1 -1
- package/dist/vite/plugins/cssScoped.js +2 -1
- package/dist/vite/plugins/easycom.js +7 -0
- package/dist/vite/plugins/json.js +69 -2
- package/dist/vite/plugins/pre.js +4 -2
- package/dist/vite/plugins/sfc.js +1 -1
- package/dist/vite/plugins/stats.js +32 -0
- package/dist/vite/plugins/uts/ext-api.js +1 -1
- package/dist/vite/plugins/uts/uni_modules.js +12 -0
- package/dist/vite/plugins/uts/uvue.js +7 -2
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -0
- package/dist/vite/plugins/vitejs/plugins/asset.js +19 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +27 -10
- package/dist/vite/utils/ast.d.ts +2 -1
- package/dist/vite/utils/ast.js +5 -1
- package/dist/vue/parse.d.ts +2 -0
- package/dist/vue/parse.js +3 -1
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +1 -0
- package/dist/vue/transforms/transformLineBreak.d.ts +2 -0
- package/dist/vue/transforms/transformLineBreak.js +15 -0
- package/dist/vue/transforms/transformTag.d.ts +1 -1
- package/dist/vue/transforms/transformTag.js +5 -0
- package/dist/vue/transforms/x/transformMPBuiltInTag.js +2 -2
- package/dist/vue/utils.js +8 -1
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +42 -23
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +42 -23
- package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +39 -19
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +4635 -1024
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +8762 -7849
- package/lib/dom2/app/@vitejs/plugin-vue/LICENSE +21 -0
- package/lib/dom2/app/@vitejs/plugin-vue/README.md +278 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +3353 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.cts +113 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.mts +111 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.ts +113 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +3338 -0
- package/lib/dom2/app/@vitejs/plugin-vue/package.json +50 -0
- package/lib/dom2/app/@vue/compiler-core/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-core/README.md +1 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +5492 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +5436 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +1187 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +4335 -0
- package/lib/dom2/app/@vue/compiler-core/index.js +7 -0
- package/lib/dom2/app/@vue/compiler-core/package.json +58 -0
- package/lib/dom2/app/@vue/compiler-dom/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-dom/README.md +1 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +762 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +736 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.d.ts +73 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +5051 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +11 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +557 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +5234 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +11 -0
- package/lib/dom2/app/@vue/compiler-dom/index.js +7 -0
- package/lib/dom2/app/@vue/compiler-dom/package.json +57 -0
- package/lib/dom2/app/@vue/compiler-sfc/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-sfc/README.md +80 -0
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +15528 -0
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.d.ts +11595 -0
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +41525 -0
- package/lib/dom2/app/@vue/compiler-sfc/package.json +68 -0
- package/lib/dom2/app/@vue/compiler-vapor/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-vapor/README.md +1 -0
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +3584 -0
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +22858 -0
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +22438 -0
- package/lib/dom2/app/@vue/compiler-vapor/package.json +51 -0
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -0
- package/lib/dom2/app/@vue/compiler-vapor-dom2/package.json +56 -0
- package/lib/dom2/app/@vue/shared/LICENSE +21 -0
- package/lib/dom2/app/@vue/shared/README.md +3 -0
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +773 -0
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +773 -0
- package/lib/dom2/app/@vue/shared/dist/shared.d.ts +412 -0
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +688 -0
- package/lib/dom2/app/@vue/shared/index.js +7 -0
- package/lib/dom2/app/@vue/shared/package.json +47 -0
- package/lib/preprocess/lib/preprocess.js +9 -3
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +1 -1
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +1 -1
- package/package.json +8 -6
package/dist/constants.d.ts
CHANGED
|
@@ -39,3 +39,6 @@ export declare const COMMON_EXCLUDE: RegExp[];
|
|
|
39
39
|
export declare const KNOWN_ASSET_TYPES: string[];
|
|
40
40
|
export declare const DEFAULT_ASSETS_RE: RegExp;
|
|
41
41
|
export declare const TEXT_STYLE: string[];
|
|
42
|
+
export declare const JS_STYLE_PLACEHOLDER_MARKER = "__js_style_placeholder__";
|
|
43
|
+
export declare const JS_STYLE_PLACEHOLDER_STR: string;
|
|
44
|
+
export declare const JS_STYLE_PLACEHOLDER_RE: RegExp;
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.X_BASE_COMPONENTS_STYLE_PATH = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = 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_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.SPECIAL_CHARS = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
3
|
+
exports.JS_STYLE_PLACEHOLDER_RE = exports.JS_STYLE_PLACEHOLDER_STR = exports.JS_STYLE_PLACEHOLDER_MARKER = exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.X_BASE_COMPONENTS_STYLE_PATH = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = 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_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.SPECIAL_CHARS = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = 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', '.uts'];
|
|
6
6
|
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
@@ -88,3 +88,8 @@ exports.KNOWN_ASSET_TYPES = [
|
|
|
88
88
|
];
|
|
89
89
|
exports.DEFAULT_ASSETS_RE = new RegExp(`\\.(` + exports.KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
|
|
90
90
|
exports.TEXT_STYLE = ['black', 'white'];
|
|
91
|
+
exports.JS_STYLE_PLACEHOLDER_MARKER = '__js_style_placeholder__';
|
|
92
|
+
exports.JS_STYLE_PLACEHOLDER_STR = JSON.stringify({
|
|
93
|
+
[exports.JS_STYLE_PLACEHOLDER_MARKER]: 0,
|
|
94
|
+
});
|
|
95
|
+
exports.JS_STYLE_PLACEHOLDER_RE = /\{\s*"__js_style_placeholder__"\s*:\s*0\s*}/g;
|
package/dist/deps.js
CHANGED
|
@@ -5,7 +5,7 @@ const constants_1 = require("./constants");
|
|
|
5
5
|
const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
|
|
6
6
|
const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
|
|
7
7
|
const API_DEPS_CSS = (isX) => {
|
|
8
|
-
|
|
8
|
+
const deps_css = {
|
|
9
9
|
showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
|
|
10
10
|
showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
|
|
11
11
|
showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
|
|
@@ -29,6 +29,11 @@ const API_DEPS_CSS = (isX) => {
|
|
|
29
29
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
|
|
30
30
|
],
|
|
31
31
|
};
|
|
32
|
+
if (isX) {
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
deps_css.showLoading = [`${constants_1.X_BASE_COMPONENTS_STYLE_PATH}loading.css`];
|
|
35
|
+
}
|
|
36
|
+
return deps_css;
|
|
32
37
|
};
|
|
33
38
|
exports.API_DEPS_CSS = API_DEPS_CSS;
|
|
34
39
|
const COMPONENT_DEPS_CSS = (isX) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sharedData';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./sharedData"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniSharedDataPlugin = void 0;
|
|
4
|
+
const uts_1 = require("../uts");
|
|
5
|
+
const pages_1 = require("../json/pages");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const asset_1 = require("../vite/plugins/vitejs/plugins/asset");
|
|
8
|
+
function uniSharedDataPlugin() {
|
|
9
|
+
const { USDP } = (0, utils_1.requireUniHelpers)();
|
|
10
|
+
const compiler = require('@dcloudio/compiler-vapor-dom2');
|
|
11
|
+
return USDP({
|
|
12
|
+
compilerVaporDom2: compiler,
|
|
13
|
+
utsCompiler: (0, uts_1.resolveUTSCompiler)(),
|
|
14
|
+
isUniPageFile: pages_1.isUniPageFile,
|
|
15
|
+
getSharedDataResult: compiler.getSharedDataResult,
|
|
16
|
+
getAssetFilenameById: asset_1.getAssetFilenameById,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.uniSharedDataPlugin = uniSharedDataPlugin;
|
package/dist/easycom.js
CHANGED
|
@@ -76,13 +76,17 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
+
const supportCustomElements = isX && process.env.UNI_APP_X_DOM2 !== 'true';
|
|
79
80
|
// ext-api 模式下,不存在 easycom 特性
|
|
80
81
|
if (process.env.UNI_COMPILE_TARGET !== 'ext-api') {
|
|
81
82
|
clearEasycom();
|
|
82
83
|
(0, uts_1.clearUTSComponents)();
|
|
83
84
|
(0, uts_1.clearUTSCustomElements)();
|
|
84
85
|
initEasycom(easyComOptions);
|
|
85
|
-
|
|
86
|
+
// dom2 模式下,不需要注册 customElements 组件
|
|
87
|
+
if (supportCustomElements) {
|
|
88
|
+
initUTSEasycomCustomElements();
|
|
89
|
+
}
|
|
86
90
|
initUTSEasycom();
|
|
87
91
|
}
|
|
88
92
|
const componentExtNames = isX ? 'uvue|vue' : 'vue';
|
|
@@ -93,7 +97,9 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
93
97
|
'uni_modules/*/components/*/*.(' + componentExtNames + '|jsx|tsx)',
|
|
94
98
|
'utssdk/*/**/*.(' + componentExtNames + ')',
|
|
95
99
|
'uni_modules/*/utssdk/*/*.(' + componentExtNames + ')',
|
|
96
|
-
|
|
100
|
+
...(supportCustomElements
|
|
101
|
+
? ['uni_modules/*/customElements/*/*.uts']
|
|
102
|
+
: []),
|
|
97
103
|
], [], {
|
|
98
104
|
resolve: inputDir,
|
|
99
105
|
}),
|
|
@@ -104,7 +110,9 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
104
110
|
(0, uts_1.clearUTSComponents)();
|
|
105
111
|
(0, uts_1.clearUTSCustomElements)();
|
|
106
112
|
initEasycom(easyComOptions);
|
|
107
|
-
|
|
113
|
+
if (isX) {
|
|
114
|
+
initUTSEasycomCustomElements();
|
|
115
|
+
}
|
|
108
116
|
initUTSEasycom();
|
|
109
117
|
}
|
|
110
118
|
},
|
|
@@ -210,20 +218,34 @@ function initAutoScanEasycom(platform, dir, rootDir, extensions) {
|
|
|
210
218
|
if (!fs_1.default.existsSync(dir)) {
|
|
211
219
|
return easycoms;
|
|
212
220
|
}
|
|
221
|
+
const isDevX = process.env.UNI_HX_VERSION_DEV === 'true' &&
|
|
222
|
+
process.env.UNI_APP_X === 'true';
|
|
213
223
|
const isMp = platform.startsWith('mp-');
|
|
214
224
|
const is_uni_modules = path_1.default.basename(path_1.default.resolve(dir, '../..')) === 'uni_modules';
|
|
225
|
+
const has_uts_sdk_dir = fs_1.default.existsSync(path_1.default.resolve(dir, '../utssdk'));
|
|
215
226
|
const is_easycom_encrypt_uni_modules = // uni_modules模式不需要此逻辑
|
|
216
227
|
process.env.UNI_COMPILE_TARGET !== 'uni_modules' &&
|
|
217
228
|
is_uni_modules &&
|
|
218
229
|
// 前端加密插件,不能包含utssdk目录
|
|
219
230
|
fs_1.default.existsSync(path_1.default.resolve(dir, '../encrypt')) &&
|
|
220
|
-
!
|
|
231
|
+
!has_uts_sdk_dir;
|
|
221
232
|
const uni_modules_plugin_id = is_easycom_encrypt_uni_modules && path_1.default.basename(path_1.default.resolve(dir, '..'));
|
|
222
233
|
fs_1.default.readdirSync(dir).forEach((name) => {
|
|
223
234
|
const folder = path_1.default.resolve(dir, name);
|
|
224
235
|
if (!isDir(folder)) {
|
|
225
236
|
return;
|
|
226
237
|
}
|
|
238
|
+
if (isDevX) {
|
|
239
|
+
if (has_uts_sdk_dir &&
|
|
240
|
+
process.env.UNI_UTS_PLATFORM &&
|
|
241
|
+
(0, uni_shared_1.isBuiltInComponent)(name)) {
|
|
242
|
+
// dev下,如果是内置组件,且存在utssdk目录,则判断utssdk下是否存在当前平台,如果不存在,则跳过
|
|
243
|
+
const utsSdkPlatformDir = path_1.default.resolve(dir, '../utssdk', process.env.UNI_UTS_PLATFORM);
|
|
244
|
+
if (!fs_1.default.existsSync(utsSdkPlatformDir)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
227
249
|
const importDir = (0, utils_1.normalizePath)(folder);
|
|
228
250
|
const files = fs_1.default.readdirSync(folder);
|
|
229
251
|
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
|
|
@@ -291,10 +313,17 @@ function createImportDeclaration(local, source, imported) {
|
|
|
291
313
|
}
|
|
292
314
|
const RESOLVE_EASYCOM_IMPORT_CODE = `import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';`;
|
|
293
315
|
function genResolveEasycomCode(importDeclarations, code, name) {
|
|
316
|
+
if (process.env.UNI_APP_X_DOM2 === 'true') {
|
|
317
|
+
// dom2 模式下,为了性能,不再考虑优先级问题,如果开发者需要区别,可以手动导入为其他名称
|
|
318
|
+
return name;
|
|
319
|
+
}
|
|
294
320
|
if (!importDeclarations.includes(RESOLVE_EASYCOM_IMPORT_CODE)) {
|
|
295
321
|
importDeclarations.push(RESOLVE_EASYCOM_IMPORT_CODE);
|
|
296
322
|
}
|
|
297
|
-
return `resolveEasycom(${code
|
|
323
|
+
return `resolveEasycom(${code
|
|
324
|
+
.replace('_resolveComponent', '__resolveDynamicComponent')
|
|
325
|
+
// 移除 maybeSelfReference 逻辑,easycom 优先级高于自引用组件
|
|
326
|
+
.replace(', true)', ')')}, ${name})`;
|
|
298
327
|
}
|
|
299
328
|
exports.genResolveEasycomCode = genResolveEasycomCode;
|
|
300
329
|
exports.UNI_EASYCOM_EXCLUDE = [/@dcloudio\/uni-h5/];
|
package/dist/env/define.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare function initDefine(stringifyBoolean?: boolean): {
|
|
2
|
+
__X_STYLE_ISOLATION__: string | boolean;
|
|
3
|
+
__X_STYLE_ISOLATION_UP_ARROW__: string | boolean;
|
|
4
|
+
'process.env.UNI_APP_X_NEW_STYLE_ISOLATION': string | boolean;
|
|
2
5
|
__UNI_FEATURE_VIRTUAL_HOST__: boolean;
|
|
3
6
|
'process.env.NODE_ENV': string;
|
|
4
7
|
'process.env.UNI_DEBUG': string | boolean;
|
package/dist/env/define.js
CHANGED
|
@@ -10,6 +10,9 @@ function initDefine(stringifyBoolean = false) {
|
|
|
10
10
|
const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
|
|
11
11
|
const isDebug = !!manifestJson.debug;
|
|
12
12
|
const isX = process.env.UNI_APP_X === 'true';
|
|
13
|
+
const isNewStyleIsolation = process.env.UNI_APP_STYLE_ISOLATION_VERSION === '2';
|
|
14
|
+
// 目前仅微信小程序支持^穿透
|
|
15
|
+
const isNewStyleIsolationUpArrow = isNewStyleIsolation && process.env.UNI_PLATFORM === 'mp-weixin';
|
|
13
16
|
const isMP = process.env.UNI_PLATFORM && process.env.UNI_PLATFORM.startsWith('mp-');
|
|
14
17
|
process.env['UNI_APP_ID'] = manifestJson.appid;
|
|
15
18
|
let mpXDefine = isX && isMP
|
|
@@ -23,6 +26,9 @@ function initDefine(stringifyBoolean = false) {
|
|
|
23
26
|
mpXDefine.__UNI_FEATURE_VIRTUAL_HOST__ =
|
|
24
27
|
platformManifestJson.enableVirtualHost !== false;
|
|
25
28
|
}
|
|
29
|
+
const styleIsolation = stringifyBoolean
|
|
30
|
+
? JSON.stringify(isNewStyleIsolation)
|
|
31
|
+
: isNewStyleIsolation;
|
|
26
32
|
return {
|
|
27
33
|
...initCustomDefine(),
|
|
28
34
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
@@ -50,6 +56,12 @@ function initDefine(stringifyBoolean = false) {
|
|
|
50
56
|
'process.env.VUE_APP_DARK_MODE': JSON.stringify(platformManifestJson.darkmode || false),
|
|
51
57
|
__UNI_PRELOAD_SHADOW_IMAGE__: JSON.stringify(process.env.UNI_PLATFORM === 'mp-weixin' ? (0, utils_1.getShadowImagePath)('grey') : ''),
|
|
52
58
|
...mpXDefine,
|
|
59
|
+
__X_STYLE_ISOLATION__: styleIsolation,
|
|
60
|
+
__X_STYLE_ISOLATION_UP_ARROW__: stringifyBoolean
|
|
61
|
+
? JSON.stringify(isNewStyleIsolationUpArrow)
|
|
62
|
+
: isNewStyleIsolationUpArrow,
|
|
63
|
+
// 下边这个主要是为web服务,因为ssr目前只能识别process.env中的内容
|
|
64
|
+
'process.env.UNI_APP_X_NEW_STYLE_ISOLATION': styleIsolation,
|
|
53
65
|
};
|
|
54
66
|
}
|
|
55
67
|
exports.initDefine = initDefine;
|
package/dist/hbx/alias.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const module_alias_1 = __importDefault(require("module-alias"));
|
|
11
10
|
const utils_1 = require("./utils");
|
|
@@ -20,35 +19,34 @@ function initModuleAlias() {
|
|
|
20
19
|
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
|
21
20
|
const compilerSfcPath = path_1.default.resolve(libDir, '@vue/compiler-sfc');
|
|
22
21
|
const serverRendererPath = require.resolve('@vue/server-renderer');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
process.env.UNI_INPUT_DIR &&
|
|
22
|
+
if (process.env.UNI_APP_X_DOM2 === 'true') {
|
|
23
|
+
if (
|
|
26
24
|
// 该代码执行较早,不能使用UNI_UTS_PLATFORM
|
|
27
|
-
|
|
28
|
-
(process.env.
|
|
29
|
-
process.env.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
process.env.UNI_VUE_VAPOR = 'true';
|
|
33
|
-
if (fs_1.default.readFileSync(vaporConfig, 'utf-8').trim() === '*') {
|
|
34
|
-
process.env.UNI_VUE_VAPOR_ALL = 'true';
|
|
25
|
+
process.env.UNI_PLATFORM === 'app-harmony') {
|
|
26
|
+
if (process.env.UNI_OUTPUT_DIR) {
|
|
27
|
+
if (!process.env.UNI_APP_HARMONY_DOM2_CPP_DIR) {
|
|
28
|
+
process.env.UNI_APP_HARMONY_DOM2_CPP_DIR = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, 'cpp');
|
|
29
|
+
}
|
|
35
30
|
}
|
|
36
31
|
}
|
|
32
|
+
else {
|
|
33
|
+
// 目前仅支持 app-harmony 平台启用 dom2
|
|
34
|
+
delete process.env.UNI_APP_X_DOM2;
|
|
35
|
+
}
|
|
37
36
|
}
|
|
38
|
-
if (process.env.
|
|
37
|
+
if (process.env.UNI_APP_X_DOM2 === 'true') {
|
|
39
38
|
const vuePkgs = [
|
|
40
39
|
'@vue/compiler-core',
|
|
41
40
|
'@vue/compiler-dom',
|
|
42
41
|
'@vue/compiler-sfc',
|
|
43
|
-
'@vue/compiler-ssr',
|
|
44
42
|
'@vue/compiler-vapor',
|
|
45
|
-
'@vue/server-renderer',
|
|
46
43
|
'@vue/shared',
|
|
47
44
|
];
|
|
48
45
|
vuePkgs.forEach((pkg) => {
|
|
49
|
-
module_alias_1.default.addAlias(pkg, path_1.default.resolve(libDir, '
|
|
46
|
+
module_alias_1.default.addAlias(pkg, path_1.default.resolve(libDir, 'dom2', 'app', '@vue', pkg.split('/').pop()));
|
|
50
47
|
});
|
|
51
|
-
module_alias_1.default.addAlias('@vitejs/plugin-vue', path_1.default.resolve(libDir, '
|
|
48
|
+
module_alias_1.default.addAlias('@vitejs/plugin-vue', path_1.default.resolve(libDir, 'dom2', 'app', '@vitejs', 'plugin-vue'));
|
|
49
|
+
module_alias_1.default.addAlias('@dcloudio/compiler-vapor-dom2', path_1.default.resolve(libDir, 'dom2', 'app', '@vue', 'compiler-vapor-dom2'));
|
|
52
50
|
}
|
|
53
51
|
else {
|
|
54
52
|
module_alias_1.default.addAliases({
|
package/dist/hbx/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { formatAtFilename } from './log';
|
|
1
|
+
export { formatAtFilename, createErrorWithBlockFlag } from './log';
|
|
2
2
|
export * from './env';
|
|
3
3
|
export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
|
|
4
4
|
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
|
package/dist/hbx/index.js
CHANGED
|
@@ -17,13 +17,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.isEnableConsole = exports.uniHBuilderXConsolePlugin = exports.formatInstallHBuilderXPluginTips = exports.installHBuilderXPlugin = exports.initModuleAlias = exports.formatAtFilename = void 0;
|
|
20
|
+
exports.isEnableConsole = exports.uniHBuilderXConsolePlugin = exports.formatInstallHBuilderXPluginTips = exports.installHBuilderXPlugin = exports.initModuleAlias = exports.createErrorWithBlockFlag = exports.formatAtFilename = void 0;
|
|
21
21
|
const path_1 = __importDefault(require("path"));
|
|
22
22
|
const utils_1 = require("../utils");
|
|
23
23
|
const console_1 = require("../vite/plugins/console");
|
|
24
24
|
const workers_1 = require("../workers");
|
|
25
25
|
var log_1 = require("./log");
|
|
26
26
|
Object.defineProperty(exports, "formatAtFilename", { enumerable: true, get: function () { return log_1.formatAtFilename; } });
|
|
27
|
+
Object.defineProperty(exports, "createErrorWithBlockFlag", { enumerable: true, get: function () { return log_1.createErrorWithBlockFlag; } });
|
|
27
28
|
__exportStar(require("./env"), exports);
|
|
28
29
|
var alias_1 = require("./alias");
|
|
29
30
|
Object.defineProperty(exports, "initModuleAlias", { enumerable: true, get: function () { return alias_1.initModuleAlias; } });
|
|
@@ -54,7 +55,8 @@ function uniHBuilderXConsolePlugin(method = '__f__') {
|
|
|
54
55
|
}
|
|
55
56
|
exports.uniHBuilderXConsolePlugin = uniHBuilderXConsolePlugin;
|
|
56
57
|
function isEnableConsole() {
|
|
57
|
-
return !!(process.env.NODE_ENV === 'development'
|
|
58
|
+
return !!((process.env.NODE_ENV === 'development' ||
|
|
59
|
+
process.env.NODE_ENV === 'test') &&
|
|
58
60
|
process.env.UNI_SOCKET_HOSTS &&
|
|
59
61
|
process.env.UNI_SOCKET_PORT &&
|
|
60
62
|
process.env.UNI_SOCKET_ID);
|
package/dist/hbx/log.d.ts
CHANGED
|
@@ -6,3 +6,8 @@ export declare const removeInfoFormatter: Formatter;
|
|
|
6
6
|
export declare const removeWarnFormatter: Formatter;
|
|
7
7
|
export declare const removeDuplicatePluginFormatter: Formatter;
|
|
8
8
|
export declare const errorFormatter: Formatter<LogErrorOptions>;
|
|
9
|
+
interface ErrorWithBlockFlag extends Error {
|
|
10
|
+
__errorBlocked: true;
|
|
11
|
+
}
|
|
12
|
+
export declare function createErrorWithBlockFlag(msg: string): ErrorWithBlockFlag;
|
|
13
|
+
export {};
|
package/dist/hbx/log.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.errorFormatter = exports.removeDuplicatePluginFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
|
|
6
|
+
exports.createErrorWithBlockFlag = exports.errorFormatter = exports.removeDuplicatePluginFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
@@ -125,7 +125,15 @@ exports.errorFormatter = {
|
|
|
125
125
|
return buildErrorMessage(opts.error, [], false);
|
|
126
126
|
},
|
|
127
127
|
};
|
|
128
|
+
function createErrorWithBlockFlag(msg) {
|
|
129
|
+
const error = new Error(msg);
|
|
130
|
+
error.__errorBlocked = true;
|
|
131
|
+
return error;
|
|
132
|
+
}
|
|
133
|
+
exports.createErrorWithBlockFlag = createErrorWithBlockFlag;
|
|
134
|
+
let shouldAddErrorBlock = null;
|
|
128
135
|
const VITE_ROLLUP_FAILED_TO_RESOLVE_IMPORT_RE = /\[vite\]: Rollup failed to resolve import "([^"]+)" from "([^"]+)"/;
|
|
136
|
+
const CANNOT_FIND_MODULE_RE = /Cannot find module '([^']+)' from '([^']+)'/;
|
|
129
137
|
function buildErrorMessage(err, args = [], includeStack = true) {
|
|
130
138
|
if (err.customPrint) {
|
|
131
139
|
err.customPrint();
|
|
@@ -136,6 +144,16 @@ function buildErrorMessage(err, args = [], includeStack = true) {
|
|
|
136
144
|
err.message = `Could not resolve "${importPath}" from "${fromPath}"`;
|
|
137
145
|
err.id = fromPath;
|
|
138
146
|
}
|
|
147
|
+
if (CANNOT_FIND_MODULE_RE.test(err.message)) {
|
|
148
|
+
const [, modulePath, fromPath] = err.message.match(CANNOT_FIND_MODULE_RE) || [];
|
|
149
|
+
// 清理模块路径和来源路径,移除查询参数等
|
|
150
|
+
const cleanModulePath = modulePath.split('?')[0];
|
|
151
|
+
const cleanFromPath = fromPath.split('?')[0];
|
|
152
|
+
const relativeFromPath = toRelativePath(cleanFromPath);
|
|
153
|
+
// 构建更友好的错误消息
|
|
154
|
+
err.id = cleanFromPath;
|
|
155
|
+
err.message = `Cannot find module "${cleanModulePath}" from "${relativeFromPath}"`;
|
|
156
|
+
}
|
|
139
157
|
// 移除 from 后面的内容
|
|
140
158
|
// 主要是处理:Could not resolve "./static/logo1.png" from "../../../../../../Users/xxx/HBuilderProjects/test-x/pages/index/index.uvue?vue&type=script&lang.uts"
|
|
141
159
|
if (err.id && err.message.startsWith('Could not resolve ')) {
|
|
@@ -203,6 +221,19 @@ function buildErrorMessage(err, args = [], includeStack = true) {
|
|
|
203
221
|
if (includeStack && err.stack) {
|
|
204
222
|
args.push(pad(cleanStack(err.stack)));
|
|
205
223
|
}
|
|
224
|
+
if (shouldAddErrorBlock === null) {
|
|
225
|
+
shouldAddErrorBlock = // 目前仅限 x 的 app 平台
|
|
226
|
+
process.env.UNI_APP_X === 'true' &&
|
|
227
|
+
(process.env.UNI_UTS_PLATFORM === 'app-android' ||
|
|
228
|
+
process.env.UNI_UTS_PLATFORM === 'app-ios' ||
|
|
229
|
+
process.env.UNI_UTS_PLATFORM === 'app-harmony');
|
|
230
|
+
}
|
|
231
|
+
if (shouldAddErrorBlock) {
|
|
232
|
+
if (!err.__errorBlocked) {
|
|
233
|
+
args[0] = constants_1.SPECIAL_CHARS.ERROR_BLOCK + args[0];
|
|
234
|
+
args[args.length - 1] = args[args.length - 1] + constants_1.SPECIAL_CHARS.ERROR_BLOCK;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
206
237
|
return args.join('\n');
|
|
207
238
|
}
|
|
208
239
|
function cleanStack(stack) {
|
|
@@ -216,3 +247,15 @@ function pad(source, n = 2) {
|
|
|
216
247
|
const lines = source.split(splitRE);
|
|
217
248
|
return lines.map((l) => ` `.repeat(n) + l).join(`\n`);
|
|
218
249
|
}
|
|
250
|
+
function toRelativePath(filePath) {
|
|
251
|
+
if (!filePath || !process.env.UNI_INPUT_DIR) {
|
|
252
|
+
return filePath;
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
return path_1.default.relative(process.env.UNI_INPUT_DIR, filePath);
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
// 转换失败时返回原路径
|
|
259
|
+
return filePath;
|
|
260
|
+
}
|
|
261
|
+
}
|
package/dist/i18n.js
CHANGED
|
@@ -18,6 +18,10 @@ function initI18nOptions(platform, inputDir, warning = false, withMessages = tru
|
|
|
18
18
|
}
|
|
19
19
|
const manifestJson = (0, json_1.parseManifestJsonOnce)(inputDir);
|
|
20
20
|
let fallbackLocale = manifestJson.fallbackLocale || 'en';
|
|
21
|
+
const IS_APP_X = process.env.UNI_APP_X === 'true';
|
|
22
|
+
if (IS_APP_X) {
|
|
23
|
+
fallbackLocale = manifestJson.locale || fallbackLocale;
|
|
24
|
+
}
|
|
21
25
|
const locale = resolveI18nLocale(platform, Object.keys(locales), fallbackLocale);
|
|
22
26
|
if (warning) {
|
|
23
27
|
if (!fallbackLocale) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./ssr"), exports);
|
|
|
24
24
|
__exportStar(require("./vue"), exports);
|
|
25
25
|
__exportStar(require("./uts"), exports);
|
|
26
26
|
__exportStar(require("./logs"), exports);
|
|
27
|
+
__exportStar(require("./dom2"), exports);
|
|
27
28
|
__exportStar(require("./i18n"), exports);
|
|
28
29
|
__exportStar(require("./deps"), exports);
|
|
29
30
|
__exportStar(require("./json"), exports);
|
|
@@ -3,3 +3,4 @@ export * from './env';
|
|
|
3
3
|
export { APP_CONFUSION_FILENAME, isConfusionFile, hasConfusionFile, } from './confusion';
|
|
4
4
|
export { getNVueCompiler, getNVueStyleCompiler, getNVueFlexDirection, } from './nvue';
|
|
5
5
|
export { parseArguments } from './arguments';
|
|
6
|
+
export { initI18n } from './i18n';
|
|
@@ -14,7 +14,7 @@ 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.parseArguments = exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = exports.normalizeAppManifestJson = void 0;
|
|
17
|
+
exports.initI18n = exports.parseArguments = exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = exports.normalizeAppManifestJson = void 0;
|
|
18
18
|
const shared_1 = require("@vue/shared");
|
|
19
19
|
const merge_1 = require("./merge");
|
|
20
20
|
const defaultManifestJson_1 = require("./defaultManifestJson");
|
|
@@ -63,3 +63,5 @@ Object.defineProperty(exports, "getNVueStyleCompiler", { enumerable: true, get:
|
|
|
63
63
|
Object.defineProperty(exports, "getNVueFlexDirection", { enumerable: true, get: function () { return nvue_2.getNVueFlexDirection; } });
|
|
64
64
|
var arguments_2 = require("./arguments");
|
|
65
65
|
Object.defineProperty(exports, "parseArguments", { enumerable: true, get: function () { return arguments_2.parseArguments; } });
|
|
66
|
+
var i18n_2 = require("./i18n");
|
|
67
|
+
Object.defineProperty(exports, "initI18n", { enumerable: true, get: function () { return i18n_2.initI18n; } });
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -14,12 +14,7 @@ const utils_2 = require("../../utils");
|
|
|
14
14
|
const project_1 = require("./project");
|
|
15
15
|
const manifest_1 = require("../manifest");
|
|
16
16
|
const theme_1 = require("../theme");
|
|
17
|
-
const utils_3 = require("../utils");
|
|
18
17
|
function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
|
|
19
|
-
if (process.env.UNI_APP_X === 'true') {
|
|
20
|
-
// 目前仅对x开放
|
|
21
|
-
(0, utils_3.checkPagesJson)(jsonStr, process.env.UNI_INPUT_DIR);
|
|
22
|
-
}
|
|
23
18
|
return parsePagesJson(jsonStr, platform, options);
|
|
24
19
|
}
|
|
25
20
|
exports.parseMiniProgramPagesJson = parseMiniProgramPagesJson;
|
package/dist/json/pages.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const pagesCacheSet: Set<string>;
|
|
2
|
-
export declare function isUniPageFile(file: string, inputDir?: string):
|
|
2
|
+
export declare function isUniPageFile(file: string, inputDir?: string): any;
|
|
3
3
|
export declare function isUniPageSetupAndUts(file: string): boolean;
|
|
4
4
|
export declare function isUniPageSetupAndTs(file: string): boolean;
|
|
5
|
-
export declare function isUniPageSfcFile(file: string, inputDir?: string):
|
|
5
|
+
export declare function isUniPageSfcFile(file: string, inputDir?: string): any;
|
|
6
6
|
/**
|
|
7
7
|
* 小程序平台慎用,因为该解析不支持 subpackages
|
|
8
8
|
* @param inputDir
|
package/dist/json/pages.js
CHANGED
|
@@ -18,7 +18,10 @@ const manifest_1 = require("./manifest");
|
|
|
18
18
|
exports.pagesCacheSet = new Set();
|
|
19
19
|
function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
20
20
|
if (inputDir && path_1.default.isAbsolute(file)) {
|
|
21
|
-
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
|
21
|
+
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file.split('?')[0]));
|
|
22
|
+
}
|
|
23
|
+
if (process.env.UNI_COMPILE_EXT_API_PAGE_PATHS) {
|
|
24
|
+
return JSON.parse(process.env.UNI_COMPILE_EXT_API_PAGE_PATHS).includes((0, utils_1.removeExt)(file));
|
|
22
25
|
}
|
|
23
26
|
return exports.pagesCacheSet.has((0, utils_1.removeExt)(file));
|
|
24
27
|
}
|
|
@@ -7,5 +7,5 @@ export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.Pa
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
export declare function normalizeUniAppXAppConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
10
|
-
export declare function isUniXPageFile(source: string, importer: string, inputDir?: string):
|
|
10
|
+
export declare function isUniXPageFile(source: string, importer: string, inputDir?: string): any;
|
|
11
11
|
export declare function getUniXPagePaths(): any;
|
package/dist/json/utils.js
CHANGED
|
@@ -11,6 +11,7 @@ const jsonc_parser_1 = require("jsonc-parser");
|
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const utils_2 = require("../vite/plugins/vitejs/utils");
|
|
13
13
|
const messages_1 = require("../messages");
|
|
14
|
+
const logs_1 = require("../logs");
|
|
14
15
|
function checkPagesJson(jsonStr, inputDir) {
|
|
15
16
|
if (!inputDir) {
|
|
16
17
|
return false;
|
|
@@ -36,41 +37,50 @@ function checkPagesJson(jsonStr, inputDir) {
|
|
|
36
37
|
return false;
|
|
37
38
|
}
|
|
38
39
|
const pagePathNodes = walkNodes(findRootNode(root, ['pages']));
|
|
40
|
+
for (const node of pagePathNodes) {
|
|
41
|
+
const pagePath = node.value ?? '';
|
|
42
|
+
if (pagePath.startsWith('/')) {
|
|
43
|
+
throwCompilerError(jsonStr, node, messages_1.M['pages.json.page.slash'].replace('{pagePath}', pagePath));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
findRootNode(root, ['subPackages', 'subpackages']).forEach((node) => {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
47
|
+
const subPackageRootNode = findSubPackageRoot(node);
|
|
48
|
+
if (subPackageRootNode) {
|
|
49
|
+
const subPackageRoot = subPackageRootNode.value ?? '';
|
|
50
|
+
if (subPackageRoot.startsWith('/')) {
|
|
51
|
+
throwCompilerError(jsonStr, subPackageRootNode, messages_1.M['pages.json.page.slash'].replace('{pagePath}', subPackageRoot));
|
|
52
|
+
}
|
|
42
53
|
findRootNode(node, ['pages']).forEach((subNode) => {
|
|
43
54
|
walkNodes(subNode.children ?? []).forEach((node) => {
|
|
55
|
+
const pagePath = node.value ?? '';
|
|
56
|
+
if (pagePath.startsWith('/')) {
|
|
57
|
+
throwCompilerError(jsonStr, node, messages_1.M['pages.json.page.slash'].replace('{pagePath}', pagePath));
|
|
58
|
+
}
|
|
44
59
|
pagePathNodes.push({
|
|
45
60
|
...node,
|
|
46
|
-
value: (0, utils_1.normalizePath)(path_1.default.join(subPackageRoot,
|
|
61
|
+
value: (0, utils_1.normalizePath)(path_1.default.join(subPackageRoot, pagePath)),
|
|
47
62
|
});
|
|
48
63
|
});
|
|
49
64
|
});
|
|
50
65
|
}
|
|
51
66
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, node.offset);
|
|
59
|
-
throw {
|
|
60
|
-
name: 'CompilerError',
|
|
61
|
-
code: 'CompilerError',
|
|
62
|
-
message: messages_1.M['pages.json.page.notfound'].replace('{pagePath}', pagePath),
|
|
63
|
-
loc: {
|
|
64
|
-
start: { line, column },
|
|
65
|
-
},
|
|
66
|
-
offsetStart: node.offset,
|
|
67
|
-
offsetEnd: node.offset + node.length,
|
|
68
|
-
};
|
|
67
|
+
for (const node of pagePathNodes) {
|
|
68
|
+
const pagePath = node.value ?? '';
|
|
69
|
+
if (!pageExistsWithCaseSync(path_1.default.join(inputDir, pagePath))) {
|
|
70
|
+
throwCompilerError(jsonStr, node, messages_1.M['pages.json.page.notfound'].replace('{pagePath}', pagePath));
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
return true;
|
|
72
74
|
}
|
|
73
75
|
exports.checkPagesJson = checkPagesJson;
|
|
76
|
+
function throwCompilerError(jsonStr, node, message) {
|
|
77
|
+
const error = new Error(message);
|
|
78
|
+
error.loc = (0, utils_2.offsetToStartAndEnd)(jsonStr, node.offset, node.offset + node.length);
|
|
79
|
+
error.customPrint = () => {
|
|
80
|
+
(0, logs_1.onCompileLog)('error', error, jsonStr, 'pages.json');
|
|
81
|
+
};
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
74
84
|
function pageExistsWithCaseSync(pagePath) {
|
|
75
85
|
try {
|
|
76
86
|
const files = fs_1.default.readdirSync(path_1.default.dirname(pagePath));
|
|
@@ -88,9 +98,8 @@ function findSubPackageRoot(node) {
|
|
|
88
98
|
child.children &&
|
|
89
99
|
child.children.find((child) => child.type === 'string' && child.value === 'root'));
|
|
90
100
|
if (child && child.children?.length === 2) {
|
|
91
|
-
return child.children[1]
|
|
101
|
+
return child.children[1];
|
|
92
102
|
}
|
|
93
|
-
return '';
|
|
94
103
|
}
|
|
95
104
|
function findRootNode(node, property) {
|
|
96
105
|
const { type, children } = node;
|
package/dist/logs/console.js
CHANGED
|
@@ -22,7 +22,7 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
|
22
22
|
map: sourceMap ? s.generateMap({ hires: true }) : { mappings: '' },
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
return { code, map:
|
|
25
|
+
return { code, map: null };
|
|
26
26
|
}
|
|
27
27
|
exports.rewriteConsoleExpr = rewriteConsoleExpr;
|
|
28
28
|
function restoreConsoleExpr(code) {
|
package/dist/logs/index.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import type { SourceLocation } from '@vue/compiler-core';
|
|
1
2
|
export { formatErrMsg, formatInfoMsg, formatWarnMsg } from './format';
|
|
2
3
|
type LogType = 'error' | 'warn' | 'info' | 'log';
|
|
3
4
|
export declare function resetOutput(type: LogType): void;
|
|
4
5
|
export declare function output(type: LogType, msg: string): void;
|
|
6
|
+
export interface CompileLogError extends Error {
|
|
7
|
+
loc?: Omit<SourceLocation, 'source'>;
|
|
8
|
+
customPrint?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface CompileLogOptions {
|
|
11
|
+
plugin?: string;
|
|
12
|
+
line?: number;
|
|
13
|
+
column?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function onCompileLog(type: 'warn' | 'error', error: CompileLogError, code: string, relativeFileName: string, options?: CompileLogOptions): void;
|