@takeoffmedia/react-native-penthera 0.1.13 → 0.2.1

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.
Files changed (66) hide show
  1. package/ios/Catalog.swift +2 -0
  2. package/ios/Penthera.m +0 -4
  3. package/ios/Penthera.swift +75 -89
  4. package/ios/Penthera.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  5. package/ios/Penthera.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  6. package/ios/Penthera.xcodeproj/project.xcworkspace/xcuserdata/joseguerreroot.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  7. package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +104 -0
  8. package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  9. package/lib/commonjs/hooks/usePenthera/index.js +28 -0
  10. package/lib/commonjs/hooks/usePenthera/index.js.map +1 -0
  11. package/lib/commonjs/hooks/usePenthera/usePenthera.js +189 -0
  12. package/lib/commonjs/hooks/usePenthera/usePenthera.js.map +1 -0
  13. package/lib/commonjs/{utils/Penthera.js → hooks/usePenthera/usePenthera.types.js} +1 -1
  14. package/lib/commonjs/hooks/usePenthera/usePenthera.types.js.map +1 -0
  15. package/lib/commonjs/index.js +11 -19
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/nativeModules/index.js +7 -2
  18. package/lib/commonjs/nativeModules/index.js.map +1 -1
  19. package/lib/module/hooks/usePenthera/index.js +3 -0
  20. package/lib/module/hooks/usePenthera/index.js.map +1 -0
  21. package/lib/module/hooks/usePenthera/usePenthera.js +181 -0
  22. package/lib/module/hooks/usePenthera/usePenthera.js.map +1 -0
  23. package/lib/module/{utils/Penthera.js → hooks/usePenthera/usePenthera.types.js} +1 -1
  24. package/lib/module/hooks/usePenthera/usePenthera.types.js.map +1 -0
  25. package/lib/module/index.js +1 -3
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/nativeModules/index.js +7 -2
  28. package/lib/module/nativeModules/index.js.map +1 -1
  29. package/lib/typescript/hooks/usePenthera/index.d.ts +3 -0
  30. package/lib/typescript/hooks/usePenthera/index.d.ts.map +1 -0
  31. package/lib/typescript/hooks/usePenthera/usePenthera.d.ts +4 -0
  32. package/lib/typescript/hooks/usePenthera/usePenthera.d.ts.map +1 -0
  33. package/lib/typescript/hooks/usePenthera/usePenthera.types.d.ts +46 -0
  34. package/lib/typescript/hooks/usePenthera/usePenthera.types.d.ts.map +1 -0
  35. package/lib/typescript/index.d.ts +1 -2
  36. package/lib/typescript/index.d.ts.map +1 -1
  37. package/lib/typescript/interface/PentheraTypes.d.ts +6 -0
  38. package/lib/typescript/interface/PentheraTypes.d.ts.map +1 -1
  39. package/lib/typescript/nativeModules/index.d.ts +1 -1
  40. package/lib/typescript/nativeModules/index.d.ts.map +1 -1
  41. package/package.json +4 -1
  42. package/src/hooks/usePenthera/index.ts +2 -0
  43. package/src/hooks/usePenthera/usePenthera.tsx +220 -0
  44. package/src/hooks/usePenthera/usePenthera.types.ts +49 -0
  45. package/src/index.tsx +1 -3
  46. package/src/interface/PentheraTypes.ts +7 -0
  47. package/src/nativeModules/index.ts +16 -9
  48. package/lib/commonjs/hooks/index.js +0 -13
  49. package/lib/commonjs/hooks/index.js.map +0 -1
  50. package/lib/commonjs/hooks/usePenthera.js +0 -147
  51. package/lib/commonjs/hooks/usePenthera.js.map +0 -1
  52. package/lib/commonjs/utils/Penthera.js.map +0 -1
  53. package/lib/module/hooks/index.js +0 -2
  54. package/lib/module/hooks/index.js.map +0 -1
  55. package/lib/module/hooks/usePenthera.js +0 -141
  56. package/lib/module/hooks/usePenthera.js.map +0 -1
  57. package/lib/module/utils/Penthera.js.map +0 -1
  58. package/lib/typescript/hooks/index.d.ts +0 -2
  59. package/lib/typescript/hooks/index.d.ts.map +0 -1
  60. package/lib/typescript/hooks/usePenthera.d.ts +0 -21
  61. package/lib/typescript/hooks/usePenthera.d.ts.map +0 -1
  62. package/lib/typescript/utils/Penthera.d.ts +0 -12
  63. package/lib/typescript/utils/Penthera.d.ts.map +0 -1
  64. package/src/hooks/index.ts +0 -1
  65. package/src/hooks/usePenthera.ts +0 -156
  66. package/src/utils/Penthera.ts +0 -11
