@dcloudio/uni-quickapp-webview 3.0.0-alpha-3030820220114006 → 3.0.0-alpha-3030820220114008
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 +95 -1
- package/package.json +7 -7
package/dist/uni.api.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap,
|
|
1
|
+
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
|
|
2
2
|
import { injectHook } from 'vue';
|
|
3
3
|
|
|
4
4
|
//App
|
|
@@ -189,6 +189,30 @@ function isBoolean(...args) {
|
|
|
189
189
|
return args.some((elem) => elem.toLowerCase() === 'boolean');
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
function tryCatch(fn) {
|
|
193
|
+
return function () {
|
|
194
|
+
try {
|
|
195
|
+
return fn.apply(fn, arguments);
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
// TODO
|
|
199
|
+
console.error(e);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function getApiCallbacks(args) {
|
|
205
|
+
const apiCallbacks = {};
|
|
206
|
+
for (const name in args) {
|
|
207
|
+
const fn = args[name];
|
|
208
|
+
if (isFunction(fn)) {
|
|
209
|
+
apiCallbacks[name] = tryCatch(fn);
|
|
210
|
+
delete args[name];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return apiCallbacks;
|
|
214
|
+
}
|
|
215
|
+
|
|
192
216
|
const HOOK_SUCCESS = 'success';
|
|
193
217
|
const HOOK_FAIL = 'fail';
|
|
194
218
|
const HOOK_COMPLETE = 'complete';
|
|
@@ -584,6 +608,72 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
|
|
|
584
608
|
emitter.emit(name, ...args);
|
|
585
609
|
}, EmitProtocol);
|
|
586
610
|
|
|
611
|
+
let cid = '';
|
|
612
|
+
/**
|
|
613
|
+
* @private
|
|
614
|
+
* @param args
|
|
615
|
+
*/
|
|
616
|
+
function invokePushCallback(args) {
|
|
617
|
+
if (args.type === 'clientId') {
|
|
618
|
+
cid = args.cid;
|
|
619
|
+
invokeGetPushCidCallbacks(cid);
|
|
620
|
+
}
|
|
621
|
+
else if (args.type === 'pushMsg') {
|
|
622
|
+
onPushMessageCallbacks.forEach((callback) => {
|
|
623
|
+
callback({ data: args.message });
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
const getPushCidCallbacks = [];
|
|
628
|
+
function invokeGetPushCidCallbacks(cid) {
|
|
629
|
+
getPushCidCallbacks.forEach((callback) => {
|
|
630
|
+
callback(cid);
|
|
631
|
+
});
|
|
632
|
+
getPushCidCallbacks.length = 0;
|
|
633
|
+
}
|
|
634
|
+
function getPushCid(args) {
|
|
635
|
+
if (!isPlainObject(args)) {
|
|
636
|
+
args = {};
|
|
637
|
+
}
|
|
638
|
+
const { success, fail, complete } = getApiCallbacks(args);
|
|
639
|
+
const hasSuccess = isFunction(success);
|
|
640
|
+
const hasFail = isFunction(fail);
|
|
641
|
+
const hasComplete = isFunction(complete);
|
|
642
|
+
getPushCidCallbacks.push((cid) => {
|
|
643
|
+
let res;
|
|
644
|
+
if (cid) {
|
|
645
|
+
res = { errMsg: 'getPushCid:ok', cid };
|
|
646
|
+
hasSuccess && success(res);
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
res = { errMsg: 'getPushCid:fail' };
|
|
650
|
+
hasFail && fail(res);
|
|
651
|
+
}
|
|
652
|
+
hasComplete && complete(res);
|
|
653
|
+
});
|
|
654
|
+
if (cid) {
|
|
655
|
+
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid));
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
const onPushMessageCallbacks = [];
|
|
659
|
+
// 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
|
|
660
|
+
const onPushMessage = (fn) => {
|
|
661
|
+
if (onPushMessageCallbacks.indexOf(fn) === -1) {
|
|
662
|
+
onPushMessageCallbacks.push(fn);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
const offPushMessage = (fn) => {
|
|
666
|
+
if (!fn) {
|
|
667
|
+
onPushMessageCallbacks.length = 0;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
const index = onPushMessageCallbacks.indexOf(fn);
|
|
671
|
+
if (index > -1) {
|
|
672
|
+
onPushMessageCallbacks.splice(index, 1);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
|
|
587
677
|
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
|
|
588
678
|
const CONTEXT_API_RE = /^create|Manager$/;
|
|
589
679
|
// Context例外情况
|
|
@@ -772,6 +862,10 @@ const baseApis = {
|
|
|
772
862
|
getLocale,
|
|
773
863
|
setLocale,
|
|
774
864
|
onLocaleChange,
|
|
865
|
+
getPushCid,
|
|
866
|
+
onPushMessage,
|
|
867
|
+
offPushMessage,
|
|
868
|
+
invokePushCallback,
|
|
775
869
|
};
|
|
776
870
|
function initUni(api, protocols) {
|
|
777
871
|
const wrapper = initWrapper(protocols);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-quickapp-webview",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3030820220114008",
|
|
4
4
|
"description": "uni-app quickapp-webview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@vue/compiler-core": "3.2.
|
|
25
|
+
"@vue/compiler-core": "3.2.30"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@dcloudio/uni-cli-shared": "3.0.0-alpha-
|
|
29
|
-
"@dcloudio/uni-mp-vite": "3.0.0-alpha-
|
|
30
|
-
"@dcloudio/uni-mp-vue": "3.0.0-alpha-
|
|
31
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
32
|
-
"@vue/shared": "3.2.
|
|
28
|
+
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3030820220114008",
|
|
29
|
+
"@dcloudio/uni-mp-vite": "3.0.0-alpha-3030820220114008",
|
|
30
|
+
"@dcloudio/uni-mp-vue": "3.0.0-alpha-3030820220114008",
|
|
31
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030820220114008",
|
|
32
|
+
"@vue/shared": "3.2.30"
|
|
33
33
|
}
|
|
34
34
|
}
|