@vueuse/firebase 14.0.0-alpha.0 → 14.0.0-alpha.2
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/{useRTDB.d.mts → dist/index-CKgxjVly.d.ts} +7 -7
- package/{useFirestore.d.mts → dist/index-CpsujYtM.d.ts} +7 -7
- package/dist/index-b8UVCofo.d.ts +78 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.iife.js +117 -0
- package/dist/index.iife.min.js +1 -0
- package/dist/index.js +5 -0
- package/dist/useAuth-Drx9pmk6.js +22 -0
- package/dist/useAuth.d.ts +2 -0
- package/dist/useAuth.iife.js +48 -0
- package/dist/useAuth.iife.min.js +1 -0
- package/dist/useAuth.js +3 -0
- package/dist/useFirestore-DlUzLR_t.js +51 -0
- package/dist/useFirestore.d.ts +2 -0
- package/dist/useFirestore.iife.js +77 -0
- package/dist/useFirestore.iife.min.js +1 -0
- package/dist/useFirestore.js +3 -0
- package/dist/useRTDB-BGccE9Ip.js +23 -0
- package/dist/useRTDB.d.ts +2 -0
- package/dist/useRTDB.iife.js +49 -0
- package/dist/useRTDB.iife.min.js +1 -0
- package/dist/useRTDB.js +3 -0
- package/package.json +14 -16
- package/index.d.mts +0 -102
- package/index.iife.js +0 -85
- package/index.iife.min.js +0 -1
- package/index.mjs +0 -83
- package/useAuth.d.mts +0 -78
- package/useAuth.iife.js +0 -17
- package/useAuth.iife.min.js +0 -1
- package/useAuth.mjs +0 -14
- package/useFirestore.iife.js +0 -57
- package/useFirestore.iife.min.js +0 -1
- package/useFirestore.mjs +0 -56
- package/useRTDB.iife.js +0 -21
- package/useRTDB.iife.min.js +0 -1
- package/useRTDB.mjs +0 -20
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
import { DatabaseReference } from "firebase/database";
|
|
3
3
|
|
|
4
|
+
//#region useRTDB/index.d.ts
|
|
4
5
|
interface UseRTDBOptions {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
errorHandler?: (err: Error) => void;
|
|
7
|
+
autoDispose?: boolean;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Reactive Firebase Realtime Database binding.
|
|
@@ -11,6 +12,5 @@ interface UseRTDBOptions {
|
|
|
11
12
|
* @see https://vueuse.org/useRTDB
|
|
12
13
|
*/
|
|
13
14
|
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined, T | undefined>;
|
|
14
|
-
|
|
15
|
-
export { useRTDB };
|
|
16
|
-
export type { UseRTDBOptions };
|
|
15
|
+
//#endregion
|
|
16
|
+
export { UseRTDBOptions, useRTDB };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { MaybeRef, Ref } from "vue";
|
|
2
|
+
import { DocumentData, DocumentReference, Query } from "firebase/firestore";
|
|
3
3
|
|
|
4
|
+
//#region useFirestore/index.d.ts
|
|
4
5
|
interface UseFirestoreOptions {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
errorHandler?: (err: Error) => void;
|
|
7
|
+
autoDispose?: boolean | number;
|
|
7
8
|
}
|
|
8
9
|
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
9
10
|
type Falsy = false | 0 | '' | null | undefined;
|
|
@@ -11,6 +12,5 @@ declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Docu
|
|
|
11
12
|
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
12
13
|
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
13
14
|
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
14
|
-
|
|
15
|
-
export { useFirestore };
|
|
16
|
-
export type { FirebaseDocRef, UseFirestoreOptions };
|
|
15
|
+
//#endregion
|
|
16
|
+
export { FirebaseDocRef, UseFirestoreOptions, useFirestore };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from "vue";
|
|
2
|
+
import * as firebase_auth0 from "firebase/auth";
|
|
3
|
+
import { Auth, User } from "firebase/auth";
|
|
4
|
+
|
|
5
|
+
//#region useAuth/index.d.ts
|
|
6
|
+
interface UseFirebaseAuthOptions {
|
|
7
|
+
isAuthenticated: ComputedRef<boolean>;
|
|
8
|
+
user: Ref<User | null>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Reactive Firebase Auth binding
|
|
12
|
+
*
|
|
13
|
+
* @see https://vueuse.org/useAuth
|
|
14
|
+
*
|
|
15
|
+
* @__NO_SIDE_EFFECTS__
|
|
16
|
+
*/
|
|
17
|
+
declare function useAuth(auth: Auth): {
|
|
18
|
+
isAuthenticated: ComputedRef<boolean>;
|
|
19
|
+
user: Ref<{
|
|
20
|
+
readonly emailVerified: boolean;
|
|
21
|
+
readonly isAnonymous: boolean;
|
|
22
|
+
readonly metadata: {
|
|
23
|
+
readonly creationTime?: string | undefined;
|
|
24
|
+
readonly lastSignInTime?: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
readonly providerData: {
|
|
27
|
+
readonly displayName: string | null;
|
|
28
|
+
readonly email: string | null;
|
|
29
|
+
readonly phoneNumber: string | null;
|
|
30
|
+
readonly photoURL: string | null;
|
|
31
|
+
readonly providerId: string;
|
|
32
|
+
readonly uid: string;
|
|
33
|
+
}[];
|
|
34
|
+
readonly refreshToken: string;
|
|
35
|
+
readonly tenantId: string | null;
|
|
36
|
+
delete: () => Promise<void>;
|
|
37
|
+
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
38
|
+
getIdTokenResult: (forceRefresh?: boolean) => Promise<firebase_auth0.IdTokenResult>;
|
|
39
|
+
reload: () => Promise<void>;
|
|
40
|
+
toJSON: () => object;
|
|
41
|
+
readonly displayName: string | null;
|
|
42
|
+
readonly email: string | null;
|
|
43
|
+
readonly phoneNumber: string | null;
|
|
44
|
+
readonly photoURL: string | null;
|
|
45
|
+
readonly providerId: string;
|
|
46
|
+
readonly uid: string;
|
|
47
|
+
} | null, User | {
|
|
48
|
+
readonly emailVerified: boolean;
|
|
49
|
+
readonly isAnonymous: boolean;
|
|
50
|
+
readonly metadata: {
|
|
51
|
+
readonly creationTime?: string | undefined;
|
|
52
|
+
readonly lastSignInTime?: string | undefined;
|
|
53
|
+
};
|
|
54
|
+
readonly providerData: {
|
|
55
|
+
readonly displayName: string | null;
|
|
56
|
+
readonly email: string | null;
|
|
57
|
+
readonly phoneNumber: string | null;
|
|
58
|
+
readonly photoURL: string | null;
|
|
59
|
+
readonly providerId: string;
|
|
60
|
+
readonly uid: string;
|
|
61
|
+
}[];
|
|
62
|
+
readonly refreshToken: string;
|
|
63
|
+
readonly tenantId: string | null;
|
|
64
|
+
delete: () => Promise<void>;
|
|
65
|
+
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
66
|
+
getIdTokenResult: (forceRefresh?: boolean) => Promise<firebase_auth0.IdTokenResult>;
|
|
67
|
+
reload: () => Promise<void>;
|
|
68
|
+
toJSON: () => object;
|
|
69
|
+
readonly displayName: string | null;
|
|
70
|
+
readonly email: string | null;
|
|
71
|
+
readonly phoneNumber: string | null;
|
|
72
|
+
readonly photoURL: string | null;
|
|
73
|
+
readonly providerId: string;
|
|
74
|
+
readonly uid: string;
|
|
75
|
+
} | null>;
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { UseFirebaseAuthOptions, useAuth };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UseFirebaseAuthOptions, useAuth } from "./index-b8UVCofo.js";
|
|
2
|
+
import { FirebaseDocRef, UseFirestoreOptions, useFirestore } from "./index-CpsujYtM.js";
|
|
3
|
+
import { UseRTDBOptions, useRTDB } from "./index-CKgxjVly.js";
|
|
4
|
+
export { FirebaseDocRef, UseFirebaseAuthOptions, UseFirestoreOptions, UseRTDBOptions, useAuth, useFirestore, useRTDB };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
(function(exports, vue, __vueuse_shared, firebase_firestore, firebase_database) {
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
vue = __toESM(vue);
|
|
27
|
+
__vueuse_shared = __toESM(__vueuse_shared);
|
|
28
|
+
firebase_firestore = __toESM(firebase_firestore);
|
|
29
|
+
firebase_database = __toESM(firebase_database);
|
|
30
|
+
|
|
31
|
+
//#region useAuth/index.ts
|
|
32
|
+
/**
|
|
33
|
+
* Reactive Firebase Auth binding
|
|
34
|
+
*
|
|
35
|
+
* @see https://vueuse.org/useAuth
|
|
36
|
+
*
|
|
37
|
+
* @__NO_SIDE_EFFECTS__
|
|
38
|
+
*/
|
|
39
|
+
function useAuth(auth) {
|
|
40
|
+
const user = (0, vue.ref)(auth.currentUser);
|
|
41
|
+
const isAuthenticated = (0, vue.computed)(() => !!user.value);
|
|
42
|
+
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
43
|
+
return {
|
|
44
|
+
isAuthenticated,
|
|
45
|
+
user
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region useFirestore/index.ts
|
|
51
|
+
function getData(docRef) {
|
|
52
|
+
const data = docRef.data();
|
|
53
|
+
if (data) Object.defineProperty(data, "id", {
|
|
54
|
+
value: docRef.id.toString(),
|
|
55
|
+
writable: false
|
|
56
|
+
});
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
function isDocumentReference(docRef) {
|
|
60
|
+
var _docRef$path;
|
|
61
|
+
return (((_docRef$path = docRef.path) === null || _docRef$path === void 0 ? void 0 : _docRef$path.match(/\//g)) || []).length % 2 !== 0;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reactive Firestore binding. Making it straightforward to always keep your
|
|
65
|
+
* local data in sync with remotes databases.
|
|
66
|
+
*
|
|
67
|
+
* @see https://vueuse.org/useFirestore
|
|
68
|
+
*/
|
|
69
|
+
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
70
|
+
const { errorHandler = (err) => console.error(err), autoDispose = true } = options;
|
|
71
|
+
const refOfDocRef = (0, vue.isRef)(maybeDocRef) ? maybeDocRef : (0, vue.computed)(() => maybeDocRef);
|
|
72
|
+
let close = () => {};
|
|
73
|
+
const data = (0, vue.ref)(initialValue);
|
|
74
|
+
(0, vue.watch)(refOfDocRef, (docRef) => {
|
|
75
|
+
close();
|
|
76
|
+
if (!refOfDocRef.value) data.value = initialValue;
|
|
77
|
+
else if (isDocumentReference(refOfDocRef.value)) close = (0, firebase_firestore.onSnapshot)(docRef, (snapshot) => {
|
|
78
|
+
data.value = getData(snapshot) || null;
|
|
79
|
+
}, errorHandler);
|
|
80
|
+
else close = (0, firebase_firestore.onSnapshot)(docRef, (snapshot) => {
|
|
81
|
+
data.value = snapshot.docs.map(getData).filter(__vueuse_shared.isDef);
|
|
82
|
+
}, errorHandler);
|
|
83
|
+
}, { immediate: true });
|
|
84
|
+
if (autoDispose === true) (0, __vueuse_shared.tryOnScopeDispose)(() => {
|
|
85
|
+
close();
|
|
86
|
+
});
|
|
87
|
+
else if (typeof autoDispose === "number") (0, __vueuse_shared.tryOnScopeDispose)(() => {
|
|
88
|
+
(0, __vueuse_shared.useTimeoutFn)(() => {
|
|
89
|
+
close();
|
|
90
|
+
}, autoDispose);
|
|
91
|
+
});
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region useRTDB/index.ts
|
|
97
|
+
/**
|
|
98
|
+
* Reactive Firebase Realtime Database binding.
|
|
99
|
+
*
|
|
100
|
+
* @see https://vueuse.org/useRTDB
|
|
101
|
+
*/
|
|
102
|
+
function useRTDB(docRef, options = {}) {
|
|
103
|
+
const { errorHandler = (err) => console.error(err), autoDispose = true } = options;
|
|
104
|
+
const data = (0, vue.ref)(void 0);
|
|
105
|
+
function update(snapshot) {
|
|
106
|
+
data.value = snapshot.val();
|
|
107
|
+
}
|
|
108
|
+
const off = (0, firebase_database.onValue)(docRef, update, errorHandler);
|
|
109
|
+
if (autoDispose) (0, __vueuse_shared.tryOnScopeDispose)(() => off());
|
|
110
|
+
return data;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.useAuth = useAuth;
|
|
115
|
+
exports.useFirestore = useFirestore;
|
|
116
|
+
exports.useRTDB = useRTDB;
|
|
117
|
+
})(this.VueUse = this.VueUse || {}, Vue, VueUse, firebase, firebase);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(exports,t,n,r,i){var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e));t=f(t),n=f(n),r=f(r),i=f(i);function p(e){let n=(0,t.ref)(e.currentUser),r=(0,t.computed)(()=>!!n.value);return e.onIdTokenChanged(e=>n.value=e),{isAuthenticated:r,user:n}}function m(e){let t=e.data();return t&&Object.defineProperty(t,`id`,{value:e.id.toString(),writable:!1}),t}function h(e){var t;return(((t=e.path)==null?void 0:t.match(/\//g))||[]).length%2!=0}function g(e,i=void 0,a={}){let{errorHandler:o=e=>console.error(e),autoDispose:s=!0}=a,c=(0,t.isRef)(e)?e:(0,t.computed)(()=>e),l=()=>{},u=(0,t.ref)(i);return(0,t.watch)(c,e=>{l(),c.value?l=h(c.value)?(0,r.onSnapshot)(e,e=>{u.value=m(e)||null},o):(0,r.onSnapshot)(e,e=>{u.value=e.docs.map(m).filter(n.isDef)},o):u.value=i},{immediate:!0}),s===!0?(0,n.tryOnScopeDispose)(()=>{l()}):typeof s==`number`&&(0,n.tryOnScopeDispose)(()=>{(0,n.useTimeoutFn)(()=>{l()},s)}),u}function _(e,r={}){let{errorHandler:a=e=>console.error(e),autoDispose:o=!0}=r,s=(0,t.ref)(void 0);function c(e){s.value=e.val()}let l=(0,i.onValue)(e,c,a);return o&&(0,n.tryOnScopeDispose)(()=>l()),s}exports.useAuth=p,exports.useFirestore=g,exports.useRTDB=_})(this.VueUse=this.VueUse||{},Vue,VueUse,firebase,firebase);
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region useAuth/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reactive Firebase Auth binding
|
|
6
|
+
*
|
|
7
|
+
* @see https://vueuse.org/useAuth
|
|
8
|
+
*
|
|
9
|
+
* @__NO_SIDE_EFFECTS__
|
|
10
|
+
*/
|
|
11
|
+
function useAuth(auth) {
|
|
12
|
+
const user = ref(auth.currentUser);
|
|
13
|
+
const isAuthenticated = computed(() => !!user.value);
|
|
14
|
+
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
15
|
+
return {
|
|
16
|
+
isAuthenticated,
|
|
17
|
+
user
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useAuth };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(function(exports, vue) {
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
vue = __toESM(vue);
|
|
27
|
+
|
|
28
|
+
//#region useAuth/index.ts
|
|
29
|
+
/**
|
|
30
|
+
* Reactive Firebase Auth binding
|
|
31
|
+
*
|
|
32
|
+
* @see https://vueuse.org/useAuth
|
|
33
|
+
*
|
|
34
|
+
* @__NO_SIDE_EFFECTS__
|
|
35
|
+
*/
|
|
36
|
+
function useAuth(auth) {
|
|
37
|
+
const user = (0, vue.ref)(auth.currentUser);
|
|
38
|
+
const isAuthenticated = (0, vue.computed)(() => !!user.value);
|
|
39
|
+
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
40
|
+
return {
|
|
41
|
+
isAuthenticated,
|
|
42
|
+
user
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.useAuth = useAuth;
|
|
48
|
+
})(this.VueUse = this.VueUse || {}, Vue);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(exports,t){var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t);function l(e){let n=(0,t.ref)(e.currentUser),r=(0,t.computed)(()=>!!n.value);return e.onIdTokenChanged(e=>n.value=e),{isAuthenticated:r,user:n}}exports.useAuth=l})(this.VueUse=this.VueUse||{},Vue);
|
package/dist/useAuth.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computed, isRef, ref, watch } from "vue";
|
|
2
|
+
import { isDef, tryOnScopeDispose, useTimeoutFn } from "@vueuse/shared";
|
|
3
|
+
import { onSnapshot } from "firebase/firestore";
|
|
4
|
+
|
|
5
|
+
//#region useFirestore/index.ts
|
|
6
|
+
function getData(docRef) {
|
|
7
|
+
const data = docRef.data();
|
|
8
|
+
if (data) Object.defineProperty(data, "id", {
|
|
9
|
+
value: docRef.id.toString(),
|
|
10
|
+
writable: false
|
|
11
|
+
});
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function isDocumentReference(docRef) {
|
|
15
|
+
var _docRef$path;
|
|
16
|
+
return (((_docRef$path = docRef.path) === null || _docRef$path === void 0 ? void 0 : _docRef$path.match(/\//g)) || []).length % 2 !== 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reactive Firestore binding. Making it straightforward to always keep your
|
|
20
|
+
* local data in sync with remotes databases.
|
|
21
|
+
*
|
|
22
|
+
* @see https://vueuse.org/useFirestore
|
|
23
|
+
*/
|
|
24
|
+
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
25
|
+
const { errorHandler = (err) => console.error(err), autoDispose = true } = options;
|
|
26
|
+
const refOfDocRef = isRef(maybeDocRef) ? maybeDocRef : computed(() => maybeDocRef);
|
|
27
|
+
let close = () => {};
|
|
28
|
+
const data = ref(initialValue);
|
|
29
|
+
watch(refOfDocRef, (docRef) => {
|
|
30
|
+
close();
|
|
31
|
+
if (!refOfDocRef.value) data.value = initialValue;
|
|
32
|
+
else if (isDocumentReference(refOfDocRef.value)) close = onSnapshot(docRef, (snapshot) => {
|
|
33
|
+
data.value = getData(snapshot) || null;
|
|
34
|
+
}, errorHandler);
|
|
35
|
+
else close = onSnapshot(docRef, (snapshot) => {
|
|
36
|
+
data.value = snapshot.docs.map(getData).filter(isDef);
|
|
37
|
+
}, errorHandler);
|
|
38
|
+
}, { immediate: true });
|
|
39
|
+
if (autoDispose === true) tryOnScopeDispose(() => {
|
|
40
|
+
close();
|
|
41
|
+
});
|
|
42
|
+
else if (typeof autoDispose === "number") tryOnScopeDispose(() => {
|
|
43
|
+
useTimeoutFn(() => {
|
|
44
|
+
close();
|
|
45
|
+
}, autoDispose);
|
|
46
|
+
});
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { useFirestore };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
(function(exports, __vueuse_shared, firebase_firestore, vue) {
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
__vueuse_shared = __toESM(__vueuse_shared);
|
|
27
|
+
firebase_firestore = __toESM(firebase_firestore);
|
|
28
|
+
vue = __toESM(vue);
|
|
29
|
+
|
|
30
|
+
//#region useFirestore/index.ts
|
|
31
|
+
function getData(docRef) {
|
|
32
|
+
const data = docRef.data();
|
|
33
|
+
if (data) Object.defineProperty(data, "id", {
|
|
34
|
+
value: docRef.id.toString(),
|
|
35
|
+
writable: false
|
|
36
|
+
});
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
function isDocumentReference(docRef) {
|
|
40
|
+
var _docRef$path;
|
|
41
|
+
return (((_docRef$path = docRef.path) === null || _docRef$path === void 0 ? void 0 : _docRef$path.match(/\//g)) || []).length % 2 !== 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reactive Firestore binding. Making it straightforward to always keep your
|
|
45
|
+
* local data in sync with remotes databases.
|
|
46
|
+
*
|
|
47
|
+
* @see https://vueuse.org/useFirestore
|
|
48
|
+
*/
|
|
49
|
+
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
50
|
+
const { errorHandler = (err) => console.error(err), autoDispose = true } = options;
|
|
51
|
+
const refOfDocRef = (0, vue.isRef)(maybeDocRef) ? maybeDocRef : (0, vue.computed)(() => maybeDocRef);
|
|
52
|
+
let close = () => {};
|
|
53
|
+
const data = (0, vue.ref)(initialValue);
|
|
54
|
+
(0, vue.watch)(refOfDocRef, (docRef) => {
|
|
55
|
+
close();
|
|
56
|
+
if (!refOfDocRef.value) data.value = initialValue;
|
|
57
|
+
else if (isDocumentReference(refOfDocRef.value)) close = (0, firebase_firestore.onSnapshot)(docRef, (snapshot) => {
|
|
58
|
+
data.value = getData(snapshot) || null;
|
|
59
|
+
}, errorHandler);
|
|
60
|
+
else close = (0, firebase_firestore.onSnapshot)(docRef, (snapshot) => {
|
|
61
|
+
data.value = snapshot.docs.map(getData).filter(__vueuse_shared.isDef);
|
|
62
|
+
}, errorHandler);
|
|
63
|
+
}, { immediate: true });
|
|
64
|
+
if (autoDispose === true) (0, __vueuse_shared.tryOnScopeDispose)(() => {
|
|
65
|
+
close();
|
|
66
|
+
});
|
|
67
|
+
else if (typeof autoDispose === "number") (0, __vueuse_shared.tryOnScopeDispose)(() => {
|
|
68
|
+
(0, __vueuse_shared.useTimeoutFn)(() => {
|
|
69
|
+
close();
|
|
70
|
+
}, autoDispose);
|
|
71
|
+
});
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
exports.useFirestore = useFirestore;
|
|
77
|
+
})(this.VueUse = this.VueUse || {}, VueUse, firebase, Vue);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(exports,t,n,r){var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:i(c(e)),u(t||!e||!e.__esModule?a(n,`default`,{value:e,enumerable:!0}):n,e));t=d(t),n=d(n),r=d(r);function f(e){let t=e.data();return t&&Object.defineProperty(t,`id`,{value:e.id.toString(),writable:!1}),t}function p(e){var t;return(((t=e.path)==null?void 0:t.match(/\//g))||[]).length%2!=0}function m(e,i=void 0,a={}){let{errorHandler:o=e=>console.error(e),autoDispose:s=!0}=a,c=(0,r.isRef)(e)?e:(0,r.computed)(()=>e),l=()=>{},u=(0,r.ref)(i);return(0,r.watch)(c,e=>{l(),c.value?l=p(c.value)?(0,n.onSnapshot)(e,e=>{u.value=f(e)||null},o):(0,n.onSnapshot)(e,e=>{u.value=e.docs.map(f).filter(t.isDef)},o):u.value=i},{immediate:!0}),s===!0?(0,t.tryOnScopeDispose)(()=>{l()}):typeof s==`number`&&(0,t.tryOnScopeDispose)(()=>{(0,t.useTimeoutFn)(()=>{l()},s)}),u}exports.useFirestore=m})(this.VueUse=this.VueUse||{},VueUse,firebase,Vue);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { tryOnScopeDispose } from "@vueuse/shared";
|
|
3
|
+
import { onValue } from "firebase/database";
|
|
4
|
+
|
|
5
|
+
//#region useRTDB/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Reactive Firebase Realtime Database binding.
|
|
8
|
+
*
|
|
9
|
+
* @see https://vueuse.org/useRTDB
|
|
10
|
+
*/
|
|
11
|
+
function useRTDB(docRef, options = {}) {
|
|
12
|
+
const { errorHandler = (err) => console.error(err), autoDispose = true } = options;
|
|
13
|
+
const data = ref(void 0);
|
|
14
|
+
function update(snapshot) {
|
|
15
|
+
data.value = snapshot.val();
|
|
16
|
+
}
|
|
17
|
+
const off = onValue(docRef, update, errorHandler);
|
|
18
|
+
if (autoDispose) tryOnScopeDispose(() => off());
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useRTDB };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
(function(exports, __vueuse_shared, firebase_database, vue) {
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
__vueuse_shared = __toESM(__vueuse_shared);
|
|
27
|
+
firebase_database = __toESM(firebase_database);
|
|
28
|
+
vue = __toESM(vue);
|
|
29
|
+
|
|
30
|
+
//#region useRTDB/index.ts
|
|
31
|
+
/**
|
|
32
|
+
* Reactive Firebase Realtime Database binding.
|
|
33
|
+
*
|
|
34
|
+
* @see https://vueuse.org/useRTDB
|
|
35
|
+
*/
|
|
36
|
+
function useRTDB(docRef, options = {}) {
|
|
37
|
+
const { errorHandler = (err) => console.error(err), autoDispose = true } = options;
|
|
38
|
+
const data = (0, vue.ref)(void 0);
|
|
39
|
+
function update(snapshot) {
|
|
40
|
+
data.value = snapshot.val();
|
|
41
|
+
}
|
|
42
|
+
const off = (0, firebase_database.onValue)(docRef, update, errorHandler);
|
|
43
|
+
if (autoDispose) (0, __vueuse_shared.tryOnScopeDispose)(() => off());
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.useRTDB = useRTDB;
|
|
49
|
+
})(this.VueUse = this.VueUse || {}, VueUse, firebase, Vue);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(exports,t,n,r){var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:i(c(e)),u(t||!e||!e.__esModule?a(n,`default`,{value:e,enumerable:!0}):n,e));t=d(t),n=d(n),r=d(r);function f(e,i={}){let{errorHandler:a=e=>console.error(e),autoDispose:o=!0}=i,s=(0,r.ref)(void 0);function c(e){s.value=e.val()}let l=(0,n.onValue)(e,c,a);return o&&(0,t.tryOnScopeDispose)(()=>l()),s}exports.useRTDB=f})(this.VueUse=this.VueUse||{},VueUse,firebase,Vue);
|
package/dist/useRTDB.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "14.0.0-alpha.
|
|
4
|
+
"version": "14.0.0-alpha.2",
|
|
5
5
|
"description": "Enables realtime bindings for Firebase",
|
|
6
6
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,31 +24,29 @@
|
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
27
|
-
".": "./index.
|
|
28
|
-
"./*": "
|
|
29
|
-
"./useAuth": "./useAuth.
|
|
30
|
-
"./useFirestore": "./useFirestore.
|
|
31
|
-
"./useRTDB": "./useRTDB.
|
|
27
|
+
".": "./dist/index.js",
|
|
28
|
+
"./*": "./dist/*",
|
|
29
|
+
"./useAuth": "./dist/useAuth.js",
|
|
30
|
+
"./useFirestore": "./dist/useFirestore.js",
|
|
31
|
+
"./useRTDB": "./dist/useRTDB.js"
|
|
32
32
|
},
|
|
33
|
-
"main": "./index.
|
|
34
|
-
"module": "./index.
|
|
35
|
-
"unpkg": "./index.iife.min.js",
|
|
36
|
-
"jsdelivr": "./index.iife.min.js",
|
|
37
|
-
"types": "./index.d.
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
|
+
"unpkg": "./dist/index.iife.min.js",
|
|
36
|
+
"jsdelivr": "./dist/index.iife.min.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
38
|
"files": [
|
|
39
|
-
"
|
|
40
|
-
"**/*.js",
|
|
41
|
-
"**/*.mjs"
|
|
39
|
+
"dist"
|
|
42
40
|
],
|
|
43
41
|
"peerDependencies": {
|
|
44
42
|
"firebase": ">=9.0.0",
|
|
45
43
|
"vue": "^3.5.0"
|
|
46
44
|
},
|
|
47
45
|
"dependencies": {
|
|
48
|
-
"@vueuse/shared": "14.0.0-alpha.
|
|
46
|
+
"@vueuse/shared": "14.0.0-alpha.2"
|
|
49
47
|
},
|
|
50
48
|
"scripts": {
|
|
51
|
-
"build": "
|
|
49
|
+
"build": "tsdown",
|
|
52
50
|
"test:attw": "attw --pack --config-path ../../.attw.json ."
|
|
53
51
|
}
|
|
54
52
|
}
|
package/index.d.mts
DELETED
|
@@ -1,102 +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
|
-
* @__NO_SIDE_EFFECTS__
|
|
17
|
-
*/
|
|
18
|
-
declare function useAuth(auth: Auth): {
|
|
19
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
20
|
-
user: Ref<{
|
|
21
|
-
readonly emailVerified: boolean;
|
|
22
|
-
readonly isAnonymous: boolean;
|
|
23
|
-
readonly metadata: {
|
|
24
|
-
readonly creationTime?: string | undefined;
|
|
25
|
-
readonly lastSignInTime?: string | undefined;
|
|
26
|
-
};
|
|
27
|
-
readonly providerData: {
|
|
28
|
-
readonly displayName: string | null;
|
|
29
|
-
readonly email: string | null;
|
|
30
|
-
readonly phoneNumber: string | null;
|
|
31
|
-
readonly photoURL: string | null;
|
|
32
|
-
readonly providerId: string;
|
|
33
|
-
readonly uid: string;
|
|
34
|
-
}[];
|
|
35
|
-
readonly refreshToken: string;
|
|
36
|
-
readonly tenantId: string | null;
|
|
37
|
-
delete: () => Promise<void>;
|
|
38
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
39
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
40
|
-
reload: () => Promise<void>;
|
|
41
|
-
toJSON: () => object;
|
|
42
|
-
readonly displayName: string | null;
|
|
43
|
-
readonly email: string | null;
|
|
44
|
-
readonly phoneNumber: string | null;
|
|
45
|
-
readonly photoURL: string | null;
|
|
46
|
-
readonly providerId: string;
|
|
47
|
-
readonly uid: string;
|
|
48
|
-
} | null, User | {
|
|
49
|
-
readonly emailVerified: boolean;
|
|
50
|
-
readonly isAnonymous: boolean;
|
|
51
|
-
readonly metadata: {
|
|
52
|
-
readonly creationTime?: string | undefined;
|
|
53
|
-
readonly lastSignInTime?: string | undefined;
|
|
54
|
-
};
|
|
55
|
-
readonly providerData: {
|
|
56
|
-
readonly displayName: string | null;
|
|
57
|
-
readonly email: string | null;
|
|
58
|
-
readonly phoneNumber: string | null;
|
|
59
|
-
readonly photoURL: string | null;
|
|
60
|
-
readonly providerId: string;
|
|
61
|
-
readonly uid: string;
|
|
62
|
-
}[];
|
|
63
|
-
readonly refreshToken: string;
|
|
64
|
-
readonly tenantId: string | null;
|
|
65
|
-
delete: () => Promise<void>;
|
|
66
|
-
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
67
|
-
getIdTokenResult: (forceRefresh?: boolean) => Promise<_firebase_auth.IdTokenResult>;
|
|
68
|
-
reload: () => Promise<void>;
|
|
69
|
-
toJSON: () => object;
|
|
70
|
-
readonly displayName: string | null;
|
|
71
|
-
readonly email: string | null;
|
|
72
|
-
readonly phoneNumber: string | null;
|
|
73
|
-
readonly photoURL: string | null;
|
|
74
|
-
readonly providerId: string;
|
|
75
|
-
readonly uid: string;
|
|
76
|
-
} | null>;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
interface UseFirestoreOptions {
|
|
80
|
-
errorHandler?: (err: Error) => void;
|
|
81
|
-
autoDispose?: boolean | number;
|
|
82
|
-
}
|
|
83
|
-
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
84
|
-
type Falsy = false | 0 | '' | null | undefined;
|
|
85
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
86
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
87
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
88
|
-
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
89
|
-
|
|
90
|
-
interface UseRTDBOptions {
|
|
91
|
-
errorHandler?: (err: Error) => void;
|
|
92
|
-
autoDispose?: boolean;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Reactive Firebase Realtime Database binding.
|
|
96
|
-
*
|
|
97
|
-
* @see https://vueuse.org/useRTDB
|
|
98
|
-
*/
|
|
99
|
-
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined, T | undefined>;
|
|
100
|
-
|
|
101
|
-
export { useAuth, useFirestore, useRTDB };
|
|
102
|
-
export type { FirebaseDocRef, UseFirebaseAuthOptions, UseFirestoreOptions, UseRTDBOptions };
|
package/index.iife.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
(function (exports, vue, shared, firestore, database) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
// @__NO_SIDE_EFFECTS__
|
|
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
|
-
function getData(docRef) {
|
|
16
|
-
const data = docRef.data();
|
|
17
|
-
if (data) {
|
|
18
|
-
Object.defineProperty(data, "id", {
|
|
19
|
-
value: docRef.id.toString(),
|
|
20
|
-
writable: false
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
25
|
-
function isDocumentReference(docRef) {
|
|
26
|
-
var _a;
|
|
27
|
-
return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
|
|
28
|
-
}
|
|
29
|
-
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
30
|
-
const {
|
|
31
|
-
errorHandler = (err) => console.error(err),
|
|
32
|
-
autoDispose = true
|
|
33
|
-
} = options;
|
|
34
|
-
const refOfDocRef = vue.isRef(maybeDocRef) ? maybeDocRef : vue.computed(() => maybeDocRef);
|
|
35
|
-
let close = () => {
|
|
36
|
-
};
|
|
37
|
-
const data = vue.ref(initialValue);
|
|
38
|
-
vue.watch(refOfDocRef, (docRef) => {
|
|
39
|
-
close();
|
|
40
|
-
if (!refOfDocRef.value) {
|
|
41
|
-
data.value = initialValue;
|
|
42
|
-
} else if (isDocumentReference(refOfDocRef.value)) {
|
|
43
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
44
|
-
data.value = getData(snapshot) || null;
|
|
45
|
-
}, errorHandler);
|
|
46
|
-
} else {
|
|
47
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
48
|
-
data.value = snapshot.docs.map(getData).filter(shared.isDef);
|
|
49
|
-
}, errorHandler);
|
|
50
|
-
}
|
|
51
|
-
}, { immediate: true });
|
|
52
|
-
if (autoDispose === true) {
|
|
53
|
-
shared.tryOnScopeDispose(() => {
|
|
54
|
-
close();
|
|
55
|
-
});
|
|
56
|
-
} else if (typeof autoDispose === "number") {
|
|
57
|
-
shared.tryOnScopeDispose(() => {
|
|
58
|
-
shared.useTimeoutFn(() => {
|
|
59
|
-
close();
|
|
60
|
-
}, autoDispose);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return data;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function useRTDB(docRef, options = {}) {
|
|
67
|
-
const {
|
|
68
|
-
errorHandler = (err) => console.error(err),
|
|
69
|
-
autoDispose = true
|
|
70
|
-
} = options;
|
|
71
|
-
const data = vue.ref(void 0);
|
|
72
|
-
function update(snapshot) {
|
|
73
|
-
data.value = snapshot.val();
|
|
74
|
-
}
|
|
75
|
-
const off = database.onValue(docRef, update, errorHandler);
|
|
76
|
-
if (autoDispose)
|
|
77
|
-
shared.tryOnScopeDispose(() => off());
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
exports.useAuth = useAuth;
|
|
82
|
-
exports.useFirestore = useFirestore;
|
|
83
|
-
exports.useRTDB = useRTDB;
|
|
84
|
-
|
|
85
|
-
})(this.VueUse = this.VueUse || {}, Vue, VueUse, firebase, firebase);
|
package/index.iife.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(f,o,i,d,v){"use strict";function h(t){const e=o.ref(t.currentUser),a=o.computed(()=>!!e.value);return t.onIdTokenChanged(s=>e.value=s),{isAuthenticated:a,user:e}}function D(t){const e=t.data();return e&&Object.defineProperty(e,"id",{value:t.id.toString(),writable:!1}),e}function m(t){var e;return(((e=t.path)==null?void 0:e.match(/\//g))||[]).length%2!==0}function S(t,e=void 0,a={}){const{errorHandler:s=l=>console.error(l),autoDispose:u=!0}=a,c=o.isRef(t)?t:o.computed(()=>t);let r=()=>{};const n=o.ref(e);return o.watch(c,l=>{r(),c.value?m(c.value)?r=d.onSnapshot(l,p=>{n.value=D(p)||null},s):r=d.onSnapshot(l,p=>{n.value=p.docs.map(D).filter(i.isDef)},s):n.value=e},{immediate:!0}),u===!0?i.tryOnScopeDispose(()=>{r()}):typeof u=="number"&&i.tryOnScopeDispose(()=>{i.useTimeoutFn(()=>{r()},u)}),n}function g(t,e={}){const{errorHandler:a=n=>console.error(n),autoDispose:s=!0}=e,u=o.ref(void 0);function c(n){u.value=n.val()}const r=v.onValue(t,c,a);return s&&i.tryOnScopeDispose(()=>r()),u}f.useAuth=h,f.useFirestore=S,f.useRTDB=g})(this.VueUse=this.VueUse||{},Vue,VueUse,firebase,firebase);
|
package/index.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { ref, computed, isRef, watch } from 'vue';
|
|
2
|
-
import { isDef, tryOnScopeDispose, useTimeoutFn } from '@vueuse/shared';
|
|
3
|
-
import { onSnapshot } from 'firebase/firestore';
|
|
4
|
-
import { onValue } from 'firebase/database';
|
|
5
|
-
|
|
6
|
-
// @__NO_SIDE_EFFECTS__
|
|
7
|
-
function useAuth(auth) {
|
|
8
|
-
const user = ref(auth.currentUser);
|
|
9
|
-
const isAuthenticated = computed(() => !!user.value);
|
|
10
|
-
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
11
|
-
return {
|
|
12
|
-
isAuthenticated,
|
|
13
|
-
user
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getData(docRef) {
|
|
18
|
-
const data = docRef.data();
|
|
19
|
-
if (data) {
|
|
20
|
-
Object.defineProperty(data, "id", {
|
|
21
|
-
value: docRef.id.toString(),
|
|
22
|
-
writable: false
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
function isDocumentReference(docRef) {
|
|
28
|
-
var _a;
|
|
29
|
-
return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
|
|
30
|
-
}
|
|
31
|
-
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
32
|
-
const {
|
|
33
|
-
errorHandler = (err) => console.error(err),
|
|
34
|
-
autoDispose = true
|
|
35
|
-
} = options;
|
|
36
|
-
const refOfDocRef = isRef(maybeDocRef) ? maybeDocRef : computed(() => maybeDocRef);
|
|
37
|
-
let close = () => {
|
|
38
|
-
};
|
|
39
|
-
const data = ref(initialValue);
|
|
40
|
-
watch(refOfDocRef, (docRef) => {
|
|
41
|
-
close();
|
|
42
|
-
if (!refOfDocRef.value) {
|
|
43
|
-
data.value = initialValue;
|
|
44
|
-
} else if (isDocumentReference(refOfDocRef.value)) {
|
|
45
|
-
close = onSnapshot(docRef, (snapshot) => {
|
|
46
|
-
data.value = getData(snapshot) || null;
|
|
47
|
-
}, errorHandler);
|
|
48
|
-
} else {
|
|
49
|
-
close = onSnapshot(docRef, (snapshot) => {
|
|
50
|
-
data.value = snapshot.docs.map(getData).filter(isDef);
|
|
51
|
-
}, errorHandler);
|
|
52
|
-
}
|
|
53
|
-
}, { immediate: true });
|
|
54
|
-
if (autoDispose === true) {
|
|
55
|
-
tryOnScopeDispose(() => {
|
|
56
|
-
close();
|
|
57
|
-
});
|
|
58
|
-
} else if (typeof autoDispose === "number") {
|
|
59
|
-
tryOnScopeDispose(() => {
|
|
60
|
-
useTimeoutFn(() => {
|
|
61
|
-
close();
|
|
62
|
-
}, autoDispose);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return data;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function useRTDB(docRef, options = {}) {
|
|
69
|
-
const {
|
|
70
|
-
errorHandler = (err) => console.error(err),
|
|
71
|
-
autoDispose = true
|
|
72
|
-
} = options;
|
|
73
|
-
const data = ref(void 0);
|
|
74
|
-
function update(snapshot) {
|
|
75
|
-
data.value = snapshot.val();
|
|
76
|
-
}
|
|
77
|
-
const off = onValue(docRef, update, errorHandler);
|
|
78
|
-
if (autoDispose)
|
|
79
|
-
tryOnScopeDispose(() => off());
|
|
80
|
-
return data;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { useAuth, useFirestore, useRTDB };
|
package/useAuth.d.mts
DELETED
|
@@ -1,78 +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
|
-
* @__NO_SIDE_EFFECTS__
|
|
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
|
-
export { useAuth };
|
|
78
|
-
export type { UseFirebaseAuthOptions };
|
package/useAuth.iife.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
(function (exports, vue) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
// @__NO_SIDE_EFFECTS__
|
|
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;
|
|
16
|
-
|
|
17
|
-
})(this.VueUse = this.VueUse || {}, Vue);
|
package/useAuth.iife.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(s,t){"use strict";function n(u){const e=t.ref(u.currentUser),c=t.computed(()=>!!e.value);return u.onIdTokenChanged(r=>e.value=r),{isAuthenticated:c,user:e}}s.useAuth=n})(this.VueUse=this.VueUse||{},Vue);
|
package/useAuth.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ref, computed } from 'vue';
|
|
2
|
-
|
|
3
|
-
// @__NO_SIDE_EFFECTS__
|
|
4
|
-
function useAuth(auth) {
|
|
5
|
-
const user = ref(auth.currentUser);
|
|
6
|
-
const isAuthenticated = computed(() => !!user.value);
|
|
7
|
-
auth.onIdTokenChanged((authUser) => user.value = authUser);
|
|
8
|
-
return {
|
|
9
|
-
isAuthenticated,
|
|
10
|
-
user
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { useAuth };
|
package/useFirestore.iife.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
(function (exports, shared, firestore, vue) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
function getData(docRef) {
|
|
5
|
-
const data = docRef.data();
|
|
6
|
-
if (data) {
|
|
7
|
-
Object.defineProperty(data, "id", {
|
|
8
|
-
value: docRef.id.toString(),
|
|
9
|
-
writable: false
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function isDocumentReference(docRef) {
|
|
15
|
-
var _a;
|
|
16
|
-
return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
|
|
17
|
-
}
|
|
18
|
-
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
19
|
-
const {
|
|
20
|
-
errorHandler = (err) => console.error(err),
|
|
21
|
-
autoDispose = true
|
|
22
|
-
} = options;
|
|
23
|
-
const refOfDocRef = vue.isRef(maybeDocRef) ? maybeDocRef : vue.computed(() => maybeDocRef);
|
|
24
|
-
let close = () => {
|
|
25
|
-
};
|
|
26
|
-
const data = vue.ref(initialValue);
|
|
27
|
-
vue.watch(refOfDocRef, (docRef) => {
|
|
28
|
-
close();
|
|
29
|
-
if (!refOfDocRef.value) {
|
|
30
|
-
data.value = initialValue;
|
|
31
|
-
} else if (isDocumentReference(refOfDocRef.value)) {
|
|
32
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
33
|
-
data.value = getData(snapshot) || null;
|
|
34
|
-
}, errorHandler);
|
|
35
|
-
} else {
|
|
36
|
-
close = firestore.onSnapshot(docRef, (snapshot) => {
|
|
37
|
-
data.value = snapshot.docs.map(getData).filter(shared.isDef);
|
|
38
|
-
}, errorHandler);
|
|
39
|
-
}
|
|
40
|
-
}, { immediate: true });
|
|
41
|
-
if (autoDispose === true) {
|
|
42
|
-
shared.tryOnScopeDispose(() => {
|
|
43
|
-
close();
|
|
44
|
-
});
|
|
45
|
-
} else if (typeof autoDispose === "number") {
|
|
46
|
-
shared.tryOnScopeDispose(() => {
|
|
47
|
-
shared.useTimeoutFn(() => {
|
|
48
|
-
close();
|
|
49
|
-
}, autoDispose);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return data;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
exports.useFirestore = useFirestore;
|
|
56
|
-
|
|
57
|
-
})(this.VueUse = this.VueUse || {}, VueUse, firebase, Vue);
|
package/useFirestore.iife.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(d,s,c,o){"use strict";function f(t){const e=t.data();return e&&Object.defineProperty(e,"id",{value:t.id.toString(),writable:!1}),e}function m(t){var e;return(((e=t.path)==null?void 0:e.match(/\//g))||[]).length%2!==0}function v(t,e=void 0,h={}){const{errorHandler:p=i=>console.error(i),autoDispose:u=!0}=h,a=o.isRef(t)?t:o.computed(()=>t);let n=()=>{};const r=o.ref(e);return o.watch(a,i=>{n(),a.value?m(a.value)?n=c.onSnapshot(i,l=>{r.value=f(l)||null},p):n=c.onSnapshot(i,l=>{r.value=l.docs.map(f).filter(s.isDef)},p):r.value=e},{immediate:!0}),u===!0?s.tryOnScopeDispose(()=>{n()}):typeof u=="number"&&s.tryOnScopeDispose(()=>{s.useTimeoutFn(()=>{n()},u)}),r}d.useFirestore=v})(this.VueUse=this.VueUse||{},VueUse,firebase,Vue);
|
package/useFirestore.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { isDef, tryOnScopeDispose, useTimeoutFn } from '@vueuse/shared';
|
|
2
|
-
import { onSnapshot } from 'firebase/firestore';
|
|
3
|
-
import { isRef, computed, ref, watch } from 'vue';
|
|
4
|
-
|
|
5
|
-
function getData(docRef) {
|
|
6
|
-
const data = docRef.data();
|
|
7
|
-
if (data) {
|
|
8
|
-
Object.defineProperty(data, "id", {
|
|
9
|
-
value: docRef.id.toString(),
|
|
10
|
-
writable: false
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
function isDocumentReference(docRef) {
|
|
16
|
-
var _a;
|
|
17
|
-
return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
|
|
18
|
-
}
|
|
19
|
-
function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
20
|
-
const {
|
|
21
|
-
errorHandler = (err) => console.error(err),
|
|
22
|
-
autoDispose = true
|
|
23
|
-
} = options;
|
|
24
|
-
const refOfDocRef = isRef(maybeDocRef) ? maybeDocRef : computed(() => maybeDocRef);
|
|
25
|
-
let close = () => {
|
|
26
|
-
};
|
|
27
|
-
const data = ref(initialValue);
|
|
28
|
-
watch(refOfDocRef, (docRef) => {
|
|
29
|
-
close();
|
|
30
|
-
if (!refOfDocRef.value) {
|
|
31
|
-
data.value = initialValue;
|
|
32
|
-
} else if (isDocumentReference(refOfDocRef.value)) {
|
|
33
|
-
close = onSnapshot(docRef, (snapshot) => {
|
|
34
|
-
data.value = getData(snapshot) || null;
|
|
35
|
-
}, errorHandler);
|
|
36
|
-
} else {
|
|
37
|
-
close = onSnapshot(docRef, (snapshot) => {
|
|
38
|
-
data.value = snapshot.docs.map(getData).filter(isDef);
|
|
39
|
-
}, errorHandler);
|
|
40
|
-
}
|
|
41
|
-
}, { immediate: true });
|
|
42
|
-
if (autoDispose === true) {
|
|
43
|
-
tryOnScopeDispose(() => {
|
|
44
|
-
close();
|
|
45
|
-
});
|
|
46
|
-
} else if (typeof autoDispose === "number") {
|
|
47
|
-
tryOnScopeDispose(() => {
|
|
48
|
-
useTimeoutFn(() => {
|
|
49
|
-
close();
|
|
50
|
-
}, autoDispose);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { useFirestore };
|
package/useRTDB.iife.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
(function (exports, shared, database, vue) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
function useRTDB(docRef, options = {}) {
|
|
5
|
-
const {
|
|
6
|
-
errorHandler = (err) => console.error(err),
|
|
7
|
-
autoDispose = true
|
|
8
|
-
} = options;
|
|
9
|
-
const data = vue.ref(void 0);
|
|
10
|
-
function update(snapshot) {
|
|
11
|
-
data.value = snapshot.val();
|
|
12
|
-
}
|
|
13
|
-
const off = database.onValue(docRef, update, errorHandler);
|
|
14
|
-
if (autoDispose)
|
|
15
|
-
shared.tryOnScopeDispose(() => off());
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
exports.useRTDB = useRTDB;
|
|
20
|
-
|
|
21
|
-
})(this.VueUse = this.VueUse || {}, VueUse, firebase, Vue);
|
package/useRTDB.iife.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(o,t,u,n){"use strict";function r(i,a={}){const{errorHandler:c=e=>console.error(e),autoDispose:f=!0}=a,s=n.ref(void 0);function l(e){s.value=e.val()}const V=u.onValue(i,l,c);return f&&t.tryOnScopeDispose(()=>V()),s}o.useRTDB=r})(this.VueUse=this.VueUse||{},VueUse,firebase,Vue);
|
package/useRTDB.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { tryOnScopeDispose } from '@vueuse/shared';
|
|
2
|
-
import { onValue } from 'firebase/database';
|
|
3
|
-
import { ref } from 'vue';
|
|
4
|
-
|
|
5
|
-
function useRTDB(docRef, options = {}) {
|
|
6
|
-
const {
|
|
7
|
-
errorHandler = (err) => console.error(err),
|
|
8
|
-
autoDispose = true
|
|
9
|
-
} = options;
|
|
10
|
-
const data = ref(void 0);
|
|
11
|
-
function update(snapshot) {
|
|
12
|
-
data.value = snapshot.val();
|
|
13
|
-
}
|
|
14
|
-
const off = onValue(docRef, update, errorHandler);
|
|
15
|
-
if (autoDispose)
|
|
16
|
-
tryOnScopeDispose(() => off());
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { useRTDB };
|