@react-native-firebase/storage 21.10.0 → 21.11.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.
- package/CHANGELOG.md +10 -0
- package/lib/StorageReference.js +8 -8
- package/lib/StorageStatics.js +15 -17
- package/lib/StorageTask.js +5 -5
- package/lib/index.js +9 -5
- package/lib/modular/index.d.ts +4 -0
- package/lib/modular/index.js +2 -0
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [21.11.0](https://github.com/invertase/react-native-firebase/compare/v21.10.1...v21.11.0) (2025-02-20)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @react-native-firebase/storage
|
9
|
+
|
10
|
+
## [21.10.1](https://github.com/invertase/react-native-firebase/compare/v21.10.0...v21.10.1) (2025-02-18)
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
- **storage:** expose static types for modular API ([#8322](https://github.com/invertase/react-native-firebase/issues/8322)) ([d4e532a](https://github.com/invertase/react-native-firebase/commit/d4e532af97ab1a512fc4ba2bc7c8293b50020887))
|
15
|
+
|
6
16
|
## [21.10.0](https://github.com/invertase/react-native-firebase/compare/v21.9.0...v21.10.0) (2025-02-11)
|
7
17
|
|
8
18
|
**Note:** Version bump only for package @react-native-firebase/storage
|
package/lib/StorageReference.js
CHANGED
@@ -32,7 +32,7 @@ import {
|
|
32
32
|
} from '@react-native-firebase/app/lib/common';
|
33
33
|
import StorageDownloadTask from './StorageDownloadTask';
|
34
34
|
import StorageListResult, { provideStorageReferenceClass } from './StorageListResult';
|
35
|
-
import
|
35
|
+
import { StringFormat } from './StorageStatics';
|
36
36
|
import StorageUploadTask from './StorageUploadTask';
|
37
37
|
import { validateMetadata } from './utils';
|
38
38
|
|
@@ -198,7 +198,7 @@ export default class StorageReference extends ReferenceBase {
|
|
198
198
|
/**
|
199
199
|
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Reference#putString
|
200
200
|
*/
|
201
|
-
putString(string, format =
|
201
|
+
putString(string, format = StringFormat.RAW, metadata) {
|
202
202
|
const { _string, _format, _metadata } = this._updateString(string, format, metadata, false);
|
203
203
|
|
204
204
|
return new StorageUploadTask(this, task =>
|
@@ -270,10 +270,10 @@ export default class StorageReference extends ReferenceBase {
|
|
270
270
|
);
|
271
271
|
}
|
272
272
|
|
273
|
-
if (!Object.values(
|
273
|
+
if (!Object.values(StringFormat).includes(format)) {
|
274
274
|
throw new Error(
|
275
275
|
`firebase.storage.StorageReference.putString(_, *, _) 'format' provided is invalid, must be one of ${Object.values(
|
276
|
-
|
276
|
+
StringFormat,
|
277
277
|
).join(',')}.`,
|
278
278
|
);
|
279
279
|
}
|
@@ -286,10 +286,10 @@ export default class StorageReference extends ReferenceBase {
|
|
286
286
|
let _format = format;
|
287
287
|
let _metadata = metadata;
|
288
288
|
|
289
|
-
if (format ===
|
289
|
+
if (format === StringFormat.RAW) {
|
290
290
|
_string = Base64.btoa(_string);
|
291
|
-
_format =
|
292
|
-
} else if (format ===
|
291
|
+
_format = StringFormat.BASE64;
|
292
|
+
} else if (format === StringFormat.DATA_URL) {
|
293
293
|
const { mediaType, base64String } = getDataUrlParts(_string);
|
294
294
|
if (isUndefined(base64String)) {
|
295
295
|
throw new Error(
|
@@ -303,7 +303,7 @@ export default class StorageReference extends ReferenceBase {
|
|
303
303
|
}
|
304
304
|
_metadata.contentType = mediaType;
|
305
305
|
_string = base64String;
|
306
|
-
_format =
|
306
|
+
_format = StringFormat.BASE64;
|
307
307
|
}
|
308
308
|
}
|
309
309
|
return { _string, _metadata, _format };
|
package/lib/StorageStatics.js
CHANGED
@@ -15,21 +15,19 @@
|
|
15
15
|
*
|
16
16
|
*/
|
17
17
|
|
18
|
-
export
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
ERROR: 'error',
|
34
|
-
},
|
18
|
+
export const StringFormat = {
|
19
|
+
RAW: 'raw',
|
20
|
+
BASE64: 'base64',
|
21
|
+
BASE64URL: 'base64url',
|
22
|
+
DATA_URL: 'data_url',
|
23
|
+
};
|
24
|
+
export const TaskEvent = {
|
25
|
+
STATE_CHANGED: 'state_changed',
|
26
|
+
};
|
27
|
+
export const TaskState = {
|
28
|
+
RUNNING: 'running',
|
29
|
+
PAUSED: 'paused',
|
30
|
+
SUCCESS: 'success',
|
31
|
+
CANCELLED: 'cancelled',
|
32
|
+
ERROR: 'error',
|
35
33
|
};
|
package/lib/StorageTask.js
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
*/
|
17
17
|
|
18
18
|
import { isFunction, isNull, isObject } from '@react-native-firebase/app/lib/common';
|
19
|
-
import
|
19
|
+
import { TaskEvent } from './StorageStatics';
|
20
20
|
|
21
21
|
let TASK_ID = 0;
|
22
22
|
|
@@ -69,7 +69,7 @@ function wrapSnapshotEventListener(task, listenerFn, unsubscribe) {
|
|
69
69
|
|
70
70
|
function addTaskEventListener(task, eventName, listener) {
|
71
71
|
let _eventName = eventName;
|
72
|
-
if (_eventName !==
|
72
|
+
if (_eventName !== TaskEvent.STATE_CHANGED) {
|
73
73
|
_eventName = `${task._type}_${eventName}`;
|
74
74
|
}
|
75
75
|
|
@@ -119,7 +119,7 @@ function subscribeToEvents(task, nextOrObserver, error, complete) {
|
|
119
119
|
}
|
120
120
|
|
121
121
|
if (_next) {
|
122
|
-
_nextSubscription = addTaskEventListener(task,
|
122
|
+
_nextSubscription = addTaskEventListener(task, TaskEvent.STATE_CHANGED, _next);
|
123
123
|
}
|
124
124
|
|
125
125
|
if (_error) {
|
@@ -191,9 +191,9 @@ export default class StorageTask {
|
|
191
191
|
* @url https://firebase.google.com/docs/reference/js/firebase.storage.UploadTask#on
|
192
192
|
*/
|
193
193
|
on(event, nextOrObserver, error, complete) {
|
194
|
-
if (event !==
|
194
|
+
if (event !== TaskEvent.STATE_CHANGED) {
|
195
195
|
throw new Error(
|
196
|
-
`firebase.storage.StorageTask.on event argument must be a string with a value of '${
|
196
|
+
`firebase.storage.StorageTask.on event argument must be a string with a value of '${TaskEvent.STATE_CHANGED}'`,
|
197
197
|
);
|
198
198
|
}
|
199
199
|
|
package/lib/index.js
CHANGED
@@ -23,11 +23,18 @@ import {
|
|
23
23
|
getFirebaseRoot,
|
24
24
|
} from '@react-native-firebase/app/lib/internal';
|
25
25
|
import StorageReference from './StorageReference';
|
26
|
-
import
|
26
|
+
import { StringFormat, TaskEvent, TaskState } from './StorageStatics';
|
27
27
|
import { getGsUrlParts, getHttpUrlParts, handleStorageEvent } from './utils';
|
28
28
|
import version from './version';
|
29
29
|
import fallBackModule from './web/RNFBStorageModule';
|
30
30
|
|
31
|
+
// import { STATICS } from '@react-native-firebase/storage';
|
32
|
+
const statics = {
|
33
|
+
StringFormat,
|
34
|
+
TaskEvent,
|
35
|
+
TaskState,
|
36
|
+
};
|
37
|
+
|
31
38
|
const namespace = 'storage';
|
32
39
|
const nativeEvents = ['storage_event'];
|
33
40
|
const nativeModuleName = 'RNFBStorageModule';
|
@@ -186,13 +193,10 @@ class FirebaseStorageModule extends FirebaseModule {
|
|
186
193
|
// import { SDK_VERSION } from '@react-native-firebase/storage';
|
187
194
|
export const SDK_VERSION = version;
|
188
195
|
|
189
|
-
// import { STATICS } from '@react-native-firebase/storage';
|
190
|
-
export const STATICS = StorageStatics;
|
191
|
-
|
192
196
|
// import storage from '@react-native-firebase/storage';
|
193
197
|
// storage().X(...);
|
194
198
|
export default createModuleNamespace({
|
195
|
-
statics
|
199
|
+
statics,
|
196
200
|
version,
|
197
201
|
namespace,
|
198
202
|
nativeEvents,
|
package/lib/modular/index.d.ts
CHANGED
@@ -29,6 +29,10 @@ import SettableMetadata = FirebaseStorageTypes.SettableMetadata;
|
|
29
29
|
import EmulatorMockTokenOptions = FirebaseStorageTypes.EmulatorMockTokenOptions;
|
30
30
|
import FirebaseApp = ReactNativeFirebase.FirebaseApp;
|
31
31
|
|
32
|
+
export const StringFormat: FirebaseStorageTypes.StringFormat;
|
33
|
+
export const TaskEvent: FirebaseStorageTypes.TaskEvent;
|
34
|
+
export const TaskState: FirebaseStorageTypes.TaskState;
|
35
|
+
|
32
36
|
/**
|
33
37
|
* Returns the existing default {@link Storage} instance that is associated with the
|
34
38
|
* default {@link FirebaseApp}. The default storage bucket is used. If no instance exists, initializes a new
|
package/lib/modular/index.js
CHANGED
package/lib/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// Generated by genversion.
|
2
|
-
module.exports = '21.
|
2
|
+
module.exports = '21.11.0';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-firebase/storage",
|
3
|
-
"version": "21.
|
3
|
+
"version": "21.11.0",
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
5
5
|
"description": "React Native Firebase - React Native Firebase provides native integration with Cloud Storage, providing support to upload and download files directly from your device and from your Firebase Cloud Storage bucket.",
|
6
6
|
"main": "lib/index.js",
|
@@ -29,10 +29,10 @@
|
|
29
29
|
"download"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"@react-native-firebase/app": "21.
|
32
|
+
"@react-native-firebase/app": "21.11.0"
|
33
33
|
},
|
34
34
|
"publishConfig": {
|
35
35
|
"access": "public"
|
36
36
|
},
|
37
|
-
"gitHead": "
|
37
|
+
"gitHead": "082a1e496cb1f8496f53869d9ab9e6f88ecbdc00"
|
38
38
|
}
|