react-native-video-trim 1.0.10 → 1.0.11

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.
@@ -1,10 +1,53 @@
1
1
  export interface EditorConfig {
2
2
  saveToPhoto?: boolean;
3
+ removeAfterSavedToPhoto?: boolean;
3
4
  maxDuration?: number;
4
- title?: string;
5
5
  cancelButtonText?: string;
6
6
  saveButtonText?: string;
7
+ enableCancelDialog?: boolean;
8
+ cancelDialogTitle?: string;
9
+ cancelDialogMessage?: string;
10
+ cancelDialogCancelText?: string;
11
+ cancelDialogConfirmText?: string;
12
+ enableSaveDialog?: boolean;
13
+ saveDialogTitle?: string;
14
+ saveDialogMessage?: string;
15
+ saveDialogCancelText?: string;
16
+ saveDialogConfirmText?: string;
17
+ trimmingText?: string;
7
18
  }
8
- export declare function showEditor(videoPath: string, config?: EditorConfig): Promise<void>;
9
- export declare function isValidVideo(videoPath: string): Promise<boolean>;
19
+ /**
20
+ * Delete a file
21
+ *
22
+ * @param {string} videoPath: absolute non-empty file path to edit
23
+ * @param {EditorConfig} config: editor configuration
24
+ * @returns {void} A **Promise** which resolves `void`
25
+ */
26
+ export declare function showEditor(filePath: string, config?: EditorConfig): Promise<void>;
27
+ /**
28
+ * Delete a file
29
+ *
30
+ * @param {string} filePath: absolute non-empty file path to check if editable
31
+ * @returns {Promise} A **Promise** which resolves `true` if editable
32
+ */
33
+ export declare function isValidVideo(filePath: string): Promise<boolean>;
34
+ /**
35
+ * Clean output files generated at all time
36
+ *
37
+ * @returns {Promise<string[]>} A **Promise** which resolves to array of files
38
+ */
39
+ export declare function listFiles(): Promise<string[]>;
40
+ /**
41
+ * Clean output files generated at all time
42
+ *
43
+ * @returns {Promise} A **Promise** which resolves to number of deleted files
44
+ */
45
+ export declare function cleanFiles(): Promise<number>;
46
+ /**
47
+ * Delete a file
48
+ *
49
+ * @param {string} filePath: absolute non-empty file path to delete
50
+ * @returns {Promise} A **Promise** which resolves `true` if successful
51
+ */
52
+ export declare function deleteFile(filePath: string): Promise<boolean>;
10
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAgDf;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -15,6 +15,7 @@ Pod::Spec.new do |s|
15
15
  s.source = { :git => "https://github.com/maitrungduc1410/react-native-video-trim.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+ s.dependency 'ffmpeg-kit-ios-min', '~> 6.0'
18
19
 
19
20
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
21
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
package/src/index.tsx CHANGED
@@ -19,18 +19,40 @@ const VideoTrim = NativeModules.VideoTrim
19
19
 
20
20
  export interface EditorConfig {
21
21
  saveToPhoto?: boolean;
22
+ removeAfterSavedToPhoto?: boolean;
22
23
  maxDuration?: number;
23
- title?: string;
24
24
  cancelButtonText?: string;
25
25
  saveButtonText?: string;
26
+ enableCancelDialog?: boolean;
27
+ cancelDialogTitle?: string;
28
+ cancelDialogMessage?: string;
29
+ cancelDialogCancelText?: string;
30
+ cancelDialogConfirmText?: string;
31
+ enableSaveDialog?: boolean;
32
+ saveDialogTitle?: string;
33
+ saveDialogMessage?: string;
34
+ saveDialogCancelText?: string;
35
+ saveDialogConfirmText?: string;
36
+ trimmingText?: string;
26
37
  }
27
38
 
39
+ /**
40
+ * Delete a file
41
+ *
42
+ * @param {string} videoPath: absolute non-empty file path to edit
43
+ * @param {EditorConfig} config: editor configuration
44
+ * @returns {void} A **Promise** which resolves `void`
45
+ */
28
46
  export async function showEditor(
29
- videoPath: string,
47
+ filePath: string,
30
48
  config: EditorConfig = {}
31
49
  ): Promise<void> {
50
+ if (!filePath?.trim().length) {
51
+ throw new Error('File path cannot be empty!');
52
+ }
53
+
32
54
  const { saveToPhoto = true } = config;
33
- const outputPath = await VideoTrim.showEditor(videoPath, config);
55
+ const outputPath = await VideoTrim.showEditor(filePath, config);
34
56
 
35
57
  if (Platform.OS === 'android') {
36
58
  if (saveToPhoto) {
@@ -38,6 +60,10 @@ export async function showEditor(
38
60
  if (Platform.Version >= 33) {
39
61
  // since android 13 it's not needed to request permission for write storage: https://github.com/facebook/react-native/issues/36714#issuecomment-1491338276
40
62
  await VideoTrim.saveVideo(outputPath);
63
+
64
+ if (config.removeAfterSavedToPhoto) {
65
+ deleteFile(outputPath);
66
+ }
41
67
  } else {
42
68
  const granted = await PermissionsAndroid.request(
43
69
  PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE!,
@@ -51,6 +77,10 @@ export async function showEditor(
51
77
  );
52
78
  if (granted === PermissionsAndroid.RESULTS.GRANTED) {
53
79
  await VideoTrim.saveVideo(outputPath);
80
+
81
+ if (config.removeAfterSavedToPhoto) {
82
+ deleteFile(outputPath);
83
+ }
54
84
  } else {
55
85
  throw new Error('Photos Library permission denied');
56
86
  }
@@ -66,6 +96,46 @@ export async function showEditor(
66
96
  }
67
97
  }
68
98
 
69
- export function isValidVideo(videoPath: string): Promise<boolean> {
70
- return VideoTrim.isValidVideo(videoPath);
99
+ /**
100
+ * Delete a file
101
+ *
102
+ * @param {string} filePath: absolute non-empty file path to check if editable
103
+ * @returns {Promise} A **Promise** which resolves `true` if editable
104
+ */
105
+ export function isValidVideo(filePath: string): Promise<boolean> {
106
+ if (!filePath?.trim().length) {
107
+ throw new Error('File path cannot be empty!');
108
+ }
109
+ return VideoTrim.isValidVideo(filePath);
110
+ }
111
+
112
+ /**
113
+ * Clean output files generated at all time
114
+ *
115
+ * @returns {Promise<string[]>} A **Promise** which resolves to array of files
116
+ */
117
+ export function listFiles(): Promise<string[]> {
118
+ return VideoTrim.listFiles();
119
+ }
120
+
121
+ /**
122
+ * Clean output files generated at all time
123
+ *
124
+ * @returns {Promise} A **Promise** which resolves to number of deleted files
125
+ */
126
+ export function cleanFiles(): Promise<number> {
127
+ return VideoTrim.cleanFiles();
128
+ }
129
+
130
+ /**
131
+ * Delete a file
132
+ *
133
+ * @param {string} filePath: absolute non-empty file path to delete
134
+ * @returns {Promise} A **Promise** which resolves `true` if successful
135
+ */
136
+ export function deleteFile(filePath: string): Promise<boolean> {
137
+ if (!filePath?.trim().length) {
138
+ throw new Error('File path cannot be empty!');
139
+ }
140
+ return VideoTrim.deleteFile(filePath);
71
141
  }