@@ -1,21 +0,0 @@
1
- /// <reference types="react" />
2
- import type { PentheraTypes } from '../interface/PentheraTypes';
3
- interface IUsePenthera {
4
- tokenDevice?: string;
5
- data?: PentheraTypes.ItemCatalog[];
6
- sessionConnect: (event: any) => void;
7
- }
8
- export declare const usePenthera: ({ sessionConnect, data }: IUsePenthera) => {
9
- catalog: PentheraTypes.ItemCatalog[];
10
- setCatalogResult: import("react").Dispatch<import("react").SetStateAction<PentheraTypes.ItemCatalog[]>>;
11
- playVideo: (assetId: string) => Promise<any>;
12
- handleDeleteAsset: (assetId: string) => Promise<void>;
13
- downloadVideo: ({ item, drm, url, }: PentheraTypes.IDownloadAsset) => Promise<void>;
14
- getAllDownloads: () => Promise<void>;
15
- updateDownload: ({ assetID, percentage, }: PentheraTypes.IUpdateDownload) => void;
16
- deletedAsset: ({ assetId }: any) => void;
17
- pauseDownloadHandle: (assetId: string) => Promise<void>;
18
- updateDataWhenIsPaused: (assetId: string, isPause: boolean) => void;
19
- };
20
- export {};
21
- //# sourceMappingURL=usePenthera.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePenthera.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePenthera.ts"],"names":[],"mappings":";AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGhE,UAAU,YAAY;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,EAAE,CAAC;IACnC,cAAc,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,WAAW,6BAA8B,YAAY;;;yBAyC9B,MAAM;iCASE,MAAM;yCAzB7C,cAAc,cAAc;;+CA0E5B,cAAc,eAAe;gCAdG,GAAG;mCAuBM,MAAM;sCAIT,MAAM,WAAW,OAAO;CAqBlE,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare enum PentheraEvent {
2
- VIRTUOSO_SUCCESS = "Virtuoso Success",
3
- DID_START_DOWNLOADING = "DID_START_DOWNLOADING",
4
- PROGRESS_UPDATED = "PROGRESS_UPDATED",
5
- DOWNLOAD_COMPLETE = "DOWNLOAD_COMPLETE",
6
- CONFIG_ASSET_FAILED = "CONFIG_ASSET_FAILED",
7
- ASSET_RESUME_DOWNLOAD_UPDATED = "ASSET_RESUME_DOWNLOAD_UPDATED",
8
- ASSET_DELETED = "ASSET_DELETED",
9
- ERROR_DOWNLOAD = "ERROR_DOWNLOAD",
10
- PENDING_ASSET_FOUND = "PENDING_ASSET_FOUND"
11
- }
12
- //# sourceMappingURL=Penthera.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Penthera.d.ts","sourceRoot":"","sources":["../../../src/utils/Penthera.ts"],"names":[],"mappings":"AAAA,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"}
@@ -1 +0,0 @@
1
- export { usePenthera } from './usePenthera';
@@ -1,156 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import {
3
- NativeModules,
4
- NativeEventEmitter,
5
- EmitterSubscription,
6
- } from 'react-native';
7
- import {
8
- getDownloads,
9
- deleteAsset,
10
- download,
11
- playAsset,
12
- pauseDownload,
13
- } from '@takeoffmedia/react-native-penthera';
14
- import type { PentheraTypes } from '../interface/PentheraTypes';
15
- import { Platform } from 'react-native';
16
-
17
- interface IUsePenthera {
18
- tokenDevice?: string;
19
- data?: PentheraTypes.ItemCatalog[];
20
- sessionConnect: (event: any) => void;
21
- }
22
-
23
- export const usePenthera = ({ sessionConnect, data }: IUsePenthera) => {
24
- const [catalog, setCatalogResult] = useState<PentheraTypes.ItemCatalog[]>(
25
- data ? data : []
26
- );
27
-
28
- useEffect(() => {
29
- const eventListener: EmitterSubscription = listenerPethera();
30
- return () => {
31
- eventListener.remove();
32
- };
33
- // eslint-disable-next-line react-hooks/exhaustive-deps
34
- }, []);
35
-
36
- // Config Event Listener
37
- const listenerPethera = () => {
38
- const NEventEmitter = NativeModules.Penthera;
39
- const eventEmitter = new NativeEventEmitter(NEventEmitter);
40
- const eventListener = eventEmitter.addListener('penthera', sessionConnect);
41
- return eventListener;
42
- };
43
-
44
- const downloadVideo = async ({
45
- item,
46
- drm,
47
- url,
48
- }: PentheraTypes.IDownloadAsset) => {
49
- const dataAndroid = {
50
- asset_id: item.id,
51
- content_url: url,
52
- poster: item.thumbnails?.thumbnail,
53
- subtitle: '',
54
- };
55
- const dataBySO =
56
- Platform.OS === 'android' ? dataAndroid : { item, url, drm };
57
- try {
58
- await download(JSON.stringify(dataBySO));
59
- } catch (error) {
60
- console.error('error: downloadAsset', error);
61
- }
62
- };
63
-
64
- const playVideo = async (assetId: string) => {
65
- try {
66
- const response = await playAsset(assetId);
67
- return JSON.parse(response);
68
- } catch (error) {
69
- console.error('Error in reproduceVideo>>>', error);
70
- }
71
- };
72
-
73
- const handleDeleteAsset = async (assetId: string) => {
74
- try {
75
- await deleteAsset(assetId);
76
- deletedAsset({ assetId });
77
- } catch (error) {
78
- console.error('Error: handleDeleteAsset', error);
79
- }
80
- };
81
-
82
- const getAllDownloads = async () => {
83
- try {
84
- const response: PentheraTypes.ItemCatalog[] = await getDownloads('');
85
- if (response.length > 0) {
86
- setCatalogResult(response);
87
- response.forEach((item: PentheraTypes.ItemCatalog) => {
88
- const newCatalog = [...catalog];
89
- const index: number = newCatalog.findIndex((i) => i.id === item.id);
90
- if (index >= 0) {
91
- if (item.isCompleted) {
92
- newCatalog[index]!.download_percentage = 100;
93
- }
94
- newCatalog[index]!.isCompleted = item.isCompleted;
95
- newCatalog[index]!.isPaused = item.isPaused;
96
- newCatalog[index]!.thumbnails!.thumbnail =
97
- item.thumbnails!.thumbnail;
98
- newCatalog[index]!.thumbnails!.show = item.thumbnails!.show;
99
- setCatalogResult(newCatalog);
100
- }
101
- });
102
- }
103
- } catch (error) {
104
- console.error('Error: getAllDownloads', error);
105
- }
106
- };
107
-
108
- const deletedAsset = ({ assetId }: any) => {
109
- const newCatalog = [...catalog];
110
- let index = newCatalog.findIndex((i) => i.id === assetId);
111
- if (index >= 0) {
112
- newCatalog[index]!.download_percentage = 0;
113
- newCatalog[index]!.isCompleted = false;
114
- newCatalog[index]!.isPaused = false;
115
- setCatalogResult(newCatalog);
116
- }
117
- };
118
-
119
- const updateDownload = ({
120
- assetID,
121
- percentage,
122
- }: PentheraTypes.IUpdateDownload) => {
123
- const newCatalog = [...catalog];
124
- let index = newCatalog.findIndex((i) => i.id === assetID);
125
- if (index >= 0) {
126
- newCatalog[index]!.download_percentage = percentage;
127
- setCatalogResult(newCatalog);
128
- }
129
- };
130
-
131
- const pauseDownloadHandle = async (assetId: string) => {
132
- await pauseDownload(assetId);
133
- };
134
-
135
- const updateDataWhenIsPaused = (assetId: string, isPause: boolean) => {
136
- const newCatalog = [...catalog];
137
- let index = newCatalog.findIndex((i) => i.id === assetId);
138
- if (index >= 0) {
139
- newCatalog[index]!.isPaused = isPause;
140
- setCatalogResult(newCatalog);
141
- }
142
- };
143
-
144
- return {
145
- catalog,
146
- setCatalogResult,
147
- playVideo,
148
- handleDeleteAsset,
149
- downloadVideo,
150
- getAllDownloads,
151
- updateDownload,
152
- deletedAsset,
153
- pauseDownloadHandle,
154
- updateDataWhenIsPaused,
155
- };
156
- };
@@ -1,11 +0,0 @@
1
- export enum PentheraEvent {
2
- VIRTUOSO_SUCCESS = 'Virtuoso Success',
3
- DID_START_DOWNLOADING = 'DID_START_DOWNLOADING',
4
- PROGRESS_UPDATED = 'PROGRESS_UPDATED',
5
- DOWNLOAD_COMPLETE = 'DOWNLOAD_COMPLETE',
6
- CONFIG_ASSET_FAILED = 'CONFIG_ASSET_FAILED',
7
- ASSET_RESUME_DOWNLOAD_UPDATED = 'ASSET_RESUME_DOWNLOAD_UPDATED',
8
- ASSET_DELETED = 'ASSET_DELETED',
9
- ERROR_DOWNLOAD = 'ERROR_DOWNLOAD',
10
- PENDING_ASSET_FOUND = 'PENDING_ASSET_FOUND',
11
- }