@pensasystems/pensa-react-native 0.1.0-beta-2
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/LICENSE +20 -0
- package/PensaSdkReactNative.podspec +25 -0
- package/README.md +373 -0
- package/android/build.gradle +90 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/pensasdkreactnative/PensaEventEmitterModule.kt +21 -0
- package/android/src/main/java/com/pensasdkreactnative/PensaListeners.kt +44 -0
- package/android/src/main/java/com/pensasdkreactnative/PensaSdkReactNativeModule.kt +172 -0
- package/android/src/main/java/com/pensasdkreactnative/PensaSdkReactNativePackage.kt +20 -0
- package/ios/PensaEventEmitter.swift +26 -0
- package/ios/PensaListeners.swift +37 -0
- package/ios/PensaSdkReactNative-Bridging-Header.h +43 -0
- package/ios/PensaSdkReactNative.mm +48 -0
- package/ios/PensaSdkReactNative.swift +121 -0
- package/ios/Podfile +35 -0
- package/lib/module/events.js +11 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +42 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/events.d.ts +7 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +16 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +26 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +154 -0
- package/src/events.ts +16 -0
- package/src/index.tsx +77 -0
- package/src/types.ts +29 -0
package/package.json
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pensasystems/pensa-react-native",
|
|
3
|
+
"version": "0.1.0-beta-2",
|
|
4
|
+
"description": "The Pensa Mobile App SDK is a developer toolkit designed to simplify adding Pensa’s capabilities to your mobile applications. It provides pre-built libraries, tools, and APIs to accelerate development and integration, offering streamlined SDK integration, easy initialization, and comprehensive functionality. With the Pensa SDK, you can enhance your app’s features or seamlessly integrate with other services for a cohesive user experience.",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace pensa-sdk-react-native-example",
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"typecheck": "tsc",
|
|
38
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
40
|
+
"prepare": "bob build",
|
|
41
|
+
"release": "release-it"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios",
|
|
46
|
+
"android"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/Pensasystems/pensa-react-native-sdk.git"
|
|
51
|
+
},
|
|
52
|
+
"author": "PensaSystems <info@pensasystems.com> (https://pensasystems.com)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/Pensasystems/pensa-react-native-sdk/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/Pensasystems/pensa-react-native-sdk#readme",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
63
|
+
"@eslint/compat": "^1.2.7",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
65
|
+
"@eslint/js": "^9.22.0",
|
|
66
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
67
|
+
"@react-native/eslint-config": "^0.78.0",
|
|
68
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
69
|
+
"@types/jest": "^29.5.5",
|
|
70
|
+
"@types/react": "^19.0.0",
|
|
71
|
+
"commitlint": "^19.6.1",
|
|
72
|
+
"del-cli": "^5.1.0",
|
|
73
|
+
"eslint": "^9.22.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.1",
|
|
75
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"prettier": "^3.0.3",
|
|
78
|
+
"react": "19.0.0",
|
|
79
|
+
"react-native": "0.78.2",
|
|
80
|
+
"react-native-builder-bob": "^0.40.12",
|
|
81
|
+
"release-it": "^17.10.0",
|
|
82
|
+
"turbo": "^1.10.7",
|
|
83
|
+
"typescript": "^5.2.2"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"react": "*",
|
|
87
|
+
"react-native": "*"
|
|
88
|
+
},
|
|
89
|
+
"workspaces": [
|
|
90
|
+
"example"
|
|
91
|
+
],
|
|
92
|
+
"packageManager": "yarn@3.6.1",
|
|
93
|
+
"jest": {
|
|
94
|
+
"preset": "react-native",
|
|
95
|
+
"modulePathIgnorePatterns": [
|
|
96
|
+
"<rootDir>/example/node_modules",
|
|
97
|
+
"<rootDir>/lib/"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"commitlint": {
|
|
101
|
+
"extends": [
|
|
102
|
+
"@commitlint/config-conventional"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"release-it": {
|
|
106
|
+
"git": {
|
|
107
|
+
"commitMessage": "chore: release ${version}",
|
|
108
|
+
"tagName": "v${version}"
|
|
109
|
+
},
|
|
110
|
+
"npm": {
|
|
111
|
+
"publish": true
|
|
112
|
+
},
|
|
113
|
+
"github": {
|
|
114
|
+
"release": true
|
|
115
|
+
},
|
|
116
|
+
"plugins": {
|
|
117
|
+
"@release-it/conventional-changelog": {
|
|
118
|
+
"preset": {
|
|
119
|
+
"name": "angular"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"prettier": {
|
|
125
|
+
"quoteProps": "consistent",
|
|
126
|
+
"singleQuote": true,
|
|
127
|
+
"tabWidth": 2,
|
|
128
|
+
"trailingComma": "es5",
|
|
129
|
+
"useTabs": false
|
|
130
|
+
},
|
|
131
|
+
"react-native-builder-bob": {
|
|
132
|
+
"source": "src",
|
|
133
|
+
"output": "lib",
|
|
134
|
+
"targets": [
|
|
135
|
+
[
|
|
136
|
+
"module",
|
|
137
|
+
{
|
|
138
|
+
"esm": true
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
"typescript",
|
|
143
|
+
{
|
|
144
|
+
"project": "tsconfig.build.json"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
"create-react-native-library": {
|
|
150
|
+
"type": "legacy-module",
|
|
151
|
+
"languages": "kotlin-swift",
|
|
152
|
+
"version": "0.49.8"
|
|
153
|
+
}
|
|
154
|
+
}
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import type { PensaEventPayloads } from './types';
|
|
3
|
+
|
|
4
|
+
const nativeEmitter = new NativeEventEmitter(NativeModules.PensaEventEmitter);
|
|
5
|
+
|
|
6
|
+
type PensaEvent = keyof PensaEventPayloads;
|
|
7
|
+
|
|
8
|
+
export const PensaEvents = {
|
|
9
|
+
addListener: <E extends PensaEvent>(
|
|
10
|
+
event: E,
|
|
11
|
+
callback: (data: PensaEventPayloads[E]) => void
|
|
12
|
+
) => {
|
|
13
|
+
const sub = nativeEmitter.addListener(event, callback);
|
|
14
|
+
return () => sub.remove();
|
|
15
|
+
},
|
|
16
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package 'pensa-sdk-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
+
'- You rebuilt the app after installing the package\n' +
|
|
7
|
+
'- You are not using Expo Go\n';
|
|
8
|
+
|
|
9
|
+
const PensaSdkReactNative = NativeModules.PensaSdkReactNative
|
|
10
|
+
? NativeModules.PensaSdkReactNative
|
|
11
|
+
: new Proxy(
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const initPensa = (config: {
|
|
21
|
+
clientId: string;
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
isLoggingEnabled?: boolean;
|
|
24
|
+
}): Promise<void> => {
|
|
25
|
+
return PensaSdkReactNative.initPensa(config);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const isPensaStarted = (): Promise<boolean> => {
|
|
29
|
+
return PensaSdkReactNative.isPensaStarted();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const showShelfScans = (): Promise<void> => {
|
|
33
|
+
return PensaSdkReactNative.showShelfScans();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const showProductScans = (): Promise<void> => {
|
|
37
|
+
return PensaSdkReactNative.showProductScans();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const showStoreSearchView = (): Promise<void> => {
|
|
41
|
+
return PensaSdkReactNative.showStoreSearchView();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const showStoresScreen = (): Promise<void> => {
|
|
45
|
+
return PensaSdkReactNative.showStoresScreen();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const showScanArea = (
|
|
49
|
+
scanId: number,
|
|
50
|
+
storeId?: number,
|
|
51
|
+
globalStoreId?: string
|
|
52
|
+
): Promise<void> => {
|
|
53
|
+
return PensaSdkReactNative.showScanArea(
|
|
54
|
+
scanId,
|
|
55
|
+
storeId ?? null,
|
|
56
|
+
globalStoreId ?? null
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const showStockingScreen = (): Promise<void> => {
|
|
61
|
+
return PensaSdkReactNative.showStockingScreen();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const showStoreChecklist = (
|
|
65
|
+
globalStoreId: string,
|
|
66
|
+
guid?: string,
|
|
67
|
+
sectionKey?: string
|
|
68
|
+
): Promise<void> => {
|
|
69
|
+
return PensaSdkReactNative.showStoreChecklist(
|
|
70
|
+
globalStoreId,
|
|
71
|
+
guid,
|
|
72
|
+
sectionKey
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export * from './events';
|
|
77
|
+
export * from './types';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type OnScanUploadProgressUpdate = {
|
|
2
|
+
tdlinxId: string;
|
|
3
|
+
scanAreaId: string;
|
|
4
|
+
progress: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type OnScanUploadCompleted = {
|
|
8
|
+
tdlinxId: string;
|
|
9
|
+
scanAreaId: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type OnScanUploadFailed = {
|
|
13
|
+
tdlinxId: string;
|
|
14
|
+
scanAreaId: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type OnCantScanReported = {
|
|
19
|
+
tdlinxId: string;
|
|
20
|
+
scanAreaId: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type PensaEventPayloads = {
|
|
25
|
+
onScanUploadProgressUpdate: OnScanUploadProgressUpdate;
|
|
26
|
+
onScanUploadCompleted: OnScanUploadCompleted;
|
|
27
|
+
onScanUploadFailed: OnScanUploadFailed;
|
|
28
|
+
onCantScanReported: OnCantScanReported;
|
|
29
|
+
};
|