@vueuse/firebase 12.8.0 → 13.0.0-beta.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.
- package/package.json +8 -23
- package/index.cjs +0 -86
- package/index.d.cts +0 -99
- package/index.d.ts +0 -99
- package/useAuth.cjs +0 -15
- package/useAuth.d.cts +0 -75
- package/useAuth.d.ts +0 -75
- package/useFirestore.cjs +0 -58
- package/useFirestore.d.cts +0 -15
- package/useFirestore.d.ts +0 -15
- package/useRTDB.cjs +0 -22
- package/useRTDB.d.cts +0 -15
- package/useRTDB.d.ts +0 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "13.0.0-beta.1",
|
|
5
5
|
"description": "Enables realtime bindings for Firebase",
|
|
6
6
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,34 +24,19 @@
|
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
27
|
-
".":
|
|
28
|
-
"import": "./index.mjs",
|
|
29
|
-
"require": "./index.cjs"
|
|
30
|
-
},
|
|
27
|
+
".": "./index.mjs",
|
|
31
28
|
"./*": "./*",
|
|
32
|
-
"./useAuth":
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
"./useFirestore": {
|
|
37
|
-
"import": "./useFirestore.mjs",
|
|
38
|
-
"require": "./useFirestore.cjs"
|
|
39
|
-
},
|
|
40
|
-
"./useRTDB": {
|
|
41
|
-
"import": "./useRTDB.mjs",
|
|
42
|
-
"require": "./useRTDB.cjs"
|
|
43
|
-
}
|
|
29
|
+
"./useAuth": "./useAuth.mjs",
|
|
30
|
+
"./useFirestore": "./useFirestore.mjs",
|
|
31
|
+
"./useRTDB": "./useRTDB.mjs"
|
|
44
32
|
},
|
|
45
|
-
"main": "./index.
|
|
33
|
+
"main": "./index.mjs",
|
|
46
34
|
"module": "./index.mjs",
|
|
47
35
|
"unpkg": "./index.iife.min.js",
|
|
48
36
|
"jsdelivr": "./index.iife.min.js",
|
|
49
|
-
"types": "./index.d.
|
|
37
|
+
"types": "./index.d.mts",
|
|
50
38
|
"files": [
|
|
51
|
-
"**/*.cjs",
|
|
52
|
-
"**/*.d.cts",
|
|
53
39
|
"**/*.d.mts",
|
|
54
|
-
"**/*.d.ts",
|
|
55
40
|
"**/*.js",
|
|
56
41
|
"**/*.mjs"
|
|
57
42
|
],
|
|
@@ -60,7 +45,7 @@
|
|
|
60
45
|
},
|
|
61
46
|
"dependencies": {
|
|
62
47
|
"vue": "^3.5.13",
|
|
63
|
-
"@vueuse/shared": "
|
|
48
|
+
"@vueuse/shared": "13.0.0-beta.1"
|
|
64
49
|
},
|
|
65
50
|
"scripts": {
|
|
66
51
|
"build": "rollup --config=rollup.config.ts --configPlugin=rollup-plugin-esbuild"
|
package/index.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var vue = require('vue');
|
|
4
|
-
var shared = require('@vueuse/shared');
|
|
5
|
-
var firestore = require('firebase/firestore');
|
|
6
|
-
var database = require('firebase/database');
|
|
7
|
-
|
|
8
|
-
function useAuth(auth) {
|
|
9
|
-
const user = vue.ref(auth.currentUser);
|
|
10
|
-
const isAuthenticated = vue.computed(() => !!user.value);
|
|
11
|
-
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
12
|
-
return {
|
|
13
|
-
isAuthenticated,
|
|
14
|
-
user
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getData(docRef) {
|
|
19
|
-
const data = docRef.data();
|
|
20
|
-
if (data) {
|
|
21
|
-
Object.defineProperty(data, "id", {
|
|
22
|
-
value: docRef.id.toString(),
|
|
23
|
-
writable: false
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function isDocumentReference(docRef) {
|
|
29
|
-
var _a;
|
|
30
|
-
return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
|
|
31
|
-
}
|
|
32
|
-
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
33
|
-
const {
|
|
34
|
-
errorHandler = (err) => console.error(err),
|
|
35
|
-
autoDispose = true
|
|
36
|
-
} = options;
|
|
37
|
-
const refOfDocRef = vue.isRef(maybeDocRef) ? maybeDocRef : vue.computed(() => maybeDocRef);
|
|
38
|
-
let close = () => {
|
|
39
|
-
};
|
|
40
|
-
const data = vue.ref(initialValue);
|
|
41
|
-
vue.watch(refOfDocRef, (docRef) => {
|
|
42
|
-
close();
|
|
43
|
-
if (!refOfDocRef.value) {
|
|
44
|
-
data.value = initialValue;
|
|
45
|
-
} else if (isDocumentReference(refOfDocRef.value)) {
|
|
46
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
47
|
-
data.value = getData(snapshot) || null;
|
|
48
|
-
}, errorHandler);
|
|
49
|
-
} else {
|
|
50
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
51
|
-
data.value = snapshot.docs.map(getData).filter(shared.isDef);
|
|
52
|
-
}, errorHandler);
|
|
53
|
-
}
|
|
54
|
-
}, { immediate: true });
|
|
55
|
-
if (autoDispose === true) {
|
|
56
|
-
shared.tryOnScopeDispose(() => {
|
|
57
|
-
close();
|
|
58
|
-
});
|
|
59
|
-
} else if (typeof autoDispose === "number") {
|
|
60
|
-
shared.tryOnScopeDispose(() => {
|
|
61
|
-
shared.useTimeoutFn(() => {
|
|
62
|
-
close();
|
|
63
|
-
}, autoDispose);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return data;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function useRTDB(docRef, options = {}) {
|
|
70
|
-
const {
|
|
71
|
-
errorHandler = (err) => console.error(err),
|
|
72
|
-
autoDispose = true
|
|
73
|
-
} = options;
|
|
74
|
-
const data = vue.ref(void 0);
|
|
75
|
-
function update(snapshot) {
|
|
76
|
-
data.value = snapshot.val();
|
|
77
|
-
}
|
|
78
|
-
const off = database.onValue(docRef, update, errorHandler);
|
|
79
|
-
if (autoDispose)
|
|
80
|
-
shared.tryOnScopeDispose(() => off());
|
|
81
|
-
return data;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports.useAuth = useAuth;
|
|
85
|
-
exports.useFirestore = useFirestore;
|
|
86
|
-
exports.useRTDB = useRTDB;
|
package/index.d.cts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
-
import { User, Auth } from 'firebase/auth';
|
|
3
|
-
import { ComputedRef, Ref, MaybeRef } from 'vue';
|
|
4
|
-
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
5
|
-
import { DatabaseReference } from 'firebase/database';
|
|
6
|
-
|
|
7
|
-
interface UseFirebaseAuthOptions {
|
|
8
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
9
|
-
user: Ref<User | null>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Reactive Firebase Auth binding
|
|
13
|
-
*
|
|
14
|
-
* @see https://vueuse.org/useAuth
|
|
15
|
-
*/
|
|
16
|
-
declare function useAuth(auth: Auth): {
|
|
17
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
18
|
-
user: Ref<{
|
|
19
|
-
readonly emailVerified: boolean;
|
|
20
|
-
readonly isAnonymous: boolean;
|
|
21
|
-
readonly metadata: {
|
|
22
|
-
readonly creationTime?: string | undefined;
|
|
23
|
-
readonly lastSignInTime?: string | undefined;
|
|
24
|
-
};
|
|
25
|
-
readonly providerData: {
|
|
26
|
-
readonly displayName: string | null;
|
|
27
|
-
readonly email: string | null;
|
|
28
|
-
readonly phoneNumber: string | null;
|
|
29
|
-
readonly photoURL: string | null;
|
|
30
|
-
readonly providerId: string;
|
|
31
|
-
readonly uid: string;
|
|
32
|
-
}[];
|
|
33
|
-
readonly refreshToken: string;
|
|
34
|
-
readonly tenantId: string | null;
|
|
35
|
-
delete: () => Promise<void>;
|
|
36
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
37
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
38
|
-
reload: () => Promise<void>;
|
|
39
|
-
toJSON: () => object;
|
|
40
|
-
readonly displayName: string | null;
|
|
41
|
-
readonly email: string | null;
|
|
42
|
-
readonly phoneNumber: string | null;
|
|
43
|
-
readonly photoURL: string | null;
|
|
44
|
-
readonly providerId: string;
|
|
45
|
-
readonly uid: string;
|
|
46
|
-
} | null, User | {
|
|
47
|
-
readonly emailVerified: boolean;
|
|
48
|
-
readonly isAnonymous: boolean;
|
|
49
|
-
readonly metadata: {
|
|
50
|
-
readonly creationTime?: string | undefined;
|
|
51
|
-
readonly lastSignInTime?: string | undefined;
|
|
52
|
-
};
|
|
53
|
-
readonly providerData: {
|
|
54
|
-
readonly displayName: string | null;
|
|
55
|
-
readonly email: string | null;
|
|
56
|
-
readonly phoneNumber: string | null;
|
|
57
|
-
readonly photoURL: string | null;
|
|
58
|
-
readonly providerId: string;
|
|
59
|
-
readonly uid: string;
|
|
60
|
-
}[];
|
|
61
|
-
readonly refreshToken: string;
|
|
62
|
-
readonly tenantId: string | null;
|
|
63
|
-
delete: () => Promise<void>;
|
|
64
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
65
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
66
|
-
reload: () => Promise<void>;
|
|
67
|
-
toJSON: () => object;
|
|
68
|
-
readonly displayName: string | null;
|
|
69
|
-
readonly email: string | null;
|
|
70
|
-
readonly phoneNumber: string | null;
|
|
71
|
-
readonly photoURL: string | null;
|
|
72
|
-
readonly providerId: string;
|
|
73
|
-
readonly uid: string;
|
|
74
|
-
} | null>;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
interface UseFirestoreOptions {
|
|
78
|
-
errorHandler?: (err: Error) => void;
|
|
79
|
-
autoDispose?: boolean | number;
|
|
80
|
-
}
|
|
81
|
-
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
82
|
-
type Falsy = false | 0 | '' | null | undefined;
|
|
83
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
84
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
85
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
86
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
87
|
-
|
|
88
|
-
interface UseRTDBOptions {
|
|
89
|
-
errorHandler?: (err: Error) => void;
|
|
90
|
-
autoDispose?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Reactive Firebase Realtime Database binding.
|
|
94
|
-
*
|
|
95
|
-
* @see https://vueuse.org/useRTDB
|
|
96
|
-
*/
|
|
97
|
-
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined, T | undefined>;
|
|
98
|
-
|
|
99
|
-
export { type FirebaseDocRef, type UseFirebaseAuthOptions, type UseFirestoreOptions, type UseRTDBOptions, useAuth, useFirestore, useRTDB };
|
package/index.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
-
import { User, Auth } from 'firebase/auth';
|
|
3
|
-
import { ComputedRef, Ref, MaybeRef } from 'vue';
|
|
4
|
-
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
5
|
-
import { DatabaseReference } from 'firebase/database';
|
|
6
|
-
|
|
7
|
-
interface UseFirebaseAuthOptions {
|
|
8
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
9
|
-
user: Ref<User | null>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Reactive Firebase Auth binding
|
|
13
|
-
*
|
|
14
|
-
* @see https://vueuse.org/useAuth
|
|
15
|
-
*/
|
|
16
|
-
declare function useAuth(auth: Auth): {
|
|
17
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
18
|
-
user: Ref<{
|
|
19
|
-
readonly emailVerified: boolean;
|
|
20
|
-
readonly isAnonymous: boolean;
|
|
21
|
-
readonly metadata: {
|
|
22
|
-
readonly creationTime?: string | undefined;
|
|
23
|
-
readonly lastSignInTime?: string | undefined;
|
|
24
|
-
};
|
|
25
|
-
readonly providerData: {
|
|
26
|
-
readonly displayName: string | null;
|
|
27
|
-
readonly email: string | null;
|
|
28
|
-
readonly phoneNumber: string | null;
|
|
29
|
-
readonly photoURL: string | null;
|
|
30
|
-
readonly providerId: string;
|
|
31
|
-
readonly uid: string;
|
|
32
|
-
}[];
|
|
33
|
-
readonly refreshToken: string;
|
|
34
|
-
readonly tenantId: string | null;
|
|
35
|
-
delete: () => Promise<void>;
|
|
36
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
37
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
38
|
-
reload: () => Promise<void>;
|
|
39
|
-
toJSON: () => object;
|
|
40
|
-
readonly displayName: string | null;
|
|
41
|
-
readonly email: string | null;
|
|
42
|
-
readonly phoneNumber: string | null;
|
|
43
|
-
readonly photoURL: string | null;
|
|
44
|
-
readonly providerId: string;
|
|
45
|
-
readonly uid: string;
|
|
46
|
-
} | null, User | {
|
|
47
|
-
readonly emailVerified: boolean;
|
|
48
|
-
readonly isAnonymous: boolean;
|
|
49
|
-
readonly metadata: {
|
|
50
|
-
readonly creationTime?: string | undefined;
|
|
51
|
-
readonly lastSignInTime?: string | undefined;
|
|
52
|
-
};
|
|
53
|
-
readonly providerData: {
|
|
54
|
-
readonly displayName: string | null;
|
|
55
|
-
readonly email: string | null;
|
|
56
|
-
readonly phoneNumber: string | null;
|
|
57
|
-
readonly photoURL: string | null;
|
|
58
|
-
readonly providerId: string;
|
|
59
|
-
readonly uid: string;
|
|
60
|
-
}[];
|
|
61
|
-
readonly refreshToken: string;
|
|
62
|
-
readonly tenantId: string | null;
|
|
63
|
-
delete: () => Promise<void>;
|
|
64
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
65
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
66
|
-
reload: () => Promise<void>;
|
|
67
|
-
toJSON: () => object;
|
|
68
|
-
readonly displayName: string | null;
|
|
69
|
-
readonly email: string | null;
|
|
70
|
-
readonly phoneNumber: string | null;
|
|
71
|
-
readonly photoURL: string | null;
|
|
72
|
-
readonly providerId: string;
|
|
73
|
-
readonly uid: string;
|
|
74
|
-
} | null>;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
interface UseFirestoreOptions {
|
|
78
|
-
errorHandler?: (err: Error) => void;
|
|
79
|
-
autoDispose?: boolean | number;
|
|
80
|
-
}
|
|
81
|
-
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
82
|
-
type Falsy = false | 0 | '' | null | undefined;
|
|
83
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
84
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
85
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
86
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
87
|
-
|
|
88
|
-
interface UseRTDBOptions {
|
|
89
|
-
errorHandler?: (err: Error) => void;
|
|
90
|
-
autoDispose?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Reactive Firebase Realtime Database binding.
|
|
94
|
-
*
|
|
95
|
-
* @see https://vueuse.org/useRTDB
|
|
96
|
-
*/
|
|
97
|
-
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined, T | undefined>;
|
|
98
|
-
|
|
99
|
-
export { type FirebaseDocRef, type UseFirebaseAuthOptions, type UseFirestoreOptions, type UseRTDBOptions, useAuth, useFirestore, useRTDB };
|
package/useAuth.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var vue = require('vue');
|
|
4
|
-
|
|
5
|
-
function useAuth(auth) {
|
|
6
|
-
const user = vue.ref(auth.currentUser);
|
|
7
|
-
const isAuthenticated = vue.computed(() => !!user.value);
|
|
8
|
-
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
9
|
-
return {
|
|
10
|
-
isAuthenticated,
|
|
11
|
-
user
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.useAuth = useAuth;
|
package/useAuth.d.cts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
-
import { User, Auth } from 'firebase/auth';
|
|
3
|
-
import { ComputedRef, Ref } from 'vue';
|
|
4
|
-
|
|
5
|
-
interface UseFirebaseAuthOptions {
|
|
6
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
7
|
-
user: Ref<User | null>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Reactive Firebase Auth binding
|
|
11
|
-
*
|
|
12
|
-
* @see https://vueuse.org/useAuth
|
|
13
|
-
*/
|
|
14
|
-
declare function useAuth(auth: Auth): {
|
|
15
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
16
|
-
user: Ref<{
|
|
17
|
-
readonly emailVerified: boolean;
|
|
18
|
-
readonly isAnonymous: boolean;
|
|
19
|
-
readonly metadata: {
|
|
20
|
-
readonly creationTime?: string | undefined;
|
|
21
|
-
readonly lastSignInTime?: string | undefined;
|
|
22
|
-
};
|
|
23
|
-
readonly providerData: {
|
|
24
|
-
readonly displayName: string | null;
|
|
25
|
-
readonly email: string | null;
|
|
26
|
-
readonly phoneNumber: string | null;
|
|
27
|
-
readonly photoURL: string | null;
|
|
28
|
-
readonly providerId: string;
|
|
29
|
-
readonly uid: string;
|
|
30
|
-
}[];
|
|
31
|
-
readonly refreshToken: string;
|
|
32
|
-
readonly tenantId: string | null;
|
|
33
|
-
delete: () => Promise<void>;
|
|
34
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
35
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
36
|
-
reload: () => Promise<void>;
|
|
37
|
-
toJSON: () => object;
|
|
38
|
-
readonly displayName: string | null;
|
|
39
|
-
readonly email: string | null;
|
|
40
|
-
readonly phoneNumber: string | null;
|
|
41
|
-
readonly photoURL: string | null;
|
|
42
|
-
readonly providerId: string;
|
|
43
|
-
readonly uid: string;
|
|
44
|
-
} | null, User | {
|
|
45
|
-
readonly emailVerified: boolean;
|
|
46
|
-
readonly isAnonymous: boolean;
|
|
47
|
-
readonly metadata: {
|
|
48
|
-
readonly creationTime?: string | undefined;
|
|
49
|
-
readonly lastSignInTime?: string | undefined;
|
|
50
|
-
};
|
|
51
|
-
readonly providerData: {
|
|
52
|
-
readonly displayName: string | null;
|
|
53
|
-
readonly email: string | null;
|
|
54
|
-
readonly phoneNumber: string | null;
|
|
55
|
-
readonly photoURL: string | null;
|
|
56
|
-
readonly providerId: string;
|
|
57
|
-
readonly uid: string;
|
|
58
|
-
}[];
|
|
59
|
-
readonly refreshToken: string;
|
|
60
|
-
readonly tenantId: string | null;
|
|
61
|
-
delete: () => Promise<void>;
|
|
62
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
63
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
64
|
-
reload: () => Promise<void>;
|
|
65
|
-
toJSON: () => object;
|
|
66
|
-
readonly displayName: string | null;
|
|
67
|
-
readonly email: string | null;
|
|
68
|
-
readonly phoneNumber: string | null;
|
|
69
|
-
readonly photoURL: string | null;
|
|
70
|
-
readonly providerId: string;
|
|
71
|
-
readonly uid: string;
|
|
72
|
-
} | null>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export { type UseFirebaseAuthOptions, useAuth };
|
package/useAuth.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
-
import { User, Auth } from 'firebase/auth';
|
|
3
|
-
import { ComputedRef, Ref } from 'vue';
|
|
4
|
-
|
|
5
|
-
interface UseFirebaseAuthOptions {
|
|
6
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
7
|
-
user: Ref<User | null>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Reactive Firebase Auth binding
|
|
11
|
-
*
|
|
12
|
-
* @see https://vueuse.org/useAuth
|
|
13
|
-
*/
|
|
14
|
-
declare function useAuth(auth: Auth): {
|
|
15
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
16
|
-
user: Ref<{
|
|
17
|
-
readonly emailVerified: boolean;
|
|
18
|
-
readonly isAnonymous: boolean;
|
|
19
|
-
readonly metadata: {
|
|
20
|
-
readonly creationTime?: string | undefined;
|
|
21
|
-
readonly lastSignInTime?: string | undefined;
|
|
22
|
-
};
|
|
23
|
-
readonly providerData: {
|
|
24
|
-
readonly displayName: string | null;
|
|
25
|
-
readonly email: string | null;
|
|
26
|
-
readonly phoneNumber: string | null;
|
|
27
|
-
readonly photoURL: string | null;
|
|
28
|
-
readonly providerId: string;
|
|
29
|
-
readonly uid: string;
|
|
30
|
-
}[];
|
|
31
|
-
readonly refreshToken: string;
|
|
32
|
-
readonly tenantId: string | null;
|
|
33
|
-
delete: () => Promise<void>;
|
|
34
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
35
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
36
|
-
reload: () => Promise<void>;
|
|
37
|
-
toJSON: () => object;
|
|
38
|
-
readonly displayName: string | null;
|
|
39
|
-
readonly email: string | null;
|
|
40
|
-
readonly phoneNumber: string | null;
|
|
41
|
-
readonly photoURL: string | null;
|
|
42
|
-
readonly providerId: string;
|
|
43
|
-
readonly uid: string;
|
|
44
|
-
} | null, User | {
|
|
45
|
-
readonly emailVerified: boolean;
|
|
46
|
-
readonly isAnonymous: boolean;
|
|
47
|
-
readonly metadata: {
|
|
48
|
-
readonly creationTime?: string | undefined;
|
|
49
|
-
readonly lastSignInTime?: string | undefined;
|
|
50
|
-
};
|
|
51
|
-
readonly providerData: {
|
|
52
|
-
readonly displayName: string | null;
|
|
53
|
-
readonly email: string | null;
|
|
54
|
-
readonly phoneNumber: string | null;
|
|
55
|
-
readonly photoURL: string | null;
|
|
56
|
-
readonly providerId: string;
|
|
57
|
-
readonly uid: string;
|
|
58
|
-
}[];
|
|
59
|
-
readonly refreshToken: string;
|
|
60
|
-
readonly tenantId: string | null;
|
|
61
|
-
delete: () => Promise<void>;
|
|
62
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
63
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
64
|
-
reload: () => Promise<void>;
|
|
65
|
-
toJSON: () => object;
|
|
66
|
-
readonly displayName: string | null;
|
|
67
|
-
readonly email: string | null;
|
|
68
|
-
readonly phoneNumber: string | null;
|
|
69
|
-
readonly photoURL: string | null;
|
|
70
|
-
readonly providerId: string;
|
|
71
|
-
readonly uid: string;
|
|
72
|
-
} | null>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export { type UseFirebaseAuthOptions, useAuth };
|
package/useFirestore.cjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var shared = require('@vueuse/shared');
|
|
4
|
-
var firestore = require('firebase/firestore');
|
|
5
|
-
var vue = require('vue');
|
|
6
|
-
|
|
7
|
-
function getData(docRef) {
|
|
8
|
-
const data = docRef.data();
|
|
9
|
-
if (data) {
|
|
10
|
-
Object.defineProperty(data, "id", {
|
|
11
|
-
value: docRef.id.toString(),
|
|
12
|
-
writable: false
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
function isDocumentReference(docRef) {
|
|
18
|
-
var _a;
|
|
19
|
-
return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
|
|
20
|
-
}
|
|
21
|
-
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
22
|
-
const {
|
|
23
|
-
errorHandler = (err) => console.error(err),
|
|
24
|
-
autoDispose = true
|
|
25
|
-
} = options;
|
|
26
|
-
const refOfDocRef = vue.isRef(maybeDocRef) ? maybeDocRef : vue.computed(() => maybeDocRef);
|
|
27
|
-
let close = () => {
|
|
28
|
-
};
|
|
29
|
-
const data = vue.ref(initialValue);
|
|
30
|
-
vue.watch(refOfDocRef, (docRef) => {
|
|
31
|
-
close();
|
|
32
|
-
if (!refOfDocRef.value) {
|
|
33
|
-
data.value = initialValue;
|
|
34
|
-
} else if (isDocumentReference(refOfDocRef.value)) {
|
|
35
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
36
|
-
data.value = getData(snapshot) || null;
|
|
37
|
-
}, errorHandler);
|
|
38
|
-
} else {
|
|
39
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
40
|
-
data.value = snapshot.docs.map(getData).filter(shared.isDef);
|
|
41
|
-
}, errorHandler);
|
|
42
|
-
}
|
|
43
|
-
}, { immediate: true });
|
|
44
|
-
if (autoDispose === true) {
|
|
45
|
-
shared.tryOnScopeDispose(() => {
|
|
46
|
-
close();
|
|
47
|
-
});
|
|
48
|
-
} else if (typeof autoDispose === "number") {
|
|
49
|
-
shared.tryOnScopeDispose(() => {
|
|
50
|
-
shared.useTimeoutFn(() => {
|
|
51
|
-
close();
|
|
52
|
-
}, autoDispose);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exports.useFirestore = useFirestore;
|
package/useFirestore.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
2
|
-
import { MaybeRef, Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseFirestoreOptions {
|
|
5
|
-
errorHandler?: (err: Error) => void;
|
|
6
|
-
autoDispose?: boolean | number;
|
|
7
|
-
}
|
|
8
|
-
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
9
|
-
type Falsy = false | 0 | '' | null | undefined;
|
|
10
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
11
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
12
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
13
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
14
|
-
|
|
15
|
-
export { type FirebaseDocRef, type UseFirestoreOptions, useFirestore };
|
package/useFirestore.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
2
|
-
import { MaybeRef, Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseFirestoreOptions {
|
|
5
|
-
errorHandler?: (err: Error) => void;
|
|
6
|
-
autoDispose?: boolean | number;
|
|
7
|
-
}
|
|
8
|
-
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
9
|
-
type Falsy = false | 0 | '' | null | undefined;
|
|
10
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
11
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
12
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
13
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
14
|
-
|
|
15
|
-
export { type FirebaseDocRef, type UseFirestoreOptions, useFirestore };
|
package/useRTDB.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var shared = require('@vueuse/shared');
|
|
4
|
-
var database = require('firebase/database');
|
|
5
|
-
var vue = require('vue');
|
|
6
|
-
|
|
7
|
-
function useRTDB(docRef, options = {}) {
|
|
8
|
-
const {
|
|
9
|
-
errorHandler = (err) => console.error(err),
|
|
10
|
-
autoDispose = true
|
|
11
|
-
} = options;
|
|
12
|
-
const data = vue.ref(void 0);
|
|
13
|
-
function update(snapshot) {
|
|
14
|
-
data.value = snapshot.val();
|
|
15
|
-
}
|
|
16
|
-
const off = database.onValue(docRef, update, errorHandler);
|
|
17
|
-
if (autoDispose)
|
|
18
|
-
shared.tryOnScopeDispose(() => off());
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.useRTDB = useRTDB;
|
package/useRTDB.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DatabaseReference } from 'firebase/database';
|
|
2
|
-
import { Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseRTDBOptions {
|
|
5
|
-
errorHandler?: (err: Error) => void;
|
|
6
|
-
autoDispose?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Reactive Firebase Realtime Database binding.
|
|
10
|
-
*
|
|
11
|
-
* @see https://vueuse.org/useRTDB
|
|
12
|
-
*/
|
|
13
|
-
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined, T | undefined>;
|
|
14
|
-
|
|
15
|
-
export { type UseRTDBOptions, useRTDB };
|
package/useRTDB.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DatabaseReference } from 'firebase/database';
|
|
2
|
-
import { Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseRTDBOptions {
|
|
5
|
-
errorHandler?: (err: Error) => void;
|
|
6
|
-
autoDispose?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Reactive Firebase Realtime Database binding.
|
|
10
|
-
*
|
|
11
|
-
* @see https://vueuse.org/useRTDB
|
|
12
|
-
*/
|
|
13
|
-
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined, T | undefined>;
|
|
14
|
-
|
|
15
|
-
export { type UseRTDBOptions, useRTDB };
|