@mpgd/adapter-capacitor 0.19.1 → 0.19.3
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bridgeNotificationsEventProtocol, } from '@mpgd/bridge';
|
|
1
|
+
import { bridgeNotificationsEventProtocol, isThrownInstance, readThrownField, thrownMessage, } from '@mpgd/bridge';
|
|
2
2
|
import { assertBridgeNotificationsV2Payload, assertBridgeNotificationsV2Result, createNotificationsV2BridgeHandler, } from '@mpgd/bridge/notifications';
|
|
3
3
|
import { PlatformOperationError } from '@mpgd/platform';
|
|
4
4
|
import { assertNotificationEventEnvelope, isNotificationErrorCode, NotificationError, notificationsProtocol, notificationsProtocolVersion, toNotificationSubscriptionAdapter, } from '@mpgd/platform/notifications';
|
|
@@ -207,16 +207,16 @@ function topicsPayload(request) {
|
|
|
207
207
|
return { topics: request?.topics };
|
|
208
208
|
}
|
|
209
209
|
function toNotificationError(error) {
|
|
210
|
-
if (error
|
|
210
|
+
if (isThrownInstance(error, NotificationError)) {
|
|
211
211
|
return error;
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
// A field whose getter or Proxy trap throws counts as missing.
|
|
214
|
+
const code = readThrownField(error, 'code');
|
|
215
|
+
const retryable = readThrownField(error, 'retryable');
|
|
216
216
|
const options = {
|
|
217
|
-
...(error
|
|
217
|
+
...(isThrownInstance(error, Error) ? { message: thrownMessage(error) } : {}),
|
|
218
218
|
// A transport failure keeps its retryability.
|
|
219
|
-
...(error
|
|
219
|
+
...(isThrownInstance(error, PlatformOperationError) && typeof retryable === 'boolean' ? { retryable } : {}),
|
|
220
220
|
cause: error,
|
|
221
221
|
};
|
|
222
222
|
return new NotificationError(isNotificationErrorCode(code) ? code : 'NOTIFICATIONS_TEMPORARILY_UNAVAILABLE', options);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { App } from '@capacitor/app';
|
|
2
|
+
import { isThrownInstance, readThrownField } from '@mpgd/bridge';
|
|
2
3
|
import { assertLocalNotificationRequest, isRootRelativeNotificationRoute, normalizeNotificationTimestamp, notificationAdvertisingOptOutActionId, NotificationError, } from '@mpgd/platform/notifications';
|
|
3
4
|
// The Capacitor notifications v2 provider (notifications RFC "Provider
|
|
4
5
|
// profiles", Capacitor): app-scope OS permission, FCM device endpoints, local
|
|
@@ -182,7 +183,7 @@ export function createCapacitorNotificationProvider(input) {
|
|
|
182
183
|
}
|
|
183
184
|
catch (error) {
|
|
184
185
|
// A shell built before the renderer answers UNIMPLEMENTED: it has none.
|
|
185
|
-
if (error
|
|
186
|
+
if (readThrownField(error, 'code') !== 'UNIMPLEMENTED') {
|
|
186
187
|
reportError(error);
|
|
187
188
|
}
|
|
188
189
|
}
|
|
@@ -997,7 +998,7 @@ export function createCapacitorNotificationProvider(input) {
|
|
|
997
998
|
value = (await push.getToken()).token;
|
|
998
999
|
}
|
|
999
1000
|
catch (error) {
|
|
1000
|
-
if (error
|
|
1001
|
+
if (isThrownInstance(error, NotificationError) || isConfigurationFailure(error)) {
|
|
1001
1002
|
throw toNotificationError(error);
|
|
1002
1003
|
}
|
|
1003
1004
|
// No address yet (iOS before APNs registration, offline):
|
|
@@ -1322,11 +1323,12 @@ async function callSdk(call) {
|
|
|
1322
1323
|
}
|
|
1323
1324
|
}
|
|
1324
1325
|
function toNotificationError(error) {
|
|
1325
|
-
if (error
|
|
1326
|
+
if (isThrownInstance(error, NotificationError)) {
|
|
1326
1327
|
return error;
|
|
1327
1328
|
}
|
|
1328
|
-
|
|
1329
|
-
|
|
1329
|
+
// A field whose getter or Proxy trap throws counts as missing.
|
|
1330
|
+
const code = stringOf(readThrownField(error, 'code'));
|
|
1331
|
+
if (code === 'UNIMPLEMENTED' || code === 'UNAVAILABLE') {
|
|
1330
1332
|
return new NotificationError('NOTIFICATIONS_CONFIGURATION_REQUIRED', {
|
|
1331
1333
|
...(code === undefined ? {} : { hostCode: code }),
|
|
1332
1334
|
cause: error,
|
|
@@ -1336,7 +1338,7 @@ function toNotificationError(error) {
|
|
|
1336
1338
|
}
|
|
1337
1339
|
/** Capacitor's answer for a plugin the native shell does not implement. */
|
|
1338
1340
|
function isConfigurationFailure(error) {
|
|
1339
|
-
const code =
|
|
1341
|
+
const code = readThrownField(error, 'code');
|
|
1340
1342
|
return code === 'UNIMPLEMENTED' || code === 'UNAVAILABLE';
|
|
1341
1343
|
}
|
|
1342
1344
|
function defaultTimeZone() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpgd/adapter-capacitor",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "Capacitor platform adapter for mpgd Android and iOS shells.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@capacitor/app": "8.1.1",
|
|
54
|
-
"@mpgd/bridge": "0.
|
|
55
|
-
"@mpgd/
|
|
56
|
-
"@mpgd/
|
|
57
|
-
"@mpgd/
|
|
58
|
-
"@mpgd/
|
|
54
|
+
"@mpgd/bridge": "0.19.1",
|
|
55
|
+
"@mpgd/target-config": "0.24.9",
|
|
56
|
+
"@mpgd/game-services": "0.35.0",
|
|
57
|
+
"@mpgd/capacitor-game-services": "0.9.8",
|
|
58
|
+
"@mpgd/platform": "0.36.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@capacitor-community/admob": "^8.1.0",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"ttsc": "0.34.2",
|
|
93
93
|
"typescript": "7.0.2",
|
|
94
94
|
"vitest": "^4.0.0",
|
|
95
|
-
"@mpgd/game-runtime": "0.10.
|
|
95
|
+
"@mpgd/game-runtime": "0.10.3"
|
|
96
96
|
},
|
|
97
97
|
"main": "./dist/index.js",
|
|
98
98
|
"types": "./dist/index.d.ts",
|