sveltedfire 0.1.18 → 0.1.19

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.
@@ -1,2 +1,2 @@
1
1
  import { type AuthSig } from './AuthSig.js';
2
- export declare const authState: import("svelte/store").Writable<AuthSig>;
2
+ export declare const authState: AuthSig;
@@ -1,8 +1,9 @@
1
- import { writable } from "svelte/store";
1
+ import { signOut } from './signOut.js';
2
+ import { signInWithGoogle } from './signInWithGoogle.js';
2
3
  import {} from './AuthSig.js';
3
- export const authState = writable({
4
+ export const authState = $state({
4
5
  currentUser: null,
5
- signInWithGoogle: null,
6
- signOut: null,
7
- initialized: false
6
+ initialized: false,
7
+ signInWithGoogle,
8
+ signOut
8
9
  });
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
2
  import { authState } from "../auth/authState.js";
3
3
 
4
- $authState.signInWithGoogle()
4
+ authState.signInWithGoogle()
5
5
  </script>
@@ -3,6 +3,6 @@
3
3
  import { authState } from '../auth/authState.js';
4
4
  </script>
5
5
 
6
- {#if $authState.initialized && $authState!.currentUser}
6
+ {#if authState.initialized && authState!.currentUser}
7
7
  {@render children()}
8
8
  {/if}
@@ -3,6 +3,6 @@
3
3
  import { authState } from '../auth/authState.js';
4
4
  </script>
5
5
 
6
- {#if $authState && $authState.initialized && !$authState!.currentUser}
6
+ {#if authState && authState.initialized && !authState!.currentUser}
7
7
  {@render children()}
8
8
  {/if}
@@ -1,8 +1,5 @@
1
1
  <script lang="ts">
2
2
  import { getAuth, type User } from 'firebase/auth'
3
- import { signOut } from '../auth/signOut.js'
4
- import { signInWithGoogle } from '../auth/signInWithGoogle.js'
5
- import { type AuthSig } from '../auth/AuthSig.js';
6
3
  import { authState } from '../auth/authState.js'
7
4
 
8
5
  const { children, ...rest } = $props()
@@ -17,35 +14,24 @@
17
14
 
18
15
  const auth = getAuth()
19
16
 
20
- let fullAuth = $state<AuthSig>({
21
- currentUser: null,
22
- initialized: false,
23
- signOut,
24
- signInWithGoogle
25
- })
26
-
27
17
  auth.authStateReady().then(() => {
28
18
  console.log('Received authStateReady')
29
- fullAuth.initialized = true
30
- authState.set(fullAuth)
19
+ authState.initialized = true
31
20
  })
32
21
 
33
22
  auth.onAuthStateChanged(user => {
34
- fullAuth.initialized = true
35
- fullAuth.currentUser = user
23
+ authState.initialized = true
24
+ authState.currentUser = user
36
25
  Object.keys(additionalKeys).forEach((k: string) => {
37
- fullAuth[k] = rest[additionalKeys[k]](null, null)
26
+ authState[k] = rest[additionalKeys[k]](null, null)
38
27
  })
39
28
  user?.getIdTokenResult().then(token => {
40
29
  Object.keys(additionalKeys).forEach((k: string) => {
41
- fullAuth[k] = rest[additionalKeys[k]](user, token)
30
+ authState[k] = rest[additionalKeys[k]](user, token)
42
31
  })
43
32
  })
44
- authState.set(fullAuth)
45
33
  })
46
34
 
47
- authState.set(fullAuth)
48
-
49
35
  </script>
50
36
 
51
37
  {@render children()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltedfire",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",