sveltedfire 0.1.14 → 0.1.16

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.
@@ -3,5 +3,6 @@ export type AuthSig = {
3
3
  currentUser: User | null;
4
4
  signInWithGoogle: any;
5
5
  signOut: any;
6
+ initialized: boolean;
6
7
  [k: string]: any;
7
8
  };
@@ -1,11 +1,11 @@
1
1
  <script lang="ts">
2
2
  const { children } = $props()
3
3
  import { getContext } from 'svelte';
4
- import { AuthSig } from '../auth/AuthSig.js';
4
+ import { type AuthSig } from '../auth/AuthSig.js';
5
5
 
6
6
  let fullAuth = getContext<AuthSig>('sveltedAuth')
7
7
  </script>
8
8
 
9
- {#if fullAuth!.currentUser}
9
+ {#if fullAuth.initialized && fullAuth!.currentUser}
10
10
  {@render children()}
11
11
  {/if}
@@ -6,6 +6,6 @@
6
6
  let fullAuth = getContext<AuthSig>('sveltedAuth')
7
7
  </script>
8
8
 
9
- {#if fullAuth && !fullAuth!.currentUser}
9
+ {#if fullAuth && fullAuth.initialized && !fullAuth!.currentUser}
10
10
  {@render children()}
11
11
  {/if}
@@ -20,11 +20,17 @@
20
20
 
21
21
  let fullAuth = $state<AuthSig>({
22
22
  currentUser: null,
23
+ initialized: false,
23
24
  signOut,
24
25
  signInWithGoogle
25
26
  })
26
27
 
28
+ auth.authStateReady().then(() => {
29
+ fullAuth.initialized = true
30
+ })
31
+
27
32
  auth.onAuthStateChanged(user => {
33
+ fullAuth.initialized = true
28
34
  fullAuth.currentUser = user
29
35
  Object.keys(additionalKeys).forEach((k: string) => {
30
36
  fullAuth[k] = rest[additionalKeys[k]](null, null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltedfire",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",