@dcloudio/uni-quickapp-webview 2.0.0 → 2.0.1-32920211122002
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 +300 -118
- package/dist/uni.api.esm.js +500 -132
- package/dist/uni.mp.esm.js +476 -192
- package/package.json +2 -2
package/dist/uni.mp.esm.js
CHANGED
|
@@ -1,4 +1,310 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
|
|
2
|
+
import { injectHook, ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
const encode = encodeURIComponent;
|
|
5
|
+
function stringifyQuery(obj, encodeStr = encode) {
|
|
6
|
+
const res = obj
|
|
7
|
+
? Object.keys(obj)
|
|
8
|
+
.map((key) => {
|
|
9
|
+
let val = obj[key];
|
|
10
|
+
if (typeof val === undefined || val === null) {
|
|
11
|
+
val = '';
|
|
12
|
+
}
|
|
13
|
+
else if (isPlainObject(val)) {
|
|
14
|
+
val = JSON.stringify(val);
|
|
15
|
+
}
|
|
16
|
+
return encodeStr(key) + '=' + encodeStr(val);
|
|
17
|
+
})
|
|
18
|
+
.filter((x) => x.length > 0)
|
|
19
|
+
.join('&')
|
|
20
|
+
: null;
|
|
21
|
+
return res ? `?${res}` : '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function cache(fn) {
|
|
25
|
+
const cache = Object.create(null);
|
|
26
|
+
return (str) => {
|
|
27
|
+
const hit = cache[str];
|
|
28
|
+
return hit || (cache[str] = fn(str));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const invokeArrayFns = (fns, arg) => {
|
|
32
|
+
let ret;
|
|
33
|
+
for (let i = 0; i < fns.length; i++) {
|
|
34
|
+
ret = fns[i](arg);
|
|
35
|
+
}
|
|
36
|
+
return ret;
|
|
37
|
+
};
|
|
38
|
+
// lifecycle
|
|
39
|
+
// App and Page
|
|
40
|
+
const ON_SHOW = 'onShow';
|
|
41
|
+
const ON_HIDE = 'onHide';
|
|
42
|
+
//App
|
|
43
|
+
const ON_LAUNCH = 'onLaunch';
|
|
44
|
+
const ON_ERROR = 'onError';
|
|
45
|
+
const ON_THEME_CHANGE = 'onThemeChange';
|
|
46
|
+
const ON_PAGE_NOT_FOUND = 'onPageNotFound';
|
|
47
|
+
const ON_UNHANDLE_REJECTION = 'onUnhandledRejection';
|
|
48
|
+
//Page
|
|
49
|
+
const ON_LOAD = 'onLoad';
|
|
50
|
+
const ON_READY = 'onReady';
|
|
51
|
+
const ON_UNLOAD = 'onUnload';
|
|
52
|
+
const ON_RESIZE = 'onResize';
|
|
53
|
+
const ON_TAB_ITEM_TAP = 'onTabItemTap';
|
|
54
|
+
const ON_REACH_BOTTOM = 'onReachBottom';
|
|
55
|
+
const ON_PULL_DOWN_REFRESH = 'onPullDownRefresh';
|
|
56
|
+
const ON_ADD_TO_FAVORITES = 'onAddToFavorites';
|
|
57
|
+
|
|
58
|
+
class EventChannel {
|
|
59
|
+
constructor(id, events) {
|
|
60
|
+
this.id = id;
|
|
61
|
+
this.listener = {};
|
|
62
|
+
this.emitCache = {};
|
|
63
|
+
if (events) {
|
|
64
|
+
Object.keys(events).forEach((name) => {
|
|
65
|
+
this.on(name, events[name]);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
emit(eventName, ...args) {
|
|
70
|
+
const fns = this.listener[eventName];
|
|
71
|
+
if (!fns) {
|
|
72
|
+
return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args);
|
|
73
|
+
}
|
|
74
|
+
fns.forEach((opt) => {
|
|
75
|
+
opt.fn.apply(opt.fn, args);
|
|
76
|
+
});
|
|
77
|
+
this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
|
|
78
|
+
}
|
|
79
|
+
on(eventName, fn) {
|
|
80
|
+
this._addListener(eventName, 'on', fn);
|
|
81
|
+
this._clearCache(eventName);
|
|
82
|
+
}
|
|
83
|
+
once(eventName, fn) {
|
|
84
|
+
this._addListener(eventName, 'once', fn);
|
|
85
|
+
this._clearCache(eventName);
|
|
86
|
+
}
|
|
87
|
+
off(eventName, fn) {
|
|
88
|
+
const fns = this.listener[eventName];
|
|
89
|
+
if (!fns) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (fn) {
|
|
93
|
+
for (let i = 0; i < fns.length;) {
|
|
94
|
+
if (fns[i].fn === fn) {
|
|
95
|
+
fns.splice(i, 1);
|
|
96
|
+
i--;
|
|
97
|
+
}
|
|
98
|
+
i++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
delete this.listener[eventName];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_clearCache(eventName) {
|
|
106
|
+
const cacheArgs = this.emitCache[eventName];
|
|
107
|
+
if (cacheArgs) {
|
|
108
|
+
for (; cacheArgs.length > 0;) {
|
|
109
|
+
this.emit.apply(this, [eventName, ...cacheArgs.shift()]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_addListener(eventName, type, fn) {
|
|
114
|
+
(this.listener[eventName] || (this.listener[eventName] = [])).push({
|
|
115
|
+
fn,
|
|
116
|
+
type,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const eventChannels = {};
|
|
122
|
+
const eventChannelStack = [];
|
|
123
|
+
function getEventChannel(id) {
|
|
124
|
+
if (id) {
|
|
125
|
+
const eventChannel = eventChannels[id];
|
|
126
|
+
delete eventChannels[id];
|
|
127
|
+
return eventChannel;
|
|
128
|
+
}
|
|
129
|
+
return eventChannelStack.shift();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function initBehavior(options) {
|
|
133
|
+
return Behavior(options);
|
|
134
|
+
}
|
|
135
|
+
function initVueIds(vueIds, mpInstance) {
|
|
136
|
+
if (!vueIds) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const ids = vueIds.split(',');
|
|
140
|
+
const len = ids.length;
|
|
141
|
+
if (len === 1) {
|
|
142
|
+
mpInstance._$vueId = ids[0];
|
|
143
|
+
}
|
|
144
|
+
else if (len === 2) {
|
|
145
|
+
mpInstance._$vueId = ids[0];
|
|
146
|
+
mpInstance._$vuePid = ids[1];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const EXTRAS = ['externalClasses'];
|
|
150
|
+
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
|
151
|
+
EXTRAS.forEach((name) => {
|
|
152
|
+
if (hasOwn(vueOptions, name)) {
|
|
153
|
+
miniProgramComponentOptions[name] = vueOptions[name];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
158
|
+
if (!isArray(wxsCallMethods)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
wxsCallMethods.forEach((callMethod) => {
|
|
162
|
+
methods[callMethod] = function (args) {
|
|
163
|
+
return this.$vm[callMethod](args);
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function selectAllComponents(mpInstance, selector, $refs) {
|
|
168
|
+
const components = mpInstance.selectAllComponents(selector);
|
|
169
|
+
components.forEach((component) => {
|
|
170
|
+
const ref = component.dataset.ref;
|
|
171
|
+
$refs[ref] = component.$vm || component;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function initRefs(instance, mpInstance) {
|
|
175
|
+
Object.defineProperty(instance, 'refs', {
|
|
176
|
+
get() {
|
|
177
|
+
const $refs = {};
|
|
178
|
+
selectAllComponents(mpInstance, '.vue-ref', $refs);
|
|
179
|
+
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
|
|
180
|
+
forComponents.forEach((component) => {
|
|
181
|
+
const ref = component.dataset.ref;
|
|
182
|
+
if (!$refs[ref]) {
|
|
183
|
+
$refs[ref] = [];
|
|
184
|
+
}
|
|
185
|
+
$refs[ref].push(component.$vm || component);
|
|
186
|
+
});
|
|
187
|
+
return $refs;
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function getTarget(obj, path) {
|
|
192
|
+
const parts = path.split('.');
|
|
193
|
+
let key = parts[0];
|
|
194
|
+
if (key.indexOf('__$n') === 0) {
|
|
195
|
+
//number index
|
|
196
|
+
key = parseInt(key.replace('__$n', ''));
|
|
197
|
+
}
|
|
198
|
+
if (!obj) {
|
|
199
|
+
obj = {};
|
|
200
|
+
}
|
|
201
|
+
if (parts.length === 1) {
|
|
202
|
+
return obj[key];
|
|
203
|
+
}
|
|
204
|
+
return getTarget(obj[key], parts.slice(1).join('.'));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function getValue(dataPath, target) {
|
|
208
|
+
return getTarget(target || this, dataPath);
|
|
209
|
+
}
|
|
210
|
+
function getClass(dynamicClass, staticClass) {
|
|
211
|
+
return renderClass(staticClass, dynamicClass);
|
|
212
|
+
}
|
|
213
|
+
function getStyle(dynamicStyle, staticStyle) {
|
|
214
|
+
if (!dynamicStyle && !staticStyle) {
|
|
215
|
+
return '';
|
|
216
|
+
}
|
|
217
|
+
var dynamicStyleObj = normalizeStyleBinding(dynamicStyle);
|
|
218
|
+
var styleObj = staticStyle
|
|
219
|
+
? extend(staticStyle, dynamicStyleObj)
|
|
220
|
+
: dynamicStyleObj;
|
|
221
|
+
return Object.keys(styleObj)
|
|
222
|
+
.map(function (name) {
|
|
223
|
+
return hyphenate(name) + ':' + styleObj[name];
|
|
224
|
+
})
|
|
225
|
+
.join(';');
|
|
226
|
+
}
|
|
227
|
+
function toObject(arr) {
|
|
228
|
+
var res = {};
|
|
229
|
+
for (var i = 0; i < arr.length; i++) {
|
|
230
|
+
if (arr[i]) {
|
|
231
|
+
extend(res, arr[i]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return res;
|
|
235
|
+
}
|
|
236
|
+
function normalizeStyleBinding(bindingStyle) {
|
|
237
|
+
if (Array.isArray(bindingStyle)) {
|
|
238
|
+
return toObject(bindingStyle);
|
|
239
|
+
}
|
|
240
|
+
if (typeof bindingStyle === 'string') {
|
|
241
|
+
return parseStyleText(bindingStyle);
|
|
242
|
+
}
|
|
243
|
+
return bindingStyle;
|
|
244
|
+
}
|
|
245
|
+
var parseStyleText = cache(function parseStyleText(cssText) {
|
|
246
|
+
var res = {};
|
|
247
|
+
var listDelimiter = /;(?![^(]*\))/g;
|
|
248
|
+
var propertyDelimiter = /:(.+)/;
|
|
249
|
+
cssText.split(listDelimiter).forEach(function (item) {
|
|
250
|
+
if (item) {
|
|
251
|
+
var tmp = item.split(propertyDelimiter);
|
|
252
|
+
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return res;
|
|
256
|
+
});
|
|
257
|
+
function isDef(v) {
|
|
258
|
+
return v !== undefined && v !== null;
|
|
259
|
+
}
|
|
260
|
+
function renderClass(staticClass, dynamicClass) {
|
|
261
|
+
if (isDef(staticClass) || isDef(dynamicClass)) {
|
|
262
|
+
return concat(staticClass, stringifyClass(dynamicClass));
|
|
263
|
+
}
|
|
264
|
+
/* istanbul ignore next */
|
|
265
|
+
return '';
|
|
266
|
+
}
|
|
267
|
+
function concat(a, b) {
|
|
268
|
+
return a ? (b ? a + ' ' + b : a) : b || '';
|
|
269
|
+
}
|
|
270
|
+
function stringifyClass(value) {
|
|
271
|
+
if (Array.isArray(value)) {
|
|
272
|
+
return stringifyArray(value);
|
|
273
|
+
}
|
|
274
|
+
if (isObject(value)) {
|
|
275
|
+
return stringifyObject(value);
|
|
276
|
+
}
|
|
277
|
+
if (typeof value === 'string') {
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
/* istanbul ignore next */
|
|
281
|
+
return '';
|
|
282
|
+
}
|
|
283
|
+
function stringifyArray(value) {
|
|
284
|
+
var res = '';
|
|
285
|
+
var stringified;
|
|
286
|
+
for (var i = 0, l = value.length; i < l; i++) {
|
|
287
|
+
if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
|
|
288
|
+
if (res) {
|
|
289
|
+
res += ' ';
|
|
290
|
+
}
|
|
291
|
+
res += stringified;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return res;
|
|
295
|
+
}
|
|
296
|
+
function stringifyObject(value) {
|
|
297
|
+
var res = '';
|
|
298
|
+
for (var key in value) {
|
|
299
|
+
if (value[key]) {
|
|
300
|
+
if (res) {
|
|
301
|
+
res += ' ';
|
|
302
|
+
}
|
|
303
|
+
res += key;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return res;
|
|
307
|
+
}
|
|
2
308
|
|
|
3
309
|
function setModel(target, key, value, modifiers) {
|
|
4
310
|
if (isArray(modifiers)) {
|
|
@@ -50,7 +356,7 @@ const MP_METHODS = [
|
|
|
50
356
|
'createSelectorQuery',
|
|
51
357
|
'createIntersectionObserver',
|
|
52
358
|
'selectAllComponents',
|
|
53
|
-
'selectComponent'
|
|
359
|
+
'selectComponent',
|
|
54
360
|
];
|
|
55
361
|
function createEmitFn(oldEmit, ctx) {
|
|
56
362
|
return function emit(event, ...args) {
|
|
@@ -77,18 +383,26 @@ function initBaseInstance(instance, options) {
|
|
|
77
383
|
{
|
|
78
384
|
instance.slots = {};
|
|
79
385
|
if (isArray(options.slots) && options.slots.length) {
|
|
80
|
-
options.slots.forEach(name => {
|
|
386
|
+
options.slots.forEach((name) => {
|
|
81
387
|
instance.slots[name] = true;
|
|
82
388
|
});
|
|
83
389
|
}
|
|
84
390
|
}
|
|
391
|
+
ctx.getOpenerEventChannel = function () {
|
|
392
|
+
if (!this.__eventChannel__) {
|
|
393
|
+
this.__eventChannel__ = new EventChannel();
|
|
394
|
+
}
|
|
395
|
+
return this.__eventChannel__;
|
|
396
|
+
};
|
|
397
|
+
ctx.$hasHook = hasHook;
|
|
398
|
+
ctx.$callHook = callHook;
|
|
85
399
|
// $emit
|
|
86
400
|
instance.emit = createEmitFn(instance.emit, ctx);
|
|
87
401
|
}
|
|
88
402
|
function initComponentInstance(instance, options) {
|
|
89
403
|
initBaseInstance(instance, options);
|
|
90
404
|
const ctx = instance.ctx;
|
|
91
|
-
MP_METHODS.forEach(method => {
|
|
405
|
+
MP_METHODS.forEach((method) => {
|
|
92
406
|
ctx[method] = function (...args) {
|
|
93
407
|
const mpInstance = ctx.$scope;
|
|
94
408
|
if (mpInstance && mpInstance[method]) {
|
|
@@ -101,36 +415,58 @@ function initComponentInstance(instance, options) {
|
|
|
101
415
|
ctx.__set_sync = setSync;
|
|
102
416
|
ctx.__get_orig = getOrig;
|
|
103
417
|
// TODO
|
|
104
|
-
|
|
418
|
+
ctx.__get_value = getValue;
|
|
419
|
+
ctx.__get_class = getClass;
|
|
420
|
+
ctx.__get_style = getStyle;
|
|
105
421
|
ctx.__map = map;
|
|
106
422
|
}
|
|
107
423
|
function initMocks(instance, mpInstance, mocks) {
|
|
108
424
|
const ctx = instance.ctx;
|
|
109
|
-
mocks.forEach(mock => {
|
|
425
|
+
mocks.forEach((mock) => {
|
|
110
426
|
if (hasOwn(mpInstance, mock)) {
|
|
111
427
|
ctx[mock] = mpInstance[mock];
|
|
112
428
|
}
|
|
113
429
|
});
|
|
430
|
+
}
|
|
431
|
+
function hasHook(name) {
|
|
432
|
+
const hooks = this.$[name];
|
|
433
|
+
if (hooks && hooks.length) {
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
function callHook(name, args) {
|
|
439
|
+
if (name === 'mounted') {
|
|
440
|
+
callHook.call(this, 'bm'); // beforeMount
|
|
441
|
+
this.$.isMounted = true;
|
|
442
|
+
name = 'm';
|
|
443
|
+
}
|
|
444
|
+
else if (name === 'onLoad' && args && args.__id__) {
|
|
445
|
+
this.__eventChannel__ = getEventChannel(args.__id__);
|
|
446
|
+
delete args.__id__;
|
|
447
|
+
}
|
|
448
|
+
const hooks = this.$[name];
|
|
449
|
+
return hooks && invokeArrayFns(hooks, args);
|
|
114
450
|
}
|
|
115
451
|
|
|
116
452
|
const PAGE_HOOKS = [
|
|
117
|
-
|
|
118
|
-
|
|
453
|
+
ON_LOAD,
|
|
454
|
+
ON_SHOW,
|
|
455
|
+
ON_HIDE,
|
|
456
|
+
ON_UNLOAD,
|
|
457
|
+
ON_RESIZE,
|
|
458
|
+
ON_TAB_ITEM_TAP,
|
|
459
|
+
ON_REACH_BOTTOM,
|
|
460
|
+
ON_PULL_DOWN_REFRESH,
|
|
461
|
+
ON_ADD_TO_FAVORITES,
|
|
119
462
|
// 'onReady', // lifetimes.ready
|
|
120
|
-
'onHide',
|
|
121
|
-
'onUnload',
|
|
122
|
-
'onResize',
|
|
123
463
|
// 'onPageScroll', // 影响性能,开发者手动注册
|
|
124
|
-
'onTabItemTap',
|
|
125
|
-
'onReachBottom',
|
|
126
|
-
'onPullDownRefresh',
|
|
127
464
|
// 'onShareTimeline', // 右上角菜单,开发者手动注册
|
|
128
|
-
'onAddToFavorites'
|
|
129
465
|
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
|
|
130
466
|
];
|
|
131
467
|
function findHooks(vueOptions, hooks = new Set()) {
|
|
132
468
|
if (vueOptions) {
|
|
133
|
-
Object.keys(vueOptions).forEach(name => {
|
|
469
|
+
Object.keys(vueOptions).forEach((name) => {
|
|
134
470
|
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
|
|
135
471
|
hooks.add(name);
|
|
136
472
|
}
|
|
@@ -138,7 +474,7 @@ function findHooks(vueOptions, hooks = new Set()) {
|
|
|
138
474
|
if (__VUE_OPTIONS_API__) {
|
|
139
475
|
const { extends: extendsOptions, mixins } = vueOptions;
|
|
140
476
|
if (mixins) {
|
|
141
|
-
mixins.forEach(mixin => findHooks(mixin, hooks));
|
|
477
|
+
mixins.forEach((mixin) => findHooks(mixin, hooks));
|
|
142
478
|
}
|
|
143
479
|
if (extendsOptions) {
|
|
144
480
|
findHooks(extendsOptions, hooks);
|
|
@@ -147,28 +483,35 @@ function findHooks(vueOptions, hooks = new Set()) {
|
|
|
147
483
|
}
|
|
148
484
|
return hooks;
|
|
149
485
|
}
|
|
150
|
-
function initHook(mpOptions, hook, excludes) {
|
|
486
|
+
function initHook$1(mpOptions, hook, excludes) {
|
|
151
487
|
if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
|
|
152
488
|
mpOptions[hook] = function (args) {
|
|
153
489
|
return this.$vm && this.$vm.$callHook(hook, args);
|
|
154
490
|
};
|
|
155
491
|
}
|
|
156
492
|
}
|
|
157
|
-
const EXCLUDE_HOOKS = [
|
|
493
|
+
const EXCLUDE_HOOKS = [ON_READY];
|
|
158
494
|
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
|
|
159
|
-
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
|
|
495
|
+
hooks.forEach((hook) => initHook$1(mpOptions, hook, excludes));
|
|
160
496
|
}
|
|
161
497
|
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
|
|
162
|
-
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
|
|
498
|
+
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
qa.appLaunchHooks = [];
|
|
502
|
+
function injectAppLaunchHooks(appInstance) {
|
|
503
|
+
qa.appLaunchHooks.forEach((hook) => {
|
|
504
|
+
injectHook(ON_LAUNCH, hook, appInstance);
|
|
505
|
+
});
|
|
163
506
|
}
|
|
164
507
|
|
|
165
508
|
const HOOKS = [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
509
|
+
ON_SHOW,
|
|
510
|
+
ON_HIDE,
|
|
511
|
+
ON_ERROR,
|
|
512
|
+
ON_THEME_CHANGE,
|
|
513
|
+
ON_PAGE_NOT_FOUND,
|
|
514
|
+
ON_UNHANDLE_REJECTION,
|
|
172
515
|
];
|
|
173
516
|
function parseApp(instance, parseAppOptions) {
|
|
174
517
|
const internalInstance = instance.$;
|
|
@@ -184,12 +527,14 @@ function parseApp(instance, parseAppOptions) {
|
|
|
184
527
|
initBaseInstance(internalInstance, {
|
|
185
528
|
mpType: 'app',
|
|
186
529
|
mpInstance: this,
|
|
187
|
-
slots: []
|
|
530
|
+
slots: [],
|
|
188
531
|
});
|
|
532
|
+
injectAppLaunchHooks(internalInstance);
|
|
189
533
|
ctx.globalData = this.globalData;
|
|
190
|
-
instance.$callHook(
|
|
191
|
-
}
|
|
534
|
+
instance.$callHook(ON_LAUNCH, extend({ app: this }, options));
|
|
535
|
+
},
|
|
192
536
|
};
|
|
537
|
+
initLocale(instance);
|
|
193
538
|
const vueOptions = instance.$.type;
|
|
194
539
|
initHooks(appOptions, HOOKS);
|
|
195
540
|
initUnknownHooks(appOptions, vueOptions);
|
|
@@ -206,82 +551,16 @@ function initCreateApp(parseAppOptions) {
|
|
|
206
551
|
return function createApp(vm) {
|
|
207
552
|
return App(parseApp(vm, parseAppOptions));
|
|
208
553
|
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const encode = encodeURIComponent;
|
|
212
|
-
function stringifyQuery(obj, encodeStr = encode) {
|
|
213
|
-
const res = obj
|
|
214
|
-
? Object.keys(obj)
|
|
215
|
-
.map(key => {
|
|
216
|
-
let val = obj[key];
|
|
217
|
-
if (typeof val === undefined || val === null) {
|
|
218
|
-
val = '';
|
|
219
|
-
}
|
|
220
|
-
else if (isPlainObject(val)) {
|
|
221
|
-
val = JSON.stringify(val);
|
|
222
|
-
}
|
|
223
|
-
return encodeStr(key) + '=' + encodeStr(val);
|
|
224
|
-
})
|
|
225
|
-
.filter(x => x.length > 0)
|
|
226
|
-
.join('&')
|
|
227
|
-
: null;
|
|
228
|
-
return res ? `?${res}` : '';
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function initBehavior(options) {
|
|
232
|
-
return Behavior(options);
|
|
233
|
-
}
|
|
234
|
-
function initVueIds(vueIds, mpInstance) {
|
|
235
|
-
if (!vueIds) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const ids = vueIds.split(',');
|
|
239
|
-
const len = ids.length;
|
|
240
|
-
if (len === 1) {
|
|
241
|
-
mpInstance._$vueId = ids[0];
|
|
242
|
-
}
|
|
243
|
-
else if (len === 2) {
|
|
244
|
-
mpInstance._$vueId = ids[0];
|
|
245
|
-
mpInstance._$vuePid = ids[1];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
const EXTRAS = ['externalClasses'];
|
|
249
|
-
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
|
250
|
-
EXTRAS.forEach(name => {
|
|
251
|
-
if (hasOwn(vueOptions, name)) {
|
|
252
|
-
miniProgramComponentOptions[name] = vueOptions[name];
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
554
|
}
|
|
256
|
-
function
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
wxsCallMethods.forEach((callMethod) => {
|
|
261
|
-
methods[callMethod] = function (args) {
|
|
262
|
-
return this.$vm[callMethod](args);
|
|
263
|
-
};
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
function initRefs(instance, mpInstance) {
|
|
267
|
-
Object.defineProperty(instance, 'refs', {
|
|
555
|
+
function initLocale(appVm) {
|
|
556
|
+
const locale = ref(qa.getSystemInfoSync().language || 'zh-Hans');
|
|
557
|
+
Object.defineProperty(appVm, '$locale', {
|
|
268
558
|
get() {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
275
|
-
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
|
|
276
|
-
forComponents.forEach(component => {
|
|
277
|
-
const ref = component.dataset.ref;
|
|
278
|
-
if (!$refs[ref]) {
|
|
279
|
-
$refs[ref] = [];
|
|
280
|
-
}
|
|
281
|
-
$refs[ref].push(component.$vm || component);
|
|
282
|
-
});
|
|
283
|
-
return $refs;
|
|
284
|
-
}
|
|
559
|
+
return locale.value;
|
|
560
|
+
},
|
|
561
|
+
set(v) {
|
|
562
|
+
locale.value = v;
|
|
563
|
+
},
|
|
285
564
|
});
|
|
286
565
|
}
|
|
287
566
|
|
|
@@ -305,7 +584,7 @@ function initDefaultProps(isBehavior = false) {
|
|
|
305
584
|
if (!isBehavior) {
|
|
306
585
|
properties.vueId = {
|
|
307
586
|
type: String,
|
|
308
|
-
value: ''
|
|
587
|
+
value: '',
|
|
309
588
|
};
|
|
310
589
|
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
|
|
311
590
|
properties.vueSlots = {
|
|
@@ -317,9 +596,9 @@ function initDefaultProps(isBehavior = false) {
|
|
|
317
596
|
$slots[slotName] = true;
|
|
318
597
|
});
|
|
319
598
|
this.setData({
|
|
320
|
-
$slots
|
|
599
|
+
$slots,
|
|
321
600
|
});
|
|
322
|
-
}
|
|
601
|
+
},
|
|
323
602
|
};
|
|
324
603
|
}
|
|
325
604
|
return properties;
|
|
@@ -331,14 +610,14 @@ function createProperty(key, prop) {
|
|
|
331
610
|
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
|
|
332
611
|
const properties = initDefaultProps(isBehavior);
|
|
333
612
|
if (isArray(rawProps)) {
|
|
334
|
-
rawProps.forEach(key => {
|
|
613
|
+
rawProps.forEach((key) => {
|
|
335
614
|
properties[key] = createProperty(key, {
|
|
336
|
-
type: null
|
|
615
|
+
type: null,
|
|
337
616
|
});
|
|
338
617
|
});
|
|
339
618
|
}
|
|
340
619
|
else if (isPlainObject(rawProps)) {
|
|
341
|
-
Object.keys(rawProps).forEach(key => {
|
|
620
|
+
Object.keys(rawProps).forEach((key) => {
|
|
342
621
|
const opts = rawProps[key];
|
|
343
622
|
if (isPlainObject(opts)) {
|
|
344
623
|
// title:{type:String,default:''}
|
|
@@ -350,14 +629,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
|
|
|
350
629
|
opts.type = parsePropType(key, type);
|
|
351
630
|
properties[key] = createProperty(key, {
|
|
352
631
|
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
|
|
353
|
-
value
|
|
632
|
+
value,
|
|
354
633
|
});
|
|
355
634
|
}
|
|
356
635
|
else {
|
|
357
636
|
// content:String
|
|
358
637
|
const type = parsePropType(key, opts);
|
|
359
638
|
properties[key] = createProperty(key, {
|
|
360
|
-
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
|
|
639
|
+
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
|
|
361
640
|
});
|
|
362
641
|
}
|
|
363
642
|
});
|
|
@@ -369,8 +648,7 @@ function initData(vueOptions) {
|
|
|
369
648
|
let data = vueOptions.data || {};
|
|
370
649
|
if (typeof data === 'function') {
|
|
371
650
|
try {
|
|
372
|
-
const appConfig = getApp().$vm.$.appContext
|
|
373
|
-
.config;
|
|
651
|
+
const appConfig = getApp().$vm.$.appContext.config;
|
|
374
652
|
data = data.call(appConfig.globalProperties);
|
|
375
653
|
}
|
|
376
654
|
catch (e) {
|
|
@@ -401,7 +679,7 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
401
679
|
}
|
|
402
680
|
const behaviors = [];
|
|
403
681
|
if (isArray(vueBehaviors)) {
|
|
404
|
-
vueBehaviors.forEach(behavior => {
|
|
682
|
+
vueBehaviors.forEach((behavior) => {
|
|
405
683
|
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
|
|
406
684
|
if (behavior === 'uni://form-field') {
|
|
407
685
|
if (isArray(vueProps)) {
|
|
@@ -411,24 +689,24 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
411
689
|
else {
|
|
412
690
|
vueProps.name = {
|
|
413
691
|
type: String,
|
|
414
|
-
default: ''
|
|
692
|
+
default: '',
|
|
415
693
|
};
|
|
416
694
|
vueProps.value = {
|
|
417
695
|
type: [String, Number, Boolean, Array, Object, Date],
|
|
418
|
-
default: ''
|
|
696
|
+
default: '',
|
|
419
697
|
};
|
|
420
698
|
}
|
|
421
699
|
}
|
|
422
700
|
});
|
|
423
701
|
}
|
|
424
|
-
if (
|
|
702
|
+
if (vueExtends && vueExtends.props) {
|
|
425
703
|
const behavior = {};
|
|
426
704
|
initProps(behavior, vueExtends.props, true);
|
|
427
705
|
behaviors.push(initBehavior(behavior));
|
|
428
706
|
}
|
|
429
707
|
if (isArray(vueMixins)) {
|
|
430
|
-
vueMixins.forEach(vueMixin => {
|
|
431
|
-
if (
|
|
708
|
+
vueMixins.forEach((vueMixin) => {
|
|
709
|
+
if (vueMixin.props) {
|
|
432
710
|
const behavior = {};
|
|
433
711
|
initProps(behavior, vueMixin.props, true);
|
|
434
712
|
behaviors.push(initBehavior(behavior));
|
|
@@ -442,21 +720,9 @@ function applyOptions(componentOptions, vueOptions, initBehavior) {
|
|
|
442
720
|
componentOptions.behaviors = initBehaviors(vueOptions, initBehavior);
|
|
443
721
|
}
|
|
444
722
|
|
|
445
|
-
function getValue(obj, path) {
|
|
446
|
-
const parts = path.split('.');
|
|
447
|
-
let key = parts[0];
|
|
448
|
-
if (key.indexOf('__$n') === 0) {
|
|
449
|
-
//number index
|
|
450
|
-
key = parseInt(key.replace('__$n', ''));
|
|
451
|
-
}
|
|
452
|
-
if (parts.length === 1) {
|
|
453
|
-
return obj[key];
|
|
454
|
-
}
|
|
455
|
-
return getValue(obj[key], parts.slice(1).join('.'));
|
|
456
|
-
}
|
|
457
723
|
function getExtraValue(instance, dataPathsArray) {
|
|
458
724
|
let context = instance;
|
|
459
|
-
dataPathsArray.forEach(dataPathArray => {
|
|
725
|
+
dataPathsArray.forEach((dataPathArray) => {
|
|
460
726
|
const dataPath = dataPathArray[0];
|
|
461
727
|
const value = dataPathArray[2];
|
|
462
728
|
if (dataPath || typeof value !== 'undefined') {
|
|
@@ -475,7 +741,7 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
475
741
|
vFor = dataPath.substr(3);
|
|
476
742
|
}
|
|
477
743
|
else {
|
|
478
|
-
vFor =
|
|
744
|
+
vFor = getTarget(context, dataPath);
|
|
479
745
|
}
|
|
480
746
|
}
|
|
481
747
|
if (Number.isInteger(vFor)) {
|
|
@@ -486,13 +752,13 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
486
752
|
}
|
|
487
753
|
else {
|
|
488
754
|
if (isArray(vFor)) {
|
|
489
|
-
context = vFor.find(vForItem => {
|
|
490
|
-
return
|
|
755
|
+
context = vFor.find((vForItem) => {
|
|
756
|
+
return getTarget(vForItem, propPath) === value;
|
|
491
757
|
});
|
|
492
758
|
}
|
|
493
759
|
else if (isPlainObject(vFor)) {
|
|
494
|
-
context = Object.keys(vFor).find(vForKey => {
|
|
495
|
-
return
|
|
760
|
+
context = Object.keys(vFor).find((vForKey) => {
|
|
761
|
+
return getTarget(vFor[vForKey], propPath) === value;
|
|
496
762
|
});
|
|
497
763
|
}
|
|
498
764
|
else {
|
|
@@ -500,7 +766,7 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
500
766
|
}
|
|
501
767
|
}
|
|
502
768
|
if (valuePath) {
|
|
503
|
-
context =
|
|
769
|
+
context = getTarget(context, valuePath);
|
|
504
770
|
}
|
|
505
771
|
}
|
|
506
772
|
});
|
|
@@ -541,10 +807,10 @@ function processEventExtra(instance, extra, event) {
|
|
|
541
807
|
}
|
|
542
808
|
else if (dataPath.indexOf('$event.') === 0) {
|
|
543
809
|
// $event.target.value
|
|
544
|
-
extraObj['$' + index] =
|
|
810
|
+
extraObj['$' + index] = getTarget(event, dataPath.replace('$event.', ''));
|
|
545
811
|
}
|
|
546
812
|
else {
|
|
547
|
-
extraObj['$' + index] =
|
|
813
|
+
extraObj['$' + index] = getTarget(instance, dataPath);
|
|
548
814
|
}
|
|
549
815
|
}
|
|
550
816
|
}
|
|
@@ -581,7 +847,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
|
|
|
581
847
|
}
|
|
582
848
|
const extraObj = processEventExtra(instance, extra, event);
|
|
583
849
|
const ret = [];
|
|
584
|
-
args.forEach(arg => {
|
|
850
|
+
args.forEach((arg) => {
|
|
585
851
|
if (arg === '$event') {
|
|
586
852
|
if (methodName === '__set_model' && !isCustom) {
|
|
587
853
|
// input v-model value
|
|
@@ -623,7 +889,7 @@ function wrapper(event) {
|
|
|
623
889
|
event.detail.markerId = event.markerId;
|
|
624
890
|
}
|
|
625
891
|
if (isPlainObject(event.detail)) {
|
|
626
|
-
event.target =
|
|
892
|
+
event.target = extend({}, event.target, event.detail);
|
|
627
893
|
}
|
|
628
894
|
return event;
|
|
629
895
|
}
|
|
@@ -681,7 +947,14 @@ function handleEvent(event) {
|
|
|
681
947
|
}
|
|
682
948
|
handler.once = true;
|
|
683
949
|
}
|
|
684
|
-
|
|
950
|
+
let params = processEventArgs(this.$vm, event, eventArray[1], eventArray[2], isCustom, methodName);
|
|
951
|
+
params = Array.isArray(params) ? params : [];
|
|
952
|
+
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
|
|
953
|
+
if (/=\s*\S+\.eventParams\s*\|\|\s*\S+\[['"]event-params['"]\]/.test(handler.toString())) {
|
|
954
|
+
// eslint-disable-next-line no-sparse-arrays
|
|
955
|
+
params = params.concat([, , , , , , , , , , event]);
|
|
956
|
+
}
|
|
957
|
+
ret.push(handler.apply(handlerCtx, params));
|
|
685
958
|
}
|
|
686
959
|
});
|
|
687
960
|
}
|
|
@@ -693,11 +966,11 @@ function handleEvent(event) {
|
|
|
693
966
|
}
|
|
694
967
|
}
|
|
695
968
|
|
|
696
|
-
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
|
|
969
|
+
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
|
|
697
970
|
vueOptions = vueOptions.default || vueOptions;
|
|
698
971
|
const options = {
|
|
699
972
|
multipleSlots: true,
|
|
700
|
-
addGlobalClass: true
|
|
973
|
+
addGlobalClass: true,
|
|
701
974
|
};
|
|
702
975
|
if (vueOptions.options) {
|
|
703
976
|
extend(options, vueOptions.options);
|
|
@@ -714,12 +987,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
|
|
|
714
987
|
},
|
|
715
988
|
resize(size) {
|
|
716
989
|
this.$vm && this.$vm.$callHook('onPageResize', size);
|
|
717
|
-
}
|
|
990
|
+
},
|
|
718
991
|
},
|
|
719
992
|
methods: {
|
|
720
993
|
__l: handleLink,
|
|
721
|
-
__e: handleEvent
|
|
722
|
-
}
|
|
994
|
+
__e: handleEvent,
|
|
995
|
+
},
|
|
723
996
|
};
|
|
724
997
|
if (__VUE_OPTIONS_API__) {
|
|
725
998
|
applyOptions(mpComponentOptions, vueOptions, initBehavior);
|
|
@@ -759,15 +1032,15 @@ function parsePage(vueOptions, parseOptions) {
|
|
|
759
1032
|
isPage,
|
|
760
1033
|
initRelation,
|
|
761
1034
|
handleLink,
|
|
762
|
-
initLifetimes
|
|
1035
|
+
initLifetimes,
|
|
763
1036
|
});
|
|
764
1037
|
const methods = miniProgramPageOptions.methods;
|
|
765
1038
|
methods.onLoad = function (query) {
|
|
766
1039
|
this.options = query;
|
|
767
1040
|
this.$page = {
|
|
768
|
-
fullPath: '/' + this.route + stringifyQuery(query)
|
|
1041
|
+
fullPath: '/' + this.route + stringifyQuery(query),
|
|
769
1042
|
};
|
|
770
|
-
return this.$vm && this.$vm.$callHook(
|
|
1043
|
+
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
|
|
771
1044
|
};
|
|
772
1045
|
initHooks(methods, PAGE_HOOKS);
|
|
773
1046
|
initUnknownHooks(methods, vueOptions);
|
|
@@ -792,7 +1065,7 @@ function initTriggerEvent(mpInstance) {
|
|
|
792
1065
|
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args]);
|
|
793
1066
|
};
|
|
794
1067
|
}
|
|
795
|
-
function initHook
|
|
1068
|
+
function initHook(name, options) {
|
|
796
1069
|
const oldHook = options[name];
|
|
797
1070
|
if (!oldHook) {
|
|
798
1071
|
options[name] = function () {
|
|
@@ -807,11 +1080,11 @@ function initHook$1(name, options) {
|
|
|
807
1080
|
}
|
|
808
1081
|
}
|
|
809
1082
|
Page = function (options) {
|
|
810
|
-
initHook
|
|
1083
|
+
initHook(ON_LOAD, options);
|
|
811
1084
|
return MPPage(options);
|
|
812
1085
|
};
|
|
813
1086
|
Component = function (options) {
|
|
814
|
-
initHook
|
|
1087
|
+
initHook('created', options);
|
|
815
1088
|
return MPComponent(options);
|
|
816
1089
|
};
|
|
817
1090
|
|
|
@@ -849,15 +1122,22 @@ function initProvide(instance) {
|
|
|
849
1122
|
provide(internalInstance, key, provides[key]);
|
|
850
1123
|
}
|
|
851
1124
|
}
|
|
852
|
-
function inject(instance, key, defaultValue) {
|
|
1125
|
+
function inject(instance, key, defaultValue, treatDefaultAsFactory = false) {
|
|
853
1126
|
if (instance) {
|
|
854
|
-
|
|
855
|
-
|
|
1127
|
+
// #2400
|
|
1128
|
+
// to support `app.use` plugins,
|
|
1129
|
+
// fallback to appContext's `provides` if the intance is at root
|
|
1130
|
+
const provides = instance.parent == null
|
|
1131
|
+
? instance.vnode.appContext && instance.vnode.appContext.provides
|
|
1132
|
+
: instance.parent.provides;
|
|
1133
|
+
if (provides && key in provides) {
|
|
856
1134
|
// TS doesn't allow symbol as index type
|
|
857
1135
|
return provides[key];
|
|
858
1136
|
}
|
|
859
1137
|
else if (arguments.length > 1) {
|
|
860
|
-
return defaultValue
|
|
1138
|
+
return treatDefaultAsFactory && isFunction(defaultValue)
|
|
1139
|
+
? defaultValue()
|
|
1140
|
+
: defaultValue;
|
|
861
1141
|
}
|
|
862
1142
|
else if ((process.env.NODE_ENV !== 'production')) {
|
|
863
1143
|
console.warn(`injection "${String(key)}" not found.`);
|
|
@@ -884,7 +1164,7 @@ function initInjections(instance) {
|
|
|
884
1164
|
for (const key in injectOptions) {
|
|
885
1165
|
const opt = injectOptions[key];
|
|
886
1166
|
if (isObject(opt)) {
|
|
887
|
-
ctx[key] = inject(internalInstance, opt.from, opt.default);
|
|
1167
|
+
ctx[key] = inject(internalInstance, opt.from || key, opt.default, true /* treat default function as factory */);
|
|
888
1168
|
}
|
|
889
1169
|
else {
|
|
890
1170
|
ctx[key] = inject(internalInstance, opt);
|
|
@@ -893,13 +1173,13 @@ function initInjections(instance) {
|
|
|
893
1173
|
}
|
|
894
1174
|
}
|
|
895
1175
|
|
|
896
|
-
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
1176
|
+
function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
|
|
897
1177
|
return {
|
|
898
1178
|
attached() {
|
|
899
1179
|
const properties = this.properties;
|
|
900
1180
|
initVueIds(properties.vueId, this);
|
|
901
1181
|
const relationOptions = {
|
|
902
|
-
vuePid: this._$vuePid
|
|
1182
|
+
vuePid: this._$vuePid,
|
|
903
1183
|
};
|
|
904
1184
|
// 初始化 vue 实例
|
|
905
1185
|
const mpInstance = this;
|
|
@@ -909,7 +1189,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
|
909
1189
|
}
|
|
910
1190
|
this.$vm = $createComponent({
|
|
911
1191
|
type: vueOptions,
|
|
912
|
-
props: properties
|
|
1192
|
+
props: properties,
|
|
913
1193
|
}, {
|
|
914
1194
|
mpType,
|
|
915
1195
|
mpInstance,
|
|
@@ -919,14 +1199,14 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
|
919
1199
|
initRefs(instance, mpInstance);
|
|
920
1200
|
initMocks(instance, mpInstance, mocks);
|
|
921
1201
|
initComponentInstance(instance, options);
|
|
922
|
-
}
|
|
1202
|
+
},
|
|
923
1203
|
});
|
|
924
1204
|
// 处理父子关系
|
|
925
1205
|
initRelation(this, relationOptions);
|
|
926
1206
|
},
|
|
927
1207
|
detached() {
|
|
928
1208
|
this.$vm && $destroyComponent(this.$vm);
|
|
929
|
-
}
|
|
1209
|
+
},
|
|
930
1210
|
};
|
|
931
1211
|
}
|
|
932
1212
|
|
|
@@ -935,16 +1215,16 @@ function parse(componentOptions, { handleLink }) {
|
|
|
935
1215
|
componentOptions.methods.__l = handleLink;
|
|
936
1216
|
}
|
|
937
1217
|
|
|
938
|
-
function initLifetimes
|
|
939
|
-
return extend(initLifetimes(lifetimesOptions), {
|
|
1218
|
+
function initLifetimes(lifetimesOptions) {
|
|
1219
|
+
return extend(initLifetimes$1(lifetimesOptions), {
|
|
940
1220
|
ready() {
|
|
941
1221
|
if (this.$vm && lifetimesOptions.isPage(this)) {
|
|
942
|
-
if (
|
|
1222
|
+
if (this.pageinstance) {
|
|
943
1223
|
this.__webviewId__ = this.pageinstance.__pageId__;
|
|
944
1224
|
}
|
|
945
|
-
this.$vm.$
|
|
1225
|
+
this.$vm.$callCreatedHook();
|
|
946
1226
|
this.$vm.$callHook('mounted');
|
|
947
|
-
this.$vm.$callHook(
|
|
1227
|
+
this.$vm.$callHook(ON_READY);
|
|
948
1228
|
}
|
|
949
1229
|
else {
|
|
950
1230
|
this.is && console.warn(this.is + ' is not ready');
|
|
@@ -955,12 +1235,12 @@ function initLifetimes$1(lifetimesOptions) {
|
|
|
955
1235
|
// 清理
|
|
956
1236
|
const webviewId = this.__webviewId__;
|
|
957
1237
|
webviewId &&
|
|
958
|
-
Object.keys(instances).forEach(key => {
|
|
1238
|
+
Object.keys(instances).forEach((key) => {
|
|
959
1239
|
if (key.indexOf(webviewId + '_') === 0) {
|
|
960
1240
|
delete instances[key];
|
|
961
1241
|
}
|
|
962
1242
|
});
|
|
963
|
-
}
|
|
1243
|
+
},
|
|
964
1244
|
});
|
|
965
1245
|
}
|
|
966
1246
|
|
|
@@ -976,10 +1256,10 @@ function initRelation(mpInstance) {
|
|
|
976
1256
|
instances[webviewId + '_' + nodeId] = mpInstance.$vm;
|
|
977
1257
|
mpInstance.triggerEvent('__l', {
|
|
978
1258
|
nodeId,
|
|
979
|
-
webviewId
|
|
1259
|
+
webviewId,
|
|
980
1260
|
});
|
|
981
1261
|
}
|
|
982
|
-
function handleLink({ detail: { nodeId, webviewId } }) {
|
|
1262
|
+
function handleLink({ detail: { nodeId, webviewId }, }) {
|
|
983
1263
|
const vm = instances[webviewId + '_' + nodeId];
|
|
984
1264
|
if (!vm) {
|
|
985
1265
|
return;
|
|
@@ -999,7 +1279,7 @@ function handleLink({ detail: { nodeId, webviewId } }) {
|
|
|
999
1279
|
initInjections(vm);
|
|
1000
1280
|
initProvide(vm);
|
|
1001
1281
|
}
|
|
1002
|
-
vm.$
|
|
1282
|
+
vm.$callCreatedHook();
|
|
1003
1283
|
};
|
|
1004
1284
|
const mountedVm = function () {
|
|
1005
1285
|
// 处理当前 vm 子
|
|
@@ -1009,7 +1289,7 @@ function handleLink({ detail: { nodeId, webviewId } }) {
|
|
|
1009
1289
|
delete vm._$childVues;
|
|
1010
1290
|
}
|
|
1011
1291
|
vm.$callHook('mounted');
|
|
1012
|
-
vm.$callHook(
|
|
1292
|
+
vm.$callHook(ON_READY);
|
|
1013
1293
|
};
|
|
1014
1294
|
// 当 parentVm 已经 mounted 时,直接触发,否则延迟
|
|
1015
1295
|
if (!parentVm || parentVm.$.isMounted) {
|
|
@@ -1019,33 +1299,37 @@ function handleLink({ detail: { nodeId, webviewId } }) {
|
|
|
1019
1299
|
else {
|
|
1020
1300
|
(parentVm._$childVues || (parentVm._$childVues = [])).push([
|
|
1021
1301
|
createdVm,
|
|
1022
|
-
mountedVm
|
|
1302
|
+
mountedVm,
|
|
1023
1303
|
]);
|
|
1024
1304
|
}
|
|
1025
1305
|
}
|
|
1026
1306
|
|
|
1027
1307
|
var parseComponentOptions = /*#__PURE__*/Object.freeze({
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1308
|
+
__proto__: null,
|
|
1309
|
+
initRelation: initRelation,
|
|
1310
|
+
handleLink: handleLink,
|
|
1311
|
+
mocks: mocks,
|
|
1312
|
+
isPage: isPage,
|
|
1313
|
+
parse: parse,
|
|
1314
|
+
initLifetimes: initLifetimes$1
|
|
1035
1315
|
});
|
|
1036
1316
|
|
|
1037
1317
|
var parsePageOptions = /*#__PURE__*/Object.freeze({
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1318
|
+
__proto__: null,
|
|
1319
|
+
mocks: mocks,
|
|
1320
|
+
isPage: isPage,
|
|
1321
|
+
initRelation: initRelation,
|
|
1322
|
+
handleLink: handleLink,
|
|
1323
|
+
parse: parse,
|
|
1324
|
+
initLifetimes: initLifetimes
|
|
1045
1325
|
});
|
|
1046
1326
|
|
|
1047
1327
|
const createApp = initCreateApp();
|
|
1048
1328
|
const createPage = initCreatePage(parsePageOptions);
|
|
1049
|
-
const createComponent = initCreateComponent(parseComponentOptions);
|
|
1329
|
+
const createComponent = initCreateComponent(parseComponentOptions);
|
|
1330
|
+
qa.EventChannel = EventChannel;
|
|
1331
|
+
qa.createApp = createApp;
|
|
1332
|
+
qa.createPage = createPage;
|
|
1333
|
+
qa.createComponent = createComponent;
|
|
1050
1334
|
|
|
1051
1335
|
export { createApp, createComponent, createPage };
|