@trycourier/courier-react-native 5.6.16 → 5.7.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 +66 -135
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +1 -0
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +3 -0
- package/android/src/main/java/com/courierreactnative/Utils.kt +11 -1
- package/courier-react-native.podspec +1 -1
- package/ios/CourierClientModule.swift +1 -0
- package/ios/CourierReactNativeDelegate.m +1 -1
- package/ios/CourierReactNativeEventEmitter.swift +1 -1
- package/ios/CourierReactNativeModule.m +1 -0
- package/ios/CourierSharedModule.swift +10 -3
- package/ios/Utils.swift +10 -0
- package/lib/commonjs/Broadcaster.js +5 -5
- package/lib/commonjs/Broadcaster.js.map +1 -1
- package/lib/commonjs/CourierApiUrls.js +29 -0
- package/lib/commonjs/CourierApiUrls.js.map +1 -0
- package/lib/commonjs/Modules.js.map +1 -1
- package/lib/commonjs/client/BrandClient.js.map +1 -1
- package/lib/commonjs/client/ClientModule.js.map +1 -1
- package/lib/commonjs/client/CourierClient.js +4 -1
- package/lib/commonjs/client/CourierClient.js.map +1 -1
- package/lib/commonjs/client/InboxClient.js.map +1 -1
- package/lib/commonjs/client/PreferenceClient.js.map +1 -1
- package/lib/commonjs/client/TokenClient.js.map +1 -1
- package/lib/commonjs/client/TrackingClient.js.map +1 -1
- package/lib/commonjs/index.js +22 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/commonjs/models/CourierPushListener.js.map +1 -1
- package/lib/commonjs/models/CourierUserPreferences.js +13 -13
- package/lib/commonjs/models/CourierUserPreferences.js.map +1 -1
- package/lib/commonjs/models/InboxAction.js.map +1 -1
- package/lib/commonjs/models/InboxMessage.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/CourierInboxView.js +13 -13
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/commonjs/views/CourierPreferencesView.js +4 -4
- package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
- package/lib/module/Broadcaster.js +7 -7
- package/lib/module/Broadcaster.js.map +1 -1
- package/lib/module/CourierApiUrls.js +20 -0
- package/lib/module/CourierApiUrls.js.map +1 -0
- package/lib/module/Modules.js +1 -1
- package/lib/module/Modules.js.map +1 -1
- package/lib/module/client/BrandClient.js +1 -1
- package/lib/module/client/BrandClient.js.map +1 -1
- package/lib/module/client/ClientModule.js +1 -1
- package/lib/module/client/ClientModule.js.map +1 -1
- package/lib/module/client/CourierClient.js +10 -7
- package/lib/module/client/CourierClient.js.map +1 -1
- package/lib/module/client/InboxClient.js +1 -1
- package/lib/module/client/InboxClient.js.map +1 -1
- package/lib/module/client/PreferenceClient.js +1 -1
- package/lib/module/client/PreferenceClient.js.map +1 -1
- package/lib/module/client/TokenClient.js +1 -1
- package/lib/module/client/TokenClient.js.map +1 -1
- package/lib/module/client/TrackingClient.js +1 -1
- package/lib/module/client/TrackingClient.js.map +1 -1
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierAuthenticationListener.js +1 -1
- package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +1 -1
- package/lib/module/models/CourierPushListener.js.map +1 -1
- package/lib/module/models/CourierUserPreferences.js +13 -13
- package/lib/module/models/CourierUserPreferences.js.map +1 -1
- package/lib/module/models/InboxAction.js.map +1 -1
- package/lib/module/models/InboxMessage.js +1 -1
- package/lib/module/models/InboxMessage.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/CourierInboxView.js +18 -18
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/module/views/CourierPreferencesView.js +7 -7
- package/lib/module/views/CourierPreferencesView.js.map +1 -1
- package/lib/typescript/src/Broadcaster.d.ts +7 -7
- package/lib/typescript/src/Broadcaster.d.ts.map +1 -1
- package/lib/typescript/src/CourierApiUrls.d.ts +11 -0
- package/lib/typescript/src/CourierApiUrls.d.ts.map +1 -0
- package/lib/typescript/src/Modules.d.ts.map +1 -1
- package/lib/typescript/src/client/BrandClient.d.ts +1 -1
- package/lib/typescript/src/client/BrandClient.d.ts.map +1 -1
- package/lib/typescript/src/client/ClientModule.d.ts +1 -1
- package/lib/typescript/src/client/ClientModule.d.ts.map +1 -1
- package/lib/typescript/src/client/CourierClient.d.ts +9 -6
- package/lib/typescript/src/client/CourierClient.d.ts.map +1 -1
- package/lib/typescript/src/client/InboxClient.d.ts +1 -1
- package/lib/typescript/src/client/InboxClient.d.ts.map +1 -1
- package/lib/typescript/src/client/PreferenceClient.d.ts +1 -1
- package/lib/typescript/src/client/PreferenceClient.d.ts.map +1 -1
- package/lib/typescript/src/client/TokenClient.d.ts +1 -1
- package/lib/typescript/src/client/TokenClient.d.ts.map +1 -1
- package/lib/typescript/src/client/TrackingClient.d.ts +1 -1
- package/lib/typescript/src/client/TrackingClient.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models/Android_CourierSheet.d.ts +1 -1
- package/lib/typescript/src/models/Android_CourierSheet.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts +1 -1
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierBrand.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierButton.d.ts +1 -1
- package/lib/typescript/src/models/CourierButton.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierFont.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts +1 -1
- package/lib/typescript/src/models/CourierInboxMessages.d.ts +1 -1
- package/lib/typescript/src/models/CourierInboxTheme.d.ts +3 -3
- package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInfoViewStyle.d.ts +2 -2
- package/lib/typescript/src/models/CourierInfoViewStyle.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierPreferencesTheme.d.ts +6 -6
- package/lib/typescript/src/models/CourierPreferencesTheme.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierPushListener.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierUserPreferences.d.ts +1 -1
- package/lib/typescript/src/models/CourierUserPreferences.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessage.d.ts +1 -1
- package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageSet.d.ts +1 -1
- package/lib/typescript/src/models/iOS_CourierCell.d.ts.map +1 -1
- package/lib/typescript/src/models/iOS_CourierSheet.d.ts +1 -1
- package/lib/typescript/src/models/iOS_CourierSheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/views/CourierInboxView.d.ts +5 -5
- package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -1
- package/lib/typescript/src/views/CourierPreferencesView.d.ts +3 -3
- package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/Broadcaster.tsx +21 -15
- package/src/CourierApiUrls.tsx +30 -0
- package/src/Modules.tsx +22 -13
- package/src/client/BrandClient.tsx +6 -6
- package/src/client/ClientModule.tsx +4 -6
- package/src/client/CourierClient.tsx +20 -13
- package/src/client/InboxClient.tsx +40 -13
- package/src/client/PreferenceClient.tsx +47 -21
- package/src/client/TokenClient.tsx +14 -7
- package/src/client/TrackingClient.tsx +7 -6
- package/src/index.tsx +208 -115
- package/src/models/Android_CourierSheet.tsx +5 -5
- package/src/models/CourierAuthenticationListener.tsx +5 -9
- package/src/models/CourierBrand.tsx +6 -6
- package/src/models/CourierButton.tsx +5 -5
- package/src/models/CourierDevice.tsx +1 -1
- package/src/models/CourierFont.tsx +4 -4
- package/src/models/CourierInboxListener.tsx +3 -3
- package/src/models/CourierInboxMessages.tsx +2 -2
- package/src/models/CourierInboxTheme.tsx +55 -42
- package/src/models/CourierInfoViewStyle.tsx +5 -5
- package/src/models/CourierPaging.tsx +1 -1
- package/src/models/CourierPreferencesTheme.tsx +32 -27
- package/src/models/CourierPushListener.tsx +9 -7
- package/src/models/CourierPushProvider.tsx +1 -1
- package/src/models/CourierTrackingEvent.tsx +6 -6
- package/src/models/CourierUserPreferences.tsx +32 -28
- package/src/models/InboxAction.tsx +2 -6
- package/src/models/InboxMessage.tsx +4 -5
- package/src/models/InboxMessageEvent.tsx +7 -1
- package/src/models/InboxMessageFeed.tsx +1 -1
- package/src/models/InboxMessageSet.tsx +1 -1
- package/src/models/iOS_CourierCell.tsx +10 -5
- package/src/models/iOS_CourierSheet.tsx +4 -4
- package/src/utils.tsx +4 -7
- package/src/views/CourierInboxView.tsx +79 -71
- package/src/views/CourierPreferencesView.tsx +34 -35
- package/lib/example/src/App.js +0 -11
- package/lib/example/src/Emitter.js +0 -11
- package/lib/example/src/Env.js +0 -6
- package/lib/example/src/Home.js +0 -67
- package/lib/example/src/Poke.js +0 -75
- package/lib/example/src/Tabs.js +0 -36
- package/lib/example/src/Utils.js +0 -71
- package/lib/example/src/pages/Auth.js +0 -224
- package/lib/example/src/pages/Inbox.js +0 -38
- package/lib/example/src/pages/Preferences.js +0 -13
- package/lib/example/src/pages/PreferencesStack.js +0 -11
- package/lib/example/src/pages/Push.js +0 -93
- package/lib/example/src/pages/Styles.js +0 -26
- package/lib/example/src/pages/Tests.js +0 -1068
- package/lib/example/src/pages/inbox/InboxCustom.js +0 -141
- package/lib/example/src/pages/inbox/InboxDefault.js +0 -22
- package/lib/example/src/pages/inbox/InboxStyled.js +0 -220
- package/lib/example/src/pages/preferences/PreferencesCustom.js +0 -91
- package/lib/example/src/pages/preferences/PreferencesDefault.js +0 -17
- package/lib/example/src/pages/preferences/PreferencesDetail.js +0 -127
- package/lib/example/src/pages/preferences/PreferencesStyled.js +0 -110
- package/lib/package.json +0 -171
- package/lib/src/Broadcaster.js +0 -24
- package/lib/src/Modules.js +0 -26
- package/lib/src/client/BrandClient.js +0 -17
- package/lib/src/client/ClientModule.js +0 -14
- package/lib/src/client/CourierClient.js +0 -31
- package/lib/src/client/InboxClient.js +0 -99
- package/lib/src/client/PreferenceClient.js +0 -63
- package/lib/src/client/TokenClient.js +0 -27
- package/lib/src/client/TrackingClient.js +0 -17
- package/lib/src/index.js +0 -567
- package/lib/src/models/Android_CourierSheet.js +0 -1
- package/lib/src/models/CourierAuthenticationListener.js +0 -14
- package/lib/src/models/CourierBrand.js +0 -1
- package/lib/src/models/CourierButton.js +0 -1
- package/lib/src/models/CourierDevice.js +0 -1
- package/lib/src/models/CourierFont.js +0 -1
- package/lib/src/models/CourierInboxListener.js +0 -20
- package/lib/src/models/CourierInboxMessages.js +0 -1
- package/lib/src/models/CourierInboxTheme.js +0 -1
- package/lib/src/models/CourierInfoViewStyle.js +0 -1
- package/lib/src/models/CourierPaging.js +0 -1
- package/lib/src/models/CourierPreferencesTheme.js +0 -1
- package/lib/src/models/CourierPushListener.js +0 -14
- package/lib/src/models/CourierPushProvider.js +0 -8
- package/lib/src/models/CourierTrackingEvent.js +0 -8
- package/lib/src/models/CourierUserPreferences.js +0 -51
- package/lib/src/models/InboxAction.js +0 -1
- package/lib/src/models/InboxMessage.js +0 -1
- package/lib/src/models/InboxMessageFeed.js +0 -1
- package/lib/src/models/InboxMessageSet.js +0 -1
- package/lib/src/models/iOS_CourierCell.js +0 -1
- package/lib/src/models/iOS_CourierSheet.js +0 -1
- package/lib/src/utils.js +0 -27
- package/lib/src/views/CourierInboxView.js +0 -75
- package/lib/src/views/CourierPreferencesView.js +0 -33
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { CourierPreferencesView } from "@trycourier/courier-react-native";
|
|
2
|
-
import Env from "../../Env";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { StyleSheet, View } from "react-native";
|
|
5
|
-
import { Styles } from "../Styles";
|
|
6
|
-
const PreferencesStyled = () => {
|
|
7
|
-
function getTheme(isDark) {
|
|
8
|
-
const styles = Styles(isDark);
|
|
9
|
-
return {
|
|
10
|
-
brandId: Env.brandId,
|
|
11
|
-
sectionTitleFont: {
|
|
12
|
-
family: styles.Fonts.heading,
|
|
13
|
-
size: styles.TextSizes.heading,
|
|
14
|
-
color: styles.Colors.heading
|
|
15
|
-
},
|
|
16
|
-
topicTitleFont: {
|
|
17
|
-
family: styles.Fonts.title,
|
|
18
|
-
size: styles.TextSizes.title,
|
|
19
|
-
color: styles.Colors.title
|
|
20
|
-
},
|
|
21
|
-
topicSubtitleFont: {
|
|
22
|
-
family: styles.Fonts.subtitle,
|
|
23
|
-
size: styles.TextSizes.subtitle,
|
|
24
|
-
color: styles.Colors.subtitle
|
|
25
|
-
},
|
|
26
|
-
topicButton: {
|
|
27
|
-
font: {
|
|
28
|
-
family: styles.Fonts.subtitle,
|
|
29
|
-
size: styles.TextSizes.subtitle,
|
|
30
|
-
color: styles.Colors.title
|
|
31
|
-
},
|
|
32
|
-
backgroundColor: styles.Colors.option,
|
|
33
|
-
cornerRadius: styles.Corners.button
|
|
34
|
-
},
|
|
35
|
-
sheetTitleFont: {
|
|
36
|
-
family: styles.Fonts.heading,
|
|
37
|
-
size: styles.TextSizes.heading,
|
|
38
|
-
color: styles.Colors.heading
|
|
39
|
-
},
|
|
40
|
-
infoViewStyle: {
|
|
41
|
-
font: {
|
|
42
|
-
family: styles.Fonts.title,
|
|
43
|
-
size: styles.TextSizes.title,
|
|
44
|
-
color: styles.Colors.title
|
|
45
|
-
},
|
|
46
|
-
button: {
|
|
47
|
-
font: {
|
|
48
|
-
family: styles.Fonts.subtitle,
|
|
49
|
-
size: styles.TextSizes.subtitle,
|
|
50
|
-
color: styles.Colors.action
|
|
51
|
-
},
|
|
52
|
-
backgroundColor: styles.Colors.title,
|
|
53
|
-
cornerRadius: styles.Corners.button
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
iOS: {
|
|
57
|
-
topicCellStyles: {
|
|
58
|
-
separatorStyle: 'none'
|
|
59
|
-
},
|
|
60
|
-
sheetSettingStyles: {
|
|
61
|
-
font: {
|
|
62
|
-
family: styles.Fonts.title,
|
|
63
|
-
size: styles.TextSizes.title,
|
|
64
|
-
color: styles.Colors.title
|
|
65
|
-
},
|
|
66
|
-
toggleColor: styles.Colors.action
|
|
67
|
-
},
|
|
68
|
-
sheetCornerRadius: 20,
|
|
69
|
-
sheetCellStyles: {
|
|
70
|
-
separatorStyle: 'none'
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
android: {
|
|
74
|
-
topicDividerItemDecoration: 'vertical',
|
|
75
|
-
sheetDividerItemDecoration: 'vertical',
|
|
76
|
-
sheetSettingStyles: {
|
|
77
|
-
font: {
|
|
78
|
-
family: styles.Fonts.title,
|
|
79
|
-
size: styles.TextSizes.title,
|
|
80
|
-
color: styles.Colors.title
|
|
81
|
-
},
|
|
82
|
-
toggleThumbColor: styles.Colors.action,
|
|
83
|
-
toggleTrackColor: styles.Colors.option,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
const styles = StyleSheet.create({
|
|
89
|
-
container: {
|
|
90
|
-
flex: 1,
|
|
91
|
-
},
|
|
92
|
-
box: {
|
|
93
|
-
width: '100%',
|
|
94
|
-
height: '100%',
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
return (React.createElement(View, { style: styles.container },
|
|
98
|
-
React.createElement(CourierPreferencesView, { mode: {
|
|
99
|
-
type: 'channels',
|
|
100
|
-
channels: ['push', 'sms', 'email']
|
|
101
|
-
}, theme: {
|
|
102
|
-
light: getTheme(false),
|
|
103
|
-
dark: getTheme(true),
|
|
104
|
-
}, onScrollPreferences: (offsetX, offsetY) => {
|
|
105
|
-
console.log(offsetX, offsetY);
|
|
106
|
-
}, onPreferenceError: (error) => {
|
|
107
|
-
console.log(error);
|
|
108
|
-
}, style: styles.box })));
|
|
109
|
-
};
|
|
110
|
-
export default PreferencesStyled;
|
package/lib/package.json
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@trycourier/courier-react-native",
|
|
3
|
-
"version": "5.4.3",
|
|
4
|
-
"description": "Inbox, Push Notifications, and Preferences for React Native",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"module": "lib/index.js",
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"react-native": "src/index",
|
|
9
|
-
"source": "src/index",
|
|
10
|
-
"files": [
|
|
11
|
-
"src",
|
|
12
|
-
"lib",
|
|
13
|
-
"android",
|
|
14
|
-
"ios",
|
|
15
|
-
"cpp",
|
|
16
|
-
"*.podspec",
|
|
17
|
-
"!lib/typescript/example",
|
|
18
|
-
"!ios/build",
|
|
19
|
-
"!android/build",
|
|
20
|
-
"!android/gradle",
|
|
21
|
-
"!android/gradlew",
|
|
22
|
-
"!android/gradlew.bat",
|
|
23
|
-
"!android/local.properties",
|
|
24
|
-
"!**/__tests__",
|
|
25
|
-
"!**/__fixtures__",
|
|
26
|
-
"!**/__mocks__",
|
|
27
|
-
"!**/.*"
|
|
28
|
-
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"test": "jest",
|
|
31
|
-
"typecheck": "tsc --noEmit",
|
|
32
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
-
"prepack": "bob build",
|
|
34
|
-
"release": "release-it",
|
|
35
|
-
"example": "yarn --cwd example",
|
|
36
|
-
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
37
|
-
"build:ios": "cd example/ios && xcodebuild -workspace CourierReactNativeExample.xcworkspace -scheme CourierReactNativeExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
38
|
-
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
39
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build",
|
|
40
|
-
"linkPackage": "yarn link && yarn example link @trycourier/courier-react-native && yarn example setupEnv",
|
|
41
|
-
"setup": "sh setup.sh",
|
|
42
|
-
"build": "tsc",
|
|
43
|
-
"prepare": "yarn build"
|
|
44
|
-
},
|
|
45
|
-
"keywords": [
|
|
46
|
-
"react-native",
|
|
47
|
-
"ios",
|
|
48
|
-
"android"
|
|
49
|
-
],
|
|
50
|
-
"repository": "https://github.com/trycourier/courier-react-native",
|
|
51
|
-
"author": "mikemilla <mike@mikemiller.design> (https://github.com/mikemilla)",
|
|
52
|
-
"license": "MIT",
|
|
53
|
-
"bugs": {
|
|
54
|
-
"url": "https://github.com/trycourier/courier-react-native/issues"
|
|
55
|
-
},
|
|
56
|
-
"homepage": "https://github.com/trycourier/courier-react-native#readme",
|
|
57
|
-
"publishConfig": {
|
|
58
|
-
"registry": "https://registry.npmjs.org/"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@commitlint/config-conventional": "^17.0.2",
|
|
62
|
-
"@evilmartians/lefthook": "^1.2.2",
|
|
63
|
-
"@react-native-community/eslint-config": "^3.0.2",
|
|
64
|
-
"@release-it/conventional-changelog": "^5.0.0",
|
|
65
|
-
"@types/jest": "^28.1.2",
|
|
66
|
-
"@types/react": "~17.0.21",
|
|
67
|
-
"@types/react-native": "0.70.0",
|
|
68
|
-
"commitlint": "^17.0.2",
|
|
69
|
-
"del-cli": "^5.0.0",
|
|
70
|
-
"eslint": "^8.4.1",
|
|
71
|
-
"eslint-config-prettier": "^8.5.0",
|
|
72
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
73
|
-
"jest": "^28.1.1",
|
|
74
|
-
"pod-install": "^0.1.0",
|
|
75
|
-
"prettier": "^2.0.5",
|
|
76
|
-
"react": "18.2.0",
|
|
77
|
-
"react-native": "0.73.7",
|
|
78
|
-
"react-native-builder-bob": "^0.21.3",
|
|
79
|
-
"release-it": "^15.0.0",
|
|
80
|
-
"turbo": "^1.10.7",
|
|
81
|
-
"typescript": "^5.0.2"
|
|
82
|
-
},
|
|
83
|
-
"resolutions": {
|
|
84
|
-
"@types/react": "17.0.21"
|
|
85
|
-
},
|
|
86
|
-
"peerDependencies": {
|
|
87
|
-
"react": "*",
|
|
88
|
-
"react-native": "*"
|
|
89
|
-
},
|
|
90
|
-
"engines": {
|
|
91
|
-
"node": ">= 16.0.0"
|
|
92
|
-
},
|
|
93
|
-
"packageManager": "yarn@1.22.22",
|
|
94
|
-
"jest": {
|
|
95
|
-
"preset": "react-native",
|
|
96
|
-
"modulePathIgnorePatterns": [
|
|
97
|
-
"<rootDir>/example/node_modules",
|
|
98
|
-
"<rootDir>/lib/"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"commitlint": {
|
|
102
|
-
"extends": [
|
|
103
|
-
"@commitlint/config-conventional"
|
|
104
|
-
]
|
|
105
|
-
},
|
|
106
|
-
"release-it": {
|
|
107
|
-
"git": {
|
|
108
|
-
"commitMessage": "chore: release ${version}",
|
|
109
|
-
"tagName": "v${version}"
|
|
110
|
-
},
|
|
111
|
-
"npm": {
|
|
112
|
-
"publish": true
|
|
113
|
-
},
|
|
114
|
-
"github": {
|
|
115
|
-
"release": true
|
|
116
|
-
},
|
|
117
|
-
"plugins": {
|
|
118
|
-
"@release-it/conventional-changelog": {
|
|
119
|
-
"preset": "angular"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"eslintConfig": {
|
|
124
|
-
"root": true,
|
|
125
|
-
"extends": [
|
|
126
|
-
"@react-native-community",
|
|
127
|
-
"prettier"
|
|
128
|
-
],
|
|
129
|
-
"rules": {
|
|
130
|
-
"prettier/prettier": [
|
|
131
|
-
"error",
|
|
132
|
-
{
|
|
133
|
-
"quoteProps": "consistent",
|
|
134
|
-
"singleQuote": true,
|
|
135
|
-
"tabWidth": 2,
|
|
136
|
-
"trailingComma": "off",
|
|
137
|
-
"useTabs": false
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
"eslintIgnore": [
|
|
143
|
-
"node_modules/",
|
|
144
|
-
"lib/"
|
|
145
|
-
],
|
|
146
|
-
"prettier": {
|
|
147
|
-
"quoteProps": "consistent",
|
|
148
|
-
"singleQuote": true,
|
|
149
|
-
"tabWidth": 2,
|
|
150
|
-
"trailingComma": "es5",
|
|
151
|
-
"useTabs": false
|
|
152
|
-
},
|
|
153
|
-
"react-native-builder-bob": {
|
|
154
|
-
"source": "src",
|
|
155
|
-
"output": "lib",
|
|
156
|
-
"targets": [
|
|
157
|
-
"commonjs",
|
|
158
|
-
"module",
|
|
159
|
-
[
|
|
160
|
-
"typescript",
|
|
161
|
-
{
|
|
162
|
-
"project": "tsconfig.build.json"
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
]
|
|
166
|
-
},
|
|
167
|
-
"dependencies": {
|
|
168
|
-
"react-native-toast-message": "^2.2.0"
|
|
169
|
-
},
|
|
170
|
-
"private": false
|
|
171
|
-
}
|
package/lib/src/Broadcaster.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NativeEventEmitter, Platform, DeviceEventEmitter } from "react-native";
|
|
2
|
-
import { Modules } from "./Modules";
|
|
3
|
-
export default class Broadcaster {
|
|
4
|
-
emitter;
|
|
5
|
-
constructor(module) {
|
|
6
|
-
this.emitter = new NativeEventEmitter(module);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates an event listener for the native function
|
|
10
|
-
* @param key Key for the listener
|
|
11
|
-
* @param callback Value returned for the listener callback
|
|
12
|
-
* @returns Subscription
|
|
13
|
-
*/
|
|
14
|
-
async addListener(id, callback) {
|
|
15
|
-
await Modules.Shared.attachEmitter(id);
|
|
16
|
-
if (Platform.OS === 'android') {
|
|
17
|
-
return DeviceEventEmitter.addListener(id, (event) => callback(event));
|
|
18
|
-
}
|
|
19
|
-
if (Platform.OS === 'ios') {
|
|
20
|
-
return this.emitter.addListener(id, (event) => callback(event));
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
}
|
package/lib/src/Modules.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { NativeModules, Platform, UIManager, requireNativeComponent } from "react-native";
|
|
2
|
-
export class Modules {
|
|
3
|
-
static LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
4
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
5
|
-
'- You rebuilt the app after installing the package\n' +
|
|
6
|
-
'- You are not using Expo Go\n';
|
|
7
|
-
static Client = Modules.getNativeModule(NativeModules.CourierClientModule);
|
|
8
|
-
static Shared = Modules.getNativeModule(NativeModules.CourierSharedModule);
|
|
9
|
-
static System = Modules.getNativeModule(NativeModules.CourierSystemModule);
|
|
10
|
-
static getNativeModule(nativeModule) {
|
|
11
|
-
return nativeModule
|
|
12
|
-
? nativeModule
|
|
13
|
-
: new Proxy({}, {
|
|
14
|
-
get() {
|
|
15
|
-
throw new Error(Modules.LINKING_ERROR);
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
static getNativeComponent(componentName) {
|
|
20
|
-
return UIManager.getViewManagerConfig(componentName) != null
|
|
21
|
-
? requireNativeComponent(componentName)
|
|
22
|
-
: () => {
|
|
23
|
-
throw new Error(Modules.LINKING_ERROR);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Modules } from "../Modules";
|
|
2
|
-
export class BrandClient {
|
|
3
|
-
clientId;
|
|
4
|
-
constructor(clientId) {
|
|
5
|
-
this.clientId = clientId;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves brand information for a specific brand ID.
|
|
9
|
-
* @param props - The properties for getting the brand.
|
|
10
|
-
* @param props.brandId - The ID of the brand to retrieve.
|
|
11
|
-
* @returns A promise that resolves with the CourierBrandResponse containing brand information.
|
|
12
|
-
*/
|
|
13
|
-
async getBrand(props) {
|
|
14
|
-
const json = await Modules.Client.getBrand(this.clientId, props.brandId);
|
|
15
|
-
return JSON.parse(json);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Modules } from "../Modules";
|
|
2
|
-
export class ClientModule {
|
|
3
|
-
clientId;
|
|
4
|
-
// Constructor to create a low level CourierClient
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.clientId = this.add(options);
|
|
7
|
-
}
|
|
8
|
-
add(options) {
|
|
9
|
-
return Modules.Client.addClient(options);
|
|
10
|
-
}
|
|
11
|
-
remove() {
|
|
12
|
-
return Modules.Client.removeClient(this.clientId);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BrandClient } from "..";
|
|
2
|
-
import { ClientModule } from "./ClientModule";
|
|
3
|
-
import { InboxClient } from "./InboxClient";
|
|
4
|
-
import { PreferenceClient } from "./PreferenceClient";
|
|
5
|
-
import { TokenClient } from "./TokenClient";
|
|
6
|
-
import { TrackingClient } from "./TrackingClient";
|
|
7
|
-
export class CourierClient extends ClientModule {
|
|
8
|
-
options;
|
|
9
|
-
tokens;
|
|
10
|
-
brands;
|
|
11
|
-
inbox;
|
|
12
|
-
preferences;
|
|
13
|
-
tracking;
|
|
14
|
-
constructor(props) {
|
|
15
|
-
const options = {
|
|
16
|
-
userId: props.userId,
|
|
17
|
-
showLogs: props.showLogs ?? __DEV__,
|
|
18
|
-
jwt: props.jwt,
|
|
19
|
-
clientKey: props.clientKey,
|
|
20
|
-
connectionId: props.clientKey,
|
|
21
|
-
tenantId: props.tenantId,
|
|
22
|
-
};
|
|
23
|
-
super(options);
|
|
24
|
-
this.options = options;
|
|
25
|
-
this.tokens = new TokenClient(this.clientId);
|
|
26
|
-
this.brands = new BrandClient(this.clientId);
|
|
27
|
-
this.inbox = new InboxClient(this.clientId);
|
|
28
|
-
this.preferences = new PreferenceClient(this.clientId);
|
|
29
|
-
this.tracking = new TrackingClient(this.clientId);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Modules } from "../Modules";
|
|
2
|
-
export class InboxClient {
|
|
3
|
-
clientId;
|
|
4
|
-
constructor(clientId) {
|
|
5
|
-
this.clientId = clientId;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves messages from the inbox.
|
|
9
|
-
* @param props - The properties for getting messages.
|
|
10
|
-
* @param props.paginationLimit - Optional. The number of messages to retrieve per page. Defaults to 24.
|
|
11
|
-
* @param props.startCursor - Optional. The cursor to start retrieving messages from.
|
|
12
|
-
* @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the messages.
|
|
13
|
-
*/
|
|
14
|
-
async getMessages(props) {
|
|
15
|
-
const json = await Modules.Client.getMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor);
|
|
16
|
-
return JSON.parse(json);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves archived messages from the inbox.
|
|
20
|
-
* @param props - The properties for getting archived messages.
|
|
21
|
-
* @param props.paginationLimit - Optional. The number of messages to retrieve per page. Defaults to 24.
|
|
22
|
-
* @param props.startCursor - Optional. The cursor to start retrieving messages from.
|
|
23
|
-
* @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the archived messages.
|
|
24
|
-
*/
|
|
25
|
-
async getArchivedMessages(props) {
|
|
26
|
-
const json = await Modules.Client.getArchivedMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor);
|
|
27
|
-
return JSON.parse(json);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Retrieves a specific message by its ID.
|
|
31
|
-
* @param props - The properties for getting the message.
|
|
32
|
-
* @param props.messageId - The ID of the message to retrieve.
|
|
33
|
-
* @returns A promise that resolves with the CourierGetInboxMessageResponse containing the message.
|
|
34
|
-
*/
|
|
35
|
-
async getMessageById(props) {
|
|
36
|
-
const json = await Modules.Client.getMessageById(this.clientId, props.messageId);
|
|
37
|
-
return JSON.parse(json);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Retrieves the count of unread messages in the inbox.
|
|
41
|
-
* @returns A promise that resolves with the number of unread messages.
|
|
42
|
-
*/
|
|
43
|
-
async getUnreadMessageCount() {
|
|
44
|
-
return await Modules.Client.getUnreadMessageCount(this.clientId);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Marks a message as opened.
|
|
48
|
-
* @param props - The properties for opening the message.
|
|
49
|
-
* @param props.messageId - The ID of the message to mark as opened.
|
|
50
|
-
* @returns A promise that resolves with a number indicating the operation result.
|
|
51
|
-
*/
|
|
52
|
-
async open(props) {
|
|
53
|
-
return await Modules.Client.openMessage(this.clientId, props.messageId);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Marks a message as read.
|
|
57
|
-
* @param props - The properties for reading the message.
|
|
58
|
-
* @param props.messageId - The ID of the message to mark as read.
|
|
59
|
-
* @returns A promise that resolves with a number indicating the operation result.
|
|
60
|
-
*/
|
|
61
|
-
async read(props) {
|
|
62
|
-
return await Modules.Client.readMessage(this.clientId, props.messageId);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Marks a message as unread.
|
|
66
|
-
* @param props - The properties for marking the message as unread.
|
|
67
|
-
* @param props.messageId - The ID of the message to mark as unread.
|
|
68
|
-
* @returns A promise that resolves with a number indicating the operation result.
|
|
69
|
-
*/
|
|
70
|
-
async unread(props) {
|
|
71
|
-
return await Modules.Client.unreadMessage(this.clientId, props.messageId);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Records a click event for a message.
|
|
75
|
-
* @param props - The properties for clicking the message.
|
|
76
|
-
* @param props.messageId - The ID of the message that was clicked.
|
|
77
|
-
* @param props.trackingId - The tracking ID associated with the click event.
|
|
78
|
-
* @returns A promise that resolves with a number indicating the operation result.
|
|
79
|
-
*/
|
|
80
|
-
async click(props) {
|
|
81
|
-
return await Modules.Client.clickMessage(this.clientId, props.messageId, props.trackingId);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Archives a message.
|
|
85
|
-
* @param props - The properties for archiving the message.
|
|
86
|
-
* @param props.messageId - The ID of the message to archive.
|
|
87
|
-
* @returns A promise that resolves with a number indicating the operation result.
|
|
88
|
-
*/
|
|
89
|
-
async archive(props) {
|
|
90
|
-
return await Modules.Client.archiveMessage(this.clientId, props.messageId);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Marks all messages as read.
|
|
94
|
-
* @returns A promise that resolves with a number indicating the operation result.
|
|
95
|
-
*/
|
|
96
|
-
async readAll() {
|
|
97
|
-
return await Modules.Client.readAllMessages(this.clientId);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Modules } from "../Modules";
|
|
2
|
-
export class PreferenceClient {
|
|
3
|
-
clientId;
|
|
4
|
-
constructor(clientId) {
|
|
5
|
-
this.clientId = clientId;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves user preferences.
|
|
9
|
-
* @param props - Optional properties for pagination.
|
|
10
|
-
* @param props.paginationCursor - Optional cursor for pagination.
|
|
11
|
-
* @returns A promise that resolves with CourierUserPreferences containing user preference items and paging information.
|
|
12
|
-
*/
|
|
13
|
-
async getUserPreferences(props) {
|
|
14
|
-
const json = await Modules.Client.getUserPreferences(this.clientId, props?.paginationCursor);
|
|
15
|
-
const rawData = JSON.parse(json);
|
|
16
|
-
return {
|
|
17
|
-
items: rawData.items.map((item) => ({
|
|
18
|
-
defaultStatus: item.default_status,
|
|
19
|
-
hasCustomRouting: item.has_custom_routing,
|
|
20
|
-
customRouting: item.custom_routing.map((channel) => channel),
|
|
21
|
-
status: item.status,
|
|
22
|
-
topicId: item.topic_id,
|
|
23
|
-
topicName: item.topic_name,
|
|
24
|
-
sectionName: item.section_name,
|
|
25
|
-
sectionId: item.section_id
|
|
26
|
-
})),
|
|
27
|
-
paging: rawData.paging
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Retrieves user preference for a specific topic.
|
|
32
|
-
* @param props - Properties for getting the user preference topic.
|
|
33
|
-
* @param props.topicId - The ID of the topic to retrieve preferences for.
|
|
34
|
-
* @returns A promise that resolves with CourierUserPreferencesTopic containing the topic preference details.
|
|
35
|
-
*/
|
|
36
|
-
async getUserPreferenceTopic(props) {
|
|
37
|
-
const json = await Modules.Client.getUserPreferenceTopic(this.clientId, props.topicId);
|
|
38
|
-
const rawData = JSON.parse(json);
|
|
39
|
-
const convertedTopic = {
|
|
40
|
-
defaultStatus: rawData.default_status,
|
|
41
|
-
hasCustomRouting: rawData.has_custom_routing,
|
|
42
|
-
customRouting: rawData.custom_routing.map((channel) => channel),
|
|
43
|
-
status: rawData.status,
|
|
44
|
-
topicId: rawData.topic_id,
|
|
45
|
-
topicName: rawData.topic_name,
|
|
46
|
-
sectionName: rawData.section_name,
|
|
47
|
-
sectionId: rawData.section_id
|
|
48
|
-
};
|
|
49
|
-
return convertedTopic;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Updates user preference for a specific topic.
|
|
53
|
-
* @param props - Properties for updating the user preference topic.
|
|
54
|
-
* @param props.topicId - The ID of the topic to update preferences for.
|
|
55
|
-
* @param props.status - The new status for the topic preference.
|
|
56
|
-
* @param props.hasCustomRouting - Whether the topic has custom routing.
|
|
57
|
-
* @param props.customRouting - Array of custom routing channels.
|
|
58
|
-
* @returns A promise that resolves when the update is complete.
|
|
59
|
-
*/
|
|
60
|
-
async putUserPreferenceTopic(props) {
|
|
61
|
-
await Modules.Client.putUserPreferenceTopic(this.clientId, props.topicId, props.status, props.hasCustomRouting, props.customRouting);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Modules } from "../Modules";
|
|
2
|
-
export class TokenClient {
|
|
3
|
-
clientId;
|
|
4
|
-
constructor(clientId) {
|
|
5
|
-
this.clientId = clientId;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Stores a user token for a specific provider.
|
|
9
|
-
* @param props - The properties for storing the user token.
|
|
10
|
-
* @param props.token - The token to be stored.
|
|
11
|
-
* @param props.provider - The provider associated with the token.
|
|
12
|
-
* @param props.device - Optional device information.
|
|
13
|
-
* @returns A promise that resolves when the token is successfully stored.
|
|
14
|
-
*/
|
|
15
|
-
async putUserToken(props) {
|
|
16
|
-
await Modules.Client.putUserToken(this.clientId, props.token, props.provider, props.device);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Deletes a user token.
|
|
20
|
-
* @param props - The properties for deleting the user token.
|
|
21
|
-
* @param props.token - The token to be deleted.
|
|
22
|
-
* @returns A promise that resolves when the token is successfully deleted.
|
|
23
|
-
*/
|
|
24
|
-
async deleteUserToken(props) {
|
|
25
|
-
await Modules.Client.deleteUserToken(this.clientId, props.token);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Modules } from "../Modules";
|
|
2
|
-
export class TrackingClient {
|
|
3
|
-
clientId;
|
|
4
|
-
constructor(clientId) {
|
|
5
|
-
this.clientId = clientId;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Posts a tracking URL with associated event data.
|
|
9
|
-
* @param props - The properties for posting the tracking URL.
|
|
10
|
-
* @param props.url - The tracking URL to be posted.
|
|
11
|
-
* @param props.event - The CourierTrackingEvent associated with the URL.
|
|
12
|
-
* @returns A promise that resolves when the tracking URL is successfully posted.
|
|
13
|
-
*/
|
|
14
|
-
async postTrackingUrl(props) {
|
|
15
|
-
await Modules.Client.postTrackingUrl(this.clientId, props.url, props.event);
|
|
16
|
-
}
|
|
17
|
-
}
|