@dcloudio/uni-mp-harmony 2.0.2-4080720251210002 → 2.0.2-5000420260318002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +61 -65
- package/lib/uni.config.js +12 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -326,7 +326,7 @@ const promiseInterceptor = {
|
|
|
326
326
|
};
|
|
327
327
|
|
|
328
328
|
const SYNC_API_RE =
|
|
329
|
-
/^\$|__f__|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|rpx2px|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/;
|
|
329
|
+
/^\$|__f__|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|rpx2px|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS|getFacialRecognitionMetaInfo/;
|
|
330
330
|
|
|
331
331
|
const CONTEXT_API_RE = /^create|Manager$/;
|
|
332
332
|
|
|
@@ -1682,6 +1682,15 @@ function createObserver (name) {
|
|
|
1682
1682
|
return function observer (newVal, oldVal) {
|
|
1683
1683
|
if (this.$vm) {
|
|
1684
1684
|
this.$vm[name] = newVal; // 为了触发其他非 render watcher
|
|
1685
|
+
} else {
|
|
1686
|
+
// mp-harmony 平台兼容 observer 触发时 this.$vm 不稳定的情况
|
|
1687
|
+
{
|
|
1688
|
+
// 缓存在 attached 之前触发的 observer 更新
|
|
1689
|
+
if (!this._pendingProps) {
|
|
1690
|
+
this._pendingProps = {};
|
|
1691
|
+
}
|
|
1692
|
+
this._pendingProps[name] = newVal;
|
|
1693
|
+
}
|
|
1685
1694
|
}
|
|
1686
1695
|
}
|
|
1687
1696
|
}
|
|
@@ -2223,68 +2232,45 @@ function isPage () {
|
|
|
2223
2232
|
const instances = Object.create(null);
|
|
2224
2233
|
|
|
2225
2234
|
function initRelation ({
|
|
2226
|
-
|
|
2235
|
+
options,
|
|
2227
2236
|
mpInstance
|
|
2228
2237
|
}) {
|
|
2229
2238
|
// triggerEvent 后,接收事件时机特别晚,已经到了 ready 之后
|
|
2230
2239
|
const nodeId = mpInstance.nodeId + '';
|
|
2231
2240
|
const webviewId = mpInstance.pageinstance.__pageId__ + '';
|
|
2232
2241
|
|
|
2233
|
-
instances[webviewId + '_' + nodeId] = mpInstance
|
|
2242
|
+
instances[webviewId + '_' + nodeId] = mpInstance;
|
|
2234
2243
|
|
|
2235
|
-
|
|
2236
|
-
vuePid,
|
|
2244
|
+
Object.assign(options, {
|
|
2237
2245
|
nodeId,
|
|
2238
2246
|
webviewId
|
|
2239
2247
|
});
|
|
2248
|
+
|
|
2249
|
+
handleLink$1.call(mpInstance, {
|
|
2250
|
+
detail: options
|
|
2251
|
+
});
|
|
2240
2252
|
}
|
|
2241
2253
|
|
|
2242
2254
|
function handleLink$1 ({
|
|
2243
|
-
detail
|
|
2244
|
-
nodeId,
|
|
2245
|
-
webviewId
|
|
2246
|
-
}
|
|
2255
|
+
detail
|
|
2247
2256
|
}) {
|
|
2248
|
-
const
|
|
2249
|
-
|
|
2257
|
+
const { nodeId, webviewId } = detail;
|
|
2258
|
+
const mpInstance = instances[webviewId + '_' + nodeId];
|
|
2259
|
+
if (!mpInstance) {
|
|
2250
2260
|
return
|
|
2251
2261
|
}
|
|
2252
|
-
|
|
2262
|
+
|
|
2263
|
+
const owner = instances[webviewId + '_' + mpInstance.ownerId];
|
|
2264
|
+
let parentVm = owner && owner.$vm;
|
|
2265
|
+
|
|
2253
2266
|
if (!parentVm) {
|
|
2254
2267
|
parentVm = this.$vm;
|
|
2255
2268
|
}
|
|
2256
2269
|
|
|
2257
|
-
|
|
2258
|
-
vm.$root = parentVm.$root;
|
|
2259
|
-
parentVm.$children.push(vm);
|
|
2260
|
-
|
|
2261
|
-
const createdVm = function () {
|
|
2262
|
-
vm.__call_hook('created');
|
|
2263
|
-
};
|
|
2264
|
-
const mountedVm = function () {
|
|
2265
|
-
// 处理当前 vm 子
|
|
2266
|
-
if (vm._$childVues) {
|
|
2267
|
-
vm._$childVues.forEach(([createdVm]) => createdVm());
|
|
2268
|
-
vm._$childVues.forEach(([, mountedVm]) => mountedVm());
|
|
2269
|
-
delete vm._$childVues;
|
|
2270
|
-
}
|
|
2271
|
-
vm.__call_hook('beforeMount');
|
|
2272
|
-
vm._isMounted = true;
|
|
2273
|
-
vm.__call_hook('mounted');
|
|
2274
|
-
vm.__call_hook('onReady');
|
|
2275
|
-
};
|
|
2276
|
-
// 当 parentVm 已经 mounted 时,直接触发,否则延迟
|
|
2277
|
-
if (!parentVm || parentVm._isMounted) {
|
|
2278
|
-
createdVm();
|
|
2279
|
-
mountedVm();
|
|
2280
|
-
} else {
|
|
2281
|
-
(parentVm._$childVues || (parentVm._$childVues = [])).push([createdVm, mountedVm]);
|
|
2282
|
-
}
|
|
2270
|
+
detail.parent = parentVm;
|
|
2283
2271
|
}
|
|
2284
2272
|
|
|
2285
2273
|
function parseApp (vm) {
|
|
2286
|
-
Vue.prototype._$fallback = true; // 降级(调整原 vue 的部分生命周期,如 created,beforeMount,inject,provide)
|
|
2287
|
-
|
|
2288
2274
|
Vue.mixin({
|
|
2289
2275
|
created () { // 处理 injections, triggerEvent 是异步,且触发时机很慢,故延迟 relation 设置
|
|
2290
2276
|
if (this.mpType !== 'app') {
|
|
@@ -2445,25 +2431,25 @@ function parseBaseComponent (vueComponentOptions, {
|
|
|
2445
2431
|
return [componentOptions, VueComponent]
|
|
2446
2432
|
}
|
|
2447
2433
|
|
|
2448
|
-
function resolvePropsData (properties) {
|
|
2449
|
-
{
|
|
2450
|
-
const propsData = {};
|
|
2451
|
-
Object.keys(properties).forEach(name => {
|
|
2452
|
-
propsData[name] = resolvePropValue(properties[name]);
|
|
2453
|
-
});
|
|
2454
|
-
return propsData
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
function resolvePropValue (prop) {
|
|
2459
|
-
{
|
|
2460
|
-
if (isPlainObject(prop) && hasOwn(prop, 'value')) {
|
|
2461
|
-
// 目前 mp-harmony 的 prop 返回的是配置项?
|
|
2462
|
-
return prop.value
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
|
-
return prop
|
|
2466
|
-
}
|
|
2434
|
+
function resolvePropsData (properties) {
|
|
2435
|
+
{
|
|
2436
|
+
const propsData = {};
|
|
2437
|
+
Object.keys(properties).forEach(name => {
|
|
2438
|
+
propsData[name] = resolvePropValue(properties[name]);
|
|
2439
|
+
});
|
|
2440
|
+
return propsData
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
function resolvePropValue (prop) {
|
|
2445
|
+
{
|
|
2446
|
+
if (isPlainObject(prop) && hasOwn(prop, 'value')) {
|
|
2447
|
+
// 目前 mp-harmony 的 prop 返回的是配置项?
|
|
2448
|
+
return prop.value
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
return prop
|
|
2452
|
+
}
|
|
2467
2453
|
|
|
2468
2454
|
function parseComponent (vueComponentOptions, needVueOptions) {
|
|
2469
2455
|
const [componentOptions, vueOptions, VueComponent] = parseBaseComponent(vueComponentOptions, {
|
|
@@ -2496,18 +2482,28 @@ function parseComponent (vueComponentOptions, needVueOptions) {
|
|
|
2496
2482
|
|
|
2497
2483
|
initVueIds(resolvePropValue(properties.vueId), this);
|
|
2498
2484
|
|
|
2485
|
+
// 处理父子关系
|
|
2486
|
+
initRelation.call(this, {
|
|
2487
|
+
options,
|
|
2488
|
+
mpInstance: this
|
|
2489
|
+
});
|
|
2490
|
+
|
|
2499
2491
|
// 初始化 vue 实例
|
|
2500
2492
|
this.$vm = new VueComponent(options);
|
|
2501
2493
|
|
|
2494
|
+
// mp-harmony 平台兼容 observer 触发时 this.$vm 不稳定的情况
|
|
2495
|
+
{
|
|
2496
|
+
if (this._pendingProps) {
|
|
2497
|
+
Object.keys(this._pendingProps).forEach(name => {
|
|
2498
|
+
this.$vm[name] = this._pendingProps[name];
|
|
2499
|
+
});
|
|
2500
|
+
delete this._pendingProps;
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2502
2504
|
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
|
|
2503
2505
|
initSlots(this.$vm, resolvePropValue(properties.vueSlots));
|
|
2504
2506
|
|
|
2505
|
-
// 处理父子关系
|
|
2506
|
-
initRelation.call(this, {
|
|
2507
|
-
vuePid: this._$vuePid,
|
|
2508
|
-
mpInstance: this
|
|
2509
|
-
});
|
|
2510
|
-
|
|
2511
2507
|
// 触发首次 setData
|
|
2512
2508
|
this.$vm.$mount();
|
|
2513
2509
|
};
|
package/lib/uni.config.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
+
const {
|
|
4
|
+
parseJson
|
|
5
|
+
} = require('@dcloudio/uni-cli-shared/lib/json')
|
|
3
6
|
|
|
4
7
|
const SIGN_DIR_NAME = 'sign'
|
|
5
8
|
// TODO quickapp ide 有bug,不识别项目根目录 sign,暂时拷贝到 .quickapp 目录
|
|
@@ -36,7 +39,7 @@ module.exports = {
|
|
|
36
39
|
Object.assign(platformOptions, manifestJson['mp-harmony'] || {}, platformOptions)
|
|
37
40
|
},
|
|
38
41
|
copyWebpackOptions (platformOptions, vueOptions) {
|
|
39
|
-
const copyOptions = []
|
|
42
|
+
const copyOptions = ['ascf.config.json']
|
|
40
43
|
let jsConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'jsconfig.json')
|
|
41
44
|
if (!fs.existsSync(jsConfigPath)) {
|
|
42
45
|
jsConfigPath = path.resolve(__dirname, 'assets/jsconfig.json')
|
|
@@ -48,6 +51,14 @@ module.exports = {
|
|
|
48
51
|
copyOptions.push(signCopyOption)
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
const extJsonPath = path.resolve(process.env.UNI_INPUT_DIR, 'ext.json')
|
|
55
|
+
if (fs.existsSync(extJsonPath)) {
|
|
56
|
+
copyOptions.push({
|
|
57
|
+
from: extJsonPath,
|
|
58
|
+
transform: content => JSON.stringify(parseJson(content.toString(), true), null, 2)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
return copyOptions
|
|
52
63
|
}
|
|
53
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-mp-harmony",
|
|
3
|
-
"version": "2.0.2-
|
|
3
|
+
"version": "2.0.2-5000420260318002",
|
|
4
4
|
"description": "uni-app mp-harmony",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"name": "mp-harmony",
|
|
18
18
|
"title": "鸿蒙元服务"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "5ee212292b880f06dde5d198e5ceb09f9d3769e1"
|
|
21
21
|
}
|