@takeoffmedia/react-native-penthera 0.2.11 → 0.2.14
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/ios/Penthera.swift +45 -2
- package/ios/Util.swift +8 -0
- package/lib/commonjs/hooks/usePenthera/usePenthera.js +6 -87
- package/lib/commonjs/hooks/usePenthera/usePenthera.js.map +1 -1
- package/lib/commonjs/hooks/usePenthera/usePenthera.types.js.map +1 -1
- package/lib/commonjs/hooks/usePenthera/usePentheraInit.js +96 -0
- package/lib/commonjs/hooks/usePenthera/usePentheraInit.js.map +1 -0
- package/lib/commonjs/index.js +0 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/hooks/usePenthera/usePenthera.js +8 -88
- package/lib/module/hooks/usePenthera/usePenthera.js.map +1 -1
- package/lib/module/hooks/usePenthera/usePenthera.types.js.map +1 -1
- package/lib/module/hooks/usePenthera/usePentheraInit.js +90 -0
- package/lib/module/hooks/usePenthera/usePentheraInit.js.map +1 -0
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePenthera.d.ts +1 -2
- package/lib/typescript/hooks/usePenthera/usePenthera.d.ts.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePenthera.types.d.ts +6 -3
- package/lib/typescript/hooks/usePenthera/usePenthera.types.d.ts.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePentheraInit.d.ts +3 -0
- package/lib/typescript/hooks/usePenthera/usePentheraInit.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/usePenthera/usePenthera.tsx +8 -113
- package/src/hooks/usePenthera/usePenthera.types.ts +7 -3
- package/src/hooks/usePenthera/usePentheraInit.tsx +112 -0
- package/src/index.tsx +0 -1
- package/ios/Penthera.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Penthera.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Penthera.xcodeproj/project.xcworkspace/xcuserdata/joseguerreroot.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -104
- package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/lib/commonjs/utils/utils.js +0 -33
- package/lib/commonjs/utils/utils.js.map +0 -1
- package/lib/module/utils/utils.js +0 -25
- package/lib/module/utils/utils.js.map +0 -1
- package/lib/typescript/utils/utils.d.ts +0 -12
- package/lib/typescript/utils/utils.d.ts.map +0 -1
- package/src/utils/utils.ts +0 -35
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PentheraState, PentheraAction } from './usePenthera.types';
|
|
2
2
|
export declare const usePenthera: import("zustand").UseBoundStore<import("zustand").StoreApi<PentheraState & PentheraAction>>;
|
|
3
|
-
export declare function usePentheraInit({ userId, BACKPLANE_PRIVATE_KEY, BACKPLANE_PUBLIC_KEY, BACKPLANE_URL, }: PentheraProviderProps): void;
|
|
4
3
|
//# sourceMappingURL=usePenthera.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePenthera.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePenthera/usePenthera.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePenthera.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePenthera/usePenthera.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAU7B,eAAO,MAAM,WAAW,6FAmGrB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PentheraTypes } from 'src/interface/PentheraTypes';
|
|
3
|
-
import type { IParseError } from 'src/utils/utils';
|
|
4
3
|
export declare enum PentheraEvent {
|
|
5
4
|
VIRTUOSO_SUCCESS = "Virtuoso Success",
|
|
6
5
|
DID_START_DOWNLOADING = "DID_START_DOWNLOADING",
|
|
@@ -26,7 +25,7 @@ export interface InterfaceDataPlay {
|
|
|
26
25
|
export type PentheraState = {
|
|
27
26
|
assets: PentheraTypes.ItemCatalog[] | [];
|
|
28
27
|
assetsProgress: AssetProgress | {};
|
|
29
|
-
assetError:
|
|
28
|
+
assetError: AssetError;
|
|
30
29
|
};
|
|
31
30
|
export type PentheraProviderProps = React.PropsWithChildren<{
|
|
32
31
|
userId: string;
|
|
@@ -34,6 +33,10 @@ export type PentheraProviderProps = React.PropsWithChildren<{
|
|
|
34
33
|
BACKPLANE_PUBLIC_KEY: string;
|
|
35
34
|
BACKPLANE_PRIVATE_KEY: string;
|
|
36
35
|
}>;
|
|
36
|
+
export type AssetError = {
|
|
37
|
+
assetId: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
37
40
|
export type PentheraAction = {
|
|
38
41
|
loadAssets: (assets: PentheraTypes.ItemCatalog[]) => void;
|
|
39
42
|
addAsset: (asset: PentheraTypes.ItemCatalog) => void;
|
|
@@ -44,7 +47,7 @@ export type PentheraAction = {
|
|
|
44
47
|
onDelete: (assetIDs: string[]) => void;
|
|
45
48
|
onPauseDownload: (assetID: string) => void;
|
|
46
49
|
onPlayVideo: (assetID: string) => Promise<InterfaceDataPlay>;
|
|
47
|
-
setError: (data:
|
|
50
|
+
setError: (data: AssetError) => void;
|
|
48
51
|
};
|
|
49
52
|
export type Event = {
|
|
50
53
|
code: PentheraEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePenthera.types.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePenthera/usePenthera.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"usePenthera.types.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePenthera/usePenthera.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,oBAAY,aAAa;IACvB,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,mBAAmB,wBAAwB;IAC3C,6BAA6B,kCAAkC;IAC/D,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;CAC5C;AACD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC;IACzC,cAAc,EAAE,aAAa,GAAG,EAAE,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC;IAC1D,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,KAAK,IAAI,CAAC;IACrD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC/C,oBAAoB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7D,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,UAAU,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,cAAc,KAAK,IAAI,CAAC;IACzD,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC7D,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePentheraInit.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePenthera/usePentheraInit.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,qBAAqB,CAAC;AAW7B,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GACd,EAAE,qBAAqB,QAuFvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
3
|
-
import type { EmitterSubscription } from 'react-native';
|
|
1
|
+
import { Platform } from 'react-native';
|
|
4
2
|
import { create } from 'zustand';
|
|
5
3
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
type PentheraState,
|
|
9
|
-
type PentheraProviderProps,
|
|
4
|
+
import type {
|
|
5
|
+
PentheraState,
|
|
10
6
|
PentheraAction,
|
|
11
|
-
Event,
|
|
12
7
|
InterfaceDataPlay,
|
|
13
8
|
} from './usePenthera.types';
|
|
14
9
|
import {
|
|
15
10
|
deleteMany,
|
|
16
11
|
download,
|
|
17
12
|
getDownloads,
|
|
18
|
-
initialize,
|
|
19
13
|
pauseDownload,
|
|
20
14
|
playAsset,
|
|
21
15
|
} from '../../nativeModules';
|
|
22
16
|
import type { PentheraTypes } from '../../interface/PentheraTypes';
|
|
23
|
-
import { manageDataError } from '../../utils/utils';
|
|
24
17
|
|
|
25
18
|
export const usePenthera = create<PentheraState & PentheraAction>((set) => ({
|
|
26
19
|
assets: [],
|
|
27
20
|
assetsProgress: {},
|
|
28
|
-
assetError: {
|
|
21
|
+
assetError: {
|
|
22
|
+
assetId: '',
|
|
23
|
+
description: '',
|
|
24
|
+
},
|
|
29
25
|
loadAssets: (assets: PentheraState['assets']) =>
|
|
30
26
|
set(() => ({
|
|
31
27
|
assets,
|
|
@@ -115,108 +111,7 @@ export const usePenthera = create<PentheraState & PentheraAction>((set) => ({
|
|
|
115
111
|
setError: (dataParse) => {
|
|
116
112
|
return set(() => ({
|
|
117
113
|
assetError: dataParse,
|
|
114
|
+
assetsProgress: {},
|
|
118
115
|
}));
|
|
119
116
|
},
|
|
120
117
|
}));
|
|
121
|
-
|
|
122
|
-
const onListener = (sessionConnect: (event: string) => void) => {
|
|
123
|
-
const NEventEmitter = NativeModules.Penthera;
|
|
124
|
-
const eventEmitter = new NativeEventEmitter(NEventEmitter);
|
|
125
|
-
eventEmitter.removeAllListeners('penthera');
|
|
126
|
-
const eventListener = eventEmitter.addListener('penthera', sessionConnect);
|
|
127
|
-
return eventListener;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export function usePentheraInit({
|
|
131
|
-
userId,
|
|
132
|
-
BACKPLANE_PRIVATE_KEY,
|
|
133
|
-
BACKPLANE_PUBLIC_KEY,
|
|
134
|
-
BACKPLANE_URL,
|
|
135
|
-
}: PentheraProviderProps) {
|
|
136
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
137
|
-
const addAsset = usePenthera((state) => state.addAsset);
|
|
138
|
-
const deleteManyAssets = usePenthera((state) => state.deleteManyAssets);
|
|
139
|
-
const updateAssetsProgress = usePenthera(
|
|
140
|
-
(state) => state.updateAssetsProgress
|
|
141
|
-
);
|
|
142
|
-
const onGetAllAssets = usePenthera((state) => state.onGetAllAssets);
|
|
143
|
-
const setError = usePenthera((state) => state.setError);
|
|
144
|
-
useEffect(() => {
|
|
145
|
-
if (
|
|
146
|
-
!userId ||
|
|
147
|
-
!BACKPLANE_PRIVATE_KEY ||
|
|
148
|
-
!BACKPLANE_PUBLIC_KEY ||
|
|
149
|
-
!BACKPLANE_URL
|
|
150
|
-
) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const init = async () => {
|
|
155
|
-
await initialize(
|
|
156
|
-
userId,
|
|
157
|
-
BACKPLANE_URL,
|
|
158
|
-
BACKPLANE_PUBLIC_KEY,
|
|
159
|
-
BACKPLANE_PRIVATE_KEY
|
|
160
|
-
);
|
|
161
|
-
setIsInitialized(true);
|
|
162
|
-
};
|
|
163
|
-
init();
|
|
164
|
-
}, [userId, BACKPLANE_PRIVATE_KEY, BACKPLANE_PUBLIC_KEY, BACKPLANE_URL]);
|
|
165
|
-
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
if (!isInitialized) return;
|
|
168
|
-
console.log('starting init');
|
|
169
|
-
const sessionConnect = (newEvent: string) => {
|
|
170
|
-
const info: Event = JSON.parse(newEvent);
|
|
171
|
-
console.log('info', info);
|
|
172
|
-
switch (info.code) {
|
|
173
|
-
case PentheraEvent.VIRTUOSO_SUCCESS:
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
|
-
case PentheraEvent.DID_START_DOWNLOADING:
|
|
177
|
-
updateAssetsProgress({ [info?.assetId]: '0' });
|
|
178
|
-
break;
|
|
179
|
-
|
|
180
|
-
case PentheraEvent.PROGRESS_UPDATED:
|
|
181
|
-
updateAssetsProgress({ [info?.assetId]: info.body });
|
|
182
|
-
break;
|
|
183
|
-
|
|
184
|
-
case PentheraEvent.DOWNLOAD_COMPLETE:
|
|
185
|
-
updateAssetsProgress({ [info.assetId]: '100' });
|
|
186
|
-
onGetAllAssets();
|
|
187
|
-
break;
|
|
188
|
-
|
|
189
|
-
case PentheraEvent.ASSET_RESUME_DOWNLOAD_UPDATED:
|
|
190
|
-
//TODO: Can be util for pause and resume download state
|
|
191
|
-
break;
|
|
192
|
-
|
|
193
|
-
case PentheraEvent.ASSET_DELETED:
|
|
194
|
-
deleteManyAssets([info?.assetId]);
|
|
195
|
-
break;
|
|
196
|
-
case PentheraEvent.ERROR_DOWNLOAD:
|
|
197
|
-
setError(manageDataError(info));
|
|
198
|
-
break;
|
|
199
|
-
case PentheraEvent.CONFIG_ASSET_FAILED:
|
|
200
|
-
case PentheraEvent.PENDING_ASSET_FOUND:
|
|
201
|
-
default:
|
|
202
|
-
console.log('case nout found:', info);
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
onGetAllAssets();
|
|
207
|
-
let eventListener: EmitterSubscription | undefined;
|
|
208
|
-
eventListener = onListener(sessionConnect);
|
|
209
|
-
|
|
210
|
-
return () => {
|
|
211
|
-
eventListener?.remove();
|
|
212
|
-
setIsInitialized(false);
|
|
213
|
-
};
|
|
214
|
-
}, [
|
|
215
|
-
isInitialized,
|
|
216
|
-
addAsset,
|
|
217
|
-
deleteManyAssets,
|
|
218
|
-
onGetAllAssets,
|
|
219
|
-
updateAssetsProgress,
|
|
220
|
-
setError,
|
|
221
|
-
]);
|
|
222
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PentheraTypes } from 'src/interface/PentheraTypes';
|
|
2
|
-
import type { IParseError } from 'src/utils/utils';
|
|
3
2
|
|
|
4
3
|
export enum PentheraEvent {
|
|
5
4
|
VIRTUOSO_SUCCESS = 'Virtuoso Success',
|
|
@@ -29,7 +28,7 @@ export interface InterfaceDataPlay {
|
|
|
29
28
|
export type PentheraState = {
|
|
30
29
|
assets: PentheraTypes.ItemCatalog[] | [];
|
|
31
30
|
assetsProgress: AssetProgress | {};
|
|
32
|
-
assetError:
|
|
31
|
+
assetError: AssetError;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
export type PentheraProviderProps = React.PropsWithChildren<{
|
|
@@ -39,6 +38,11 @@ export type PentheraProviderProps = React.PropsWithChildren<{
|
|
|
39
38
|
BACKPLANE_PRIVATE_KEY: string;
|
|
40
39
|
}>;
|
|
41
40
|
|
|
41
|
+
export type AssetError = {
|
|
42
|
+
assetId: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
42
46
|
export type PentheraAction = {
|
|
43
47
|
loadAssets: (assets: PentheraTypes.ItemCatalog[]) => void;
|
|
44
48
|
addAsset: (asset: PentheraTypes.ItemCatalog) => void;
|
|
@@ -49,7 +53,7 @@ export type PentheraAction = {
|
|
|
49
53
|
onDelete: (assetIDs: string[]) => void;
|
|
50
54
|
onPauseDownload: (assetID: string) => void;
|
|
51
55
|
onPlayVideo: (assetID: string) => Promise<InterfaceDataPlay>;
|
|
52
|
-
setError: (data:
|
|
56
|
+
setError: (data: AssetError) => void;
|
|
53
57
|
};
|
|
54
58
|
|
|
55
59
|
export type Event = {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
3
|
+
import type { EmitterSubscription } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
PentheraEvent,
|
|
7
|
+
type PentheraProviderProps,
|
|
8
|
+
Event,
|
|
9
|
+
} from './usePenthera.types';
|
|
10
|
+
import { initialize } from '../../nativeModules';
|
|
11
|
+
import { usePenthera } from './usePenthera';
|
|
12
|
+
const onListener = (sessionConnect: (event: string) => void) => {
|
|
13
|
+
const NEventEmitter = NativeModules.Penthera;
|
|
14
|
+
const eventEmitter = new NativeEventEmitter(NEventEmitter);
|
|
15
|
+
eventEmitter.removeAllListeners('penthera');
|
|
16
|
+
const eventListener = eventEmitter.addListener('penthera', sessionConnect);
|
|
17
|
+
return eventListener;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function usePentheraInit({
|
|
21
|
+
userId,
|
|
22
|
+
BACKPLANE_PRIVATE_KEY,
|
|
23
|
+
BACKPLANE_PUBLIC_KEY,
|
|
24
|
+
BACKPLANE_URL,
|
|
25
|
+
}: PentheraProviderProps) {
|
|
26
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
27
|
+
const addAsset = usePenthera((state) => state.addAsset);
|
|
28
|
+
const deleteManyAssets = usePenthera((state) => state.deleteManyAssets);
|
|
29
|
+
const updateAssetsProgress = usePenthera(
|
|
30
|
+
(state) => state.updateAssetsProgress
|
|
31
|
+
);
|
|
32
|
+
const onGetAllAssets = usePenthera((state) => state.onGetAllAssets);
|
|
33
|
+
const setError = usePenthera((state) => state.setError);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (
|
|
36
|
+
!userId ||
|
|
37
|
+
!BACKPLANE_PRIVATE_KEY ||
|
|
38
|
+
!BACKPLANE_PUBLIC_KEY ||
|
|
39
|
+
!BACKPLANE_URL
|
|
40
|
+
) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const init = async () => {
|
|
45
|
+
await initialize(
|
|
46
|
+
userId,
|
|
47
|
+
BACKPLANE_URL,
|
|
48
|
+
BACKPLANE_PUBLIC_KEY,
|
|
49
|
+
BACKPLANE_PRIVATE_KEY
|
|
50
|
+
);
|
|
51
|
+
setIsInitialized(true);
|
|
52
|
+
};
|
|
53
|
+
init();
|
|
54
|
+
}, [userId, BACKPLANE_PRIVATE_KEY, BACKPLANE_PUBLIC_KEY, BACKPLANE_URL]);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!isInitialized) return;
|
|
58
|
+
console.log('starting init');
|
|
59
|
+
const sessionConnect = (newEvent: string) => {
|
|
60
|
+
const info: Event = JSON.parse(newEvent);
|
|
61
|
+
console.log('info', info);
|
|
62
|
+
switch (info.code) {
|
|
63
|
+
case PentheraEvent.VIRTUOSO_SUCCESS:
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case PentheraEvent.DID_START_DOWNLOADING:
|
|
67
|
+
updateAssetsProgress({ [info?.assetId]: '0' });
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case PentheraEvent.PROGRESS_UPDATED:
|
|
71
|
+
updateAssetsProgress({ [info?.assetId]: info.body });
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case PentheraEvent.DOWNLOAD_COMPLETE:
|
|
75
|
+
updateAssetsProgress({ [info.assetId]: '100' });
|
|
76
|
+
onGetAllAssets();
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case PentheraEvent.ASSET_RESUME_DOWNLOAD_UPDATED:
|
|
80
|
+
//TODO: Can be util for pause and resume download state
|
|
81
|
+
break;
|
|
82
|
+
|
|
83
|
+
case PentheraEvent.ASSET_DELETED:
|
|
84
|
+
deleteManyAssets([info?.assetId]);
|
|
85
|
+
break;
|
|
86
|
+
case PentheraEvent.ERROR_DOWNLOAD:
|
|
87
|
+
setError({ assetId: info?.assetId, description: info?.body });
|
|
88
|
+
break;
|
|
89
|
+
case PentheraEvent.CONFIG_ASSET_FAILED:
|
|
90
|
+
case PentheraEvent.PENDING_ASSET_FOUND:
|
|
91
|
+
default:
|
|
92
|
+
console.log('case nout found:', info);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
onGetAllAssets();
|
|
97
|
+
let eventListener: EmitterSubscription | undefined;
|
|
98
|
+
eventListener = onListener(sessionConnect);
|
|
99
|
+
|
|
100
|
+
return () => {
|
|
101
|
+
eventListener?.remove();
|
|
102
|
+
setIsInitialized(false);
|
|
103
|
+
};
|
|
104
|
+
}, [
|
|
105
|
+
isInitialized,
|
|
106
|
+
addAsset,
|
|
107
|
+
deleteManyAssets,
|
|
108
|
+
onGetAllAssets,
|
|
109
|
+
updateAssetsProgress,
|
|
110
|
+
setError,
|
|
111
|
+
]);
|
|
112
|
+
}
|
package/src/index.tsx
CHANGED
|
Binary file
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<Bucket
|
|
3
|
-
uuid = "3AE98629-7421-4561-B12C-C06B8B6A3023"
|
|
4
|
-
type = "1"
|
|
5
|
-
version = "2.0">
|
|
6
|
-
<Breakpoints>
|
|
7
|
-
<BreakpointProxy
|
|
8
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
9
|
-
<BreakpointContent
|
|
10
|
-
uuid = "A5D166B0-3C57-4F4D-A845-BDB81498DA0F"
|
|
11
|
-
shouldBeEnabled = "No"
|
|
12
|
-
ignoreCount = "0"
|
|
13
|
-
continueAfterRunningActions = "No"
|
|
14
|
-
filePath = "Penthera.swift"
|
|
15
|
-
startingColumnNumber = "9223372036854775807"
|
|
16
|
-
endingColumnNumber = "9223372036854775807"
|
|
17
|
-
startingLineNumber = "18"
|
|
18
|
-
endingLineNumber = "18"
|
|
19
|
-
landmarkName = "initializeSdk(user:backplaneUrl:publicKey:privateKey:resolve:reject:)"
|
|
20
|
-
landmarkType = "7">
|
|
21
|
-
</BreakpointContent>
|
|
22
|
-
</BreakpointProxy>
|
|
23
|
-
<BreakpointProxy
|
|
24
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
25
|
-
<BreakpointContent
|
|
26
|
-
uuid = "5D7AE47B-D5FC-4468-A75B-C414F3F8A58C"
|
|
27
|
-
shouldBeEnabled = "No"
|
|
28
|
-
ignoreCount = "0"
|
|
29
|
-
continueAfterRunningActions = "No"
|
|
30
|
-
filePath = "Penthera.swift"
|
|
31
|
-
startingColumnNumber = "9223372036854775807"
|
|
32
|
-
endingColumnNumber = "9223372036854775807"
|
|
33
|
-
startingLineNumber = "25"
|
|
34
|
-
endingLineNumber = "25"
|
|
35
|
-
landmarkName = "initializeSdk(user:backplaneUrl:publicKey:privateKey:resolve:reject:)"
|
|
36
|
-
landmarkType = "7">
|
|
37
|
-
</BreakpointContent>
|
|
38
|
-
</BreakpointProxy>
|
|
39
|
-
<BreakpointProxy
|
|
40
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
41
|
-
<BreakpointContent
|
|
42
|
-
uuid = "E3C50B30-46CF-4D56-8C49-C257C70E0ACC"
|
|
43
|
-
shouldBeEnabled = "No"
|
|
44
|
-
ignoreCount = "0"
|
|
45
|
-
continueAfterRunningActions = "No"
|
|
46
|
-
filePath = "Penthera.swift"
|
|
47
|
-
startingColumnNumber = "9223372036854775807"
|
|
48
|
-
endingColumnNumber = "9223372036854775807"
|
|
49
|
-
startingLineNumber = "26"
|
|
50
|
-
endingLineNumber = "26"
|
|
51
|
-
landmarkName = "initializeSdk(user:backplaneUrl:publicKey:privateKey:resolve:reject:)"
|
|
52
|
-
landmarkType = "7">
|
|
53
|
-
</BreakpointContent>
|
|
54
|
-
</BreakpointProxy>
|
|
55
|
-
<BreakpointProxy
|
|
56
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
57
|
-
<BreakpointContent
|
|
58
|
-
uuid = "75EF43BF-56FF-4727-B372-E1A0EBC02C61"
|
|
59
|
-
shouldBeEnabled = "Yes"
|
|
60
|
-
ignoreCount = "0"
|
|
61
|
-
continueAfterRunningActions = "No"
|
|
62
|
-
filePath = "Penthera.swift"
|
|
63
|
-
startingColumnNumber = "9223372036854775807"
|
|
64
|
-
endingColumnNumber = "9223372036854775807"
|
|
65
|
-
startingLineNumber = "101"
|
|
66
|
-
endingLineNumber = "101"
|
|
67
|
-
landmarkName = "getDownloads(blank:resolve:reject:)"
|
|
68
|
-
landmarkType = "7">
|
|
69
|
-
</BreakpointContent>
|
|
70
|
-
</BreakpointProxy>
|
|
71
|
-
<BreakpointProxy
|
|
72
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
73
|
-
<BreakpointContent
|
|
74
|
-
uuid = "EF36B51B-4FC2-4989-A791-180E3212EFE3"
|
|
75
|
-
shouldBeEnabled = "Yes"
|
|
76
|
-
ignoreCount = "0"
|
|
77
|
-
continueAfterRunningActions = "No"
|
|
78
|
-
filePath = "Penthera.swift"
|
|
79
|
-
startingColumnNumber = "9223372036854775807"
|
|
80
|
-
endingColumnNumber = "9223372036854775807"
|
|
81
|
-
startingLineNumber = "149"
|
|
82
|
-
endingLineNumber = "149"
|
|
83
|
-
landmarkName = "getDownloads(blank:resolve:reject:)"
|
|
84
|
-
landmarkType = "7">
|
|
85
|
-
</BreakpointContent>
|
|
86
|
-
</BreakpointProxy>
|
|
87
|
-
<BreakpointProxy
|
|
88
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
89
|
-
<BreakpointContent
|
|
90
|
-
uuid = "C467C00E-2428-4D24-843A-E7CDF28CB553"
|
|
91
|
-
shouldBeEnabled = "Yes"
|
|
92
|
-
ignoreCount = "0"
|
|
93
|
-
continueAfterRunningActions = "No"
|
|
94
|
-
filePath = "Penthera.swift"
|
|
95
|
-
startingColumnNumber = "9223372036854775807"
|
|
96
|
-
endingColumnNumber = "9223372036854775807"
|
|
97
|
-
startingLineNumber = "148"
|
|
98
|
-
endingLineNumber = "148"
|
|
99
|
-
landmarkName = "getDownloads(blank:resolve:reject:)"
|
|
100
|
-
landmarkType = "7">
|
|
101
|
-
</BreakpointContent>
|
|
102
|
-
</BreakpointProxy>
|
|
103
|
-
</Breakpoints>
|
|
104
|
-
</Bucket>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>Penthera.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.manageDataError = exports.Description = void 0;
|
|
7
|
-
let Description = /*#__PURE__*/function (Description) {
|
|
8
|
-
Description["ASSET_ALREADY_DOWNLOADED"] = "ASSET_ALREADY_DOWNLOADED";
|
|
9
|
-
Description["LIMIT_EXCEEDED"] = "LIMIT_EXCEEDED";
|
|
10
|
-
Description["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
11
|
-
return Description;
|
|
12
|
-
}({});
|
|
13
|
-
exports.Description = Description;
|
|
14
|
-
const errorMappings = {
|
|
15
|
-
'The asset has already been downloaded as many times as permitted. To download this asset again, administrative action is required.': Description.ASSET_ALREADY_DOWNLOADED,
|
|
16
|
-
'There are already as many downloads as permitted on this account. To continue downloading, the user must delete downloaded assets from one of their devices.': Description.LIMIT_EXCEEDED
|
|
17
|
-
};
|
|
18
|
-
const manageDataError = event => {
|
|
19
|
-
for (const [pattern, code] of Object.entries(errorMappings)) {
|
|
20
|
-
if (event.body.includes(pattern)) {
|
|
21
|
-
return {
|
|
22
|
-
assetId: event.assetId,
|
|
23
|
-
description: code
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
assetId: event.assetId,
|
|
29
|
-
description: Description.UNKNOWN_ERROR
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.manageDataError = manageDataError;
|
|
33
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Description","exports","errorMappings","ASSET_ALREADY_DOWNLOADED","LIMIT_EXCEEDED","manageDataError","event","pattern","code","Object","entries","body","includes","assetId","description","UNKNOWN_ERROR"],"sourceRoot":"../../../src","sources":["utils/utils.ts"],"mappings":";;;;;;IAEYA,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAAAC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AAMvB,MAAME,aAAa,GAAG;EACpB,qIAAqI,EACnIF,WAAW,CAACG,wBAAwB;EACtC,+JAA+J,EAC7JH,WAAW,CAACI;AAChB,CAAC;AAOM,MAAMC,eAAe,GAAIC,KAAY,IAAkB;EAC5D,KAAK,MAAM,CAACC,OAAO,EAAEC,IAAI,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,aAAa,CAAC,EAAE;IAC3D,IAAII,KAAK,CAACK,IAAI,CAACC,QAAQ,CAACL,OAAO,CAAC,EAAE;MAChC,OAAO;QACLM,OAAO,EAAEP,KAAK,CAACO,OAAO;QACtBC,WAAW,EAAEN;MACf,CAAC;IACH;EACF;EAEA,OAAO;IACLK,OAAO,EAAEP,KAAK,CAACO,OAAO;IACtBC,WAAW,EAAEd,WAAW,CAACe;EAC3B,CAAC;AACH,CAAC;AAACd,OAAA,CAAAI,eAAA,GAAAA,eAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export let Description = /*#__PURE__*/function (Description) {
|
|
2
|
-
Description["ASSET_ALREADY_DOWNLOADED"] = "ASSET_ALREADY_DOWNLOADED";
|
|
3
|
-
Description["LIMIT_EXCEEDED"] = "LIMIT_EXCEEDED";
|
|
4
|
-
Description["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
5
|
-
return Description;
|
|
6
|
-
}({});
|
|
7
|
-
const errorMappings = {
|
|
8
|
-
'The asset has already been downloaded as many times as permitted. To download this asset again, administrative action is required.': Description.ASSET_ALREADY_DOWNLOADED,
|
|
9
|
-
'There are already as many downloads as permitted on this account. To continue downloading, the user must delete downloaded assets from one of their devices.': Description.LIMIT_EXCEEDED
|
|
10
|
-
};
|
|
11
|
-
export const manageDataError = event => {
|
|
12
|
-
for (const [pattern, code] of Object.entries(errorMappings)) {
|
|
13
|
-
if (event.body.includes(pattern)) {
|
|
14
|
-
return {
|
|
15
|
-
assetId: event.assetId,
|
|
16
|
-
description: code
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
assetId: event.assetId,
|
|
22
|
-
description: Description.UNKNOWN_ERROR
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Description","errorMappings","ASSET_ALREADY_DOWNLOADED","LIMIT_EXCEEDED","manageDataError","event","pattern","code","Object","entries","body","includes","assetId","description","UNKNOWN_ERROR"],"sourceRoot":"../../../src","sources":["utils/utils.ts"],"mappings":"AAEA,WAAYA,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAMvB,MAAMC,aAAa,GAAG;EACpB,qIAAqI,EACnID,WAAW,CAACE,wBAAwB;EACtC,+JAA+J,EAC7JF,WAAW,CAACG;AAChB,CAAC;AAOD,OAAO,MAAMC,eAAe,GAAIC,KAAY,IAAkB;EAC5D,KAAK,MAAM,CAACC,OAAO,EAAEC,IAAI,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,aAAa,CAAC,EAAE;IAC3D,IAAII,KAAK,CAACK,IAAI,CAACC,QAAQ,CAACL,OAAO,CAAC,EAAE;MAChC,OAAO;QACLM,OAAO,EAAEP,KAAK,CAACO,OAAO;QACtBC,WAAW,EAAEN;MACf,CAAC;IACH;EACF;EAEA,OAAO;IACLK,OAAO,EAAEP,KAAK,CAACO,OAAO;IACtBC,WAAW,EAAEb,WAAW,CAACc;EAC3B,CAAC;AACH,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Event } from '..';
|
|
2
|
-
export declare enum Description {
|
|
3
|
-
ASSET_ALREADY_DOWNLOADED = "ASSET_ALREADY_DOWNLOADED",
|
|
4
|
-
LIMIT_EXCEEDED = "LIMIT_EXCEEDED",
|
|
5
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
6
|
-
}
|
|
7
|
-
export interface IParseError {
|
|
8
|
-
assetId: string;
|
|
9
|
-
description: Description;
|
|
10
|
-
}
|
|
11
|
-
export declare const manageDataError: (event: Event) => IParseError;
|
|
12
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAEhC,oBAAY,WAAW;IACrB,wBAAwB,6BAA6B;IACrD,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;CAChC;AASD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,UAAW,KAAK,KAAG,WAc9C,CAAC"}
|
package/src/utils/utils.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Event } from '..';
|
|
2
|
-
|
|
3
|
-
export enum Description {
|
|
4
|
-
ASSET_ALREADY_DOWNLOADED = 'ASSET_ALREADY_DOWNLOADED',
|
|
5
|
-
LIMIT_EXCEEDED = 'LIMIT_EXCEEDED',
|
|
6
|
-
UNKNOWN_ERROR = 'UNKNOWN_ERROR',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const errorMappings = {
|
|
10
|
-
'The asset has already been downloaded as many times as permitted. To download this asset again, administrative action is required.':
|
|
11
|
-
Description.ASSET_ALREADY_DOWNLOADED,
|
|
12
|
-
'There are already as many downloads as permitted on this account. To continue downloading, the user must delete downloaded assets from one of their devices.':
|
|
13
|
-
Description.LIMIT_EXCEEDED,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export interface IParseError {
|
|
17
|
-
assetId: string;
|
|
18
|
-
description: Description;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const manageDataError = (event: Event): IParseError => {
|
|
22
|
-
for (const [pattern, code] of Object.entries(errorMappings)) {
|
|
23
|
-
if (event.body.includes(pattern)) {
|
|
24
|
-
return {
|
|
25
|
-
assetId: event.assetId,
|
|
26
|
-
description: code,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
assetId: event.assetId,
|
|
33
|
-
description: Description.UNKNOWN_ERROR,
|
|
34
|
-
};
|
|
35
|
-
};
|