@dcloudio/uni-cli-shared 3.0.0-5000720260410001 → 3.0.0-5010520260709001
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 +1 -3
- package/dist/constants.js +2 -6
- package/dist/deps.d.ts +1 -0
- package/dist/deps.js +22 -13
- package/dist/dom2/fontFamily.d.ts +4 -0
- package/dist/dom2/fontFamily.js +21 -0
- package/dist/dom2/index.d.ts +3 -0
- package/dist/dom2/index.js +3 -0
- package/dist/dom2/rootScrollView.d.ts +47 -0
- package/dist/dom2/rootScrollView.js +283 -0
- package/dist/dom2/sharedData.d.ts +4 -0
- package/dist/dom2/sharedData.js +40 -5
- package/dist/dom2/vue.d.ts +16 -0
- package/dist/dom2/vue.js +37 -0
- package/dist/easycom.d.ts +1 -0
- package/dist/easycom.js +23 -9
- package/dist/env/define.d.ts +0 -1
- package/dist/env/define.js +3 -11
- package/dist/hbx/alias.js +64 -10
- package/dist/hbx/log.js +9 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/json/app/manifest/plus.js +9 -1
- package/dist/json/app/pages/definePage.js +3 -1
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +2 -1
- package/dist/json/mp/index.d.ts +2 -0
- package/dist/json/mp/index.js +23 -1
- package/dist/json/mp/jsonFile.d.ts +3 -2
- package/dist/json/mp/jsonFile.js +83 -13
- package/dist/json/mp/pages.d.ts +1 -0
- package/dist/json/mp/pages.js +6 -2
- package/dist/json/mp/subpackage.d.ts +26 -0
- package/dist/json/mp/subpackage.js +236 -0
- package/dist/json/uni-x/index.d.ts +6 -0
- package/dist/json/uni-x/index.js +54 -1
- package/dist/json/uni-x/manifest.d.ts +1 -1
- package/dist/json/uni-x/manifest.js +2 -1
- package/dist/json/utils.js +24 -0
- package/dist/logs/console.js +4 -1
- package/dist/messages/en.d.ts +11 -2
- package/dist/messages/en.js +11 -2
- package/dist/messages/index.d.ts +22 -4
- package/dist/messages/zh_CN.d.ts +11 -2
- package/dist/messages/zh_CN.js +11 -2
- package/dist/mp/style.js +6 -2
- package/dist/mp/usingComponents.d.ts +7 -5
- package/dist/mp/usingComponents.js +63 -34
- package/dist/postcss/plugins/stylePluginExternal.d.ts +9 -10
- package/dist/postcss/plugins/stylePluginExternal.js +51 -45
- package/dist/resolve.d.ts +1 -0
- package/dist/resolve.js +9 -2
- package/dist/uni_modules.cloud.d.ts +7 -1
- package/dist/uni_modules.cloud.js +131 -14
- package/dist/uni_modules.js +3 -2
- package/dist/utils.js +5 -0
- package/dist/uts.d.ts +1 -0
- package/dist/uts.js +90 -6
- package/dist/vite/autoImport.js +7 -4
- package/dist/vite/cloud.js +13 -6
- package/dist/vite/extApi.js +4 -1
- package/dist/vite/plugins/cssScoped.js +11 -2
- package/dist/vite/plugins/easycom.js +3 -1
- package/dist/vite/plugins/inject.js +11 -3
- package/dist/vite/plugins/json.js +2 -69
- package/dist/vite/plugins/jsonJs.js +41 -3
- package/dist/vite/plugins/pre.js +2 -0
- package/dist/vite/plugins/sfc.js +4 -1
- package/dist/vite/plugins/stats.d.ts +5 -1
- package/dist/vite/plugins/stats.js +74 -3
- package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
- package/dist/vite/plugins/uts/uni_modules.js +30 -12
- package/dist/vite/plugins/vitejs/plugins/asset.js +14 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -2
- package/dist/vite/plugins/vitejs/plugins/css.js +45 -6
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +2 -1
- package/dist/vue/transforms/transformTeleport.d.ts +2 -0
- package/dist/vue/transforms/transformTeleport.js +68 -0
- package/dist/vue/transforms/x/transformDirection.js +33 -4
- package/dist/workers.d.ts +1 -0
- package/dist/workers.js +12 -5
- package/dist/x.d.ts +11 -0
- package/dist/x.js +43 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +0 -7
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +0 -7
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +58 -63
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +58 -63
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +7 -1
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +22 -47
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +12 -23
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +12 -22
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +23 -74
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +5 -5
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +3 -20
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +310 -363
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +5 -5
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +810 -579
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.d.ts +33 -11114
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +1638 -1250
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +1031 -599
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +470 -328
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +1154 -709
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +16 -25
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +16 -25
- package/lib/dom2/app/@vue/shared/dist/shared.d.ts +5 -0
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +11 -23
- package/package.json +6 -6
package/dist/easycom.js
CHANGED
|
@@ -10,6 +10,7 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
10
10
|
const shared_1 = require("@vue/shared");
|
|
11
11
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
12
12
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
13
|
+
const x_1 = require("./x");
|
|
13
14
|
const utils_1 = require("./utils");
|
|
14
15
|
const pages_1 = require("./json/pages");
|
|
15
16
|
const messages_1 = require("./messages");
|
|
@@ -64,6 +65,9 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
64
65
|
;
|
|
65
66
|
globalThis.uts2jsSourceCodeMap.initUts2jsEasycom(easycoms);
|
|
66
67
|
}
|
|
68
|
+
// UTS / customElements 组件是在 initEasycom 之后补充进去的,
|
|
69
|
+
// 这里补一次状态,避免项目里只有这类组件时被误判为没有 easycom。
|
|
70
|
+
hasEasycom = !!easycoms.length;
|
|
67
71
|
};
|
|
68
72
|
const initUTSEasycomCustomElements = () => {
|
|
69
73
|
(0, uts_1.initUTSCustomElements)(inputDir, platform).forEach((item) => {
|
|
@@ -109,8 +113,8 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
109
113
|
clearEasycom();
|
|
110
114
|
(0, uts_1.clearUTSComponents)();
|
|
111
115
|
(0, uts_1.clearUTSCustomElements)();
|
|
112
|
-
initEasycom(easyComOptions);
|
|
113
|
-
if (
|
|
116
|
+
initEasycom(res.easyComOptions);
|
|
117
|
+
if (supportCustomElements) {
|
|
114
118
|
initUTSEasycomCustomElements();
|
|
115
119
|
}
|
|
116
120
|
initUTSEasycom();
|
|
@@ -194,9 +198,21 @@ function matchEasycom(tag) {
|
|
|
194
198
|
easycomsInvalidCache.add(tag);
|
|
195
199
|
return false;
|
|
196
200
|
}
|
|
201
|
+
// dom2 不支持旧版 uni-app 兼容模式组件,这里在 easycom 真正命中时再报错,
|
|
202
|
+
// 避免扫描阶段就对未使用的插件组件产生误报。
|
|
203
|
+
if (process.env.UNI_APP_X_DOM2 === 'true' && matcher.dom2IncompatibleFile) {
|
|
204
|
+
throw new Error(messages_1.M['dom2.compatible.component']
|
|
205
|
+
.replace('{name}', `<${tag}>`)
|
|
206
|
+
.replace('{file}', matcher.dom2IncompatibleFile));
|
|
207
|
+
}
|
|
197
208
|
source = tag.replace(matcher.pattern, matcher.replacement);
|
|
198
209
|
easycomsCache.set(tag, source);
|
|
199
210
|
debugEasycom('matchEasycom', tag, source);
|
|
211
|
+
// 检查 H5 专用组件 ask163203
|
|
212
|
+
const H5_ONLY_COMPONENTS = ['custom-tab-bar'];
|
|
213
|
+
if (H5_ONLY_COMPONENTS.includes(tag) && process.env.UNI_PLATFORM !== 'h5') {
|
|
214
|
+
console.warn(`[uni-app] 组件 <${tag}> 是 H5 平台专用组件,在 ${process.env.UNI_PLATFORM} 平台使用可能导致错误。如果你要引入自定义 tabBar 可重命名为其他名称。`);
|
|
215
|
+
}
|
|
200
216
|
return source;
|
|
201
217
|
}
|
|
202
218
|
exports.matchEasycom = matchEasycom;
|
|
@@ -255,12 +271,7 @@ function initAutoScanEasycom(platform, dir, rootDir, extensions) {
|
|
|
255
271
|
easycoms[`^${name}$`] =
|
|
256
272
|
// mp平台,这里不处理,由uniEntryPlugin处理
|
|
257
273
|
is_easycom_encrypt_uni_modules && !isMp
|
|
258
|
-
? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${
|
|
259
|
-
// android 走 proxy
|
|
260
|
-
process.env.UNI_APP_X === 'true' &&
|
|
261
|
-
process.env.UNI_UTS_PLATFORM === 'app-android'
|
|
262
|
-
? 'uts-proxy'
|
|
263
|
-
: 'uni_helpers'}`))
|
|
274
|
+
? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${(0, x_1.isUniAppXAndroidNative)() ? 'uts-proxy' : 'uni_helpers'}`))
|
|
264
275
|
: `${importDir}/${name}${ext}`;
|
|
265
276
|
break;
|
|
266
277
|
}
|
|
@@ -313,7 +324,10 @@ function createImportDeclaration(local, source, imported) {
|
|
|
313
324
|
}
|
|
314
325
|
const RESOLVE_EASYCOM_IMPORT_CODE = `import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';`;
|
|
315
326
|
function genResolveEasycomCode(importDeclarations, code, name) {
|
|
316
|
-
if (process.env.UNI_APP_X_DOM2 === 'true'
|
|
327
|
+
if (process.env.UNI_APP_X_DOM2 === 'true' ||
|
|
328
|
+
// 内部 dev 版本,需要本地开发内置组件,比如web-view,此时需要直接返回本地easycom,不然会找到基座内置的
|
|
329
|
+
(process.env.UNI_HX_VERSION_DEV === 'true' &&
|
|
330
|
+
process.env.UNI_APP_X === 'true')) {
|
|
317
331
|
// dom2 模式下,为了性能,不再考虑优先级问题,如果开发者需要区别,可以手动导入为其他名称
|
|
318
332
|
return name;
|
|
319
333
|
}
|
package/dist/env/define.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare function initDefine(stringifyBoolean?: boolean): {
|
|
|
2
2
|
__X_STYLE_ISOLATION__: string | boolean;
|
|
3
3
|
__X_STYLE_ISOLATION_UP_ARROW__: string | boolean;
|
|
4
4
|
'process.env.UNI_APP_X_NEW_STYLE_ISOLATION': string | boolean;
|
|
5
|
-
__UNI_FEATURE_VIRTUAL_HOST__: boolean;
|
|
6
5
|
'process.env.NODE_ENV': string;
|
|
7
6
|
'process.env.UNI_DEBUG': string | boolean;
|
|
8
7
|
'process.env.UNI_APP_ID': string;
|
package/dist/env/define.js
CHANGED
|
@@ -15,17 +15,9 @@ function initDefine(stringifyBoolean = false) {
|
|
|
15
15
|
const isNewStyleIsolationUpArrow = isNewStyleIsolation && process.env.UNI_PLATFORM === 'mp-weixin';
|
|
16
16
|
const isMP = process.env.UNI_PLATFORM && process.env.UNI_PLATFORM.startsWith('mp-');
|
|
17
17
|
process.env['UNI_APP_ID'] = manifestJson.appid;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
: {
|
|
23
|
-
__UNI_FEATURE_VIRTUAL_HOST__: false,
|
|
24
|
-
};
|
|
25
|
-
if (isX && isMP) {
|
|
26
|
-
mpXDefine.__UNI_FEATURE_VIRTUAL_HOST__ =
|
|
27
|
-
platformManifestJson.enableVirtualHost !== false;
|
|
28
|
-
}
|
|
18
|
+
const mpXDefine = {
|
|
19
|
+
__UNI_FEATURE_VIRTUAL_HOST__: isX && isMP && platformManifestJson.enableVirtualHost !== false,
|
|
20
|
+
};
|
|
29
21
|
const styleIsolation = stringifyBoolean
|
|
30
22
|
? JSON.stringify(isNewStyleIsolation)
|
|
31
23
|
: isNewStyleIsolation;
|
package/dist/hbx/alias.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// 注意:该文件尽可能少依赖其他文件,否则可能会导致还没有alias的时候,就加载了目标模块
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
|
|
7
|
+
// 注意:该文件尽可能少依赖其他文件,否则可能会导致还没有alias的时候,就加载了目标模块
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const module_alias_1 = __importDefault(require("module-alias"));
|
|
10
10
|
const utils_1 = require("./utils");
|
|
@@ -15,23 +15,77 @@ const hbxPlugins = {
|
|
|
15
15
|
stylus: 'compile-stylus/node_modules/stylus',
|
|
16
16
|
pug: 'compile-pug-cli/node_modules/pug',
|
|
17
17
|
};
|
|
18
|
+
function isWebOrMpPlatform(platform) {
|
|
19
|
+
return platform === 'h5' || platform === 'web' || platform?.startsWith('mp-');
|
|
20
|
+
}
|
|
18
21
|
function initModuleAlias() {
|
|
19
22
|
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
|
20
23
|
const compilerSfcPath = path_1.default.resolve(libDir, '@vue/compiler-sfc');
|
|
21
24
|
const serverRendererPath = require.resolve('@vue/server-renderer');
|
|
25
|
+
if (process.env.UNI_OUTPUT_DIR) {
|
|
26
|
+
const baseOutDir = path_1.default.basename(process.env.UNI_OUTPUT_DIR);
|
|
27
|
+
process.env.UNI_APP_X_CACHE_DIR =
|
|
28
|
+
process.env.UNI_APP_X_CACHE_DIR ||
|
|
29
|
+
path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '../cache/.' + baseOutDir);
|
|
30
|
+
}
|
|
31
|
+
// 对路径进行兼容
|
|
32
|
+
if (!process.env.UNI_APP_X_DOM2_CPP_DIR &&
|
|
33
|
+
process.env.UNI_APP_HARMONY_DOM2_CPP_DIR) {
|
|
34
|
+
process.env.UNI_APP_X_DOM2_CPP_DIR =
|
|
35
|
+
process.env.UNI_APP_HARMONY_DOM2_CPP_DIR;
|
|
36
|
+
}
|
|
37
|
+
// alias 初始化可能早于 CLI 环境初始化,这里仅依据外部预置的平台环境变量判断。
|
|
38
|
+
// 如果是 web 和小程序,目前强制非蒸汽。
|
|
39
|
+
const utsPlatform = process.env.UNI_UTS_PLATFORM;
|
|
40
|
+
const uniPlatform = process.env.UNI_PLATFORM;
|
|
41
|
+
if (isWebOrMpPlatform(utsPlatform) || isWebOrMpPlatform(uniPlatform)) {
|
|
42
|
+
delete process.env.UNI_APP_X_DOM2;
|
|
43
|
+
delete process.env.UNI_APP_X_DOM2_DYNAMIC;
|
|
44
|
+
}
|
|
22
45
|
if (process.env.UNI_APP_X_DOM2 === 'true') {
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
if (process.env.UNI_OUTPUT_DIR &&
|
|
47
|
+
(process.env.UNI_PLATFORM === 'app' ||
|
|
48
|
+
process.env.UNI_PLATFORM === 'app-plus' ||
|
|
49
|
+
process.env.UNI_PLATFORM === 'app-harmony')) {
|
|
50
|
+
if (!process.env.UNI_APP_X_DOM2_CPP_DIR) {
|
|
51
|
+
let baseDir = '';
|
|
52
|
+
const isAndroid = process.env.UNI_APP_PLATFORM === 'android';
|
|
53
|
+
const isIOS = process.env.UNI_APP_PLATFORM === 'ios';
|
|
54
|
+
if (process.env.NODE_ENV !== 'development' && (isAndroid || isIOS)) {
|
|
55
|
+
baseDir = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '.uniappx', isAndroid ? 'android' : 'ios');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
baseDir =
|
|
59
|
+
process.env.UNI_PLATFORM === 'app-harmony'
|
|
60
|
+
? process.env.UNI_OUTPUT_DIR
|
|
61
|
+
: process.env.UNI_APP_X_CACHE_DIR || process.env.UNI_OUTPUT_DIR;
|
|
62
|
+
}
|
|
63
|
+
process.env.UNI_APP_X_DOM2_CPP_DIR = path_1.default.resolve(baseDir, 'cpp');
|
|
64
|
+
process.env.UNI_APP_X_DOM2_SO_DIR = path_1.default.resolve(baseDir, 'so');
|
|
65
|
+
}
|
|
66
|
+
if (!process.env.UNI_APP_X_DOM2_KT_DIR) {
|
|
67
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
68
|
+
process.env.UNI_APP_X_DOM2_KT_DIR = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '.uniappx/android', 'src');
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
process.env.UNI_APP_X_DOM2_KT_DIR = path_1.default.resolve(process.env.UNI_APP_X_CACHE_DIR ||
|
|
72
|
+
path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '../.cache'), 'src');
|
|
29
73
|
}
|
|
30
74
|
}
|
|
31
75
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
76
|
+
if (process.env.UNI_APP_PLATFORM ||
|
|
77
|
+
process.env.UNI_PLATFORM === 'app-harmony') {
|
|
78
|
+
if (!process.env.UNI_APP_X_VAPOR_RENDER_TARGET) {
|
|
79
|
+
// 默认 app 平台使用 bytecode 目标
|
|
80
|
+
process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
|
|
81
|
+
}
|
|
82
|
+
if (process.env.UNI_APP_X_VAPOR_RENDER_TARGET?.includes('bytecode')) {
|
|
83
|
+
process.env.UNI_APP_X_DOM2_DYNAMIC = 'true';
|
|
84
|
+
}
|
|
85
|
+
// 如果是 ext-api 目标,强制使用 nativecode 目标
|
|
86
|
+
if (process.env.UNI_COMPILE_TARGET === 'ext-api') {
|
|
87
|
+
delete process.env.UNI_APP_X_DOM2_DYNAMIC;
|
|
88
|
+
}
|
|
35
89
|
}
|
|
36
90
|
}
|
|
37
91
|
if (process.env.UNI_APP_X_DOM2 === 'true') {
|
package/dist/hbx/log.js
CHANGED
|
@@ -10,9 +10,10 @@ const picocolors_1 = __importDefault(require("picocolors"));
|
|
|
10
10
|
const compiler_core_1 = require("@vue/compiler-core");
|
|
11
11
|
const shared_1 = require("@vue/shared");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
+
const utils_2 = require("./utils");
|
|
13
14
|
const constants_1 = require("../constants");
|
|
14
15
|
const ast_1 = require("../vite/utils/ast");
|
|
15
|
-
const
|
|
16
|
+
const utils_3 = require("../vite/plugins/vitejs/utils");
|
|
16
17
|
const SIGNAL_H5_LOCAL = ' ➜ Local:';
|
|
17
18
|
const SIGNAL_H5_NETWORK = ' ➜ Network:';
|
|
18
19
|
const networkLogs = [];
|
|
@@ -29,6 +30,12 @@ function overridedConsole(name, oldFn, char) {
|
|
|
29
30
|
console[name] = function (...args) {
|
|
30
31
|
oldFn.apply(this, args.map((arg) => {
|
|
31
32
|
let item;
|
|
33
|
+
if ((0, utils_2.isInHBuilderX)() && typeof arg === 'string' && arg.includes('\n')) {
|
|
34
|
+
arg = arg
|
|
35
|
+
.split('\n')
|
|
36
|
+
.map((line) => `${char}${line}${char}`)
|
|
37
|
+
.join('\n');
|
|
38
|
+
}
|
|
32
39
|
if (typeof arg !== 'object') {
|
|
33
40
|
item = `${char}${arg}${char}`;
|
|
34
41
|
}
|
|
@@ -200,7 +207,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
|
|
|
200
207
|
const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
|
|
201
208
|
if (scriptNode) {
|
|
202
209
|
const scriptLoc = scriptNode.loc;
|
|
203
|
-
args.push(picocolors_1.default.yellow(pad((0,
|
|
210
|
+
args.push(picocolors_1.default.yellow(pad((0, utils_3.generateCodeFrame)(scriptLoc.source, err.loc))));
|
|
204
211
|
// correct error location
|
|
205
212
|
err.loc.line = scriptLoc.start.line + err.loc.line - 1;
|
|
206
213
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './hbx';
|
|
|
6
6
|
export * from './ssr';
|
|
7
7
|
export * from './vue';
|
|
8
8
|
export * from './uts';
|
|
9
|
+
export * from './x';
|
|
9
10
|
export * from './logs';
|
|
10
11
|
export * from './dom2';
|
|
11
12
|
export * from './i18n';
|
|
@@ -25,7 +26,7 @@ export * from './platform';
|
|
|
25
26
|
export * from './utsUtils';
|
|
26
27
|
export * from './workers';
|
|
27
28
|
export { parseUniExtApi, parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, formatExtApiProviderName, } from './uni_modules';
|
|
28
|
-
export { getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
|
|
29
|
+
export { copyEncryptUniModulesDom2Bytes, getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
|
|
29
30
|
import type { EncryptPackageJson } from './uni_modules.cloud';
|
|
30
31
|
export type EncryptArtifacts = EncryptPackageJson['uni_modules']['artifacts'];
|
|
31
32
|
export { M } from './messages';
|
package/dist/index.js
CHANGED
|
@@ -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.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
|
|
17
|
+
exports.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.copyEncryptUniModulesDom2Bytes = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
|
|
18
18
|
__exportStar(require("./fs"), exports);
|
|
19
19
|
__exportStar(require("./mp"), exports);
|
|
20
20
|
__exportStar(require("./url"), exports);
|
|
@@ -23,6 +23,7 @@ __exportStar(require("./hbx"), exports);
|
|
|
23
23
|
__exportStar(require("./ssr"), exports);
|
|
24
24
|
__exportStar(require("./vue"), exports);
|
|
25
25
|
__exportStar(require("./uts"), exports);
|
|
26
|
+
__exportStar(require("./x"), exports);
|
|
26
27
|
__exportStar(require("./logs"), exports);
|
|
27
28
|
__exportStar(require("./dom2"), exports);
|
|
28
29
|
__exportStar(require("./i18n"), exports);
|
|
@@ -48,6 +49,7 @@ Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function
|
|
|
48
49
|
Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
|
|
49
50
|
Object.defineProperty(exports, "formatExtApiProviderName", { enumerable: true, get: function () { return uni_modules_1.formatExtApiProviderName; } });
|
|
50
51
|
var uni_modules_cloud_1 = require("./uni_modules.cloud");
|
|
52
|
+
Object.defineProperty(exports, "copyEncryptUniModulesDom2Bytes", { enumerable: true, get: function () { return uni_modules_cloud_1.copyEncryptUniModulesDom2Bytes; } });
|
|
51
53
|
Object.defineProperty(exports, "getUniModulesEncryptType", { enumerable: true, get: function () { return uni_modules_cloud_1.getUniModulesEncryptType; } });
|
|
52
54
|
Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_cloud_1.parseUniModulesArtifacts; } });
|
|
53
55
|
Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_cloud_1.resolveEncryptUniModule; } });
|
|
@@ -117,7 +117,15 @@ function initUniStatistics(manifestJson) {
|
|
|
117
117
|
if (!uniStatistics) {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
/**
|
|
121
|
+
* 判断是否为私有版统计:
|
|
122
|
+
* - 新配置:type === 'private'
|
|
123
|
+
* - 旧配置兼容:version === 2
|
|
124
|
+
*/
|
|
125
|
+
const isPrivateStat = uniStatistics.type === 'private' ||
|
|
126
|
+
uniStatistics.version === 2 ||
|
|
127
|
+
uniStatistics.version === '2';
|
|
128
|
+
if (isPrivateStat) {
|
|
121
129
|
if (uniStatistics.uniCloud && uniStatistics.uniCloud.spaceId) {
|
|
122
130
|
return;
|
|
123
131
|
}
|
|
@@ -46,7 +46,9 @@ function defineNVuePageCode(pagesJson) {
|
|
|
46
46
|
}
|
|
47
47
|
const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
|
|
48
48
|
if (pagePathWithExtname) {
|
|
49
|
-
importNVuePagesCode.push(
|
|
49
|
+
importNVuePagesCode.push(
|
|
50
|
+
// 使用 res.default 确保 rollup 不会摇树
|
|
51
|
+
`import('./${pagePathWithExtname}').then((res)=>{res.default})`);
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
54
|
return importNVuePagesCode.join('\n');
|
package/dist/json/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export * from './json';
|
|
|
4
4
|
export * from './pages';
|
|
5
5
|
export * from './manifest';
|
|
6
6
|
export * from './theme';
|
|
7
|
-
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, parseUniXFlexDirection, parseUniXSplashScreen, isUniXPageFile, getUniXPagePaths, parseUniXAppAndroidPackage, } from './uni-x';
|
|
7
|
+
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, parseUniXPageOptions, parseUniXFlexDirection, parseUniXSplashScreen, isUniXPageFile, getUniXPagePaths, parseUniXAppAndroidPackage, } from './uni-x';
|
|
8
8
|
export { checkPagesJson } from './utils';
|
package/dist/json/index.js
CHANGED
|
@@ -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.checkPagesJson = exports.parseUniXAppAndroidPackage = exports.getUniXPagePaths = exports.isUniXPageFile = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
17
|
+
exports.checkPagesJson = exports.parseUniXAppAndroidPackage = exports.getUniXPagePaths = exports.isUniXPageFile = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.parseUniXPageOptions = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
18
18
|
__exportStar(require("./mp"), exports);
|
|
19
19
|
__exportStar(require("./app"), exports);
|
|
20
20
|
__exportStar(require("./json"), exports);
|
|
@@ -24,6 +24,7 @@ __exportStar(require("./theme"), exports);
|
|
|
24
24
|
var uni_x_1 = require("./uni-x");
|
|
25
25
|
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppPagesJson; } });
|
|
26
26
|
Object.defineProperty(exports, "normalizeUniAppXAppConfig", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppConfig; } });
|
|
27
|
+
Object.defineProperty(exports, "parseUniXPageOptions", { enumerable: true, get: function () { return uni_x_1.parseUniXPageOptions; } });
|
|
27
28
|
Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return uni_x_1.parseUniXFlexDirection; } });
|
|
28
29
|
Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return uni_x_1.parseUniXSplashScreen; } });
|
|
29
30
|
Object.defineProperty(exports, "isUniXPageFile", { enumerable: true, get: function () { return uni_x_1.isUniXPageFile; } });
|
package/dist/json/mp/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export * from './jsonFile';
|
|
|
2
2
|
export { AppJson, ComponentJson, MiniProgramComponentsType } from './types';
|
|
3
3
|
export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
|
|
4
4
|
export { parseMiniProgramProjectJson } from './project';
|
|
5
|
+
export { MP_INDEPENDENT_ROOT_QUERY, MP_INDEPENDENT_MAIN_PREFIX, MP_INDEPENDENT_VIRTUAL_ROOT_QUERY, formatIndependentVirtualId, getIndependentRootByFilename, getIndependentRoots, getIndependentSubPackages, hasIndependentRoot, isAppPagesJson, isInIndependentRoot, normalizeIndependentRoot, parseIndependentMainRoot, parseIndependentRoot, parseIndependentSubPackages, parseIndependentVirtualRoot, resolveIndependentRoot, setIndependentSubPackages, stringifyIndependentRoots, withIndependentRoot, withIndependentRootIfNeeded, withoutIndependentRoot, } from './subpackage';
|
|
6
|
+
export type { IndependentSubPackage } from './subpackage';
|
package/dist/json/mp/index.js
CHANGED
|
@@ -14,10 +14,32 @@ 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.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = exports.mergeMiniProgramAppJson = void 0;
|
|
17
|
+
exports.withoutIndependentRoot = exports.withIndependentRootIfNeeded = exports.withIndependentRoot = exports.stringifyIndependentRoots = exports.setIndependentSubPackages = exports.resolveIndependentRoot = exports.parseIndependentVirtualRoot = exports.parseIndependentSubPackages = exports.parseIndependentRoot = exports.parseIndependentMainRoot = exports.normalizeIndependentRoot = exports.isInIndependentRoot = exports.isAppPagesJson = exports.hasIndependentRoot = exports.getIndependentSubPackages = exports.getIndependentRoots = exports.getIndependentRootByFilename = exports.formatIndependentVirtualId = exports.MP_INDEPENDENT_VIRTUAL_ROOT_QUERY = exports.MP_INDEPENDENT_MAIN_PREFIX = exports.MP_INDEPENDENT_ROOT_QUERY = exports.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = exports.mergeMiniProgramAppJson = void 0;
|
|
18
18
|
__exportStar(require("./jsonFile"), exports);
|
|
19
19
|
var pages_1 = require("./pages");
|
|
20
20
|
Object.defineProperty(exports, "mergeMiniProgramAppJson", { enumerable: true, get: function () { return pages_1.mergeMiniProgramAppJson; } });
|
|
21
21
|
Object.defineProperty(exports, "parseMiniProgramPagesJson", { enumerable: true, get: function () { return pages_1.parseMiniProgramPagesJson; } });
|
|
22
22
|
var project_1 = require("./project");
|
|
23
23
|
Object.defineProperty(exports, "parseMiniProgramProjectJson", { enumerable: true, get: function () { return project_1.parseMiniProgramProjectJson; } });
|
|
24
|
+
var subpackage_1 = require("./subpackage");
|
|
25
|
+
Object.defineProperty(exports, "MP_INDEPENDENT_ROOT_QUERY", { enumerable: true, get: function () { return subpackage_1.MP_INDEPENDENT_ROOT_QUERY; } });
|
|
26
|
+
Object.defineProperty(exports, "MP_INDEPENDENT_MAIN_PREFIX", { enumerable: true, get: function () { return subpackage_1.MP_INDEPENDENT_MAIN_PREFIX; } });
|
|
27
|
+
Object.defineProperty(exports, "MP_INDEPENDENT_VIRTUAL_ROOT_QUERY", { enumerable: true, get: function () { return subpackage_1.MP_INDEPENDENT_VIRTUAL_ROOT_QUERY; } });
|
|
28
|
+
Object.defineProperty(exports, "formatIndependentVirtualId", { enumerable: true, get: function () { return subpackage_1.formatIndependentVirtualId; } });
|
|
29
|
+
Object.defineProperty(exports, "getIndependentRootByFilename", { enumerable: true, get: function () { return subpackage_1.getIndependentRootByFilename; } });
|
|
30
|
+
Object.defineProperty(exports, "getIndependentRoots", { enumerable: true, get: function () { return subpackage_1.getIndependentRoots; } });
|
|
31
|
+
Object.defineProperty(exports, "getIndependentSubPackages", { enumerable: true, get: function () { return subpackage_1.getIndependentSubPackages; } });
|
|
32
|
+
Object.defineProperty(exports, "hasIndependentRoot", { enumerable: true, get: function () { return subpackage_1.hasIndependentRoot; } });
|
|
33
|
+
Object.defineProperty(exports, "isAppPagesJson", { enumerable: true, get: function () { return subpackage_1.isAppPagesJson; } });
|
|
34
|
+
Object.defineProperty(exports, "isInIndependentRoot", { enumerable: true, get: function () { return subpackage_1.isInIndependentRoot; } });
|
|
35
|
+
Object.defineProperty(exports, "normalizeIndependentRoot", { enumerable: true, get: function () { return subpackage_1.normalizeIndependentRoot; } });
|
|
36
|
+
Object.defineProperty(exports, "parseIndependentMainRoot", { enumerable: true, get: function () { return subpackage_1.parseIndependentMainRoot; } });
|
|
37
|
+
Object.defineProperty(exports, "parseIndependentRoot", { enumerable: true, get: function () { return subpackage_1.parseIndependentRoot; } });
|
|
38
|
+
Object.defineProperty(exports, "parseIndependentSubPackages", { enumerable: true, get: function () { return subpackage_1.parseIndependentSubPackages; } });
|
|
39
|
+
Object.defineProperty(exports, "parseIndependentVirtualRoot", { enumerable: true, get: function () { return subpackage_1.parseIndependentVirtualRoot; } });
|
|
40
|
+
Object.defineProperty(exports, "resolveIndependentRoot", { enumerable: true, get: function () { return subpackage_1.resolveIndependentRoot; } });
|
|
41
|
+
Object.defineProperty(exports, "setIndependentSubPackages", { enumerable: true, get: function () { return subpackage_1.setIndependentSubPackages; } });
|
|
42
|
+
Object.defineProperty(exports, "stringifyIndependentRoots", { enumerable: true, get: function () { return subpackage_1.stringifyIndependentRoots; } });
|
|
43
|
+
Object.defineProperty(exports, "withIndependentRoot", { enumerable: true, get: function () { return subpackage_1.withIndependentRoot; } });
|
|
44
|
+
Object.defineProperty(exports, "withIndependentRootIfNeeded", { enumerable: true, get: function () { return subpackage_1.withIndependentRootIfNeeded; } });
|
|
45
|
+
Object.defineProperty(exports, "withoutIndependentRoot", { enumerable: true, get: function () { return subpackage_1.withoutIndependentRoot; } });
|
|
@@ -6,11 +6,12 @@ export declare function getComponentJsonFilenames(): string[];
|
|
|
6
6
|
export declare function findJsonFile(filename: string): Record<string, any> | ComponentJson | PageWindowOptions | 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(supportGlobalUsingComponents?: boolean): Map<string, string>;
|
|
9
|
+
export declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean | ((filename: string) => 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;
|
|
13
13
|
export declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void;
|
|
14
|
+
export declare function resetMiniProgramJsonFiles(): void;
|
|
14
15
|
export declare function isMiniProgramUsingComponent(name: string, options: {
|
|
15
16
|
filename: string;
|
|
16
17
|
inputDir: string;
|
|
@@ -39,5 +40,5 @@ export declare function findMiniProgramUsingComponents({ filename, inputDir, com
|
|
|
39
40
|
* - "demo": "wxcomponents/demo"
|
|
40
41
|
* - [TODO 待确认] "demo": "../wxcomponents/demo"
|
|
41
42
|
*/
|
|
42
|
-
export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string): Record<any, any>;
|
|
43
|
+
export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string, ownerFilename?: string): Record<any, any>;
|
|
43
44
|
export {};
|
package/dist/json/mp/jsonFile.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.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
|
6
|
+
exports.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.resetMiniProgramJsonFiles = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -11,7 +11,9 @@ const utils_1 = require("../../utils");
|
|
|
11
11
|
const resolve_1 = require("../../resolve");
|
|
12
12
|
const utils_2 = require("../../vue/utils");
|
|
13
13
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
14
|
+
const subpackage_1 = require("./subpackage");
|
|
14
15
|
let appJsonCache = {};
|
|
16
|
+
let independentRootsCache = [];
|
|
15
17
|
const jsonFilesCache = new Map();
|
|
16
18
|
const jsonPagesCache = new Map();
|
|
17
19
|
const jsonComponentsCache = new Map();
|
|
@@ -64,8 +66,12 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
64
66
|
// app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
|
|
65
67
|
if (filename !== 'app') {
|
|
66
68
|
let usingComponents = newJson.usingComponents;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const independentRoot = findIndependentRoot(filename, independentRootsCache);
|
|
70
|
+
const supportGlobalUsingComponentsForFile = typeof supportGlobalUsingComponents === 'function'
|
|
71
|
+
? supportGlobalUsingComponents(filename)
|
|
72
|
+
: supportGlobalUsingComponents;
|
|
73
|
+
// 如果小程序不支持 global 的 usingComponents,或独立分包冷启动不能依赖 app.json
|
|
74
|
+
if (!supportGlobalUsingComponentsForFile || independentRoot) {
|
|
69
75
|
// 从取全局的 usingComponents 并补充到子组件 usingComponents 中
|
|
70
76
|
const globalUsingComponents = appJsonCache?.usingComponents || {};
|
|
71
77
|
const globalComponents = findUsingComponents('app') || {};
|
|
@@ -75,6 +81,9 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
75
81
|
...newJson.usingComponents,
|
|
76
82
|
};
|
|
77
83
|
}
|
|
84
|
+
if (independentRoot) {
|
|
85
|
+
validateIndependentUsingComponents(filename, independentRoot, usingComponents);
|
|
86
|
+
}
|
|
78
87
|
Object.keys(usingComponents).forEach((name) => {
|
|
79
88
|
const componentFilename = usingComponents[name];
|
|
80
89
|
if (componentFilename.startsWith('/')) {
|
|
@@ -102,8 +111,40 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
102
111
|
return changedJsonFiles;
|
|
103
112
|
}
|
|
104
113
|
exports.findChangedJsonFiles = findChangedJsonFiles;
|
|
114
|
+
function findIndependentRoot(filename, independentRoots) {
|
|
115
|
+
return independentRoots.find((root) => {
|
|
116
|
+
return filename === root || filename.startsWith(root + '/');
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function validateIndependentUsingComponents(filename, root, usingComponents) {
|
|
120
|
+
Object.keys(usingComponents).forEach((name) => {
|
|
121
|
+
const componentFilename = usingComponents[name];
|
|
122
|
+
if (isLocalUsingComponent(componentFilename) &&
|
|
123
|
+
!isUsingComponentInRoot(componentFilename, root, filename)) {
|
|
124
|
+
throw new Error(`独立分包 "${root}" 不能在 "${filename}" 中使用 root 外组件 "${name}"(${componentFilename}),请移动到 "${root}" 内或改为页面局部组件。`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function isUsingComponentInRoot(componentFilename, root, ownerFilename) {
|
|
129
|
+
const filename = normalizeUsingComponentFilename(componentFilename, ownerFilename);
|
|
130
|
+
return filename === root || filename.startsWith(root + '/');
|
|
131
|
+
}
|
|
132
|
+
function normalizeUsingComponentFilename(componentFilename, ownerFilename) {
|
|
133
|
+
if (componentFilename.startsWith('/')) {
|
|
134
|
+
return (0, utils_1.normalizePath)(componentFilename).replace(/^\/+/, '');
|
|
135
|
+
}
|
|
136
|
+
if (componentFilename.startsWith('.')) {
|
|
137
|
+
return (0, utils_1.normalizePath)(path_1.default.join(path_1.default.dirname(ownerFilename), componentFilename));
|
|
138
|
+
}
|
|
139
|
+
return (0, utils_1.normalizePath)(componentFilename);
|
|
140
|
+
}
|
|
141
|
+
function isLocalUsingComponent(componentFilename) {
|
|
142
|
+
return (!/^(?:plugin|dynamicLib|ext):\/\//.test(componentFilename) &&
|
|
143
|
+
!componentFilename.startsWith('weui-miniprogram'));
|
|
144
|
+
}
|
|
105
145
|
function addMiniProgramAppJson(appJson) {
|
|
106
146
|
appJsonCache = appJson;
|
|
147
|
+
independentRootsCache = (0, subpackage_1.parseIndependentSubPackages)(appJson).map(({ root }) => root);
|
|
107
148
|
}
|
|
108
149
|
exports.addMiniProgramAppJson = addMiniProgramAppJson;
|
|
109
150
|
function addMiniProgramPageJson(filename, json) {
|
|
@@ -118,6 +159,16 @@ function addMiniProgramUsingComponents(filename, json) {
|
|
|
118
159
|
jsonUsingComponentsCache.set(filename, json);
|
|
119
160
|
}
|
|
120
161
|
exports.addMiniProgramUsingComponents = addMiniProgramUsingComponents;
|
|
162
|
+
function resetMiniProgramJsonFiles() {
|
|
163
|
+
appJsonCache = {};
|
|
164
|
+
independentRootsCache = [];
|
|
165
|
+
(0, subpackage_1.setIndependentSubPackages)([]);
|
|
166
|
+
jsonFilesCache.clear();
|
|
167
|
+
jsonPagesCache.clear();
|
|
168
|
+
jsonComponentsCache.clear();
|
|
169
|
+
jsonUsingComponentsCache.clear();
|
|
170
|
+
}
|
|
171
|
+
exports.resetMiniProgramJsonFiles = resetMiniProgramJsonFiles;
|
|
121
172
|
function isMiniProgramUsingComponent(name, options) {
|
|
122
173
|
return !!findMiniProgramUsingComponents(options)[name];
|
|
123
174
|
}
|
|
@@ -135,20 +186,21 @@ function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, })
|
|
|
135
186
|
if (globalUsingComponents) {
|
|
136
187
|
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(globalUsingComponents, componentsDir));
|
|
137
188
|
}
|
|
138
|
-
const
|
|
189
|
+
const ownerFilename = (0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(filename, inputDir));
|
|
190
|
+
const jsonFile = findJsonFile(ownerFilename);
|
|
139
191
|
if (jsonFile) {
|
|
140
192
|
if (jsonFile.usingComponents) {
|
|
141
|
-
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir));
|
|
193
|
+
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir, ownerFilename));
|
|
142
194
|
}
|
|
143
195
|
// mp-baidu 特有
|
|
144
196
|
if (jsonFile.usingSwanComponents) {
|
|
145
|
-
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingSwanComponents, componentsDir));
|
|
197
|
+
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingSwanComponents, componentsDir, ownerFilename));
|
|
146
198
|
}
|
|
147
199
|
}
|
|
148
200
|
return miniProgramComponents;
|
|
149
201
|
}
|
|
150
202
|
exports.findMiniProgramUsingComponents = findMiniProgramUsingComponents;
|
|
151
|
-
function findMiniProgramUsingComponent(usingComponents, componentsDir) {
|
|
203
|
+
function findMiniProgramUsingComponent(usingComponents, componentsDir, ownerFilename) {
|
|
152
204
|
return Object.keys(usingComponents).reduce((res, name) => {
|
|
153
205
|
const path = usingComponents[name];
|
|
154
206
|
if (path.includes('plugin://')) {
|
|
@@ -165,7 +217,8 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
|
|
|
165
217
|
}
|
|
166
218
|
else if (componentsDir &&
|
|
167
219
|
path.includes(componentsDir + '/') &&
|
|
168
|
-
findUsingComponentsJson(path, componentsDir).renderer ===
|
|
220
|
+
findUsingComponentsJson(path, componentsDir, ownerFilename).renderer ===
|
|
221
|
+
'xr-frame') {
|
|
169
222
|
// mp-weixin & x-frame
|
|
170
223
|
res[name] = 'xr-frame';
|
|
171
224
|
}
|
|
@@ -193,17 +246,15 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
|
|
|
193
246
|
* - "demo": "wxcomponents/demo"
|
|
194
247
|
* - [TODO 待确认] "demo": "../wxcomponents/demo"
|
|
195
248
|
*/
|
|
196
|
-
function findUsingComponentsJson(pathInpages, componentsDir) {
|
|
249
|
+
function findUsingComponentsJson(pathInpages, componentsDir, ownerFilename) {
|
|
197
250
|
// 兼容test case
|
|
198
251
|
if (!process.env.UNI_INPUT_DIR)
|
|
199
252
|
return {};
|
|
200
|
-
|
|
201
|
-
if (
|
|
253
|
+
const fulldir = resolveUsingComponentsDir(pathInpages, componentsDir, ownerFilename);
|
|
254
|
+
if (!fulldir) {
|
|
202
255
|
console.warn(`${pathInpages} 路径里没有找到对应的 ${componentsDir} 目录`);
|
|
203
256
|
return {};
|
|
204
257
|
}
|
|
205
|
-
dir = '.' + dir;
|
|
206
|
-
const fulldir = path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, dir);
|
|
207
258
|
let jsonPath = fulldir + '.json';
|
|
208
259
|
if (fs_1.default.existsSync(jsonPath)) {
|
|
209
260
|
return require(jsonPath);
|
|
@@ -216,3 +267,22 @@ function findUsingComponentsJson(pathInpages, componentsDir) {
|
|
|
216
267
|
return {};
|
|
217
268
|
}
|
|
218
269
|
exports.findUsingComponentsJson = findUsingComponentsJson;
|
|
270
|
+
function resolveUsingComponentsDir(pathInpages, componentsDir, ownerFilename) {
|
|
271
|
+
const normalizedPath = (0, utils_1.normalizePath)(pathInpages);
|
|
272
|
+
if (normalizedPath.startsWith('/')) {
|
|
273
|
+
return path_1.default.resolve(process.env.UNI_INPUT_DIR, '.' + normalizedPath);
|
|
274
|
+
}
|
|
275
|
+
if (ownerFilename && normalizedPath.startsWith('.')) {
|
|
276
|
+
return path_1.default.resolve(process.env.UNI_INPUT_DIR, path_1.default.dirname(ownerFilename), normalizedPath);
|
|
277
|
+
}
|
|
278
|
+
const marker = componentsDir + '/';
|
|
279
|
+
const index = normalizedPath.indexOf(marker);
|
|
280
|
+
if (index === -1) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const dir = normalizedPath.slice(index + componentsDir.length);
|
|
284
|
+
if (!dir) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
return path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, '.' + dir);
|
|
288
|
+
}
|
package/dist/json/mp/pages.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ interface ParsePagesJsonOptions {
|
|
|
3
3
|
debug?: boolean;
|
|
4
4
|
darkmode?: boolean;
|
|
5
5
|
subpackages: boolean;
|
|
6
|
+
independentSubpackages?: boolean;
|
|
6
7
|
windowOptionsMap?: Record<string, string>;
|
|
7
8
|
tabBarOptionsMap?: Record<string, string>;
|
|
8
9
|
tabBarItemOptionsMap?: Record<string, string>;
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -44,7 +44,7 @@ function mergeMiniProgramAppJson(appJson, platformJson = {}, source = {}) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
exports.mergeMiniProgramAppJson = mergeMiniProgramAppJson;
|
|
47
|
-
function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
|
|
47
|
+
function parsePagesJson(jsonStr, platform, { debug, darkmode, independentSubpackages, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
|
|
48
48
|
subpackages: false,
|
|
49
49
|
}) {
|
|
50
50
|
let appJson = {
|
|
@@ -81,7 +81,11 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
|
|
|
81
81
|
pagesJson.subPackages = pagesJson.subPackages || pagesJson.subpackages;
|
|
82
82
|
if (pagesJson.subPackages) {
|
|
83
83
|
if (subpackages) {
|
|
84
|
-
appJson.subPackages = pagesJson.subPackages.map((
|
|
84
|
+
appJson.subPackages = pagesJson.subPackages.map((subPackage) => {
|
|
85
|
+
const { root, pages, ...rest } = subPackage;
|
|
86
|
+
if (!independentSubpackages) {
|
|
87
|
+
delete rest.independent;
|
|
88
|
+
}
|
|
85
89
|
return (0, shared_1.extend)({
|
|
86
90
|
root,
|
|
87
91
|
pages: pages.map((page) => {
|