react-native-insider 7.1.0 → 8.0.0
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/README.md +1 -0
- package/RNInsider.podspec +2 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/useinsider/react/RNInsiderModule.java +145 -4
- package/android/src/main/java/com/useinsider/react/RNUtils.java +21 -2
- package/index.d.ts +99 -5
- package/index.js +166 -105
- package/ios/RNInsider/RNInsider.m +140 -6
- package/ios/RNInsider/RNUtils.h +3 -0
- package/ios/RNInsider/RNUtils.m +20 -0
- package/package.json +2 -2
- package/src/InsiderAppCard.d.ts +186 -0
- package/src/InsiderAppCard.js +290 -0
- package/src/InsiderAppCards.d.ts +268 -0
- package/src/InsiderAppCards.js +98 -0
- package/src/InsiderAppCardsError.js +69 -0
- package/src/Util.js +10 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for App Cards operations.
|
|
3
|
+
*
|
|
4
|
+
* These codes are aligned with the native SDK error codes on both Android and iOS:
|
|
5
|
+
* - Android: AppCardsException.AppCardsExceptionCode
|
|
6
|
+
* - iOS: InsiderAppCardsErrorCode
|
|
7
|
+
*
|
|
8
|
+
* @readonly
|
|
9
|
+
* @enum {string}
|
|
10
|
+
*/
|
|
11
|
+
const InsiderAppCardsErrorCode = Object.freeze({
|
|
12
|
+
UNKNOWN: 'unknown',
|
|
13
|
+
SDK_NOT_INITIALIZED: 'sdkNotInitialized',
|
|
14
|
+
INVALID_PARAMETER: 'invalidParameter',
|
|
15
|
+
NETWORK_ERROR: 'networkError',
|
|
16
|
+
SERVER_ERROR: 'serverError',
|
|
17
|
+
PARSE_ERROR: 'parseError',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents a typed error from an App Cards operation.
|
|
22
|
+
*
|
|
23
|
+
* Extends the standard Error class with a structured error code
|
|
24
|
+
* that maps to the native SDK error codes on both Android and iOS.
|
|
25
|
+
*/
|
|
26
|
+
class InsiderAppCardsError extends Error {
|
|
27
|
+
#code;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} code - One of InsiderAppCardsErrorCode values.
|
|
31
|
+
* @param {string} message - A human-readable error description.
|
|
32
|
+
*/
|
|
33
|
+
constructor(code, message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = 'InsiderAppCardsError';
|
|
36
|
+
this.#code = code;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The error code identifying the type of error.
|
|
41
|
+
* @returns {string} One of InsiderAppCardsErrorCode values.
|
|
42
|
+
*/
|
|
43
|
+
get code() {
|
|
44
|
+
return this.#code;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates an InsiderAppCardsError from a native bridge error response.
|
|
49
|
+
*
|
|
50
|
+
* The native bridge sends either:
|
|
51
|
+
* - A structured object: { code: string, message: string }
|
|
52
|
+
* - A plain string (legacy/fallback)
|
|
53
|
+
*
|
|
54
|
+
* @param {Object|string} error - The error from the native bridge.
|
|
55
|
+
* @returns {InsiderAppCardsError}
|
|
56
|
+
*/
|
|
57
|
+
static from(error) {
|
|
58
|
+
if (error && typeof error === 'object' && error.code && error.message) {
|
|
59
|
+
return new InsiderAppCardsError(error.code, error.message);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return new InsiderAppCardsError(
|
|
63
|
+
InsiderAppCardsErrorCode.UNKNOWN,
|
|
64
|
+
typeof error === 'string' ? error : 'An unexpected error occurred.'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { InsiderAppCardsError, InsiderAppCardsErrorCode };
|
package/src/Util.js
CHANGED
|
@@ -34,6 +34,16 @@ export function showParameterWarningLog(functionName, parameters = []) {
|
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export function resolveWithCallback(promise, completion) {
|
|
38
|
+
if (typeof completion === 'function') {
|
|
39
|
+
promise
|
|
40
|
+
.then((v) => completion(null, v))
|
|
41
|
+
.catch((e) => completion(e, null));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
return promise;
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
export function isPlainObject(value) {
|
|
38
48
|
if (value === null || typeof value !== 'object') {
|
|
39
49
|
return false;
|