@vueuse/firebase 10.2.1 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +2 -1
- package/index.d.cts +72 -0
- package/index.d.mts +72 -0
- package/index.d.ts +1 -0
- package/index.iife.js +2 -1
- package/index.iife.min.js +1 -1
- package/index.mjs +2 -1
- package/package.json +3 -7
- package/useAuth.d.cts +47 -0
- package/useAuth.d.mts +47 -0
- package/useFirestore.d.cts +16 -0
- package/useFirestore.d.mts +16 -0
- package/useRTDB.cjs +2 -1
- package/useRTDB.d.cts +15 -0
- package/useRTDB.d.mts +15 -0
- package/useRTDB.d.ts +1 -0
- package/useRTDB.iife.js +2 -1
- package/useRTDB.iife.min.js +1 -1
- package/useRTDB.mjs +2 -1
package/index.cjs
CHANGED
|
@@ -68,13 +68,14 @@ function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
|
68
68
|
|
|
69
69
|
function useRTDB(docRef, options = {}) {
|
|
70
70
|
const {
|
|
71
|
+
errorHandler = (err) => console.error(err),
|
|
71
72
|
autoDispose = true
|
|
72
73
|
} = options;
|
|
73
74
|
const data = vueDemi.ref(void 0);
|
|
74
75
|
function update(snapshot) {
|
|
75
76
|
data.value = snapshot.val();
|
|
76
77
|
}
|
|
77
|
-
const off = database.onValue(docRef, update);
|
|
78
|
+
const off = database.onValue(docRef, update, errorHandler);
|
|
78
79
|
if (autoDispose)
|
|
79
80
|
shared.tryOnScopeDispose(() => off());
|
|
80
81
|
return data;
|
package/index.d.cts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
+
import { ComputedRef, Ref } from 'vue-demi';
|
|
3
|
+
import { User, Auth } from 'firebase/auth';
|
|
4
|
+
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
5
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
6
|
+
import { DatabaseReference } from 'firebase/database';
|
|
7
|
+
|
|
8
|
+
interface UseFirebaseAuthOptions {
|
|
9
|
+
isAuthenticated: ComputedRef<boolean>;
|
|
10
|
+
user: Ref<User | null>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reactive Firebase Auth binding
|
|
14
|
+
*
|
|
15
|
+
* @see https://vueuse.org/useAuth
|
|
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 | undefined) => Promise<string>;
|
|
38
|
+
getIdTokenResult: (forceRefresh?: boolean | undefined) => Promise<_firebase_auth.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>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
interface UseFirestoreOptions {
|
|
51
|
+
errorHandler?: (err: Error) => void;
|
|
52
|
+
autoDispose?: boolean | number;
|
|
53
|
+
}
|
|
54
|
+
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
55
|
+
type Falsy = false | 0 | '' | null | undefined;
|
|
56
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
57
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
58
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
59
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
60
|
+
|
|
61
|
+
interface UseRTDBOptions {
|
|
62
|
+
errorHandler?: (err: Error) => void;
|
|
63
|
+
autoDispose?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Reactive Firebase Realtime Database binding.
|
|
67
|
+
*
|
|
68
|
+
* @see https://vueuse.org/useRTDB
|
|
69
|
+
*/
|
|
70
|
+
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined>;
|
|
71
|
+
|
|
72
|
+
export { FirebaseDocRef, UseFirebaseAuthOptions, UseFirestoreOptions, UseRTDBOptions, useAuth, useFirestore, useRTDB };
|
package/index.d.mts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
+
import { ComputedRef, Ref } from 'vue-demi';
|
|
3
|
+
import { User, Auth } from 'firebase/auth';
|
|
4
|
+
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
5
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
6
|
+
import { DatabaseReference } from 'firebase/database';
|
|
7
|
+
|
|
8
|
+
interface UseFirebaseAuthOptions {
|
|
9
|
+
isAuthenticated: ComputedRef<boolean>;
|
|
10
|
+
user: Ref<User | null>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reactive Firebase Auth binding
|
|
14
|
+
*
|
|
15
|
+
* @see https://vueuse.org/useAuth
|
|
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 | undefined) => Promise<string>;
|
|
38
|
+
getIdTokenResult: (forceRefresh?: boolean | undefined) => Promise<_firebase_auth.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>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
interface UseFirestoreOptions {
|
|
51
|
+
errorHandler?: (err: Error) => void;
|
|
52
|
+
autoDispose?: boolean | number;
|
|
53
|
+
}
|
|
54
|
+
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
55
|
+
type Falsy = false | 0 | '' | null | undefined;
|
|
56
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
57
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
58
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
59
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
60
|
+
|
|
61
|
+
interface UseRTDBOptions {
|
|
62
|
+
errorHandler?: (err: Error) => void;
|
|
63
|
+
autoDispose?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Reactive Firebase Realtime Database binding.
|
|
67
|
+
*
|
|
68
|
+
* @see https://vueuse.org/useRTDB
|
|
69
|
+
*/
|
|
70
|
+
declare function useRTDB<T = any>(docRef: DatabaseReference, options?: UseRTDBOptions): Ref<T | undefined>;
|
|
71
|
+
|
|
72
|
+
export { FirebaseDocRef, UseFirebaseAuthOptions, UseFirestoreOptions, UseRTDBOptions, useAuth, useFirestore, useRTDB };
|
package/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Docu
|
|
|
59
59
|
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
60
60
|
|
|
61
61
|
interface UseRTDBOptions {
|
|
62
|
+
errorHandler?: (err: Error) => void;
|
|
62
63
|
autoDispose?: boolean;
|
|
63
64
|
}
|
|
64
65
|
/**
|
package/index.iife.js
CHANGED
|
@@ -180,13 +180,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
180
180
|
|
|
181
181
|
function useRTDB(docRef, options = {}) {
|
|
182
182
|
const {
|
|
183
|
+
errorHandler = (err) => console.error(err),
|
|
183
184
|
autoDispose = true
|
|
184
185
|
} = options;
|
|
185
186
|
const data = vueDemi.ref(void 0);
|
|
186
187
|
function update(snapshot) {
|
|
187
188
|
data.value = snapshot.val();
|
|
188
189
|
}
|
|
189
|
-
const off = database.onValue(docRef, update);
|
|
190
|
+
const off = database.onValue(docRef, update, errorHandler);
|
|
190
191
|
if (autoDispose)
|
|
191
192
|
shared.tryOnScopeDispose(() => off());
|
|
192
193
|
return data;
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(n,
|
|
1
|
+
var VueDemi=function(n,e,u){if(n.install)return n;if(!e)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(e.version.slice(0,4)==="2.7."){let o=function(s,a){var c,b={},r={config:e.config,use:e.use.bind(e),mixin:e.mixin.bind(e),component:e.component.bind(e),provide:function(t,i){return b[t]=i,this},directive:function(t,i){return i?(e.directive(t,i),r):e.directive(t)},mount:function(t,i){return c||(c=new e(Object.assign({propsData:a},s,{provide:Object.assign(b,s.provide)})),c.$mount(t,i),c)},unmount:function(){c&&(c.$destroy(),c=void 0)}};return r};var g=o;for(var f in e)n[f]=e[f];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=e,n.Vue2=e,n.version=e.version,n.warn=e.util.warn,n.hasInjectionContext=()=>!!n.getCurrentInstance(),n.createApp=o}else if(e.version.slice(0,2)==="2.")if(u){for(var f in u)n[f]=u[f];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=e,n.Vue2=e,n.version=e.version,n.hasInjectionContext=()=>!!n.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(e.version.slice(0,2)==="3."){for(var f in e)n[f]=e[f];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=e,n.Vue2=void 0,n.version=e.version,n.set=function(o,s,a){return Array.isArray(o)?(o.length=Math.max(o.length,s),o.splice(s,1,a),a):(o[s]=a,a)},n.del=function(o,s){if(Array.isArray(o)){o.splice(s,1);return}delete o[s]}}else console.error("[vue-demi] Vue version "+e.version+" is unsupported.");return n}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(n,e,u,f,g){"use strict";function o(r){const t=e.ref(r.currentUser),i=e.computed(()=>!!t.value);return r.onIdTokenChanged(p=>t.value=p),{isAuthenticated:i,user:t}}function s(r){const t=r.data();return t&&Object.defineProperty(t,"id",{value:r.id.toString(),writable:!1}),t}function a(r){var t;return(((t=r.path)==null?void 0:t.match(/\//g))||[]).length%2!==0}function c(r,t=void 0,i={}){const{errorHandler:p=A=>console.error(A),autoDispose:v=!0}=i,h=e.isRef(r)?r:e.computed(()=>r);let d=()=>{};const l=e.ref(t);return e.watch(h,A=>{d(),h.value?a(h.value)?d=f.onSnapshot(A,y=>{l.value=s(y)||null},p):d=f.onSnapshot(A,y=>{l.value=y.docs.map(s).filter(u.isDef)},p):l.value=t},{immediate:!0}),v===!0?u.tryOnScopeDispose(()=>{d()}):typeof v=="number"&&u.tryOnScopeDispose(()=>{u.useTimeoutFn(()=>{d()},v)}),l}function b(r,t={}){const{errorHandler:i=l=>console.error(l),autoDispose:p=!0}=t,v=e.ref(void 0);function h(l){v.value=l.val()}const d=g.onValue(r,h,i);return p&&u.tryOnScopeDispose(()=>d()),v}n.useAuth=o,n.useFirestore=c,n.useRTDB=b})(this.VueUse=this.VueUse||{},VueDemi,VueUse,firebase,firebase);
|
package/index.mjs
CHANGED
|
@@ -66,13 +66,14 @@ function useFirestore(maybeDocRef, initialValue = void 0, options = {}) {
|
|
|
66
66
|
|
|
67
67
|
function useRTDB(docRef, options = {}) {
|
|
68
68
|
const {
|
|
69
|
+
errorHandler = (err) => console.error(err),
|
|
69
70
|
autoDispose = true
|
|
70
71
|
} = options;
|
|
71
72
|
const data = ref(void 0);
|
|
72
73
|
function update(snapshot) {
|
|
73
74
|
data.value = snapshot.val();
|
|
74
75
|
}
|
|
75
|
-
const off = onValue(docRef, update);
|
|
76
|
+
const off = onValue(docRef, update, errorHandler);
|
|
76
77
|
if (autoDispose)
|
|
77
78
|
tryOnScopeDispose(() => off());
|
|
78
79
|
return data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/firebase",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "Enables realtime bindings for Firebase",
|
|
5
5
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,23 +24,19 @@
|
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"types": "./index.d.ts",
|
|
28
27
|
"require": "./index.cjs",
|
|
29
28
|
"import": "./index.mjs"
|
|
30
29
|
},
|
|
31
30
|
"./*": "./*",
|
|
32
31
|
"./useAuth": {
|
|
33
|
-
"types": "./useAuth.d.ts",
|
|
34
32
|
"require": "./useAuth.cjs",
|
|
35
33
|
"import": "./useAuth.mjs"
|
|
36
34
|
},
|
|
37
35
|
"./useFirestore": {
|
|
38
|
-
"types": "./useFirestore.d.ts",
|
|
39
36
|
"require": "./useFirestore.cjs",
|
|
40
37
|
"import": "./useFirestore.mjs"
|
|
41
38
|
},
|
|
42
39
|
"./useRTDB": {
|
|
43
|
-
"types": "./useRTDB.d.ts",
|
|
44
40
|
"require": "./useRTDB.cjs",
|
|
45
41
|
"import": "./useRTDB.mjs"
|
|
46
42
|
}
|
|
@@ -49,12 +45,12 @@
|
|
|
49
45
|
"module": "./index.mjs",
|
|
50
46
|
"unpkg": "./index.iife.min.js",
|
|
51
47
|
"jsdelivr": "./index.iife.min.js",
|
|
52
|
-
"types": "./index.d.
|
|
48
|
+
"types": "./index.d.cts",
|
|
53
49
|
"peerDependencies": {
|
|
54
50
|
"firebase": ">=9.0.0"
|
|
55
51
|
},
|
|
56
52
|
"dependencies": {
|
|
57
|
-
"@vueuse/shared": "10.
|
|
53
|
+
"@vueuse/shared": "10.3.0",
|
|
58
54
|
"vue-demi": ">=0.14.5"
|
|
59
55
|
}
|
|
60
56
|
}
|
package/useAuth.d.cts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
+
import { ComputedRef, Ref } from 'vue-demi';
|
|
3
|
+
import { User, Auth } from 'firebase/auth';
|
|
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 | undefined) => Promise<string>;
|
|
35
|
+
getIdTokenResult: (forceRefresh?: boolean | undefined) => 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>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { UseFirebaseAuthOptions, useAuth };
|
package/useAuth.d.mts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as _firebase_auth from '@firebase/auth';
|
|
2
|
+
import { ComputedRef, Ref } from 'vue-demi';
|
|
3
|
+
import { User, Auth } from 'firebase/auth';
|
|
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 | undefined) => Promise<string>;
|
|
35
|
+
getIdTokenResult: (forceRefresh?: boolean | undefined) => 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>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { UseFirebaseAuthOptions, useAuth };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Ref } from 'vue-demi';
|
|
2
|
+
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
3
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
4
|
+
|
|
5
|
+
interface UseFirestoreOptions {
|
|
6
|
+
errorHandler?: (err: Error) => void;
|
|
7
|
+
autoDispose?: boolean | number;
|
|
8
|
+
}
|
|
9
|
+
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
10
|
+
type Falsy = false | 0 | '' | null | undefined;
|
|
11
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
12
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
13
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
14
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
15
|
+
|
|
16
|
+
export { FirebaseDocRef, UseFirestoreOptions, useFirestore };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Ref } from 'vue-demi';
|
|
2
|
+
import { Query, DocumentReference, DocumentData } from 'firebase/firestore';
|
|
3
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
4
|
+
|
|
5
|
+
interface UseFirestoreOptions {
|
|
6
|
+
errorHandler?: (err: Error) => void;
|
|
7
|
+
autoDispose?: boolean | number;
|
|
8
|
+
}
|
|
9
|
+
type FirebaseDocRef<T> = Query<T> | DocumentReference<T>;
|
|
10
|
+
type Falsy = false | 0 | '' | null | undefined;
|
|
11
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue: T, options?: UseFirestoreOptions): Ref<T | null>;
|
|
12
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue: T[], options?: UseFirestoreOptions): Ref<T[]>;
|
|
13
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
14
|
+
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
15
|
+
|
|
16
|
+
export { FirebaseDocRef, UseFirestoreOptions, useFirestore };
|
package/useRTDB.cjs
CHANGED
|
@@ -6,13 +6,14 @@ var shared = require('@vueuse/shared');
|
|
|
6
6
|
|
|
7
7
|
function useRTDB(docRef, options = {}) {
|
|
8
8
|
const {
|
|
9
|
+
errorHandler = (err) => console.error(err),
|
|
9
10
|
autoDispose = true
|
|
10
11
|
} = options;
|
|
11
12
|
const data = vueDemi.ref(void 0);
|
|
12
13
|
function update(snapshot) {
|
|
13
14
|
data.value = snapshot.val();
|
|
14
15
|
}
|
|
15
|
-
const off = database.onValue(docRef, update);
|
|
16
|
+
const off = database.onValue(docRef, update, errorHandler);
|
|
16
17
|
if (autoDispose)
|
|
17
18
|
shared.tryOnScopeDispose(() => off());
|
|
18
19
|
return data;
|
package/useRTDB.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DatabaseReference } from 'firebase/database';
|
|
2
|
+
import { Ref } from 'vue-demi';
|
|
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>;
|
|
14
|
+
|
|
15
|
+
export { UseRTDBOptions, useRTDB };
|
package/useRTDB.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DatabaseReference } from 'firebase/database';
|
|
2
|
+
import { Ref } from 'vue-demi';
|
|
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>;
|
|
14
|
+
|
|
15
|
+
export { UseRTDBOptions, useRTDB };
|
package/useRTDB.d.ts
CHANGED
package/useRTDB.iife.js
CHANGED
|
@@ -119,13 +119,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
119
119
|
|
|
120
120
|
function useRTDB(docRef, options = {}) {
|
|
121
121
|
const {
|
|
122
|
+
errorHandler = (err) => console.error(err),
|
|
122
123
|
autoDispose = true
|
|
123
124
|
} = options;
|
|
124
125
|
const data = vueDemi.ref(void 0);
|
|
125
126
|
function update(snapshot) {
|
|
126
127
|
data.value = snapshot.val();
|
|
127
128
|
}
|
|
128
|
-
const off = database.onValue(docRef, update);
|
|
129
|
+
const off = database.onValue(docRef, update, errorHandler);
|
|
129
130
|
if (autoDispose)
|
|
130
131
|
shared.tryOnScopeDispose(() => off());
|
|
131
132
|
return data;
|
package/useRTDB.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(n,
|
|
1
|
+
var VueDemi=function(n,r,d){if(n.install)return n;if(!r)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(r.version.slice(0,4)==="2.7."){let o=function(i,f){var e,a={},l={config:r.config,use:r.use.bind(r),mixin:r.mixin.bind(r),component:r.component.bind(r),provide:function(c,t){return a[c]=t,this},directive:function(c,t){return t?(r.directive(c,t),l):r.directive(c)},mount:function(c,t){return e||(e=new r(Object.assign({propsData:f},i,{provide:Object.assign(a,i.provide)})),e.$mount(c,t),e)},unmount:function(){e&&(e.$destroy(),e=void 0)}};return l};var u=o;for(var s in r)n[s]=r[s];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.warn=r.util.warn,n.hasInjectionContext=()=>!!n.getCurrentInstance(),n.createApp=o}else if(r.version.slice(0,2)==="2.")if(d){for(var s in d)n[s]=d[s];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.hasInjectionContext=()=>!!n.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var s in r)n[s]=r[s];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=r,n.Vue2=void 0,n.version=r.version,n.set=function(o,i,f){return Array.isArray(o)?(o.length=Math.max(o.length,i),o.splice(i,1,f),f):(o[i]=f,f)},n.del=function(o,i){if(Array.isArray(o)){o.splice(i,1);return}delete o[i]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");return n}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(n,r,d,s){"use strict";function u(o,i={}){const{errorHandler:f=t=>console.error(t),autoDispose:e=!0}=i,a=d.ref(void 0);function l(t){a.value=t.val()}const c=r.onValue(o,l,f);return e&&s.tryOnScopeDispose(()=>c()),a}n.useRTDB=u})(this.VueUse=this.VueUse||{},firebase,VueDemi,VueUse);
|
package/useRTDB.mjs
CHANGED
|
@@ -4,13 +4,14 @@ import { tryOnScopeDispose } from '@vueuse/shared';
|
|
|
4
4
|
|
|
5
5
|
function useRTDB(docRef, options = {}) {
|
|
6
6
|
const {
|
|
7
|
+
errorHandler = (err) => console.error(err),
|
|
7
8
|
autoDispose = true
|
|
8
9
|
} = options;
|
|
9
10
|
const data = ref(void 0);
|
|
10
11
|
function update(snapshot) {
|
|
11
12
|
data.value = snapshot.val();
|
|
12
13
|
}
|
|
13
|
-
const off = onValue(docRef, update);
|
|
14
|
+
const off = onValue(docRef, update, errorHandler);
|
|
14
15
|
if (autoDispose)
|
|
15
16
|
tryOnScopeDispose(() => off());
|
|
16
17
|
return data;
|