reactfire 4.0.0 → 4.0.1-exp.f6d2351
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/README.md +12 -3
- package/dist/SuspenseSubject.d.ts +21 -21
- package/dist/auth.d.ts +104 -104
- package/dist/database.d.ts +23 -23
- package/dist/firebaseApp.d.ts +14 -14
- package/dist/firestore.d.ts +35 -35
- package/dist/functions.d.ts +12 -0
- package/dist/index.d.ts +36 -35
- package/dist/index.js +2337 -5
- package/dist/index.js.map +1 -0
- package/dist/index.umd.cjs +122 -0
- package/dist/index.umd.cjs.map +1 -0
- package/dist/performance.d.ts +7 -7
- package/dist/{remote-config/index.d.ts → remote-config.d.ts} +30 -35
- package/dist/sdk.d.ts +70 -43
- package/dist/storage.d.ts +26 -26
- package/dist/useObservable.d.ts +41 -41
- package/package.json +56 -54
- package/src/SuspenseSubject.ts +6 -4
- package/src/auth.tsx +6 -6
- package/src/firebaseApp.tsx +2 -2
- package/src/functions.tsx +26 -0
- package/src/index.ts +1 -0
- package/src/{remote-config/index.tsx → remote-config.tsx} +4 -16
- package/src/sdk.tsx +26 -27
- package/src/storage.tsx +2 -24
- package/src/useObservable.ts +48 -28
- package/dist/reactfire.cjs.development.js +0 -2147
- package/dist/reactfire.cjs.development.js.map +0 -1
- package/dist/reactfire.cjs.production.min.js +0 -2
- package/dist/reactfire.cjs.production.min.js.map +0 -1
- package/dist/reactfire.esm.js +0 -2089
- package/dist/reactfire.esm.js.map +0 -1
- package/dist/remote-config/getValue.d.ts +0 -10
- package/src/remote-config/getValue.tsx +0 -58
package/dist/sdk.d.ts
CHANGED
|
@@ -1,43 +1,70 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export declare const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export declare const
|
|
25
|
-
sdk:
|
|
26
|
-
}>) => JSX.Element;
|
|
27
|
-
export declare const
|
|
28
|
-
sdk:
|
|
29
|
-
}>) => JSX.Element;
|
|
30
|
-
export declare const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export declare const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
declare
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export declare const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export declare const
|
|
43
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AppCheck } from 'firebase/app-check';
|
|
3
|
+
import type { Auth } from 'firebase/auth';
|
|
4
|
+
import type { Analytics } from 'firebase/analytics';
|
|
5
|
+
import type { Database } from 'firebase/database';
|
|
6
|
+
import type { Firestore } from 'firebase/firestore';
|
|
7
|
+
import type { Functions } from 'firebase/functions';
|
|
8
|
+
import type { FirebasePerformance } from 'firebase/performance';
|
|
9
|
+
import type { FirebaseStorage } from 'firebase/storage';
|
|
10
|
+
import type { RemoteConfig } from 'firebase/remote-config';
|
|
11
|
+
import { FirebaseApp } from 'firebase/app';
|
|
12
|
+
import { ObservableStatus } from './useObservable';
|
|
13
|
+
import { ReactFireOptions } from '.';
|
|
14
|
+
export declare const AppCheckSdkContext: React.Context<AppCheck | undefined>;
|
|
15
|
+
export declare const AuthSdkContext: React.Context<Auth | undefined>;
|
|
16
|
+
export declare const AnalyticsSdkContext: React.Context<Analytics | undefined>;
|
|
17
|
+
export declare const DatabaseSdkContext: React.Context<Database | undefined>;
|
|
18
|
+
export declare const FirestoreSdkContext: React.Context<Firestore | undefined>;
|
|
19
|
+
export declare const FunctionsSdkContext: React.Context<Functions | undefined>;
|
|
20
|
+
export declare const StorageSdkContext: React.Context<FirebaseStorage | undefined>;
|
|
21
|
+
export declare const PerformanceSdkContext: React.Context<FirebasePerformance | undefined>;
|
|
22
|
+
export declare const RemoteConfigSdkContext: React.Context<RemoteConfig | undefined>;
|
|
23
|
+
declare type FirebaseSdks = Analytics | AppCheck | Auth | Database | Firestore | FirebasePerformance | FirebaseStorage | Functions | RemoteConfig;
|
|
24
|
+
export declare const AppCheckProvider: (props: React.PropsWithChildren<{
|
|
25
|
+
sdk: AppCheck;
|
|
26
|
+
}>) => JSX.Element;
|
|
27
|
+
export declare const AuthProvider: (props: React.PropsWithChildren<{
|
|
28
|
+
sdk: Auth;
|
|
29
|
+
}>) => JSX.Element;
|
|
30
|
+
export declare const AnalyticsProvider: (props: React.PropsWithChildren<{
|
|
31
|
+
sdk: Analytics;
|
|
32
|
+
}>) => JSX.Element;
|
|
33
|
+
export declare const DatabaseProvider: (props: React.PropsWithChildren<{
|
|
34
|
+
sdk: Database;
|
|
35
|
+
}>) => JSX.Element;
|
|
36
|
+
export declare const FirestoreProvider: (props: React.PropsWithChildren<{
|
|
37
|
+
sdk: Firestore;
|
|
38
|
+
}>) => JSX.Element;
|
|
39
|
+
export declare const FunctionsProvider: (props: React.PropsWithChildren<{
|
|
40
|
+
sdk: Functions;
|
|
41
|
+
}>) => JSX.Element;
|
|
42
|
+
export declare const PerformanceProvider: (props: React.PropsWithChildren<{
|
|
43
|
+
sdk: FirebasePerformance;
|
|
44
|
+
}>) => JSX.Element;
|
|
45
|
+
export declare const StorageProvider: (props: React.PropsWithChildren<{
|
|
46
|
+
sdk: FirebaseStorage;
|
|
47
|
+
}>) => JSX.Element;
|
|
48
|
+
export declare const RemoteConfigProvider: (props: React.PropsWithChildren<{
|
|
49
|
+
sdk: RemoteConfig;
|
|
50
|
+
}>) => JSX.Element;
|
|
51
|
+
export declare const useAppCheck: () => AppCheck;
|
|
52
|
+
export declare const useAuth: () => Auth;
|
|
53
|
+
export declare const useAnalytics: () => Analytics;
|
|
54
|
+
export declare const useDatabase: () => Database;
|
|
55
|
+
export declare const useFirestore: () => Firestore;
|
|
56
|
+
export declare const useFunctions: () => Functions;
|
|
57
|
+
export declare const usePerformance: () => FirebasePerformance;
|
|
58
|
+
export declare const useStorage: () => FirebaseStorage;
|
|
59
|
+
export declare const useRemoteConfig: () => RemoteConfig;
|
|
60
|
+
declare type InitSdkHook<Sdk extends FirebaseSdks> = (initializer: (firebaseApp: FirebaseApp) => Promise<Sdk>, options?: ReactFireOptions<Sdk>) => ObservableStatus<Sdk>;
|
|
61
|
+
export declare const useInitAppCheck: InitSdkHook<AppCheck>;
|
|
62
|
+
export declare const useInitAuth: InitSdkHook<Auth>;
|
|
63
|
+
export declare const useInitAnalytics: InitSdkHook<Analytics>;
|
|
64
|
+
export declare const useInitDatabase: InitSdkHook<Database>;
|
|
65
|
+
export declare const useInitFirestore: InitSdkHook<Firestore>;
|
|
66
|
+
export declare const useInitFunctions: InitSdkHook<Functions>;
|
|
67
|
+
export declare const useInitPerformance: InitSdkHook<FirebasePerformance>;
|
|
68
|
+
export declare const useInitRemoteConfig: InitSdkHook<RemoteConfig>;
|
|
69
|
+
export declare const useInitStorage: InitSdkHook<FirebaseStorage>;
|
|
70
|
+
export {};
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ReactFireOptions, ObservableStatus } from './';
|
|
3
|
-
import type { UploadTask, UploadTaskSnapshot, StorageReference, FirebaseStorage } from 'firebase/storage';
|
|
4
|
-
/**
|
|
5
|
-
* Subscribe to the progress of a storage task
|
|
6
|
-
*
|
|
7
|
-
* @param task - the task you want to listen to
|
|
8
|
-
* @param ref - reference to the blob the task is acting on
|
|
9
|
-
* @param options
|
|
10
|
-
*/
|
|
11
|
-
export declare function useStorageTask<T = unknown>(task: UploadTask, ref: StorageReference, options?: ReactFireOptions<T>): ObservableStatus<UploadTaskSnapshot | T>;
|
|
12
|
-
/**
|
|
13
|
-
* Subscribe to a storage ref's download URL
|
|
14
|
-
*
|
|
15
|
-
* @param ref - reference to the blob you want to download
|
|
16
|
-
* @param options
|
|
17
|
-
*/
|
|
18
|
-
export declare function useStorageDownloadURL<T = string>(ref: StorageReference, options?: ReactFireOptions<T>): ObservableStatus<string | T>;
|
|
19
|
-
declare type StorageImageProps = {
|
|
20
|
-
storagePath: string;
|
|
21
|
-
storage?: FirebaseStorage;
|
|
22
|
-
suspense?: boolean;
|
|
23
|
-
placeHolder?: JSX.Element;
|
|
24
|
-
};
|
|
25
|
-
export declare function StorageImage(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>): JSX.Element;
|
|
26
|
-
export {};
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactFireOptions, ObservableStatus } from './';
|
|
3
|
+
import type { UploadTask, UploadTaskSnapshot, StorageReference, FirebaseStorage } from 'firebase/storage';
|
|
4
|
+
/**
|
|
5
|
+
* Subscribe to the progress of a storage task
|
|
6
|
+
*
|
|
7
|
+
* @param task - the task you want to listen to
|
|
8
|
+
* @param ref - reference to the blob the task is acting on
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
export declare function useStorageTask<T = unknown>(task: UploadTask, ref: StorageReference, options?: ReactFireOptions<T>): ObservableStatus<UploadTaskSnapshot | T>;
|
|
12
|
+
/**
|
|
13
|
+
* Subscribe to a storage ref's download URL
|
|
14
|
+
*
|
|
15
|
+
* @param ref - reference to the blob you want to download
|
|
16
|
+
* @param options
|
|
17
|
+
*/
|
|
18
|
+
export declare function useStorageDownloadURL<T = string>(ref: StorageReference, options?: ReactFireOptions<T>): ObservableStatus<string | T>;
|
|
19
|
+
declare type StorageImageProps = {
|
|
20
|
+
storagePath: string;
|
|
21
|
+
storage?: FirebaseStorage;
|
|
22
|
+
suspense?: boolean;
|
|
23
|
+
placeHolder?: JSX.Element;
|
|
24
|
+
};
|
|
25
|
+
export declare function StorageImage(props: StorageImageProps & React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>): JSX.Element;
|
|
26
|
+
export {};
|
package/dist/useObservable.d.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { SuspenseSubject } from './SuspenseSubject';
|
|
3
|
-
import { ReactFireOptions } from './';
|
|
4
|
-
export declare function preloadObservable<T>(source: Observable<T>, id: string): SuspenseSubject<T>;
|
|
5
|
-
export interface ObservableStatus<T> {
|
|
6
|
-
/**
|
|
7
|
-
* The loading status.
|
|
8
|
-
*
|
|
9
|
-
* - `loading`: Waiting for the first value from an observable
|
|
10
|
-
* - `error`: Something went wrong. Check `ObservableStatus.error` for more details
|
|
11
|
-
* - `success`: The hook has emitted at least one value
|
|
12
|
-
*
|
|
13
|
-
* If `initialData` is passed in, this will skip `loading` and go straight to `success`.
|
|
14
|
-
*/
|
|
15
|
-
status: 'loading' | 'error' | 'success';
|
|
16
|
-
/**
|
|
17
|
-
* Indicates whether the hook has emitted a value at some point
|
|
18
|
-
*
|
|
19
|
-
* If `initialData` is passed in, this will be `true`.
|
|
20
|
-
*/
|
|
21
|
-
hasEmitted: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* If this is `true`, the hook will be emitting no further items.
|
|
24
|
-
*/
|
|
25
|
-
isComplete: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* The most recent value.
|
|
28
|
-
*
|
|
29
|
-
* If `initialData` is passed in, the first value of `data` will be the valuea provided in `initialData` **UNLESS** the underlying observable is ready, in which case it will skip `initialData`.
|
|
30
|
-
*/
|
|
31
|
-
data: T;
|
|
32
|
-
/**
|
|
33
|
-
* Any error that may have occurred in the underlying observable
|
|
34
|
-
*/
|
|
35
|
-
error: Error | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Promise that resolves after first emit from observable
|
|
38
|
-
*/
|
|
39
|
-
firstValuePromise: Promise<void>;
|
|
40
|
-
}
|
|
41
|
-
export declare function useObservable<T = unknown>(observableId: string, source: Observable<T>, config?: ReactFireOptions): ObservableStatus<T>;
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { SuspenseSubject } from './SuspenseSubject';
|
|
3
|
+
import { ReactFireOptions } from './';
|
|
4
|
+
export declare function preloadObservable<T>(source: Observable<T>, id: string): SuspenseSubject<T>;
|
|
5
|
+
export interface ObservableStatus<T> {
|
|
6
|
+
/**
|
|
7
|
+
* The loading status.
|
|
8
|
+
*
|
|
9
|
+
* - `loading`: Waiting for the first value from an observable
|
|
10
|
+
* - `error`: Something went wrong. Check `ObservableStatus.error` for more details
|
|
11
|
+
* - `success`: The hook has emitted at least one value
|
|
12
|
+
*
|
|
13
|
+
* If `initialData` is passed in, this will skip `loading` and go straight to `success`.
|
|
14
|
+
*/
|
|
15
|
+
status: 'loading' | 'error' | 'success';
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether the hook has emitted a value at some point
|
|
18
|
+
*
|
|
19
|
+
* If `initialData` is passed in, this will be `true`.
|
|
20
|
+
*/
|
|
21
|
+
hasEmitted: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If this is `true`, the hook will be emitting no further items.
|
|
24
|
+
*/
|
|
25
|
+
isComplete: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The most recent value.
|
|
28
|
+
*
|
|
29
|
+
* If `initialData` is passed in, the first value of `data` will be the valuea provided in `initialData` **UNLESS** the underlying observable is ready, in which case it will skip `initialData`.
|
|
30
|
+
*/
|
|
31
|
+
data: T;
|
|
32
|
+
/**
|
|
33
|
+
* Any error that may have occurred in the underlying observable
|
|
34
|
+
*/
|
|
35
|
+
error: Error | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Promise that resolves after first emit from observable
|
|
38
|
+
*/
|
|
39
|
+
firstValuePromise: Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export declare function useObservable<T = unknown>(observableId: string, source: Observable<T>, config?: ReactFireOptions): ObservableStatus<T>;
|
package/package.json
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.
|
|
2
|
+
"version": "4.0.1-exp.f6d2351",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.umd.cjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"require": "./dist/index.umd.cjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
5
12
|
"typings": "dist/index.d.ts",
|
|
6
13
|
"files": [
|
|
7
14
|
"dist",
|
|
8
15
|
"src"
|
|
9
16
|
],
|
|
10
17
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
18
|
+
"node": ">=14"
|
|
12
19
|
},
|
|
13
20
|
"scripts": {
|
|
14
|
-
"start": "
|
|
15
|
-
"build": "
|
|
16
|
-
"test
|
|
17
|
-
"test": "firebase emulators:exec --only firestore
|
|
18
|
-
"test:
|
|
19
|
-
"test:
|
|
20
|
-
"test:
|
|
21
|
-
"test:storage": "firebase emulators:exec --only storage --project=rxfire-525a3 \"
|
|
22
|
-
"test:useObservable": "
|
|
23
|
-
"
|
|
21
|
+
"start": "firebase emulators:exec --project=rxfire-525a3 \"vitest --ui\"",
|
|
22
|
+
"build": "tsc && vite build && npm run docs",
|
|
23
|
+
"test": "firebase emulators:exec --project=rxfire-525a3 \"vitest\"",
|
|
24
|
+
"test:firestore": "firebase emulators:exec --only firestore --ui --project=rxfire-525a3 \"vitest firestore\"",
|
|
25
|
+
"test:database": "firebase emulators:exec --only database --project=rxfire-525a3 \"vitest database\"",
|
|
26
|
+
"test:auth": "firebase emulators:exec --only auth --project=rxfire-525a3 \"vitest auth\"",
|
|
27
|
+
"test:functions": "firebase emulators:exec --only functions --project=rxfire-525a3 \"vitest functions\"",
|
|
28
|
+
"test:storage": "firebase emulators:exec --only storage --project=rxfire-525a3 \"vitest storage\"",
|
|
29
|
+
"test:useObservable": "vitest useObservable",
|
|
30
|
+
"test:firebaseApp": "vitest firebaseApp",
|
|
31
|
+
"format": "prettier src test vite.config.ts -w",
|
|
32
|
+
"lint": "eslint src/* test/* vite.config.ts",
|
|
24
33
|
"size": "size-limit",
|
|
25
34
|
"analyze": "size-limit --why",
|
|
26
|
-
"docs": "typedoc --options typedoc.json && markdown-toc -i docs/use.md"
|
|
35
|
+
"docs": "typedoc --options typedoc.json && markdown-toc -i docs/use.md",
|
|
36
|
+
"docs:fork": "typedoc --options typedoc.json --gitRemote upstream && markdown-toc -i docs/use.md"
|
|
27
37
|
},
|
|
28
38
|
"peerDependencies": {
|
|
29
39
|
"firebase": "^9.0.0",
|
|
@@ -31,18 +41,9 @@
|
|
|
31
41
|
},
|
|
32
42
|
"husky": {
|
|
33
43
|
"hooks": {
|
|
34
|
-
"pre-commit": "
|
|
44
|
+
"pre-commit": "npm run lint"
|
|
35
45
|
}
|
|
36
46
|
},
|
|
37
|
-
"eslint": {
|
|
38
|
-
"rules": {
|
|
39
|
-
"react-hooks/rules-of-hooks": "error",
|
|
40
|
-
"no-only-tests/no-only-tests": "error"
|
|
41
|
-
},
|
|
42
|
-
"plugins": [
|
|
43
|
-
"no-only-tests"
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
47
|
"prettier": {
|
|
47
48
|
"singleQuote": true,
|
|
48
49
|
"printWidth": 160
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"url": "https://github.com/Firebase/reactfire/issues"
|
|
59
60
|
},
|
|
60
61
|
"homepage": "https://firebaseopensource.com/projects/firebaseextended/reactfire/",
|
|
61
|
-
"module": "dist/
|
|
62
|
+
"module": "./dist/index.js",
|
|
62
63
|
"size-limit": [
|
|
63
64
|
{
|
|
64
65
|
"path": "dist/reactfire.cjs.production.min.js",
|
|
@@ -70,42 +71,43 @@
|
|
|
70
71
|
}
|
|
71
72
|
],
|
|
72
73
|
"devDependencies": {
|
|
73
|
-
"@
|
|
74
|
-
"@size-limit/preset-small-lib": "^
|
|
75
|
-
"@testing-library/jest-dom": "^5.
|
|
76
|
-
"@testing-library/react": "^
|
|
77
|
-
"@testing-library/react-hooks": "^
|
|
78
|
-
"@types/
|
|
79
|
-
"@types/react": "^17.0.
|
|
80
|
-
"@
|
|
81
|
-
"
|
|
82
|
-
"
|
|
74
|
+
"@rollup/plugin-typescript": "^8.3.4",
|
|
75
|
+
"@size-limit/preset-small-lib": "^7.0.8",
|
|
76
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
77
|
+
"@testing-library/react": "^12.1.5",
|
|
78
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
79
|
+
"@types/react": "^17.0.2",
|
|
80
|
+
"@types/react-dom": "^17.0.2",
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
|
82
|
+
"@typescript-eslint/parser": "^5.32.0",
|
|
83
|
+
"@vitejs/plugin-react": "^2.0.0",
|
|
84
|
+
"@vitest/ui": "^0.20.3",
|
|
85
|
+
"cross-fetch": "^3.1.5",
|
|
86
|
+
"eslint": "^8.20.0",
|
|
83
87
|
"eslint-plugin-no-only-tests": "^2.6.0",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
88
|
+
"eslint-plugin-react": "^7.30.1",
|
|
89
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
90
|
+
"firebase": "^9.9.0",
|
|
91
|
+
"firebase-tools": "^11.3.0",
|
|
92
|
+
"globalthis": "^1.0.3",
|
|
93
|
+
"husky": "^8.0.1",
|
|
94
|
+
"jest-environment-jsdom": "^28.1.3",
|
|
95
|
+
"jsdom": "^20.0.0",
|
|
89
96
|
"markdown-toc": "^1.2.0",
|
|
90
|
-
"
|
|
97
|
+
"prettier": "^2.7.1",
|
|
91
98
|
"react": "^17.0.2",
|
|
92
99
|
"react-dom": "^17.0.2",
|
|
93
100
|
"react-test-renderer": "^17.0.2",
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"typedoc": "^
|
|
98
|
-
"
|
|
99
|
-
"
|
|
101
|
+
"rollup-plugin-visualizer": "^5.7.1",
|
|
102
|
+
"size-limit": "^7.0.8",
|
|
103
|
+
"typedoc": "^0.23.8",
|
|
104
|
+
"typedoc-plugin-markdown": "^3.13.3",
|
|
105
|
+
"typescript": "^4.7.4",
|
|
106
|
+
"vite": "^3.0.2",
|
|
107
|
+
"vitest": "^0.18.1"
|
|
100
108
|
},
|
|
101
109
|
"dependencies": {
|
|
102
|
-
"rxfire": "^6.0.
|
|
110
|
+
"rxfire": "^6.0.3",
|
|
103
111
|
"rxjs": "^6.6.3 || ^7.0.1"
|
|
104
|
-
},
|
|
105
|
-
"resolutions": {
|
|
106
|
-
"tsdx/**/jest": "^26.6.3",
|
|
107
|
-
"tsdx/**/ts-jest": "^26.5.5",
|
|
108
|
-
"tsdx/**/prettier": "^2.2.1",
|
|
109
|
-
"tsdx/**/typescript": "^4.2.4"
|
|
110
112
|
}
|
|
111
113
|
}
|
package/src/SuspenseSubject.ts
CHANGED
|
@@ -10,9 +10,9 @@ export class SuspenseSubject<T> extends Subject<T> {
|
|
|
10
10
|
private _innerObservable: Observable<T>;
|
|
11
11
|
private _warmupSubscription: Subscription;
|
|
12
12
|
|
|
13
|
-
// @ts-
|
|
13
|
+
// @ts-expect-error: TODO: double check to see if this is an RXJS thing or if we should listen to TS
|
|
14
14
|
private _innerSubscriber: Subscription;
|
|
15
|
-
// @ts-
|
|
15
|
+
// @ts-expect-error: TODO: double check to see if this is an RXJS thing or if we should listen to TS
|
|
16
16
|
private _resolveFirstEmission: () => void;
|
|
17
17
|
|
|
18
18
|
constructor(innerObservable: Observable<T>, private _timeoutWindow: number) {
|
|
@@ -48,14 +48,16 @@ export class SuspenseSubject<T> extends Subject<T> {
|
|
|
48
48
|
return this._hasValue || !!this._error;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
get value(): T
|
|
51
|
+
get value(): T {
|
|
52
52
|
// TODO figure out how to reset the cache here, if I _reset() here before throwing
|
|
53
53
|
// it doesn't seem to work.
|
|
54
54
|
// As it is now, this will burn the cache entry until the timeout fires.
|
|
55
55
|
if (this._error) {
|
|
56
56
|
throw this._error;
|
|
57
|
+
} else if (!this.hasValue) {
|
|
58
|
+
throw Error('Can only get value if SuspenseSubject has a value');
|
|
57
59
|
}
|
|
58
|
-
return this._value;
|
|
60
|
+
return this._value as T;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
get firstEmission(): Promise<void> {
|
package/src/auth.tsx
CHANGED
|
@@ -24,15 +24,15 @@ export function useUser<T = unknown>(options?: ReactFireOptions<T>): ObservableS
|
|
|
24
24
|
|
|
25
25
|
const observableId = `auth:user:${auth.name}`;
|
|
26
26
|
const observable$ = user(auth);
|
|
27
|
+
const _options: ReactFireOptions<T> = { ...options } ?? {};
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
currentUser = options.initialData ?? options.startWithValue;
|
|
29
|
+
// only set/override initialData if auth has finished loading
|
|
30
|
+
if (auth.currentUser !== undefined) {
|
|
31
|
+
_options.initialData = auth.currentUser;
|
|
32
|
+
_options.startWithValue = auth.currentUser;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return useObservable(observableId, observable$,
|
|
35
|
+
return useObservable(observableId, observable$, _options);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function useIdTokenResult(user: User, forceRefresh: boolean = false, options?: ReactFireOptions<IdTokenResult>): ObservableStatus<IdTokenResult> {
|
package/src/firebaseApp.tsx
CHANGED
|
@@ -16,8 +16,8 @@ interface FirebaseAppProviderProps {
|
|
|
16
16
|
suspense?: boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
export const version =
|
|
19
|
+
// REACTFIRE_VERSION is automatically pulled in from `package.json` by Vite
|
|
20
|
+
export const version = process.env.REACTFIRE_VERSION as string;
|
|
21
21
|
|
|
22
22
|
const shallowEq = (a: { [key: string]: any }, b: { [key: string]: any }) => a === b || [...Object.keys(a), ...Object.keys(b)].every((key) => a[key] === b[key]);
|
|
23
23
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { httpsCallable as rxHttpsCallable } from 'rxfire/functions';
|
|
2
|
+
import { ReactFireOptions, useObservable, ObservableStatus } from './';
|
|
3
|
+
import { useFunctions } from '.';
|
|
4
|
+
|
|
5
|
+
import type { HttpsCallableOptions } from 'firebase/functions';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calls a callable function.
|
|
9
|
+
*
|
|
10
|
+
* @param functionName - The name of the function to call
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
export function useCallableFunctionResponse<RequestData, ResponseData>(
|
|
14
|
+
functionName: string,
|
|
15
|
+
options?: ReactFireOptions<ResponseData> & {
|
|
16
|
+
httpsCallableOptions?: HttpsCallableOptions;
|
|
17
|
+
data?: RequestData;
|
|
18
|
+
}
|
|
19
|
+
): ObservableStatus<ResponseData> {
|
|
20
|
+
const functions = useFunctions();
|
|
21
|
+
const observableId = `functions:callableResponse:${functionName}:${JSON.stringify(options?.data)}:${JSON.stringify(options?.httpsCallableOptions)}`;
|
|
22
|
+
const obsFactory = rxHttpsCallable<RequestData, ResponseData>(functions, functionName, options?.httpsCallableOptions);
|
|
23
|
+
const observable$ = obsFactory(options?.data);
|
|
24
|
+
|
|
25
|
+
return useObservable(observableId, observable$, options);
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { useRemoteConfig } from '
|
|
2
|
-
import { useObservable, ObservableStatus } from '
|
|
3
|
-
import { getValue, getString, getBoolean, getNumber, getAll, AllParameters } from '
|
|
1
|
+
import { useRemoteConfig } from './';
|
|
2
|
+
import { useObservable, ObservableStatus } from './useObservable';
|
|
3
|
+
import { getValue, getString, getBoolean, getNumber, getAll, AllParameters } from 'rxfire/remote-config';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
|
|
6
6
|
import type { RemoteConfig, Value as RemoteConfigValue } from 'firebase/remote-config';
|
|
7
7
|
|
|
8
8
|
type Getter$<T> = (remoteConfig: RemoteConfig, key: string) => Observable<T>;
|
|
9
9
|
|
|
10
|
-
interface RemoteConfigWithPrivate extends RemoteConfig {
|
|
11
|
-
// This is a private API, assume optional
|
|
12
|
-
_storage?: { appName: string };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
10
|
/**
|
|
16
11
|
* Helper function to construct type safe functions. Since Remote Config has
|
|
17
12
|
* methods that return different types for values, we need to be extra safe
|
|
@@ -23,9 +18,7 @@ interface RemoteConfigWithPrivate extends RemoteConfig {
|
|
|
23
18
|
function useRemoteConfigValue_INTERNAL<T>(key: string, getter: Getter$<T>): ObservableStatus<T> {
|
|
24
19
|
const remoteConfig = useRemoteConfig();
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
// we might need to iterate over the Firebase apps and check for remoteConfig equality? this works for now
|
|
28
|
-
const appName = (remoteConfig as RemoteConfigWithPrivate)._storage?.appName;
|
|
21
|
+
const appName = remoteConfig.app.name;
|
|
29
22
|
const $value = getter(remoteConfig, key);
|
|
30
23
|
|
|
31
24
|
const observableId = `remoteConfig:${key}:${getter.name}:${appName}`;
|
|
@@ -37,7 +30,6 @@ function useRemoteConfigValue_INTERNAL<T>(key: string, getter: Getter$<T>): Obse
|
|
|
37
30
|
* Remote Config Value.
|
|
38
31
|
*
|
|
39
32
|
* @param key The parameter key in Remote Config
|
|
40
|
-
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
|
|
41
33
|
*/
|
|
42
34
|
export function useRemoteConfigValue(key: string): ObservableStatus<RemoteConfigValue> {
|
|
43
35
|
return useRemoteConfigValue_INTERNAL<RemoteConfigValue>(key, getValue);
|
|
@@ -46,7 +38,6 @@ export function useRemoteConfigValue(key: string): ObservableStatus<RemoteConfig
|
|
|
46
38
|
/**
|
|
47
39
|
* Convience method similar to useRemoteConfigValue. Returns a `string` from a Remote Config parameter.
|
|
48
40
|
* @param key The parameter key in Remote Config
|
|
49
|
-
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
|
|
50
41
|
*/
|
|
51
42
|
export function useRemoteConfigString(key: string): ObservableStatus<string> {
|
|
52
43
|
return useRemoteConfigValue_INTERNAL<string>(key, getString);
|
|
@@ -55,7 +46,6 @@ export function useRemoteConfigString(key: string): ObservableStatus<string> {
|
|
|
55
46
|
/**
|
|
56
47
|
* Convience method similar to useRemoteConfigValue. Returns a `number` from a Remote Config parameter.
|
|
57
48
|
* @param key The parameter key in Remote Config
|
|
58
|
-
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
|
|
59
49
|
*/
|
|
60
50
|
export function useRemoteConfigNumber(key: string): ObservableStatus<number> {
|
|
61
51
|
return useRemoteConfigValue_INTERNAL<number>(key, getNumber);
|
|
@@ -64,7 +54,6 @@ export function useRemoteConfigNumber(key: string): ObservableStatus<number> {
|
|
|
64
54
|
/**
|
|
65
55
|
* Convience method similar to useRemoteConfigValue. Returns a `boolean` from a Remote Config parameter.
|
|
66
56
|
* @param key The parameter key in Remote Config
|
|
67
|
-
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
|
|
68
57
|
*/
|
|
69
58
|
export function useRemoteConfigBoolean(key: string): ObservableStatus<boolean> {
|
|
70
59
|
return useRemoteConfigValue_INTERNAL<boolean>(key, getBoolean);
|
|
@@ -73,7 +62,6 @@ export function useRemoteConfigBoolean(key: string): ObservableStatus<boolean> {
|
|
|
73
62
|
/**
|
|
74
63
|
* Convience method similar to useRemoteConfigValue. Returns allRemote Config parameters.
|
|
75
64
|
* @param key The parameter key in Remote Config
|
|
76
|
-
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
|
|
77
65
|
*/
|
|
78
66
|
export function useRemoteConfigAll(key: string): ObservableStatus<AllParameters> {
|
|
79
67
|
return useRemoteConfigValue_INTERNAL<AllParameters>(key, getAll);
|