@vueuse/firebase 14.0.0-alpha.3 → 14.0.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/dist/{index-CKgxjVly.d.ts → index-C8l5U9ks.d.ts} +1 -1
- package/dist/{index-CpsujYtM.d.ts → index-DNr4g7De.d.ts} +1 -1
- package/dist/{index-b8UVCofo.d.ts → index-XIo_-0hT.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.iife.js +90 -90
- package/dist/index.iife.min.js +1 -1
- package/dist/index.js +3 -3
- package/dist/{useAuth-Drx9pmk6.js → useAuth-Cr9OEZWw.js} +1 -1
- package/dist/useAuth.d.ts +1 -1
- package/dist/useAuth.iife.js +35 -35
- package/dist/useAuth.iife.min.js +1 -1
- package/dist/useAuth.js +1 -1
- package/dist/{useFirestore-DlUzLR_t.js → useFirestore-BBMegHsP.js} +1 -1
- package/dist/useFirestore.d.ts +1 -1
- package/dist/useFirestore.iife.js +62 -62
- package/dist/useFirestore.iife.min.js +1 -1
- package/dist/useFirestore.js +1 -1
- package/dist/{useRTDB-BGccE9Ip.js → useRTDB-CCp2R9Wa.js} +1 -1
- package/dist/useRTDB.d.ts +1 -1
- package/dist/useRTDB.iife.js +33 -33
- package/dist/useRTDB.iife.min.js +1 -1
- package/dist/useRTDB.js +1 -1
- package/package.json +2 -2
|
@@ -13,4 +13,4 @@ declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Quer
|
|
|
13
13
|
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<DocumentReference<T> | Falsy>, initialValue?: T | undefined | null, options?: UseFirestoreOptions): Ref<T | undefined | null>;
|
|
14
14
|
declare function useFirestore<T extends DocumentData>(maybeDocRef: MaybeRef<Query<T> | Falsy>, initialValue?: T[], options?: UseFirestoreOptions): Ref<T[] | undefined>;
|
|
15
15
|
//#endregion
|
|
16
|
-
export {
|
|
16
|
+
export { UseFirestoreOptions as n, useFirestore as r, FirebaseDocRef as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as useAuth, t as UseFirebaseAuthOptions } from "./index-XIo_-0hT.js";
|
|
2
|
+
import { n as UseFirestoreOptions, r as useFirestore, t as FirebaseDocRef } from "./index-DNr4g7De.js";
|
|
3
|
+
import { n as useRTDB, t as UseRTDBOptions } from "./index-C8l5U9ks.js";
|
|
4
4
|
export { FirebaseDocRef, UseFirebaseAuthOptions, UseFirestoreOptions, UseRTDBOptions, useAuth, useFirestore, useRTDB };
|
package/dist/index.iife.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
(function(exports, vue, __vueuse_shared, firebase_firestore, firebase_database) {
|
|
2
2
|
|
|
3
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) : target, mod));
|
|
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
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
vue = __toESM(vue);
|
|
@@ -30,85 +30,85 @@ firebase_database = __toESM(firebase_database);
|
|
|
30
30
|
|
|
31
31
|
//#region useAuth/index.ts
|
|
32
32
|
/**
|
|
33
|
-
* Reactive Firebase Auth binding
|
|
34
|
-
*
|
|
35
|
-
* @see https://vueuse.org/useAuth
|
|
36
|
-
*
|
|
37
|
-
* @__NO_SIDE_EFFECTS__
|
|
38
|
-
*/
|
|
39
|
-
function useAuth(auth) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
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
48
|
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region useFirestore/index.ts
|
|
51
|
-
function getData(docRef) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function isDocumentReference(docRef) {
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
close();
|
|
86
|
-
});
|
|
87
|
-
else if (typeof autoDispose === "number") (0, __vueuse_shared.tryOnScopeDispose)(() => {
|
|
88
|
-
(0, __vueuse_shared.useTimeoutFn)(() => {
|
|
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)(() => {
|
|
89
85
|
close();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
94
|
|
|
95
95
|
//#endregion
|
|
96
96
|
//#region useRTDB/index.ts
|
|
97
97
|
/**
|
|
98
|
-
* Reactive Firebase Realtime Database binding.
|
|
99
|
-
*
|
|
100
|
-
* @see https://vueuse.org/useRTDB
|
|
101
|
-
*/
|
|
102
|
-
function useRTDB(docRef, options = {}) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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;
|
|
107
111
|
}
|
|
108
|
-
const off = (0, firebase_database.onValue)(docRef, update, errorHandler);
|
|
109
|
-
if (autoDispose) (0, __vueuse_shared.tryOnScopeDispose)(() => off());
|
|
110
|
-
return data;
|
|
111
|
-
}
|
|
112
112
|
|
|
113
113
|
//#endregion
|
|
114
114
|
exports.useAuth = useAuth;
|
package/dist/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,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}e.useAuth=p,e.useFirestore=g,e.useRTDB=_})(this.VueUse=this.VueUse||{},Vue,VueUse,firebase,firebase);
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useAuth } from "./useAuth-
|
|
2
|
-
import { useFirestore } from "./useFirestore-
|
|
3
|
-
import { useRTDB } from "./useRTDB-
|
|
1
|
+
import { t as useAuth } from "./useAuth-Cr9OEZWw.js";
|
|
2
|
+
import { t as useFirestore } from "./useFirestore-BBMegHsP.js";
|
|
3
|
+
import { t as useRTDB } from "./useRTDB-CCp2R9Wa.js";
|
|
4
4
|
|
|
5
5
|
export { useAuth, useFirestore, useRTDB };
|
package/dist/useAuth.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as useAuth, t as UseFirebaseAuthOptions } from "./index-XIo_-0hT.js";
|
|
2
2
|
export { UseFirebaseAuthOptions, useAuth };
|
package/dist/useAuth.iife.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
(function(exports, vue) {
|
|
2
2
|
|
|
3
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) : target, mod));
|
|
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
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
vue = __toESM(vue);
|
|
27
27
|
|
|
28
28
|
//#region useAuth/index.ts
|
|
29
29
|
/**
|
|
30
|
-
* Reactive Firebase Auth binding
|
|
31
|
-
*
|
|
32
|
-
* @see https://vueuse.org/useAuth
|
|
33
|
-
*
|
|
34
|
-
* @__NO_SIDE_EFFECTS__
|
|
35
|
-
*/
|
|
36
|
-
function useAuth(auth) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
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
45
|
|
|
46
46
|
//#endregion
|
|
47
47
|
exports.useAuth = useAuth;
|
package/dist/useAuth.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,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}}e.useAuth=l})(this.VueUse=this.VueUse||{},Vue);
|
package/dist/useAuth.js
CHANGED
package/dist/useFirestore.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as UseFirestoreOptions, r as useFirestore, t as FirebaseDocRef } from "./index-DNr4g7De.js";
|
|
2
2
|
export { FirebaseDocRef, UseFirestoreOptions, useFirestore };
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
(function(exports, __vueuse_shared, firebase_firestore, vue) {
|
|
2
2
|
|
|
3
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) : target, mod));
|
|
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
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
__vueuse_shared = __toESM(__vueuse_shared);
|
|
@@ -28,49 +28,49 @@ firebase_firestore = __toESM(firebase_firestore);
|
|
|
28
28
|
vue = __toESM(vue);
|
|
29
29
|
|
|
30
30
|
//#region useFirestore/index.ts
|
|
31
|
-
function getData(docRef) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
function isDocumentReference(docRef) {
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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)(() => {
|
|
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) => {
|
|
69
55
|
close();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
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
74
|
|
|
75
75
|
//#endregion
|
|
76
76
|
exports.useFirestore = useFirestore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,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}e.useFirestore=m})(this.VueUse=this.VueUse||{},VueUse,firebase,Vue);
|
package/dist/useFirestore.js
CHANGED
package/dist/useRTDB.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as useRTDB, t as UseRTDBOptions } from "./index-C8l5U9ks.js";
|
|
2
2
|
export { UseRTDBOptions, useRTDB };
|
package/dist/useRTDB.iife.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
(function(exports, __vueuse_shared, firebase_database, vue) {
|
|
2
2
|
|
|
3
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) : target, mod));
|
|
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
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
__vueuse_shared = __toESM(__vueuse_shared);
|
|
@@ -29,20 +29,20 @@ vue = __toESM(vue);
|
|
|
29
29
|
|
|
30
30
|
//#region useRTDB/index.ts
|
|
31
31
|
/**
|
|
32
|
-
* Reactive Firebase Realtime Database binding.
|
|
33
|
-
*
|
|
34
|
-
* @see https://vueuse.org/useRTDB
|
|
35
|
-
*/
|
|
36
|
-
function useRTDB(docRef, options = {}) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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;
|
|
41
45
|
}
|
|
42
|
-
const off = (0, firebase_database.onValue)(docRef, update, errorHandler);
|
|
43
|
-
if (autoDispose) (0, __vueuse_shared.tryOnScopeDispose)(() => off());
|
|
44
|
-
return data;
|
|
45
|
-
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
48
|
exports.useRTDB = useRTDB;
|
package/dist/useRTDB.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,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}e.useRTDB=f})(this.VueUse=this.VueUse||{},VueUse,firebase,Vue);
|
package/dist/useRTDB.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "14.0.0
|
|
4
|
+
"version": "14.0.0",
|
|
5
5
|
"description": "Enables realtime bindings for Firebase",
|
|
6
6
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vue": "^3.5.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@vueuse/shared": "14.0.0
|
|
46
|
+
"@vueuse/shared": "14.0.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown",
|