@react-native-firebase/storage 25.1.0 → 26.1.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/RNFBStorage.podspec +26 -7
  3. package/android/build.gradle +23 -0
  4. package/android/src/main/java/io/invertase/firebase/storage/{ReactNativeFirebaseStorageModule.java → NativeRNFBTurboStorage.java} +72 -131
  5. package/android/src/main/java/io/invertase/firebase/storage/ReactNativeFirebaseStoragePackage.java +1 -1
  6. package/android/src/main/java/io/invertase/firebase/storage/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboStorageSpec.java +125 -0
  7. package/android/src/main/java/io/invertase/firebase/storage/generated/jni/CMakeLists.txt +36 -0
  8. package/android/src/main/java/io/invertase/firebase/storage/generated/jni/RNFBStorageTurboModules-generated.cpp +116 -0
  9. package/android/src/main/java/io/invertase/firebase/storage/generated/jni/RNFBStorageTurboModules.h +31 -0
  10. package/android/src/main/java/io/invertase/firebase/storage/generated/jni/react/renderer/components/RNFBStorageTurboModules/RNFBStorageTurboModulesJSI-generated.cpp +153 -0
  11. package/android/src/main/java/io/invertase/firebase/storage/generated/jni/react/renderer/components/RNFBStorageTurboModules/RNFBStorageTurboModulesJSI.h +246 -0
  12. package/dist/module/StorageReference.js +4 -7
  13. package/dist/module/StorageReference.js.map +1 -1
  14. package/dist/module/StorageTask.js.map +1 -1
  15. package/dist/module/index.js +384 -6
  16. package/dist/module/index.js.map +1 -1
  17. package/dist/module/types/storage.js +6 -2
  18. package/dist/module/types/storage.js.map +1 -1
  19. package/dist/module/version.js +1 -1
  20. package/dist/module/web/RNFBStorageModule.js +9 -11
  21. package/dist/module/web/RNFBStorageModule.js.map +1 -1
  22. package/dist/typescript/lib/StorageReference.d.ts.map +1 -1
  23. package/dist/typescript/lib/StorageTask.d.ts +7 -8
  24. package/dist/typescript/lib/StorageTask.d.ts.map +1 -1
  25. package/dist/typescript/lib/index.d.ts +150 -4
  26. package/dist/typescript/lib/index.d.ts.map +1 -1
  27. package/dist/typescript/lib/types/internal.d.ts +5 -5
  28. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  29. package/dist/typescript/lib/types/storage.d.ts +15 -10
  30. package/dist/typescript/lib/types/storage.d.ts.map +1 -1
  31. package/dist/typescript/lib/version.d.ts +1 -1
  32. package/dist/typescript/lib/web/RNFBStorageModule.d.ts +3 -3
  33. package/dist/typescript/lib/web/RNFBStorageModule.d.ts.map +1 -1
  34. package/ios/RNFBStorage/RNFBStorageCommon.m +11 -0
  35. package/ios/RNFBStorage/RNFBStorageHelper.h +113 -0
  36. package/ios/RNFBStorage/{RNFBStorageModule.m → RNFBStorageHelper.m} +227 -222
  37. package/ios/RNFBStorage/RNFBStorageModule.h +2 -2
  38. package/ios/RNFBStorage/RNFBStorageModule.mm +252 -0
  39. package/ios/RNFBStorage.xcodeproj/project.pbxproj +8 -8
  40. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  41. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  42. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  43. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  44. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  45. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  46. package/ios/generated/RNFBStorageTurboModules/RNFBStorageTurboModules-generated.mm +142 -0
  47. package/ios/generated/RNFBStorageTurboModules/RNFBStorageTurboModules.h +198 -0
  48. package/ios/generated/RNFBStorageTurboModulesJSI-generated.cpp +153 -0
  49. package/ios/generated/RNFBStorageTurboModulesJSI.h +246 -0
  50. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  51. package/lib/StorageReference.ts +3 -8
  52. package/lib/StorageTask.ts +13 -15
  53. package/lib/index.ts +501 -7
  54. package/lib/types/internal.ts +5 -5
  55. package/lib/types/storage.ts +17 -10
  56. package/lib/version.ts +1 -1
  57. package/lib/web/RNFBStorageModule.ts +10 -12
  58. package/package.json +22 -4
  59. package/react-native.config.js +10 -0
  60. package/specs/NativeRNFBTurboStorage.ts +46 -0
  61. package/typedoc.json +2 -3
  62. package/dist/module/modular.js +0 -270
  63. package/dist/module/modular.js.map +0 -1
  64. package/dist/module/namespaced.js +0 -192
  65. package/dist/module/namespaced.js.map +0 -1
  66. package/dist/module/types/namespaced.js +0 -64
  67. package/dist/module/types/namespaced.js.map +0 -1
  68. package/dist/typescript/lib/modular.d.ts +0 -154
  69. package/dist/typescript/lib/modular.d.ts.map +0 -1
  70. package/dist/typescript/lib/namespaced.d.ts +0 -12
  71. package/dist/typescript/lib/namespaced.d.ts.map +0 -1
  72. package/dist/typescript/lib/types/namespaced.d.ts +0 -1122
  73. package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
  74. package/lib/modular.ts +0 -401
  75. package/lib/namespaced.ts +0 -264
  76. package/lib/types/namespaced.ts +0 -1248
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespaced.d.ts","sourceRoot":"","sources":["../../../../lib/types/namespaced.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;;;GAGG;AAEH,yBAAiB,oBAAoB,CAAC;IACpC,KAAK,cAAc,GAAG,mBAAmB,CAAC,cAAc,CAAC;IACzD,KAAK,mBAAmB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC;IAEnE;;;;;;;;OAQG;IACH,MAAM,WAAW,YAAY;QAC3B;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,KAAK,CAAC;QAEX;;;;;;;;;;;;;;;;;WAiBG;QACH,MAAM,EAAE,QAAQ,CAAC;QAEjB;;;;;;;;;;;;;;;WAeG;QACH,SAAS,EAAE,WAAW,CAAC;QAEvB;;;;;;;;;;;;;;WAcG;QACH,QAAQ,EAAE,UAAU,CAAC;KACtB;I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,CACtC,oBAAoB,CAAC,MAAM,EAC3B,oBAAoB,CAAC,OAAO,CAC7B,CAAC;SACH;QACD,UAAU,WAAW;YACnB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC;SACvD;KACF;CACF"}
package/lib/modular.ts DELETED
@@ -1,401 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- import { getApp } from '@react-native-firebase/app';
19
- import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
20
- import type { FirebaseApp } from '@react-native-firebase/app';
21
- import type {
22
- FirebaseStorage,
23
- StorageReference,
24
- FullMetadata,
25
- ListResult,
26
- ListOptions,
27
- TaskResult,
28
- Task,
29
- SettableMetadata,
30
- UploadMetadata,
31
- EmulatorMockTokenOptions,
32
- } from './types/storage';
33
- import type { StorageReferenceInternal, StorageInternal } from './types/internal';
34
-
35
- type WithModularDeprecationArg<F> = F extends (...args: infer P) => infer R
36
- ? (...args: [...P, typeof MODULAR_DEPRECATION_ARG]) => R
37
- : never;
38
-
39
- function isUrl(path?: string): boolean {
40
- if (typeof path !== 'string') {
41
- return false;
42
- }
43
-
44
- return /^[A-Za-z]+:\/\//.test(decodeURIComponent(path));
45
- }
46
-
47
- /**
48
- * Returns a Storage instance for the given app.
49
- * @param app - FirebaseApp. Optional.
50
- * @param bucketUrl - Storage bucket URL. Optional.
51
- * @returns {Storage}
52
- */
53
- export function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage {
54
- if (app) {
55
- if (bucketUrl != null) {
56
- return getApp(app.name).storage(bucketUrl);
57
- }
58
-
59
- return getApp(app.name).storage();
60
- }
61
-
62
- if (bucketUrl != null) {
63
- return getApp().storage(bucketUrl);
64
- }
65
-
66
- return getApp().storage();
67
- }
68
-
69
- /**
70
- * Modify this Storage instance to communicate with the Firebase Storage emulator.
71
- * @param storage - Storage instance.
72
- * @param host - emulator host (e.g. - 'localhost')
73
- * @param port - emulator port (e.g. - 9199)
74
- * @param options - `EmulatorMockTokenOptions` instance. Optional. Web only.
75
- * @returns {void}
76
- */
77
- export function connectStorageEmulator(
78
- storage: FirebaseStorage,
79
- host: string,
80
- port: number,
81
- options?: EmulatorMockTokenOptions,
82
- ): void {
83
- return (
84
- (storage as StorageInternal).useEmulator as WithModularDeprecationArg<
85
- StorageInternal['useEmulator']
86
- >
87
- ).call(storage, host, port, options, MODULAR_DEPRECATION_ARG);
88
- }
89
-
90
- /**
91
- * Returns a StorageReference for the given URL or path in the default bucket.
92
- * @param storage - FirebaseStorage instance.
93
- * @param url - Optional gs:// or https:// URL, or path. If empty, returns root reference.
94
- * @returns {StorageReference}
95
- */
96
- export function ref(storage: FirebaseStorage, url?: string): StorageReference;
97
- /**
98
- * Returns a StorageReference for the given path, or the same reference if path is omitted.
99
- * @param storageRef - StorageReference instance.
100
- * @param path - Optional child path. If omitted, returns the same reference.
101
- * @returns {StorageReference}
102
- */
103
- export function ref(storageRef: StorageReference, path?: string): StorageReference;
104
- export function ref(
105
- storageOrRef: FirebaseStorage | StorageReference,
106
- path?: string,
107
- ): StorageReference {
108
- // ref(parentRef, path) → child reference; ref(parentRef) → same reference (firebase-js-sdk overload)
109
- if (typeof (storageOrRef as StorageReference).fullPath === 'string') {
110
- if (path === undefined) {
111
- return storageOrRef as StorageReference;
112
- }
113
- return (
114
- (storageOrRef as StorageReferenceInternal).child as WithModularDeprecationArg<
115
- StorageReferenceInternal['child']
116
- >
117
- ).call(storageOrRef, path, MODULAR_DEPRECATION_ARG);
118
- }
119
-
120
- const storage = storageOrRef as FirebaseStorage;
121
-
122
- if (path != null && isUrl(path)) {
123
- return (
124
- (storage as StorageInternal).refFromURL as WithModularDeprecationArg<
125
- StorageInternal['refFromURL']
126
- >
127
- ).call(storage, path, MODULAR_DEPRECATION_ARG);
128
- }
129
- return (
130
- (storage as StorageInternal).ref as WithModularDeprecationArg<StorageInternal['ref']>
131
- ).call(storage, path, MODULAR_DEPRECATION_ARG);
132
- }
133
-
134
- /**
135
- * Deletes the object at this reference's location.
136
- * @param storageRef - Storage `Reference` instance.
137
- * @returns {Promise<void>}
138
- */
139
- export function deleteObject(storageRef: StorageReference): Promise<void> {
140
- return (
141
- (storageRef as StorageReferenceInternal).delete as WithModularDeprecationArg<
142
- StorageReferenceInternal['delete']
143
- >
144
- ).call(storageRef, MODULAR_DEPRECATION_ARG);
145
- }
146
-
147
- /**
148
- * Downloads the data at the object's location. Returns an error if the object is not found.
149
- * @param _storageRef - Storage `Reference` instance.
150
- * @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only.
151
- * @returns {Promise<Blob>}
152
- */
153
- export function getBlob(
154
- _storageRef: StorageReference,
155
- _maxDownloadSizeBytes?: number,
156
- ): Promise<Blob> {
157
- throw new Error('`getBlob()` is not implemented');
158
- }
159
-
160
- /**
161
- * Downloads the data at the object's location. Returns an error if the object is not found.
162
- * @param _storageRef - Storage `Reference` instance.
163
- * @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only.
164
- * @returns {Promise<ArrayBuffer>}
165
- */
166
- export function getBytes(
167
- _storageRef: StorageReference,
168
- _maxDownloadSizeBytes?: number,
169
- ): Promise<ArrayBuffer> {
170
- throw new Error('`getBytes()` is not implemented');
171
- }
172
-
173
- /**
174
- * Deletes the object at this reference's location.
175
- * @param storageRef - Storage `Reference` instance.
176
- * @returns {Promise<string>}
177
- */
178
- export function getDownloadURL(storageRef: StorageReference): Promise<string> {
179
- return (
180
- (storageRef as StorageReferenceInternal).getDownloadURL as WithModularDeprecationArg<
181
- StorageReferenceInternal['getDownloadURL']
182
- >
183
- ).call(storageRef, MODULAR_DEPRECATION_ARG);
184
- }
185
-
186
- /**
187
- * Fetches metadata for the object at this location, if one exists.
188
- * @param storageRef - Storage `Reference` instance.
189
- * @returns {Promise<FullMetadata>}
190
- */
191
- export function getMetadata(storageRef: StorageReference): Promise<FullMetadata> {
192
- return (
193
- (storageRef as StorageReferenceInternal).getMetadata as WithModularDeprecationArg<
194
- StorageReferenceInternal['getMetadata']
195
- >
196
- ).call(storageRef, MODULAR_DEPRECATION_ARG);
197
- }
198
-
199
- /**
200
- * Downloads the data at the object's location. This API is only available in Nodejs.
201
- * @param _storageRef - Storage `Reference` instance.
202
- * @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only.
203
- * @returns {NodeJS.ReadableStream;}
204
- */
205
- export function getStream(
206
- _storageRef: StorageReference,
207
- _maxDownloadSizeBytes?: number,
208
- ): NodeJS.ReadableStream {
209
- throw new Error('`getStream()` is not implemented');
210
- }
211
-
212
- /**
213
- * List items (files) and prefixes (folders) under this storage reference
214
- * @param storageRef - Storage `Reference` instance.
215
- * @param options - Storage `ListOptions` instance. The options list() accepts.
216
- * @returns {Promise<ListResult>}
217
- */
218
- export async function list(
219
- storageRef: StorageReference,
220
- options?: ListOptions,
221
- ): Promise<ListResult> {
222
- const result = await (
223
- (storageRef as StorageReferenceInternal).list as WithModularDeprecationArg<
224
- StorageReferenceInternal['list']
225
- >
226
- ).call(storageRef, options, MODULAR_DEPRECATION_ARG);
227
-
228
- if (result.nextPageToken === null) {
229
- delete result.nextPageToken;
230
- }
231
- return result;
232
- }
233
-
234
- /**
235
- * List all items (files) and prefixes (folders) under this storage reference.
236
- * @param storageRef - Storage `Reference` instance.
237
- * @returns {Promise<ListResult>}
238
- */
239
- export async function listAll(storageRef: StorageReference): Promise<ListResult> {
240
- const result = await (
241
- (storageRef as StorageReferenceInternal).listAll as WithModularDeprecationArg<
242
- StorageReferenceInternal['listAll']
243
- >
244
- ).call(storageRef, MODULAR_DEPRECATION_ARG);
245
-
246
- if (result.nextPageToken === null) {
247
- delete result.nextPageToken;
248
- }
249
- return result;
250
- }
251
-
252
- /**
253
- * Updates the metadata for this object.
254
- * @param storageRef - Storage `Reference` instance.
255
- * @param metadata - A Storage `SettableMetadata` instance to update.
256
- * @returns {Promise<FullMetadata>}
257
- */
258
- export function updateMetadata(
259
- storageRef: StorageReference,
260
- metadata: SettableMetadata,
261
- ): Promise<FullMetadata> {
262
- return (
263
- (storageRef as StorageReferenceInternal).updateMetadata as WithModularDeprecationArg<
264
- StorageReferenceInternal['updateMetadata']
265
- >
266
- ).call(storageRef, metadata, MODULAR_DEPRECATION_ARG);
267
- }
268
-
269
- /**
270
- * Uploads data to this object's location. The upload is not resumable.
271
- * @param _storageRef - Storage `Reference` instance.
272
- * @param _data - The data (Blob | Uint8Array | ArrayBuffer) to upload to the storage bucket at the reference location.
273
- * @param _metadata - A Storage `UploadMetadata` instance to update. Optional.
274
- * @returns {Promise<TaskResult>}
275
- */
276
- export async function uploadBytes(
277
- _storageRef: StorageReference,
278
- _data: Blob | Uint8Array | ArrayBuffer,
279
- _metadata?: UploadMetadata,
280
- ): Promise<TaskResult> {
281
- throw new Error('`uploadBytes()` is not implemented');
282
- }
283
-
284
- /**
285
- * Uploads data to this object's location. The upload is not resumable.
286
- * @param storageRef - Storage `Reference` instance.
287
- * @param data - The data (Blob | Uint8Array | ArrayBuffer) to upload to the storage bucket at the reference location.
288
- * @param metadata - A Storage `UploadMetadata` instance to update. Optional.
289
- * @returns {Task}
290
- */
291
- export function uploadBytesResumable(
292
- storageRef: StorageReference,
293
- data: Blob | Uint8Array | ArrayBuffer,
294
- metadata?: UploadMetadata,
295
- ): Task {
296
- return (
297
- (storageRef as StorageReferenceInternal).put as WithModularDeprecationArg<
298
- StorageReferenceInternal['put']
299
- >
300
- ).call(storageRef, data, metadata, MODULAR_DEPRECATION_ARG);
301
- }
302
-
303
- /**
304
- * Uploads data to this object's location. The upload is not resumable.
305
- * @param storageRef - Storage `Reference` instance.
306
- * @param data - The string to upload.
307
- * @param format - The format of the string to upload ('raw' | 'base64' | 'base64url' | 'data_url'). Optional.
308
- * @param metadata - A Storage `UploadMetadata` instance to update. Optional.
309
- * @returns {Task}
310
- */
311
- export function uploadString(
312
- storageRef: StorageReference,
313
- data: string,
314
- format?: 'raw' | 'base64' | 'base64url' | 'data_url',
315
- metadata?: UploadMetadata,
316
- ): Task {
317
- return (
318
- (storageRef as StorageReferenceInternal).putString as WithModularDeprecationArg<
319
- StorageReferenceInternal['putString']
320
- >
321
- ).call(storageRef, data, format, metadata, MODULAR_DEPRECATION_ARG);
322
- }
323
-
324
- // Methods not on the Firebase JS SDK below
325
-
326
- /**
327
- * Sets the maximum time in milliseconds to retry a download if a failure occurs.. android & iOS only.
328
- * @param storage - Storage instance.
329
- * @param time - The new maximum operation retry time in milliseconds.
330
- * @returns {Promise<void>}
331
- */
332
- export function setMaxOperationRetryTime(storage: FirebaseStorage, time: number): Promise<void> {
333
- return (
334
- (storage as StorageInternal).setMaxOperationRetryTime as WithModularDeprecationArg<
335
- StorageInternal['setMaxOperationRetryTime']
336
- >
337
- ).call(storage, time, MODULAR_DEPRECATION_ARG);
338
- }
339
-
340
- /**
341
- * Sets the maximum time in milliseconds to retry an upload if a failure occurs. android & iOS only.
342
- * @param storage - Storage instance.
343
- * @param time - The new maximum operation retry time in milliseconds.
344
- * @returns {Promise<void>}
345
- */
346
- export function setMaxUploadRetryTime(storage: FirebaseStorage, time: number): Promise<void> {
347
- return (
348
- (storage as StorageInternal).setMaxUploadRetryTime as WithModularDeprecationArg<
349
- StorageInternal['setMaxUploadRetryTime']
350
- >
351
- ).call(storage, time, MODULAR_DEPRECATION_ARG);
352
- }
353
-
354
- /**
355
- * Puts a file from local disk onto the storage bucket.
356
- * @param storageRef - Storage Reference instance.
357
- * @param filePath The local file path to upload to the bucket at the reference location.
358
- * @param metadata Any additional `UploadMetadata` for this task.
359
- * @returns {Task}
360
- */
361
- export function putFile(
362
- storageRef: StorageReference,
363
- filePath: string,
364
- metadata?: UploadMetadata,
365
- ): Task {
366
- return (
367
- (storageRef as StorageReferenceInternal).putFile as WithModularDeprecationArg<
368
- StorageReferenceInternal['putFile']
369
- >
370
- ).call(storageRef, filePath, metadata, MODULAR_DEPRECATION_ARG);
371
- }
372
-
373
- /**
374
- * Downloads a file to the specified local file path on the device.
375
- * @param storageRef - Storage Reference instance.
376
- * @param filePath The local file path to upload to on the device.
377
- * @returns {Task}
378
- */
379
- export function writeToFile(storageRef: StorageReference, filePath: string): Task {
380
- return (
381
- (storageRef as StorageReferenceInternal).writeToFile as WithModularDeprecationArg<
382
- StorageReferenceInternal['writeToFile']
383
- >
384
- ).call(storageRef, filePath, MODULAR_DEPRECATION_ARG);
385
- }
386
-
387
- /**
388
- * Sets the maximum time in milliseconds to retry a download if a failure occurs.
389
- * @param storage - Storage instance.
390
- * @param time - The new maximum download retry time in milliseconds.
391
- * @returns {Promise<void>}
392
- */
393
- export function setMaxDownloadRetryTime(storage: FirebaseStorage, time: number): Promise<void> {
394
- return (
395
- (storage as StorageInternal).setMaxDownloadRetryTime as WithModularDeprecationArg<
396
- StorageInternal['setMaxDownloadRetryTime']
397
- >
398
- ).call(storage, time, MODULAR_DEPRECATION_ARG);
399
- }
400
-
401
- export { StringFormat, TaskEvent, TaskState } from './StorageStatics';
package/lib/namespaced.ts DELETED
@@ -1,264 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- import {
19
- isAndroid,
20
- isNumber,
21
- isString,
22
- createDeprecationProxy,
23
- } from '@react-native-firebase/app/dist/module/common';
24
-
25
- import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
26
- import {
27
- createModuleNamespace,
28
- FirebaseModule,
29
- getFirebaseRoot,
30
- type ModuleConfig,
31
- } from '@react-native-firebase/app/dist/module/internal';
32
- import type { ReactNativeFirebase } from '@react-native-firebase/app';
33
- import Reference from './StorageReference';
34
- import { StringFormat, TaskEvent, TaskState } from './StorageStatics';
35
- import { getGsUrlParts, getHttpUrlParts, handleStorageEvent } from './utils';
36
- import { version } from './version';
37
- import fallBackModule from './web/RNFBStorageModule';
38
- import type { StorageInternal } from './types/internal';
39
- import type { FirebaseStorageTypes } from './types/namespaced';
40
-
41
- const statics = {
42
- StringFormat,
43
- TaskEvent,
44
- TaskState,
45
- };
46
-
47
- const namespace = 'storage';
48
- const nativeEvents = ['storage_event'];
49
- const nativeModuleName = 'RNFBStorageModule';
50
-
51
- class FirebaseStorageModule extends FirebaseModule<typeof nativeModuleName> {
52
- emulatorHost: string | undefined;
53
- emulatorPort: number;
54
- _maxUploadRetryTime: number;
55
- _maxDownloadRetryTime: number;
56
- _maxOperationRetryTime: number;
57
-
58
- constructor(
59
- app: ReactNativeFirebase.FirebaseAppBase,
60
- config: ModuleConfig,
61
- bucketUrl?: string | null,
62
- ) {
63
- super(app, config, bucketUrl ?? undefined);
64
- if (bucketUrl == null) {
65
- this._customUrlOrRegion = `gs://${app.options.storageBucket}`;
66
- } else if (!isString(bucketUrl) || !bucketUrl.startsWith('gs://')) {
67
- throw new Error(
68
- "firebase.app().storage(*) bucket url must be a string and begin with 'gs://'",
69
- );
70
- }
71
-
72
- const storageEvent = nativeEvents[0];
73
-
74
- if (!storageEvent) {
75
- throw new Error('storage_event is not defined in nativeEvents');
76
- }
77
-
78
- this.emitter.addListener(
79
- this.eventNameForApp(storageEvent),
80
- handleStorageEvent.bind(null, this),
81
- );
82
-
83
- // Emulator instance vars needed to send through on iOS, iOS does not persist emulator state between calls
84
- this.emulatorHost = undefined;
85
- this.emulatorPort = 0;
86
- this._maxUploadRetryTime = this.native.maxUploadRetryTime || 0;
87
- this._maxDownloadRetryTime = this.native.maxDownloadRetryTime || 0;
88
- this._maxOperationRetryTime = this.native.maxOperationRetryTime || 0;
89
- }
90
-
91
- /**
92
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setmaxuploadretrytime
93
- */
94
- get maxUploadRetryTime(): number {
95
- return this._maxUploadRetryTime;
96
- }
97
-
98
- /**
99
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setmaxdownloadretrytime
100
- */
101
- get maxDownloadRetryTime(): number {
102
- return this._maxDownloadRetryTime;
103
- }
104
-
105
- /**
106
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#maxoperationretrytime
107
- */
108
- get maxOperationRetryTime(): number {
109
- return this._maxOperationRetryTime;
110
- }
111
-
112
- /**
113
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#ref
114
- */
115
- ref(path: string = '/'): Reference {
116
- if (!isString(path)) {
117
- throw new Error("firebase.storage().ref(*) 'path' must be a string value.");
118
- }
119
- return createDeprecationProxy(new Reference(this, path)) as Reference;
120
- }
121
-
122
- /**
123
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#refFromURL
124
- */
125
- refFromURL(url: string): Reference {
126
- if (!isString(url) || (!url.startsWith('gs://') && !url.startsWith('http'))) {
127
- throw new Error(
128
- "firebase.storage().refFromURL(*) 'url' must be a string value and begin with 'gs://' or 'https://'.",
129
- );
130
- }
131
-
132
- let path: string;
133
- let bucket: string;
134
-
135
- if (url.startsWith('http')) {
136
- const parts = getHttpUrlParts(url);
137
- if (!parts) {
138
- throw new Error(
139
- "firebase.storage().refFromURL(*) unable to parse 'url', ensure it's a valid storage url'.",
140
- );
141
- }
142
- ({ bucket, path } = parts);
143
- } else {
144
- ({ bucket, path } = getGsUrlParts(url));
145
- }
146
-
147
- const storageInstance = this.app.storage(bucket);
148
- return new Reference(storageInstance as unknown as StorageInternal, path);
149
- }
150
-
151
- /**
152
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setMaxOperationRetryTime
153
- */
154
- setMaxOperationRetryTime(time: number): Promise<void> {
155
- if (!isNumber(time)) {
156
- throw new Error(
157
- "firebase.storage().setMaxOperationRetryTime(*) 'time' must be a number value.",
158
- );
159
- }
160
-
161
- this._maxOperationRetryTime = time;
162
- return this.native.setMaxOperationRetryTime(time);
163
- }
164
-
165
- /**
166
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setMaxUploadRetryTime
167
- */
168
- setMaxUploadRetryTime(time: number): Promise<void> {
169
- if (!isNumber(time)) {
170
- throw new Error("firebase.storage().setMaxUploadRetryTime(*) 'time' must be a number value.");
171
- }
172
-
173
- this._maxUploadRetryTime = time;
174
- return this.native.setMaxUploadRetryTime(time);
175
- }
176
-
177
- /**
178
- * @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setMaxDownloadRetryTime
179
- */
180
- setMaxDownloadRetryTime(time: number): Promise<void> {
181
- if (!isNumber(time)) {
182
- throw new Error(
183
- "firebase.storage().setMaxDownloadRetryTime(*) 'time' must be a number value.",
184
- );
185
- }
186
-
187
- this._maxDownloadRetryTime = time;
188
- return this.native.setMaxDownloadRetryTime(time);
189
- }
190
-
191
- useEmulator(
192
- host: string,
193
- port: number,
194
- _options?: FirebaseStorageTypes.EmulatorMockTokenOptions,
195
- ): void {
196
- if (!host || !isString(host) || !port || !isNumber(port)) {
197
- throw new Error('firebase.storage().useEmulator() takes a non-empty host and port');
198
- }
199
-
200
- let _host = host;
201
-
202
- const androidBypassEmulatorUrlRemap =
203
- typeof this.firebaseJson.android_bypass_emulator_url_remap === 'boolean' &&
204
- this.firebaseJson.android_bypass_emulator_url_remap;
205
- if (!androidBypassEmulatorUrlRemap && isAndroid && _host) {
206
- if (_host === 'localhost' || _host === '127.0.0.1') {
207
- _host = '10.0.2.2';
208
- // eslint-disable-next-line no-console
209
- console.log(
210
- 'Mapping storage host to "10.0.2.2" for android emulators. Use real IP on real devices. You can bypass this behaviour with "android_bypass_emulator_url_remap" flag.',
211
- );
212
- }
213
- }
214
- this.emulatorHost = host;
215
- this.emulatorPort = port;
216
- this.native.useEmulator(_host, port, this._customUrlOrRegion);
217
- // @ts-ignore undocumented return, just used to unit test android host remapping
218
- return [_host, port];
219
- }
220
- }
221
-
222
- // import { SDK_VERSION } from '@react-native-firebase/storage';
223
- export const SDK_VERSION = version;
224
-
225
- const storageNamespace = createModuleNamespace({
226
- statics,
227
- version,
228
- namespace,
229
- nativeEvents,
230
- nativeModuleName,
231
- hasMultiAppSupport: true,
232
- hasCustomUrlOrRegionSupport: true,
233
- disablePrependCustomUrlOrRegion: true,
234
- ModuleClass: FirebaseStorageModule,
235
- });
236
-
237
- type StorageNamespace = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
238
- FirebaseStorageTypes.Module,
239
- FirebaseStorageTypes.Statics
240
- > & {
241
- storage: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
242
- FirebaseStorageTypes.Module,
243
- FirebaseStorageTypes.Statics
244
- >;
245
- firebase: ReactNativeFirebase.Module;
246
- app(name?: string): ReactNativeFirebase.FirebaseApp;
247
- };
248
-
249
- // import storage from '@react-native-firebase/storage';
250
- // storage().X(...);
251
- export default storageNamespace as unknown as StorageNamespace;
252
-
253
- // import storage, { firebase } from '@react-native-firebase/storage';
254
- // storage().X(...);
255
- // firebase.storage().X(...);
256
- export const firebase =
257
- getFirebaseRoot() as unknown as ReactNativeFirebase.FirebaseNamespacedExport<
258
- 'storage',
259
- FirebaseStorageTypes.Module,
260
- FirebaseStorageTypes.Statics,
261
- true
262
- >;
263
-
264
- setReactNativeModule(nativeModuleName, fallBackModule);