File tree Expand file tree Collapse file tree 9 files changed +112
-18
lines changed Expand file tree Collapse file tree 9 files changed +112
-18
lines changed Original file line number Diff line number Diff line change 15
15
"comma-dangle": [
16
16
"error",
17
17
"always-multiline"
18
- ]
18
+ ],
19
+ "vue/require-v-for-key": "off",
19
20
}
20
21
}
Original file line number Diff line number Diff line change 10
10
"require" : " ./dist/module.cjs"
11
11
}
12
12
},
13
- "main" : " ./dist/module.cjs " ,
13
+ "main" : " ./dist/module.mjs " ,
14
14
"types" : " ./dist/types.d.ts" ,
15
15
"files" : [
16
16
" dist"
27
27
"dev:prepare" : " nuxt-module-build --stub && nuxi prepare playground"
28
28
},
29
29
"dependencies" : {
30
- "@nuxt/kit" : " 3.0.0-rc.13"
30
+ "@nuxt/kit" : " ^ 3.0.0-rc.13"
31
31
},
32
32
"devDependencies" : {
33
33
"@firebase/app-types" : " ^0.8.1" ,
34
34
"@nuxt/module-builder" : " ^0.2.0" ,
35
- "@nuxt/schema" : " 3.0.0-rc.13" ,
35
+ "@nuxt/schema" : " ^ 3.0.0-rc.13" ,
36
36
"@nuxtjs/eslint-config-typescript" : " ^11.0.0" ,
37
37
"eslint" : " ^8.27.0" ,
38
38
"firebase" : " ^9.14.0" ,
39
- "nuxt" : " ^3.0.0-rc.12" ,
39
+ "nuxt" : " ^^ 3.0.0-rc.12" ,
40
40
"vuefire" : " workspace:*"
41
41
}
42
42
}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ const router = useRouter()
3
3
4
4
const routes = router
5
5
.getRoutes ()
6
- .filter (( record ) => record .path .startsWith (' /database/' ))
6
+ .filter (record => record .path .startsWith (' /database/' ))
7
7
.map ((record ) => {
8
8
return {
9
9
name: record .name ,
@@ -14,10 +14,14 @@ const routes = router
14
14
15
15
<template >
16
16
<div >
17
- <NuxtLink to =" /" >< ;< ; Back Home</NuxtLink >
17
+ <NuxtLink to =" /" >
18
+ < ;< ; Back Home
19
+ </NuxtLink >
18
20
<ul >
19
21
<li v-for =" link in routes" >
20
- <NuxtLink :to =" link" >{{ link.path }}</NuxtLink >
22
+ <NuxtLink :to =" link" >
23
+ {{ link.path }}
24
+ </NuxtLink >
21
25
</li >
22
26
</ul >
23
27
</div >
Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import { doc , getDoc } from ' firebase/firestore'
3
+ import { useDocument , useFirestore , usePendingPromises } from ' vuefire'
4
+ import { ref } from ' vue'
5
+
6
+ const db = useFirestore ()
7
+ const configRef = doc (db , ' configs' , ' jORwjIykFo2NmkdzTkhU' )
8
+ // const itemRef = doc(db, 'tests', 'item')
9
+ const isDoneFetching = ref (false )
10
+ const isAllDoneFetching = ref (false )
11
+
12
+ getDoc (configRef ).then ((data ) => {
13
+ console .log (' got data once' , data )
14
+ })
15
+
16
+ const { data : config, promise } = useDocument (configRef , { wait: true })
17
+ // const { data: hey } = useDocument(configRef)
18
+
19
+ promise .value .then ((data ) => {
20
+ console .log (' one' , data )
21
+ isDoneFetching .value = true
22
+ })
23
+
24
+ usePendingPromises ().then ((data ) => {
25
+ console .log (data )
26
+ isAllDoneFetching .value = true
27
+ })
28
+ </script >
29
+
30
+ <template >
31
+ <div >
32
+ <p >config:</p >
33
+ <p >finished: {{ isDoneFetching }}</p >
34
+ <p >All finished: {{ isAllDoneFetching }}</p >
35
+ <pre >{{ config }}</pre >
36
+ </div >
37
+ </template >
Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ const router = useRouter ()
3
+
4
+ const routes = router
5
+ .getRoutes ()
6
+ .filter (record => record .path .startsWith (' /firestore/' ))
7
+ .map ((record ) => {
8
+ return {
9
+ name: record .name ,
10
+ path: record .path ,
11
+ }
12
+ })
13
+ </script >
14
+
15
+ <template >
16
+ <div >
17
+ <NuxtLink to =" /" >
18
+ < ;< ; Back Home
19
+ </NuxtLink >
20
+ <ul >
21
+ <li v-for =" link in routes" >
22
+ <NuxtLink :to =" link" >
23
+ {{ link.path }}
24
+ </NuxtLink >
25
+ </li >
26
+ </ul >
27
+ </div >
28
+ </template >
Original file line number Diff line number Diff line change 2
2
<div >
3
3
<ul >
4
4
<li >
5
- <NuxtLink to =" /database" >Database</NuxtLink >
5
+ <NuxtLink to =" /database" >
6
+ Database
7
+ </NuxtLink >
8
+ </li >
9
+ <li >
10
+ <NuxtLink to =" /firestore" >
11
+ Firestore
12
+ </NuxtLink >
6
13
</li >
7
14
</ul >
8
15
</div >
Original file line number Diff line number Diff line change 1
1
import { fileURLToPath } from 'node:url'
2
2
import { resolve } from 'path'
3
3
import { addPlugin , defineNuxtModule } from '@nuxt/kit'
4
- import { FirebaseOptions } from '@firebase/app-types'
4
+ import { type FirebaseOptions } from '@firebase/app-types'
5
5
6
6
export interface VueFireNuxtModuleOptions {
7
7
optionsApiPlugin : boolean
Original file line number Diff line number Diff line change 1
- import { defineNuxtPlugin } from '#app'
1
+ import { usePendingPromises , VueFire , useSSRInitialState } from 'vuefire'
2
+ import { initializeApp } from 'firebase/app'
3
+ import { defineNuxtPlugin } from '#imports'
2
4
3
5
export default defineNuxtPlugin ( async ( nuxtApp ) => {
4
- // TODO: create the plugin that stores the promises with data
6
+ // TODO: initialize firebase app from config
7
+ const firebaseApp = initializeApp ( )
5
8
6
- if ( process . server ) {
7
- await 2 // TODO: wait for promises to resolve
9
+ nuxtApp . vueApp . use (
10
+ // @ts -expect-error: nuxt type bug?
11
+ VueFire ,
12
+ {
13
+ firebaseApp,
14
+ }
15
+ )
8
16
9
- // nuxtApp.payload.firebaseState = ...
10
- } else {
11
- // hydrate the plugin state from nuxtApp.payload.firebaseState
17
+ if ( process . server ) {
18
+ await usePendingPromises ( )
19
+ // TODO: pass the firebaseApp
20
+ nuxtApp . payload . vuefire = useSSRInitialState ( )
21
+ } else if ( nuxtApp . payload ?. vuefire ) {
22
+ // hydrate the plugin state from nuxtApp.payload.vuefire
23
+ useSSRInitialState ( nuxtApp . payload . vuefire )
12
24
}
13
25
14
26
return {
Original file line number Diff line number Diff line change 1
1
{
2
- "extends" : " ./playground/.nuxt/tsconfig.json"
2
+ "extends" : " ./playground/.nuxt/tsconfig.json" ,
3
+ "include" : [
4
+ // missing in the playground
5
+ " ./src"
6
+ , " ./playground"
7
+ ]
3
8
}
You can’t perform that action at this time.
0 commit comments