@dcloudio/uni-quickapp-webview 2.0.1-34920220609002 → 2.0.1-35320220729002

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -35
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -314,7 +314,7 @@ const promiseInterceptor = {
314
314
  };
315
315
 
316
316
  const SYNC_API_RE =
317
- /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo/;
317
+ /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting/;
318
318
 
319
319
  const CONTEXT_API_RE = /^create|Manager$/;
320
320
 
@@ -322,7 +322,7 @@ const CONTEXT_API_RE = /^create|Manager$/;
322
322
  const CONTEXT_API_RE_EXC = ['createBLEConnection'];
323
323
 
324
324
  // 同步例外情况
325
- const ASYNC_API = ['createBLEConnection'];
325
+ const ASYNC_API = ['createBLEConnection', 'createPushMessage'];
326
326
 
327
327
  const CALLBACK_API_RE = /^on|^off/;
328
328
 
@@ -1168,6 +1168,7 @@ function getApiCallbacks (params) {
1168
1168
 
1169
1169
  let cid;
1170
1170
  let cidErrMsg;
1171
+ let enabled;
1171
1172
 
1172
1173
  function normalizePushMessage (message) {
1173
1174
  try {
@@ -1179,17 +1180,25 @@ function normalizePushMessage (message) {
1179
1180
  function invokePushCallback (
1180
1181
  args
1181
1182
  ) {
1182
- if (args.type === 'clientId') {
1183
+ if (args.type === 'enabled') {
1184
+ enabled = true;
1185
+ } else if (args.type === 'clientId') {
1183
1186
  cid = args.cid;
1184
1187
  cidErrMsg = args.errMsg;
1185
1188
  invokeGetPushCidCallbacks(cid, args.errMsg);
1186
1189
  } else if (args.type === 'pushMsg') {
1187
- onPushMessageCallbacks.forEach((callback) => {
1188
- callback({
1189
- type: 'receive',
1190
- data: normalizePushMessage(args.message)
1191
- });
1192
- });
1190
+ const message = {
1191
+ type: 'receive',
1192
+ data: normalizePushMessage(args.message)
1193
+ };
1194
+ for (let i = 0; i < onPushMessageCallbacks.length; i++) {
1195
+ const callback = onPushMessageCallbacks[i];
1196
+ callback(message);
1197
+ // 该消息已被阻止
1198
+ if (message.stopped) {
1199
+ break
1200
+ }
1201
+ }
1193
1202
  } else if (args.type === 'click') {
1194
1203
  onPushMessageCallbacks.forEach((callback) => {
1195
1204
  callback({
@@ -1209,7 +1218,7 @@ function invokeGetPushCidCallbacks (cid, errMsg) {
1209
1218
  getPushCidCallbacks.length = 0;
1210
1219
  }
1211
1220
 
1212
- function getPushClientid (args) {
1221
+ function getPushClientId (args) {
1213
1222
  if (!isPlainObject(args)) {
1214
1223
  args = {};
1215
1224
  }
@@ -1221,25 +1230,32 @@ function getPushClientid (args) {
1221
1230
  const hasSuccess = isFn(success);
1222
1231
  const hasFail = isFn(fail);
1223
1232
  const hasComplete = isFn(complete);
1224
- getPushCidCallbacks.push((cid, errMsg) => {
1225
- let res;
1226
- if (cid) {
1227
- res = {
1228
- errMsg: 'getPushClientid:ok',
1229
- cid
1230
- };
1231
- hasSuccess && success(res);
1232
- } else {
1233
- res = {
1234
- errMsg: 'getPushClientid:fail' + (errMsg ? ' ' + errMsg : '')
1235
- };
1236
- hasFail && fail(res);
1233
+ Promise.resolve().then(() => {
1234
+ if (typeof enabled === 'undefined') {
1235
+ enabled = false;
1236
+ cid = '';
1237
+ cidErrMsg = 'unipush is not enabled';
1238
+ }
1239
+ getPushCidCallbacks.push((cid, errMsg) => {
1240
+ let res;
1241
+ if (cid) {
1242
+ res = {
1243
+ errMsg: 'getPushClientId:ok',
1244
+ cid
1245
+ };
1246
+ hasSuccess && success(res);
1247
+ } else {
1248
+ res = {
1249
+ errMsg: 'getPushClientId:fail' + (errMsg ? ' ' + errMsg : '')
1250
+ };
1251
+ hasFail && fail(res);
1252
+ }
1253
+ hasComplete && complete(res);
1254
+ });
1255
+ if (typeof cid !== 'undefined') {
1256
+ invokeGetPushCidCallbacks(cid, cidErrMsg);
1237
1257
  }
1238
- hasComplete && complete(res);
1239
1258
  });
1240
- if (typeof cid !== 'undefined') {
1241
- Promise.resolve().then(() => invokeGetPushCidCallbacks(cid, cidErrMsg));
1242
- }
1243
1259
  }
1244
1260
 
1245
1261
  const onPushMessageCallbacks = [];
@@ -1263,7 +1279,7 @@ const offPushMessage = (fn) => {
1263
1279
 
1264
1280
  var api = /*#__PURE__*/Object.freeze({
1265
1281
  __proto__: null,
1266
- getPushClientid: getPushClientid,
1282
+ getPushClientId: getPushClientId,
1267
1283
  onPushMessage: onPushMessage,
1268
1284
  offPushMessage: offPushMessage,
1269
1285
  invokePushCallback: invokePushCallback
@@ -1517,18 +1533,13 @@ function parsePropType (key, type, defaultValue, file) {
1517
1533
  return type
1518
1534
  }
1519
1535
 
1520
- function initProperties (props, isBehavior = false, file = '') {
1536
+ function initProperties (props, isBehavior = false, file = '', options) {
1521
1537
  const properties = {};
1522
1538
  if (!isBehavior) {
1523
1539
  properties.vueId = {
1524
1540
  type: String,
1525
1541
  value: ''
1526
1542
  };
1527
- // 用于字节跳动小程序模拟抽象节点
1528
- properties.generic = {
1529
- type: Object,
1530
- value: null
1531
- };
1532
1543
  // scopedSlotsCompiler auto
1533
1544
  properties.scopedSlotsCompiler = {
1534
1545
  type: String,
@@ -1824,7 +1835,9 @@ function handleEvent (event) {
1824
1835
  }
1825
1836
  const handler = handlerCtx[methodName];
1826
1837
  if (!isFn(handler)) {
1827
- throw new Error(` _vm.${methodName} is not a function`)
1838
+ const type = this.$vm.mpType === 'page' ? 'Page' : 'Component';
1839
+ const path = this.route || this.is;
1840
+ throw new Error(`${type} "${path}" does not have a method "${methodName}"`)
1828
1841
  }
1829
1842
  if (isOnce) {
1830
1843
  if (handler.once) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-quickapp-webview",
3
- "version": "2.0.1-34920220609002",
3
+ "version": "2.0.1-35320220729002",
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": "d28c71d8a044635b27fbbb7cffb66b59424248d3"
20
+ "gitHead": "99c489d7a19425ade612162abd21b441260e7ba7"
21
21
  }