Skip to content

Commit 2de17f1

Browse files
committed
update firebase 7.24.0 -> 8.0.1
1 parent d5f5ec2 commit 2de17f1

File tree

14 files changed

+190
-184
lines changed

14 files changed

+190
-184
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"eslint": "^6.1.0",
2424
"eslint-config-prettier": "^6.0.0",
2525
"eslint-plugin-prettier": "^3.1.0",
26-
"firebase": "^7.2.3",
26+
"firebase": "^8.0.1",
2727
"jest": "^25.1.0",
2828
"lerna": "^3.16.2",
2929
"prettier": "^1.18.2",

packages/@posva/vuefire-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@posva/vuefire-core",
3-
"version": "2.3.3",
3+
"version": "2.3.4",
44
"description": "Shared code for vue + Firebase apps used by vuefire and vuexfire",
55
"author": "Eduardo San Martin Morote <[email protected]>",
66
"homepage": "https://github.com/vuejs/vuefire#readme",

packages/@posva/vuefire-core/src/firestore/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createSnapshot, extractRefs, FirestoreSerializer } from './utils'
22
import { walkGet, callOnceWithArg, OperationsType } from '../shared'
3-
import { firestore } from 'firebase'
3+
import firebase from 'firebase/app'
44

55
export interface FirestoreOptions {
66
maxRefDepth?: number
@@ -21,7 +21,7 @@ interface FirestoreSubscription {
2121
unsub: () => void
2222
// Firestore unique key eg: items/12
2323
path: string
24-
data: () => firestore.DocumentData | null
24+
data: () => firebase.firestore.DocumentData | null
2525
// // path inside the object to access the data items.3
2626
// key: string
2727
}
@@ -36,7 +36,7 @@ function updateDataFromDocumentSnapshot(
3636
options: Required<FirestoreOptions>,
3737
target: CommonBindOptionsParameter['vm'],
3838
path: string,
39-
snapshot: firestore.DocumentSnapshot,
39+
snapshot: firebase.firestore.DocumentSnapshot,
4040
subs: Record<string, FirestoreSubscription>,
4141
ops: CommonBindOptionsParameter['ops'],
4242
depth: number,
@@ -53,7 +53,7 @@ interface SubscribeToDocumentParamater {
5353
depth: number
5454
resolve: () => void
5555
ops: CommonBindOptionsParameter['ops']
56-
ref: firestore.DocumentReference
56+
ref: firebase.firestore.DocumentReference
5757
}
5858

5959
function subscribeToDocument(
@@ -79,7 +79,7 @@ function subscribeToDocument(
7979
interface SubscribeToRefsParameter {
8080
subs: Record<string, FirestoreSubscription>
8181
target: CommonBindOptionsParameter['vm']
82-
refs: Record<string, firestore.DocumentReference>
82+
refs: Record<string, firebase.firestore.DocumentReference>
8383
path: string | number
8484
depth: number
8585
resolve: CommonBindOptionsParameter['resolve']
@@ -94,7 +94,7 @@ function subscribeToRefs(
9494
target: CommonBindOptionsParameter['vm'],
9595
path: string | number,
9696
subs: Record<string, FirestoreSubscription>,
97-
refs: Record<string, firestore.DocumentReference>,
97+
refs: Record<string, firebase.firestore.DocumentReference>,
9898
ops: CommonBindOptionsParameter['ops'],
9999
depth: number,
100100
resolve: CommonBindOptionsParameter['resolve']
@@ -159,7 +159,7 @@ interface CommonBindOptionsParameter {
159159
}
160160

161161
interface BindCollectionParamater extends CommonBindOptionsParameter {
162-
collection: firestore.CollectionReference | firestore.Query
162+
collection: firebase.firestore.CollectionReference | firebase.firestore.Query
163163
}
164164

165165
// TODO: refactor without using an object to improve size like the other functions
@@ -179,14 +179,14 @@ export function bindCollection(
179179
const arraySubs: Record<string, FirestoreSubscription>[] = []
180180

181181
const change = {
182-
added: ({ newIndex, doc }: firestore.DocumentChange) => {
182+
added: ({ newIndex, doc }: firebase.firestore.DocumentChange) => {
183183
arraySubs.splice(newIndex, 0, Object.create(null))
184184
const subs = arraySubs[newIndex]
185185
const [data, refs] = extractRefs(options.serialize(doc), undefined, subs)
186186
ops.add(array, newIndex, data)
187187
subscribeToRefs(options, array, newIndex, subs, refs, ops, 0, resolve.bind(null, doc))
188188
},
189-
modified: ({ oldIndex, newIndex, doc }: firestore.DocumentChange) => {
189+
modified: ({ oldIndex, newIndex, doc }: firebase.firestore.DocumentChange) => {
190190
const subs = arraySubs[oldIndex]
191191
const oldData = array[oldIndex]
192192
const [data, refs] = extractRefs(options.serialize(doc), oldData, subs)
@@ -197,7 +197,7 @@ export function bindCollection(
197197
ops.add(array, newIndex, data)
198198
subscribeToRefs(options, array, newIndex, subs, refs, ops, 0, resolve)
199199
},
200-
removed: ({ oldIndex }: firestore.DocumentChange) => {
200+
removed: ({ oldIndex }: firebase.firestore.DocumentChange) => {
201201
ops.remove(array, oldIndex)
202202
unsubscribeAll(arraySubs.splice(oldIndex, 1)[0])
203203
},
@@ -215,7 +215,7 @@ export function bindCollection(
215215
typeof snapshot.docChanges === 'function'
216216
? snapshot.docChanges()
217217
: /* istanbul ignore next to support firebase < 5*/
218-
((snapshot.docChanges as unknown) as firestore.DocumentChange[])
218+
((snapshot.docChanges as unknown) as firebase.firestore.DocumentChange[])
219219

220220
if (!isResolved && docChanges.length) {
221221
// isResolved is only meant to make sure we do the check only once
@@ -263,7 +263,7 @@ export function bindCollection(
263263
}
264264

265265
interface BindDocumentParamater extends CommonBindOptionsParameter {
266-
document: firestore.DocumentReference
266+
document: firebase.firestore.DocumentReference
267267
}
268268

269269
/**

packages/@posva/vuefire-core/src/firestore/utils.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { firestore } from 'firebase'
1+
import firebase from 'firebase/app'
22
import { isTimestamp, isObject, isDocumentRef, TODO } from '../shared'
33

44
export type FirestoreReference =
5-
| firestore.Query
6-
| firestore.DocumentReference
7-
| firestore.CollectionReference
5+
| firebase.firestore.Query
6+
| firebase.firestore.DocumentReference
7+
| firebase.firestore.CollectionReference
88

99
// TODO: fix type not to be any
10-
export function createSnapshot(doc: firestore.DocumentSnapshot): TODO {
10+
export function createSnapshot(doc: firebase.firestore.DocumentSnapshot): TODO {
1111
// TODO: it should create a deep copy instead because otherwise we will modify internal data
1212
// defaults everything to false, so no need to set
1313
return Object.defineProperty(doc.data() || {}, 'id', { value: doc.id })
@@ -16,11 +16,11 @@ export function createSnapshot(doc: firestore.DocumentSnapshot): TODO {
1616
export type FirestoreSerializer = typeof createSnapshot
1717

1818
export function extractRefs(
19-
doc: firestore.DocumentData,
20-
oldDoc: firestore.DocumentData | void,
21-
subs: Record<string, { path: string; data: () => firestore.DocumentData | null }>
22-
): [firestore.DocumentData, Record<string, firestore.DocumentReference>] {
23-
const dataAndRefs: [firestore.DocumentData, Record<string, firestore.DocumentReference>] = [
19+
doc: firebase.firestore.DocumentData,
20+
oldDoc: firebase.firestore.DocumentData | void,
21+
subs: Record<string, { path: string; data: () => firebase.firestore.DocumentData | null }>
22+
): [firebase.firestore.DocumentData, Record<string, firebase.firestore.DocumentReference>] {
23+
const dataAndRefs: [firebase.firestore.DocumentData, Record<string, firebase.firestore.DocumentReference>] = [
2424
{},
2525
{},
2626
]
@@ -29,13 +29,13 @@ export function extractRefs(
2929
const sub = subs[subKey]
3030
resultSubs[sub.path] = sub.data()
3131
return resultSubs
32-
}, {} as Record<string, firestore.DocumentData | null>)
32+
}, {} as Record<string, firebase.firestore.DocumentData | null>)
3333

3434
function recursiveExtract(
35-
doc: firestore.DocumentData,
36-
oldDoc: firestore.DocumentData | void,
35+
doc: firebase.firestore.DocumentData,
36+
oldDoc: firebase.firestore.DocumentData | void,
3737
path: string,
38-
result: [firestore.DocumentData, Record<string, firestore.DocumentReference>]
38+
result: [firebase.firestore.DocumentData, Record<string, firebase.firestore.DocumentReference>]
3939
): void {
4040
// make it easier to later on access the value
4141
oldDoc = oldDoc || {}

packages/@posva/vuefire-core/src/rtdb/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { database } from 'firebase'
1+
import firebase from 'firebase/app'
22
import { createRecordFromRTDBSnapshot, indexForKey, RTDBSerializer } from './utils'
33
import { OperationsType, ResetOption } from '../shared'
44

@@ -27,7 +27,7 @@ interface CommonBindOptionsParameter {
2727
// TODO: refactor using normal arguments instead of an array to improve size
2828

2929
interface BindAsObjectParameter extends CommonBindOptionsParameter {
30-
document: database.Reference | database.Query
30+
document: firebase.database.Reference | firebase.database.Query
3131
}
3232

3333
/**
@@ -60,7 +60,7 @@ export function rtdbBindAsObject(
6060
}
6161

6262
interface BindAsArrayParameter extends CommonBindOptionsParameter {
63-
collection: database.Reference | database.Query
63+
collection: firebase.database.Reference | firebase.database.Query
6464
}
6565

6666
/**

packages/@posva/vuefire-core/src/rtdb/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { database } from 'firebase'
1+
import firebase from 'firebase/app'
22
import { isObject } from '../shared'
33

44
/**
@@ -7,7 +7,7 @@ import { isObject } from '../shared'
77
* @param snapshot
88
* @return
99
*/
10-
export function createRecordFromRTDBSnapshot(snapshot: database.DataSnapshot): any {
10+
export function createRecordFromRTDBSnapshot(snapshot: firebase.database.DataSnapshot): any {
1111
const value = snapshot.val()
1212
const res = isObject(value) ? value : Object.defineProperty({}, '.value', { value })
1313
// if (isObject(value)) {

packages/@posva/vuefire-core/src/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { firestore } from 'firebase'
1+
import firebase from 'firebase/app'
22

33
export interface OperationsType {
44
set: (target: Record<string, any>, key: string | number, value: any) => any
@@ -62,7 +62,7 @@ export function isTimestamp(o: any): o is Date {
6262
* Checks if a variable is a Firestore Document Reference
6363
* @param o
6464
*/
65-
export function isDocumentRef(o: any): o is firestore.DocumentReference {
65+
export function isDocumentRef(o: any): o is firebase.firestore.DocumentReference {
6666
return o && o.onSnapshot
6767
}
6868

packages/vuefire/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuefire",
3-
"version": "2.2.4",
3+
"version": "2.2.5",
44
"description": "Firestore bindings for Vue.js",
55
"main": "dist/vuefire.common.js",
66
"module": "dist/vuefire.esm.js",

packages/vuefire/src/firestore.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
FirestoreOptions,
77
OperationsType,
88
} from '@posva/vuefire-core'
9-
import { firestore } from 'firebase'
9+
import firebase from 'firebase/app'
1010
import Vue, { PluginFunction } from 'vue'
1111

1212
const ops: OperationsType = {
@@ -18,7 +18,7 @@ const ops: OperationsType = {
1818
function bind(
1919
vm: Record<string, any>,
2020
key: string,
21-
ref: firestore.CollectionReference | firestore.Query | firestore.DocumentReference,
21+
ref: firebase.firestore.CollectionReference | firebase.firestore.Query | firebase.firestore.DocumentReference,
2222
ops: OperationsType,
2323
options: FirestoreOptions
2424
) {
@@ -74,20 +74,20 @@ declare module 'vue/types/vue' {
7474
interface Vue {
7575
$bind(
7676
name: string,
77-
reference: firestore.Query | firestore.CollectionReference,
77+
reference: firebase.firestore.Query | firebase.firestore.CollectionReference,
7878
options?: FirestoreOptions
79-
): Promise<firestore.DocumentData[]>
79+
): Promise<firebase.firestore.DocumentData[]>
8080
$bind(
8181
name: string,
82-
reference: firestore.DocumentReference,
82+
reference: firebase.firestore.DocumentReference,
8383
options?: FirestoreOptions
84-
): Promise<firestore.DocumentData>
84+
): Promise<firebase.firestore.DocumentData>
8585
$unbind: (name: string, reset?: FirestoreOptions['reset']) => void
8686
$firestoreRefs: Readonly<
87-
Record<string, firestore.DocumentReference | firestore.CollectionReference>
87+
Record<string, firebase.firestore.DocumentReference | firebase.firestore.CollectionReference>
8888
>
8989
// _firestoreSources: Readonly<
90-
// Record<string, firestore.CollectionReference | firestore.Query | firestore.DocumentReference>
90+
// Record<string, firebase.firestore.CollectionReference | firebase.firestore.Query | firebase.firestore.DocumentReference>
9191
// >
9292
_firestoreUnbinds: Readonly<
9393
Record<string, ReturnType<typeof bindCollection | typeof bindDocument>>
@@ -97,7 +97,7 @@ declare module 'vue/types/vue' {
9797

9898
type VueFirestoreObject = Record<
9999
string,
100-
firestore.DocumentReference | firestore.Query | firestore.CollectionReference
100+
firebase.firestore.DocumentReference | firebase.firestore.Query | firebase.firestore.CollectionReference
101101
>
102102
type FirestoreOption<V> = VueFirestoreObject | ((this: V) => VueFirestoreObject)
103103

@@ -129,7 +129,7 @@ export const firestorePlugin: PluginFunction<PluginOptions> = function firestore
129129
Vue.prototype[bindName] = function firestoreBind(
130130
this: Vue,
131131
key: string,
132-
ref: firestore.Query | firestore.CollectionReference | firestore.DocumentReference,
132+
ref: firebase.firestore.Query | firebase.firestore.CollectionReference | firebase.firestore.DocumentReference,
133133
userOptions?: FirestoreOptions
134134
) {
135135
const options = Object.assign({}, globalOptions, userOptions)
@@ -155,7 +155,7 @@ export const firestorePlugin: PluginFunction<PluginOptions> = function firestore
155155
},
156156
created(this: Vue) {
157157
const { firestore } = this.$options
158-
const refs = typeof firestore === 'function' ? firestore.call(this) : firestore
158+
const refs = typeof firestore === 'function' ? firebase.firestore.call(this) : firestore
159159
if (!refs) return
160160
for (const key in refs) {
161161
this[bindName as keyof Vue](key, refs[key], globalOptions)

packages/vuefire/src/rtdb.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import {
66
walkSet,
77
OperationsType,
88
} from '@posva/vuefire-core'
9-
import { database } from 'firebase'
9+
import firebase from 'firebase/app'
1010
import Vue, { PluginFunction } from 'vue'
1111

1212
/**
1313
* Returns the original reference of a Firebase reference or query across SDK versions.
1414
*
15-
* @param {firebase.database.Reference|firebase.database.Query} refOrQuery
16-
* @return {firebase.database.Reference}
15+
* @param {firebase.firebase.database.Reference|firebase.firebase.database.Query} refOrQuery
16+
* @return {firebase.firebase.database.Reference}
1717
*/
18-
function getRef(refOrQuery: database.Reference | database.Query): database.Reference {
18+
function getRef(refOrQuery: firebase.database.Reference | firebase.database.Query): firebase.database.Reference {
1919
return refOrQuery.ref
2020
}
2121

@@ -28,7 +28,7 @@ const ops: OperationsType = {
2828
function bind(
2929
vm: Record<string, any>,
3030
key: string,
31-
source: database.Query | database.Reference,
31+
source: firebase.database.Query | firebase.database.Reference,
3232
options: RTDBOptions
3333
) {
3434
return new Promise((resolve, reject) => {
@@ -89,17 +89,17 @@ declare module 'vue/types/vue' {
8989
interface Vue {
9090
$rtdbBind(
9191
name: string,
92-
reference: database.Reference | database.Query,
92+
reference: firebase.database.Reference | firebase.database.Query,
9393
options?: RTDBOptions
94-
): Promise<database.DataSnapshot>
94+
): Promise<firebase.database.DataSnapshot>
9595
$rtdbUnbind: (name: string, reset?: RTDBOptions['reset']) => void
96-
$firebaseRefs: Readonly<Record<string, database.Reference>>
97-
_firebaseSources: Readonly<Record<string, database.Reference | database.Query>>
96+
$firebaseRefs: Readonly<Record<string, firebase.database.Reference>>
97+
_firebaseSources: Readonly<Record<string, firebase.database.Reference | firebase.database.Query>>
9898
_firebaseUnbinds: Readonly<Record<string, ReturnType<typeof bindAsArray | typeof bindAsObject>>>
9999
}
100100
}
101101

102-
type VueFirebaseObject = Record<string, database.Query | database.Reference>
102+
type VueFirebaseObject = Record<string, firebase.database.Query | firebase.database.Reference>
103103
type FirebaseOption<V> = VueFirebaseObject | ((this: V) => VueFirebaseObject)
104104

105105
declare module 'vue/types/options' {
@@ -126,7 +126,7 @@ export const rtdbPlugin: PluginFunction<PluginOptions> = function rtdbPlugin(
126126
Vue.prototype[bindName] = function rtdbBind(
127127
this: Vue,
128128
key: string,
129-
source: database.Reference | database.Query,
129+
source: firebase.database.Reference | firebase.database.Query,
130130
userOptions?: RTDBOptions
131131
) {
132132
const options = Object.assign({}, globalOptions, userOptions)

packages/vuexfire/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuexfire",
3-
"version": "3.2.4",
3+
"version": "3.2.5",
44
"description": "Firestore binding for Vuex",
55
"main": "dist/vuexfire.common.js",
66
"module": "dist/vuexfire.esm.js",

0 commit comments

Comments
 (0)