@dcloudio/uni-quickapp-webview 2.0.1-alpha-36820221027001 → 2.0.1-alpha-36920221111002
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 +126 -98
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -90,6 +90,10 @@ function isStr (str) {
|
|
|
90
90
|
return typeof str === 'string'
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function isObject (obj) {
|
|
94
|
+
return obj !== null && typeof obj === 'object'
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
function isPlainObject (obj) {
|
|
94
98
|
return _toString.call(obj) === '[object Object]'
|
|
95
99
|
}
|
|
@@ -1286,6 +1290,122 @@ var api = /*#__PURE__*/Object.freeze({
|
|
|
1286
1290
|
invokePushCallback: invokePushCallback
|
|
1287
1291
|
});
|
|
1288
1292
|
|
|
1293
|
+
function findVmByVueId (vm, vuePid) {
|
|
1294
|
+
const $children = vm.$children;
|
|
1295
|
+
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
|
|
1296
|
+
for (let i = $children.length - 1; i >= 0; i--) {
|
|
1297
|
+
const childVm = $children[i];
|
|
1298
|
+
if (childVm.$scope._$vueId === vuePid) {
|
|
1299
|
+
return childVm
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
// 反向递归查找
|
|
1303
|
+
let parentVm;
|
|
1304
|
+
for (let i = $children.length - 1; i >= 0; i--) {
|
|
1305
|
+
parentVm = findVmByVueId($children[i], vuePid);
|
|
1306
|
+
if (parentVm) {
|
|
1307
|
+
return parentVm
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
function initBehavior (options) {
|
|
1313
|
+
return Behavior(options)
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function selectAllComponents (mpInstance, selector, $refs) {
|
|
1317
|
+
const components = mpInstance.selectAllComponents(selector) || [];
|
|
1318
|
+
components.forEach(component => {
|
|
1319
|
+
const ref = component.dataset.ref;
|
|
1320
|
+
$refs[ref] = component.$vm || toSkip(component);
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
function syncRefs (refs, newRefs) {
|
|
1325
|
+
const oldKeys = new Set(...Object.keys(refs));
|
|
1326
|
+
const newKeys = Object.keys(newRefs);
|
|
1327
|
+
newKeys.forEach(key => {
|
|
1328
|
+
const oldValue = refs[key];
|
|
1329
|
+
const newValue = newRefs[key];
|
|
1330
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length && newValue.every(value => oldValue.includes(value))) {
|
|
1331
|
+
return
|
|
1332
|
+
}
|
|
1333
|
+
refs[key] = newValue;
|
|
1334
|
+
oldKeys.delete(key);
|
|
1335
|
+
});
|
|
1336
|
+
oldKeys.forEach(key => {
|
|
1337
|
+
delete refs[key];
|
|
1338
|
+
});
|
|
1339
|
+
return refs
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
function initRefs (vm) {
|
|
1343
|
+
const mpInstance = vm.$scope;
|
|
1344
|
+
const refs = {};
|
|
1345
|
+
Object.defineProperty(vm, '$refs', {
|
|
1346
|
+
get () {
|
|
1347
|
+
const $refs = {};
|
|
1348
|
+
selectAllComponents(mpInstance, '.vue-ref', $refs);
|
|
1349
|
+
// TODO 暂不考虑 for 中的 scoped
|
|
1350
|
+
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [];
|
|
1351
|
+
forComponents.forEach(component => {
|
|
1352
|
+
const ref = component.dataset.ref;
|
|
1353
|
+
if (!$refs[ref]) {
|
|
1354
|
+
$refs[ref] = [];
|
|
1355
|
+
}
|
|
1356
|
+
$refs[ref].push(component.$vm || toSkip(component));
|
|
1357
|
+
});
|
|
1358
|
+
return syncRefs(refs, $refs)
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
function handleLink (event) {
|
|
1364
|
+
const {
|
|
1365
|
+
vuePid,
|
|
1366
|
+
vueOptions
|
|
1367
|
+
} = event.detail || event.value; // detail 是微信,value 是百度(dipatch)
|
|
1368
|
+
|
|
1369
|
+
let parentVm;
|
|
1370
|
+
|
|
1371
|
+
if (vuePid) {
|
|
1372
|
+
parentVm = findVmByVueId(this.$vm, vuePid);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
if (!parentVm) {
|
|
1376
|
+
parentVm = this.$vm;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
vueOptions.parent = parentVm;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
function markMPComponent (component) {
|
|
1383
|
+
// 在 Vue 中标记为小程序组件
|
|
1384
|
+
const IS_MP = '__v_isMPComponent';
|
|
1385
|
+
Object.defineProperty(component, IS_MP, {
|
|
1386
|
+
configurable: true,
|
|
1387
|
+
enumerable: false,
|
|
1388
|
+
value: true
|
|
1389
|
+
});
|
|
1390
|
+
return component
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
function toSkip (obj) {
|
|
1394
|
+
const OB = '__ob__';
|
|
1395
|
+
const SKIP = '__v_skip';
|
|
1396
|
+
if (isObject(obj) && Object.isExtensible(obj)) {
|
|
1397
|
+
// 避免被 @vue/composition-api 观测
|
|
1398
|
+
Object.defineProperty(obj, OB, {
|
|
1399
|
+
configurable: true,
|
|
1400
|
+
enumerable: false,
|
|
1401
|
+
value: {
|
|
1402
|
+
[SKIP]: true
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
return obj
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1289
1409
|
const MPPage = Page;
|
|
1290
1410
|
const MPComponent = Component;
|
|
1291
1411
|
|
|
@@ -1314,16 +1434,13 @@ function initTriggerEvent (mpInstance) {
|
|
|
1314
1434
|
|
|
1315
1435
|
function initHook (name, options, isComponent) {
|
|
1316
1436
|
const oldHook = options[name];
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
} else {
|
|
1322
|
-
options[name] = function (...args) {
|
|
1323
|
-
initTriggerEvent(this);
|
|
1437
|
+
options[name] = function (...args) {
|
|
1438
|
+
markMPComponent(this);
|
|
1439
|
+
initTriggerEvent(this);
|
|
1440
|
+
if (oldHook) {
|
|
1324
1441
|
return oldHook.apply(this, args)
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1327
1444
|
}
|
|
1328
1445
|
if (!MPPage.__$wrappered) {
|
|
1329
1446
|
MPPage.__$wrappered = true;
|
|
@@ -2022,95 +2139,6 @@ function isPage () {
|
|
|
2022
2139
|
return typeof this.ownerId === 'undefined' || this.ownerId === null
|
|
2023
2140
|
}
|
|
2024
2141
|
|
|
2025
|
-
function findVmByVueId (vm, vuePid) {
|
|
2026
|
-
const $children = vm.$children;
|
|
2027
|
-
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
|
|
2028
|
-
for (let i = $children.length - 1; i >= 0; i--) {
|
|
2029
|
-
const childVm = $children[i];
|
|
2030
|
-
if (childVm.$scope._$vueId === vuePid) {
|
|
2031
|
-
return childVm
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
// 反向递归查找
|
|
2035
|
-
let parentVm;
|
|
2036
|
-
for (let i = $children.length - 1; i >= 0; i--) {
|
|
2037
|
-
parentVm = findVmByVueId($children[i], vuePid);
|
|
2038
|
-
if (parentVm) {
|
|
2039
|
-
return parentVm
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
function initBehavior (options) {
|
|
2045
|
-
return Behavior(options)
|
|
2046
|
-
}
|
|
2047
|
-
|
|
2048
|
-
function selectAllComponents (mpInstance, selector, $refs) {
|
|
2049
|
-
const components = mpInstance.selectAllComponents(selector) || [];
|
|
2050
|
-
components.forEach(component => {
|
|
2051
|
-
const ref = component.dataset.ref;
|
|
2052
|
-
$refs[ref] = component.$vm || component;
|
|
2053
|
-
});
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
function syncRefs (refs, newRefs) {
|
|
2057
|
-
const oldKeys = new Set(...Object.keys(refs));
|
|
2058
|
-
const newKeys = Object.keys(newRefs);
|
|
2059
|
-
newKeys.forEach(key => {
|
|
2060
|
-
const oldValue = refs[key];
|
|
2061
|
-
const newValue = newRefs[key];
|
|
2062
|
-
if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length && newValue.every(value => oldValue.includes(value))) {
|
|
2063
|
-
return
|
|
2064
|
-
}
|
|
2065
|
-
refs[key] = newValue;
|
|
2066
|
-
oldKeys.delete(key);
|
|
2067
|
-
});
|
|
2068
|
-
oldKeys.forEach(key => {
|
|
2069
|
-
delete refs[key];
|
|
2070
|
-
});
|
|
2071
|
-
return refs
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
function initRefs (vm) {
|
|
2075
|
-
const mpInstance = vm.$scope;
|
|
2076
|
-
const refs = {};
|
|
2077
|
-
Object.defineProperty(vm, '$refs', {
|
|
2078
|
-
get () {
|
|
2079
|
-
const $refs = {};
|
|
2080
|
-
selectAllComponents(mpInstance, '.vue-ref', $refs);
|
|
2081
|
-
// TODO 暂不考虑 for 中的 scoped
|
|
2082
|
-
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [];
|
|
2083
|
-
forComponents.forEach(component => {
|
|
2084
|
-
const ref = component.dataset.ref;
|
|
2085
|
-
if (!$refs[ref]) {
|
|
2086
|
-
$refs[ref] = [];
|
|
2087
|
-
}
|
|
2088
|
-
$refs[ref].push(component.$vm || component);
|
|
2089
|
-
});
|
|
2090
|
-
return syncRefs(refs, $refs)
|
|
2091
|
-
}
|
|
2092
|
-
});
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
function handleLink (event) {
|
|
2096
|
-
const {
|
|
2097
|
-
vuePid,
|
|
2098
|
-
vueOptions
|
|
2099
|
-
} = event.detail || event.value; // detail 是微信,value 是百度(dipatch)
|
|
2100
|
-
|
|
2101
|
-
let parentVm;
|
|
2102
|
-
|
|
2103
|
-
if (vuePid) {
|
|
2104
|
-
parentVm = findVmByVueId(this.$vm, vuePid);
|
|
2105
|
-
}
|
|
2106
|
-
|
|
2107
|
-
if (!parentVm) {
|
|
2108
|
-
parentVm = this.$vm;
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
vueOptions.parent = parentVm;
|
|
2112
|
-
}
|
|
2113
|
-
|
|
2114
2142
|
const instances = Object.create(null);
|
|
2115
2143
|
|
|
2116
2144
|
function initRelation ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-quickapp-webview",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-36920221111002",
|
|
4
4
|
"description": "uni-app quickapp-webview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"name": "quickapp-webview",
|
|
18
18
|
"title": "快应用(Webview)版"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "dc2bac7acb55d4569841b7487b4968ff7dc834c6"
|
|
21
21
|
}
|