@dcloudio/uni-quickapp-webview 3.0.0-4020920240930001 → 3.0.0-4030620241128001
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/uni.api.esm.js +75 -54
- package/dist/uni.compiler.js +40 -1
- package/dist/uni.mp.esm.js +160 -213
- package/license.md +1 -1
- package/package.json +8 -7
package/dist/uni.api.esm.js
CHANGED
|
@@ -351,30 +351,10 @@ function promisify$1(name, fn) {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
function formatApiArgs(args, options) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
!options.formatArgs ||
|
|
357
|
-
(!isPlainObject(options.formatArgs) && isPlainObject(params))) {
|
|
354
|
+
args[0];
|
|
355
|
+
{
|
|
358
356
|
return;
|
|
359
357
|
}
|
|
360
|
-
const formatArgs = options.formatArgs;
|
|
361
|
-
const keys = Object.keys(formatArgs);
|
|
362
|
-
for (let i = 0; i < keys.length; i++) {
|
|
363
|
-
const name = keys[i];
|
|
364
|
-
const formatterOrDefaultValue = formatArgs[name];
|
|
365
|
-
if (isFunction(formatterOrDefaultValue)) {
|
|
366
|
-
const errMsg = formatterOrDefaultValue(args[0][name], params);
|
|
367
|
-
if (isString(errMsg)) {
|
|
368
|
-
return errMsg;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
// defaultValue
|
|
373
|
-
if (!hasOwn(params, name)) {
|
|
374
|
-
params[name] = formatterOrDefaultValue;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
358
|
}
|
|
379
359
|
function invokeSuccess(id, name, res) {
|
|
380
360
|
const result = {
|
|
@@ -383,8 +363,20 @@ function invokeSuccess(id, name, res) {
|
|
|
383
363
|
return invokeCallback(id, extend((res || {}), result));
|
|
384
364
|
}
|
|
385
365
|
function invokeFail(id, name, errMsg, errRes = {}) {
|
|
386
|
-
const
|
|
387
|
-
|
|
366
|
+
const errMsgPrefix = name + ':fail';
|
|
367
|
+
let apiErrMsg = '';
|
|
368
|
+
if (!errMsg) {
|
|
369
|
+
apiErrMsg = errMsgPrefix;
|
|
370
|
+
}
|
|
371
|
+
else if (errMsg.indexOf(errMsgPrefix) === 0) {
|
|
372
|
+
apiErrMsg = errMsg;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
apiErrMsg = errMsgPrefix + ' ' + errMsg;
|
|
376
|
+
}
|
|
377
|
+
{
|
|
378
|
+
delete errRes.errCode;
|
|
379
|
+
}
|
|
388
380
|
let res = extend({ errMsg: apiErrMsg }, errRes);
|
|
389
381
|
return invokeCallback(id, res);
|
|
390
382
|
}
|
|
@@ -392,13 +384,7 @@ function beforeInvokeApi(name, args, protocol, options) {
|
|
|
392
384
|
if ((process.env.NODE_ENV !== 'production')) {
|
|
393
385
|
validateProtocols(name, args, protocol);
|
|
394
386
|
}
|
|
395
|
-
|
|
396
|
-
const errMsg = options.beforeInvoke(args);
|
|
397
|
-
if (isString(errMsg)) {
|
|
398
|
-
return errMsg;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const errMsg = formatApiArgs(args, options);
|
|
387
|
+
const errMsg = formatApiArgs(args);
|
|
402
388
|
if (errMsg) {
|
|
403
389
|
return errMsg;
|
|
404
390
|
}
|
|
@@ -408,7 +394,10 @@ function parseErrMsg(errMsg) {
|
|
|
408
394
|
return errMsg;
|
|
409
395
|
}
|
|
410
396
|
if (errMsg.stack) {
|
|
411
|
-
|
|
397
|
+
// 此处同时被鸿蒙arkts和jsvm使用,暂时使用运行时判断鸿蒙jsvm环境,注意此用法仅内部使用
|
|
398
|
+
if ((typeof globalThis === 'undefined' || !globalThis.harmonyChannel)) {
|
|
399
|
+
console.error(errMsg.message + '\n' + errMsg.stack);
|
|
400
|
+
}
|
|
412
401
|
return errMsg.message;
|
|
413
402
|
}
|
|
414
403
|
return errMsg;
|
|
@@ -416,7 +405,7 @@ function parseErrMsg(errMsg) {
|
|
|
416
405
|
function wrapperTaskApi(name, fn, protocol, options) {
|
|
417
406
|
return (args) => {
|
|
418
407
|
const id = createAsyncApiCallback(name, args, options);
|
|
419
|
-
const errMsg = beforeInvokeApi(name, [args], protocol
|
|
408
|
+
const errMsg = beforeInvokeApi(name, [args], protocol);
|
|
420
409
|
if (errMsg) {
|
|
421
410
|
return invokeFail(id, name, errMsg);
|
|
422
411
|
}
|
|
@@ -428,7 +417,7 @@ function wrapperTaskApi(name, fn, protocol, options) {
|
|
|
428
417
|
}
|
|
429
418
|
function wrapperSyncApi(name, fn, protocol, options) {
|
|
430
419
|
return (...args) => {
|
|
431
|
-
const errMsg = beforeInvokeApi(name, args, protocol
|
|
420
|
+
const errMsg = beforeInvokeApi(name, args, protocol);
|
|
432
421
|
if (errMsg) {
|
|
433
422
|
throw new Error(errMsg);
|
|
434
423
|
}
|
|
@@ -439,7 +428,7 @@ function wrapperAsyncApi(name, fn, protocol, options) {
|
|
|
439
428
|
return wrapperTaskApi(name, fn, protocol, options);
|
|
440
429
|
}
|
|
441
430
|
function defineSyncApi(name, fn, protocol, options) {
|
|
442
|
-
return wrapperSyncApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined
|
|
431
|
+
return wrapperSyncApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined);
|
|
443
432
|
}
|
|
444
433
|
function defineAsyncApi(name, fn, protocol, options) {
|
|
445
434
|
return promisify$1(name, wrapperAsyncApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options));
|
|
@@ -585,7 +574,7 @@ const OffProtocol = [
|
|
|
585
574
|
},
|
|
586
575
|
{
|
|
587
576
|
name: 'callback',
|
|
588
|
-
type: Function,
|
|
577
|
+
type: [Function, Number],
|
|
589
578
|
},
|
|
590
579
|
];
|
|
591
580
|
const API_EMIT = '$emit';
|
|
@@ -597,26 +586,44 @@ const EmitProtocol = [
|
|
|
597
586
|
},
|
|
598
587
|
];
|
|
599
588
|
|
|
600
|
-
|
|
589
|
+
class EventBus {
|
|
590
|
+
constructor() {
|
|
591
|
+
this.$emitter = new Emitter();
|
|
592
|
+
}
|
|
593
|
+
on(name, callback) {
|
|
594
|
+
return this.$emitter.on(name, callback);
|
|
595
|
+
}
|
|
596
|
+
once(name, callback) {
|
|
597
|
+
return this.$emitter.once(name, callback);
|
|
598
|
+
}
|
|
599
|
+
off(name, callback) {
|
|
600
|
+
if (!name) {
|
|
601
|
+
this.$emitter.e = {};
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
this.$emitter.off(name, callback);
|
|
605
|
+
}
|
|
606
|
+
emit(name, ...args) {
|
|
607
|
+
this.$emitter.emit(name, ...args);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const eventBus = new EventBus();
|
|
601
611
|
const $on = defineSyncApi(API_ON, (name, callback) => {
|
|
602
|
-
|
|
603
|
-
return () =>
|
|
612
|
+
eventBus.on(name, callback);
|
|
613
|
+
return () => eventBus.off(name, callback);
|
|
604
614
|
}, OnProtocol);
|
|
605
615
|
const $once = defineSyncApi(API_ONCE, (name, callback) => {
|
|
606
|
-
|
|
607
|
-
return () =>
|
|
616
|
+
eventBus.once(name, callback);
|
|
617
|
+
return () => eventBus.off(name, callback);
|
|
608
618
|
}, OnceProtocol);
|
|
609
619
|
const $off = defineSyncApi(API_OFF, (name, callback) => {
|
|
610
|
-
|
|
611
|
-
emitter.e = {};
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
620
|
+
// 类型中不再体现 name 支持 string[] 类型, 仅在 uni.$off 保留该逻辑向下兼容
|
|
614
621
|
if (!isArray(name))
|
|
615
|
-
name = [name];
|
|
616
|
-
name.forEach((n) =>
|
|
622
|
+
name = name ? [name] : [];
|
|
623
|
+
name.forEach((n) => eventBus.off(n, callback));
|
|
617
624
|
}, OffProtocol);
|
|
618
625
|
const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
|
|
619
|
-
|
|
626
|
+
eventBus.emit(name, ...args);
|
|
620
627
|
}, EmitProtocol);
|
|
621
628
|
|
|
622
629
|
let cid;
|
|
@@ -913,16 +920,28 @@ function addSafeAreaInsets(fromRes, toRes) {
|
|
|
913
920
|
};
|
|
914
921
|
}
|
|
915
922
|
}
|
|
916
|
-
function
|
|
917
|
-
const { brand = '', model = '', system = '', language = '', theme, version, platform, fontSizeSetting, SDKVersion, pixelRatio, deviceOrientation, } = fromRes;
|
|
918
|
-
// const isQuickApp = "quickapp-webview".indexOf('quickapp-webview') !== -1
|
|
919
|
-
// osName osVersion
|
|
923
|
+
function getOSInfo(system, platform) {
|
|
920
924
|
let osName = '';
|
|
921
925
|
let osVersion = '';
|
|
922
|
-
|
|
926
|
+
if (platform &&
|
|
927
|
+
("quickapp-webview" === 'mp-baidu')) {
|
|
928
|
+
osName = platform;
|
|
929
|
+
osVersion = system;
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
923
932
|
osName = system.split(' ')[0] || '';
|
|
924
933
|
osVersion = system.split(' ')[1] || '';
|
|
925
934
|
}
|
|
935
|
+
return {
|
|
936
|
+
osName: osName.toLocaleLowerCase(),
|
|
937
|
+
osVersion,
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
function populateParameters(fromRes, toRes) {
|
|
941
|
+
const { brand = '', model = '', system = '', language = '', theme, version, platform, fontSizeSetting, SDKVersion, pixelRatio, deviceOrientation, } = fromRes;
|
|
942
|
+
// const isQuickApp = "quickapp-webview".indexOf('quickapp-webview') !== -1
|
|
943
|
+
// osName osVersion
|
|
944
|
+
const { osName, osVersion } = getOSInfo(system, platform);
|
|
926
945
|
let hostVersion = version;
|
|
927
946
|
// deviceType
|
|
928
947
|
let deviceType = getGetDeviceType(fromRes, model);
|
|
@@ -946,6 +965,7 @@ function populateParameters(fromRes, toRes) {
|
|
|
946
965
|
appVersionCode: process.env.UNI_APP_VERSION_CODE,
|
|
947
966
|
appLanguage: getAppLanguage(hostLanguage),
|
|
948
967
|
uniCompileVersion: process.env.UNI_COMPILER_VERSION,
|
|
968
|
+
uniCompilerVersion: process.env.UNI_COMPILER_VERSION,
|
|
949
969
|
uniRuntimeVersion: process.env.UNI_COMPILER_VERSION,
|
|
950
970
|
uniPlatform: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM,
|
|
951
971
|
deviceBrand,
|
|
@@ -953,7 +973,7 @@ function populateParameters(fromRes, toRes) {
|
|
|
953
973
|
deviceType,
|
|
954
974
|
devicePixelRatio: _devicePixelRatio,
|
|
955
975
|
deviceOrientation: _deviceOrientation,
|
|
956
|
-
osName
|
|
976
|
+
osName,
|
|
957
977
|
osVersion,
|
|
958
978
|
hostTheme: theme,
|
|
959
979
|
hostVersion,
|
|
@@ -970,6 +990,7 @@ function populateParameters(fromRes, toRes) {
|
|
|
970
990
|
hostPackageName: undefined,
|
|
971
991
|
browserName: undefined,
|
|
972
992
|
browserVersion: undefined,
|
|
993
|
+
isUniAppX: false,
|
|
973
994
|
};
|
|
974
995
|
extend(toRes, parameters);
|
|
975
996
|
}
|
package/dist/uni.compiler.js
CHANGED
|
@@ -63,10 +63,27 @@ const miniProgram = {
|
|
|
63
63
|
array: true,
|
|
64
64
|
},
|
|
65
65
|
slot: {
|
|
66
|
-
fallbackContent:
|
|
66
|
+
fallbackContent: false,
|
|
67
67
|
dynamicSlotNames: true,
|
|
68
68
|
},
|
|
69
69
|
directive: 'qa:',
|
|
70
|
+
checkPropName(name, prop) {
|
|
71
|
+
// 快应用不允许使用 key 属性,应该还有很多其他保留字,目前先简单处理
|
|
72
|
+
// ERROR: Unexpected JavaScript keyword as attribute name: 'key', please change it.
|
|
73
|
+
if (name === 'key') {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (name === 'bind' &&
|
|
77
|
+
prop.type === /*NodeTypes.DIRECTIVE*/ 7 &&
|
|
78
|
+
prop.arg) {
|
|
79
|
+
if (prop.arg.type === /*NodeTypes.SIMPLE_EXPRESSION*/ 4) {
|
|
80
|
+
if (prop.arg.content === 'key') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
},
|
|
70
87
|
};
|
|
71
88
|
const projectConfigFilename = 'jsconfig.json';
|
|
72
89
|
const options = {
|
|
@@ -111,6 +128,7 @@ ${filter.code}
|
|
|
111
128
|
},
|
|
112
129
|
};
|
|
113
130
|
|
|
131
|
+
let quickappConfigJson = false;
|
|
114
132
|
const uniQuickappWebviewPlugin = {
|
|
115
133
|
name: 'uni:quickapp-webview',
|
|
116
134
|
config() {
|
|
@@ -124,6 +142,27 @@ const uniQuickappWebviewPlugin = {
|
|
|
124
142
|
},
|
|
125
143
|
};
|
|
126
144
|
},
|
|
145
|
+
generateBundle(_, bundle) {
|
|
146
|
+
if (process.env.UNI_SUB_PLATFORM === 'quickapp-webview-huawei') {
|
|
147
|
+
if (quickappConfigJson) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
quickappConfigJson = true;
|
|
151
|
+
bundle['quickapp.config.json'] = {
|
|
152
|
+
type: 'asset',
|
|
153
|
+
fileName: 'quickapp.config.json',
|
|
154
|
+
originalFileName: 'quickapp.config.json',
|
|
155
|
+
name: 'quickapp.config.json',
|
|
156
|
+
source: JSON.stringify({
|
|
157
|
+
quickappRoot: './',
|
|
158
|
+
packOptions: {
|
|
159
|
+
ignore: [],
|
|
160
|
+
},
|
|
161
|
+
}),
|
|
162
|
+
needsCodeReference: false,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
},
|
|
127
166
|
};
|
|
128
167
|
var index = [uniQuickappWebviewPlugin, ...initMiniProgramPlugin__default.default(options)];
|
|
129
168
|
|
package/dist/uni.mp.esm.js
CHANGED
|
@@ -1,8 +1,91 @@
|
|
|
1
1
|
import { SLOT_DEFAULT_NAME, EventChannel, invokeArrayFns, MINI_PROGRAM_PAGE_RUNTIME_HOOKS, ON_LOAD, ON_SHOW, ON_HIDE, ON_UNLOAD, ON_RESIZE, ON_TAB_ITEM_TAP, ON_REACH_BOTTOM, ON_PULL_DOWN_REFRESH, ON_ADD_TO_FAVORITES, isUniLifecycleHook, ON_READY, once, ON_LAUNCH, ON_ERROR, ON_THEME_CHANGE, ON_PAGE_NOT_FOUND, ON_UNHANDLE_REJECTION, addLeadingSlash, stringifyQuery, customizeEvent } from '@dcloudio/uni-shared';
|
|
2
|
-
import { isArray, isFunction,
|
|
3
|
-
import {
|
|
2
|
+
import { hasOwn, isArray, isFunction, extend, isPlainObject, isObject } from '@vue/shared';
|
|
3
|
+
import { nextTick, ref, findComponentPropsData, toRaw, updateProps, hasQueueJob, invalidateJob, devtoolsComponentAdded, getExposeProxy, pruneComponentPropsCache } from 'vue';
|
|
4
4
|
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
|
|
5
5
|
|
|
6
|
+
function initVueIds(vueIds, mpInstance) {
|
|
7
|
+
if (!vueIds) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const ids = vueIds.split(',');
|
|
11
|
+
const len = ids.length;
|
|
12
|
+
if (len === 1) {
|
|
13
|
+
mpInstance._$vueId = ids[0];
|
|
14
|
+
}
|
|
15
|
+
else if (len === 2) {
|
|
16
|
+
mpInstance._$vueId = ids[0];
|
|
17
|
+
mpInstance._$vuePid = ids[1];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const EXTRAS = ['externalClasses'];
|
|
21
|
+
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
|
22
|
+
EXTRAS.forEach((name) => {
|
|
23
|
+
if (hasOwn(vueOptions, name)) {
|
|
24
|
+
miniProgramComponentOptions[name] = vueOptions[name];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
29
|
+
if (!isArray(wxsCallMethods)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
wxsCallMethods.forEach((callMethod) => {
|
|
33
|
+
methods[callMethod] = function (args) {
|
|
34
|
+
return this.$vm[callMethod](args);
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function selectAllComponents(mpInstance, selector, $refs) {
|
|
39
|
+
const components = mpInstance.selectAllComponents(selector);
|
|
40
|
+
components.forEach((component) => {
|
|
41
|
+
const ref = component.properties.uR;
|
|
42
|
+
$refs[ref] = component.$vm || component;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function initRefs(instance, mpInstance) {
|
|
46
|
+
Object.defineProperty(instance, 'refs', {
|
|
47
|
+
get() {
|
|
48
|
+
const $refs = {};
|
|
49
|
+
selectAllComponents(mpInstance, '.r', $refs);
|
|
50
|
+
const forComponents = mpInstance.selectAllComponents('.r-i-f');
|
|
51
|
+
forComponents.forEach((component) => {
|
|
52
|
+
const ref = component.properties.uR;
|
|
53
|
+
if (!ref) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!$refs[ref]) {
|
|
57
|
+
$refs[ref] = [];
|
|
58
|
+
}
|
|
59
|
+
$refs[ref].push(component.$vm || component);
|
|
60
|
+
});
|
|
61
|
+
return $refs;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function nextSetDataTick(mpInstance, fn) {
|
|
66
|
+
// 随便设置一个字段来触发回调(部分平台必须有字段才可以,比如头条)
|
|
67
|
+
mpInstance.setData({ r1: 1 }, () => fn());
|
|
68
|
+
}
|
|
69
|
+
function initSetRef(mpInstance) {
|
|
70
|
+
if (!mpInstance._$setRef) {
|
|
71
|
+
mpInstance._$setRef = (fn) => {
|
|
72
|
+
nextTick(() => nextSetDataTick(mpInstance, fn));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let triggerEventId = 0;
|
|
77
|
+
const triggerEventDetails = {};
|
|
78
|
+
function wrapTriggerEventArgs(detail, options) {
|
|
79
|
+
triggerEventId++;
|
|
80
|
+
triggerEventDetails[triggerEventId] = detail;
|
|
81
|
+
return [triggerEventId, options];
|
|
82
|
+
}
|
|
83
|
+
function getTriggerEventDetail(eventId) {
|
|
84
|
+
const detail = triggerEventDetails[eventId];
|
|
85
|
+
delete triggerEventDetails[eventId];
|
|
86
|
+
return detail;
|
|
87
|
+
}
|
|
88
|
+
|
|
6
89
|
const MP_METHODS = [
|
|
7
90
|
'createSelectorQuery',
|
|
8
91
|
'createIntersectionObserver',
|
|
@@ -28,6 +111,9 @@ function initBaseInstance(instance, options) {
|
|
|
28
111
|
ctx.$mpType = options.mpType;
|
|
29
112
|
ctx.$mpPlatform = "quickapp-webview";
|
|
30
113
|
ctx.$scope = options.mpInstance;
|
|
114
|
+
{
|
|
115
|
+
ctx.$getTriggerEventDetail = getTriggerEventDetail;
|
|
116
|
+
}
|
|
31
117
|
// TODO @deprecated
|
|
32
118
|
ctx.$mp = {};
|
|
33
119
|
if (__VUE_OPTIONS_API__) {
|
|
@@ -205,8 +291,9 @@ function parseApp(instance, parseAppOptions) {
|
|
|
205
291
|
onLaunch(options) {
|
|
206
292
|
this.$vm = instance; // 飞书小程序可能会把 AppOptions 序列化,导致 $vm 对象部分属性丢失
|
|
207
293
|
const ctx = internalInstance.ctx;
|
|
208
|
-
if (this.$vm && ctx.$scope) {
|
|
294
|
+
if (this.$vm && ctx.$scope && ctx.$callHook) {
|
|
209
295
|
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
|
|
296
|
+
// $scope值在微信小程序混合分包情况下存在,额外用$callHook兼容判断处理
|
|
210
297
|
return;
|
|
211
298
|
}
|
|
212
299
|
initBaseInstance(internalInstance, {
|
|
@@ -232,19 +319,16 @@ function parseApp(instance, parseAppOptions) {
|
|
|
232
319
|
const methods = vueOptions.methods;
|
|
233
320
|
methods && extend(appOptions, methods);
|
|
234
321
|
}
|
|
235
|
-
if (parseAppOptions) {
|
|
236
|
-
parseAppOptions.parse(appOptions);
|
|
237
|
-
}
|
|
238
322
|
return appOptions;
|
|
239
323
|
}
|
|
240
324
|
function initCreateApp(parseAppOptions) {
|
|
241
325
|
return function createApp(vm) {
|
|
242
|
-
return App(parseApp(vm
|
|
326
|
+
return App(parseApp(vm));
|
|
243
327
|
};
|
|
244
328
|
}
|
|
245
329
|
function initCreateSubpackageApp(parseAppOptions) {
|
|
246
330
|
return function createApp(vm) {
|
|
247
|
-
const appOptions = parseApp(vm
|
|
331
|
+
const appOptions = parseApp(vm);
|
|
248
332
|
const app = isFunction(getApp) &&
|
|
249
333
|
getApp({
|
|
250
334
|
allowDefault: true,
|
|
@@ -301,77 +385,6 @@ function initLocale(appVm) {
|
|
|
301
385
|
});
|
|
302
386
|
}
|
|
303
387
|
|
|
304
|
-
function initVueIds(vueIds, mpInstance) {
|
|
305
|
-
if (!vueIds) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
const ids = vueIds.split(',');
|
|
309
|
-
const len = ids.length;
|
|
310
|
-
if (len === 1) {
|
|
311
|
-
mpInstance._$vueId = ids[0];
|
|
312
|
-
}
|
|
313
|
-
else if (len === 2) {
|
|
314
|
-
mpInstance._$vueId = ids[0];
|
|
315
|
-
mpInstance._$vuePid = ids[1];
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const EXTRAS = ['externalClasses'];
|
|
319
|
-
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
|
320
|
-
EXTRAS.forEach((name) => {
|
|
321
|
-
if (hasOwn(vueOptions, name)) {
|
|
322
|
-
miniProgramComponentOptions[name] = vueOptions[name];
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
327
|
-
if (!isArray(wxsCallMethods)) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
wxsCallMethods.forEach((callMethod) => {
|
|
331
|
-
methods[callMethod] = function (args) {
|
|
332
|
-
return this.$vm[callMethod](args);
|
|
333
|
-
};
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
function selectAllComponents(mpInstance, selector, $refs) {
|
|
337
|
-
const components = mpInstance.selectAllComponents(selector);
|
|
338
|
-
components.forEach((component) => {
|
|
339
|
-
const ref = component.properties.uR;
|
|
340
|
-
$refs[ref] = component.$vm || component;
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
function initRefs(instance, mpInstance) {
|
|
344
|
-
Object.defineProperty(instance, 'refs', {
|
|
345
|
-
get() {
|
|
346
|
-
const $refs = {};
|
|
347
|
-
selectAllComponents(mpInstance, '.r', $refs);
|
|
348
|
-
const forComponents = mpInstance.selectAllComponents('.r-i-f');
|
|
349
|
-
forComponents.forEach((component) => {
|
|
350
|
-
const ref = component.properties.uR;
|
|
351
|
-
if (!ref) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
if (!$refs[ref]) {
|
|
355
|
-
$refs[ref] = [];
|
|
356
|
-
}
|
|
357
|
-
$refs[ref].push(component.$vm || component);
|
|
358
|
-
});
|
|
359
|
-
return $refs;
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
function nextSetDataTick(mpInstance, fn) {
|
|
364
|
-
// 随便设置一个字段来触发回调(部分平台必须有字段才可以,比如头条)
|
|
365
|
-
mpInstance.setData({ r1: 1 }, () => fn());
|
|
366
|
-
}
|
|
367
|
-
function initSetRef(mpInstance) {
|
|
368
|
-
if (!mpInstance._$setRef) {
|
|
369
|
-
mpInstance._$setRef = (fn) => {
|
|
370
|
-
nextTick(() => nextSetDataTick(mpInstance, fn));
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
388
|
const builtInProps = [
|
|
376
389
|
// 百度小程序,快手小程序自定义组件不支持绑定动态事件,动态dataset,故通过props传递事件信息
|
|
377
390
|
// event-opts
|
|
@@ -400,20 +413,23 @@ function initDefaultProps(options, isBehavior = false) {
|
|
|
400
413
|
};
|
|
401
414
|
});
|
|
402
415
|
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
|
|
416
|
+
function observerSlots(newVal) {
|
|
417
|
+
const $slots = Object.create(null);
|
|
418
|
+
newVal &&
|
|
419
|
+
newVal.forEach((slotName) => {
|
|
420
|
+
$slots[slotName] = true;
|
|
421
|
+
});
|
|
422
|
+
this.setData({
|
|
423
|
+
$slots,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
403
426
|
properties.uS = {
|
|
404
427
|
type: null,
|
|
405
428
|
value: [],
|
|
406
|
-
observer: function (newVal) {
|
|
407
|
-
const $slots = Object.create(null);
|
|
408
|
-
newVal &&
|
|
409
|
-
newVal.forEach((slotName) => {
|
|
410
|
-
$slots[slotName] = true;
|
|
411
|
-
});
|
|
412
|
-
this.setData({
|
|
413
|
-
$slots,
|
|
414
|
-
});
|
|
415
|
-
},
|
|
416
429
|
};
|
|
430
|
+
{
|
|
431
|
+
properties.uS.observer = observerSlots;
|
|
432
|
+
}
|
|
417
433
|
}
|
|
418
434
|
if (options.behaviors) {
|
|
419
435
|
// wx://form-field
|
|
@@ -503,14 +519,14 @@ function initPageProps({ properties }, rawProps) {
|
|
|
503
519
|
function findPropsData(properties, isPage) {
|
|
504
520
|
return ((isPage
|
|
505
521
|
? findPagePropsData(properties)
|
|
506
|
-
: findComponentPropsData(properties.uP)) || {});
|
|
522
|
+
: findComponentPropsData(resolvePropValue(properties.uP))) || {});
|
|
507
523
|
}
|
|
508
524
|
function findPagePropsData(properties) {
|
|
509
525
|
const propsData = {};
|
|
510
526
|
if (isPlainObject(properties)) {
|
|
511
527
|
Object.keys(properties).forEach((name) => {
|
|
512
528
|
if (builtInProps.indexOf(name) === -1) {
|
|
513
|
-
propsData[name] = properties[name];
|
|
529
|
+
propsData[name] = resolvePropValue(properties[name]);
|
|
514
530
|
}
|
|
515
531
|
});
|
|
516
532
|
}
|
|
@@ -532,6 +548,9 @@ function initFormField(vm) {
|
|
|
532
548
|
});
|
|
533
549
|
}
|
|
534
550
|
}
|
|
551
|
+
function resolvePropValue(prop) {
|
|
552
|
+
return prop;
|
|
553
|
+
}
|
|
535
554
|
|
|
536
555
|
function initData(_) {
|
|
537
556
|
return {};
|
|
@@ -543,11 +562,11 @@ function initPropsObserver(componentOptions) {
|
|
|
543
562
|
return;
|
|
544
563
|
}
|
|
545
564
|
if (this.$vm) {
|
|
546
|
-
updateComponentProps(up, this.$vm.$);
|
|
565
|
+
updateComponentProps(resolvePropValue(up), this.$vm.$);
|
|
547
566
|
}
|
|
548
|
-
else if (this.properties.uT === 'm') {
|
|
567
|
+
else if (resolvePropValue(this.properties.uT) === 'm') {
|
|
549
568
|
// 小程序组件
|
|
550
|
-
updateMiniProgramComponentProperties(up, this);
|
|
569
|
+
updateMiniProgramComponentProperties(resolvePropValue(up), this);
|
|
551
570
|
}
|
|
552
571
|
};
|
|
553
572
|
{
|
|
@@ -742,7 +761,18 @@ const MPComponent = Component;
|
|
|
742
761
|
function initTriggerEvent(mpInstance) {
|
|
743
762
|
const oldTriggerEvent = mpInstance.triggerEvent;
|
|
744
763
|
const newTriggerEvent = function (event, ...args) {
|
|
745
|
-
|
|
764
|
+
{
|
|
765
|
+
if (event !== '__l' && event !== '__e') {
|
|
766
|
+
// 忽略 handleLink,还有其他内置事件吗?
|
|
767
|
+
// triggerEvent的参数被序列化,导致vue的响应式数据对比始终不相等,从而陷入死循环
|
|
768
|
+
// 比如 uni-ui 的 collapse 组件的v-model
|
|
769
|
+
args = wrapTriggerEventArgs(args[0], args[1]);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return oldTriggerEvent.apply(mpInstance, [
|
|
773
|
+
customizeEvent(event),
|
|
774
|
+
...args,
|
|
775
|
+
]);
|
|
746
776
|
};
|
|
747
777
|
// 京东小程序triggerEvent为只读属性
|
|
748
778
|
try {
|
|
@@ -781,114 +811,12 @@ Component = function (options) {
|
|
|
781
811
|
return MPComponent(options);
|
|
782
812
|
};
|
|
783
813
|
|
|
784
|
-
function provide(instance, key, value) {
|
|
785
|
-
if (!instance) {
|
|
786
|
-
if ((process.env.NODE_ENV !== 'production')) {
|
|
787
|
-
console.warn(`provide() can only be used inside setup().`);
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
else {
|
|
791
|
-
let provides = instance.provides;
|
|
792
|
-
// by default an instance inherits its parent's provides object
|
|
793
|
-
// but when it needs to provide values of its own, it creates its
|
|
794
|
-
// own provides object using parent provides object as prototype.
|
|
795
|
-
// this way in `inject` we can simply look up injections from direct
|
|
796
|
-
// parent and let the prototype chain do the work.
|
|
797
|
-
const parentProvides = instance.parent && instance.parent.provides;
|
|
798
|
-
if (parentProvides === provides) {
|
|
799
|
-
provides = instance.provides = Object.create(parentProvides);
|
|
800
|
-
}
|
|
801
|
-
// TS doesn't allow symbol as index type
|
|
802
|
-
provides[key] = value;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
function initProvide(instance) {
|
|
806
|
-
const provideOptions = instance.$options.provide;
|
|
807
|
-
if (!provideOptions) {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
const provides = isFunction(provideOptions)
|
|
811
|
-
? provideOptions.call(instance)
|
|
812
|
-
: provideOptions;
|
|
813
|
-
const internalInstance = instance.$;
|
|
814
|
-
for (const key in provides) {
|
|
815
|
-
provide(internalInstance, key, provides[key]);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
function inject(instance, key, defaultValue, treatDefaultAsFactory = false) {
|
|
819
|
-
if (instance) {
|
|
820
|
-
// #2400
|
|
821
|
-
// to support `app.use` plugins,
|
|
822
|
-
// fallback to appContext's `provides` if the intance is at root
|
|
823
|
-
const provides = instance.parent == null
|
|
824
|
-
? instance.vnode.appContext && instance.vnode.appContext.provides
|
|
825
|
-
: instance.parent.provides;
|
|
826
|
-
if (provides && key in provides) {
|
|
827
|
-
// TS doesn't allow symbol as index type
|
|
828
|
-
return provides[key];
|
|
829
|
-
}
|
|
830
|
-
else if (arguments.length > 1) {
|
|
831
|
-
return treatDefaultAsFactory && isFunction(defaultValue)
|
|
832
|
-
? defaultValue()
|
|
833
|
-
: defaultValue;
|
|
834
|
-
}
|
|
835
|
-
else if ((process.env.NODE_ENV !== 'production')) {
|
|
836
|
-
console.warn(`injection "${String(key)}" not found.`);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
else if ((process.env.NODE_ENV !== 'production')) {
|
|
840
|
-
console.warn(`inject() can only be used inside setup() or functional components.`);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
function initInjections(instance) {
|
|
844
|
-
const injectOptions = instance.$options.inject;
|
|
845
|
-
if (!injectOptions) {
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
const internalInstance = instance.$;
|
|
849
|
-
const ctx = internalInstance.ctx;
|
|
850
|
-
if (isArray(injectOptions)) {
|
|
851
|
-
for (let i = 0; i < injectOptions.length; i++) {
|
|
852
|
-
const key = injectOptions[i];
|
|
853
|
-
ctx[key] = inject(internalInstance, key);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
else {
|
|
857
|
-
for (const key in injectOptions) {
|
|
858
|
-
const opt = injectOptions[key];
|
|
859
|
-
let injected;
|
|
860
|
-
if (isObject(opt)) {
|
|
861
|
-
if ('default' in opt) {
|
|
862
|
-
injected = inject(internalInstance, opt.from || key, opt.default, true /* treat default function as factory */);
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
injected = inject(internalInstance, opt.from || key);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
injected = inject(internalInstance, opt);
|
|
870
|
-
}
|
|
871
|
-
if (isRef(injected)) {
|
|
872
|
-
Object.defineProperty(ctx, key, {
|
|
873
|
-
enumerable: true,
|
|
874
|
-
configurable: true,
|
|
875
|
-
get: () => injected.value,
|
|
876
|
-
set: (v) => (injected.value = v),
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
else {
|
|
880
|
-
ctx[key] = injected;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
814
|
// @ts-expect-error
|
|
887
815
|
function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
|
|
888
816
|
function attached() {
|
|
889
817
|
initSetRef(this);
|
|
890
818
|
const properties = this.properties;
|
|
891
|
-
initVueIds(properties.uI, this);
|
|
819
|
+
initVueIds(resolvePropValue(properties.uI), this);
|
|
892
820
|
const relationOptions = {
|
|
893
821
|
vuePid: this._$vuePid,
|
|
894
822
|
};
|
|
@@ -905,7 +833,7 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
|
|
|
905
833
|
}, {
|
|
906
834
|
mpType,
|
|
907
835
|
mpInstance,
|
|
908
|
-
slots: properties.uS || {}, // vueSlots
|
|
836
|
+
slots: resolvePropValue(properties.uS) || {}, // vueSlots
|
|
909
837
|
parentComponent: relationOptions.parent && relationOptions.parent.$,
|
|
910
838
|
onBeforeSetup(instance, options) {
|
|
911
839
|
initRefs(instance, mpInstance);
|
|
@@ -913,15 +841,18 @@ function initLifetimes$1({ mocks, isPage, initRelation, vueOptions, }) {
|
|
|
913
841
|
initComponentInstance(instance, options);
|
|
914
842
|
},
|
|
915
843
|
});
|
|
844
|
+
if (process.env.UNI_DEBUG) {
|
|
845
|
+
console.log('uni-app:[' +
|
|
846
|
+
Date.now() +
|
|
847
|
+
'][' +
|
|
848
|
+
(mpInstance.is || mpInstance.route) +
|
|
849
|
+
'][' +
|
|
850
|
+
this.$vm.$.uid +
|
|
851
|
+
']attached');
|
|
852
|
+
}
|
|
916
853
|
if (mpType === 'component') {
|
|
917
854
|
initFormField(this.$vm);
|
|
918
855
|
}
|
|
919
|
-
if (mpType === 'page') {
|
|
920
|
-
if (__VUE_OPTIONS_API__) {
|
|
921
|
-
initInjections(this.$vm);
|
|
922
|
-
initProvide(this.$vm);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
856
|
// 处理父子关系
|
|
926
857
|
initRelation(this, relationOptions);
|
|
927
858
|
}
|
|
@@ -948,8 +879,20 @@ function initLifetimes(lifetimesOptions) {
|
|
|
948
879
|
if (this.pageinstance) {
|
|
949
880
|
this.__webviewId__ = this.pageinstance.__pageId__;
|
|
950
881
|
}
|
|
882
|
+
if (process.env.UNI_DEBUG) {
|
|
883
|
+
console.log('uni-app:[' + Date.now() + '][' + (this.is || this.route) + ']ready');
|
|
884
|
+
}
|
|
951
885
|
this.$vm.$callCreatedHook();
|
|
952
886
|
nextSetDataTick(this, () => {
|
|
887
|
+
{
|
|
888
|
+
const vm = this.$vm;
|
|
889
|
+
// 处理当前 vm 子
|
|
890
|
+
if (vm._$childVues) {
|
|
891
|
+
vm._$childVues.forEach(([createdVm]) => createdVm());
|
|
892
|
+
vm._$childVues.forEach(([, mountedVm]) => mountedVm());
|
|
893
|
+
delete vm._$childVues;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
953
896
|
this.$vm.$callHook('mounted');
|
|
954
897
|
this.$vm.$callHook(ON_READY);
|
|
955
898
|
});
|
|
@@ -973,10 +916,11 @@ function initLifetimes(lifetimesOptions) {
|
|
|
973
916
|
}
|
|
974
917
|
|
|
975
918
|
const mocks = ['nodeId', 'componentName', '_componentId', 'uniquePrefix'];
|
|
919
|
+
|
|
976
920
|
function isPage(mpInstance) {
|
|
977
|
-
return !!mpInstance.
|
|
921
|
+
return (!!mpInstance.route ||
|
|
922
|
+
!!(mpInstance._methods || mpInstance.methods || mpInstance).onLoad);
|
|
978
923
|
}
|
|
979
|
-
|
|
980
924
|
function initRelation(mpInstance) {
|
|
981
925
|
// triggerEvent 后,接收事件时机特别晚,已经到了 ready 之后
|
|
982
926
|
const nodeId = mpInstance.nodeId + '';
|
|
@@ -1000,12 +944,15 @@ function handleLink({ detail: { nodeId, webviewId }, }) {
|
|
|
1000
944
|
const createdVm = function () {
|
|
1001
945
|
if (__VUE_OPTIONS_API__) {
|
|
1002
946
|
parentVm.$children.push(vm);
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
947
|
+
}
|
|
948
|
+
if (process.env.UNI_DEBUG) {
|
|
949
|
+
console.log('uni-app:[' +
|
|
950
|
+
Date.now() +
|
|
951
|
+
'][' +
|
|
952
|
+
(vm.$scope.is || vm.$scope.route) +
|
|
953
|
+
'][' +
|
|
954
|
+
vm.$.uid +
|
|
955
|
+
']created');
|
|
1009
956
|
}
|
|
1010
957
|
vm.$callCreatedHook();
|
|
1011
958
|
};
|
package/license.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[https://
|
|
1
|
+
[https://dcloud.io/license/uni-app.html](https://dcloud.io/license/uni-app.html)
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-quickapp-webview",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-4030620241128001",
|
|
4
4
|
"description": "uni-app quickapp-webview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
|
-
"dist"
|
|
7
|
+
"dist",
|
|
8
|
+
"dist-x"
|
|
8
9
|
],
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -25,13 +26,13 @@
|
|
|
25
26
|
},
|
|
26
27
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@dcloudio/uni-mp-compiler": "3.0.0-
|
|
29
|
+
"@dcloudio/uni-mp-compiler": "3.0.0-4030620241128001"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@dcloudio/uni-cli-shared": "3.0.0-
|
|
32
|
-
"@dcloudio/uni-mp-vite": "3.0.0-
|
|
33
|
-
"@dcloudio/uni-mp-vue": "3.0.0-
|
|
34
|
-
"@dcloudio/uni-shared": "3.0.0-
|
|
32
|
+
"@dcloudio/uni-cli-shared": "3.0.0-4030620241128001",
|
|
33
|
+
"@dcloudio/uni-mp-vite": "3.0.0-4030620241128001",
|
|
34
|
+
"@dcloudio/uni-mp-vue": "3.0.0-4030620241128001",
|
|
35
|
+
"@dcloudio/uni-shared": "3.0.0-4030620241128001",
|
|
35
36
|
"@vue/shared": "3.4.21"
|
|
36
37
|
}
|
|
37
38
|
}
|