Skip to content

Commit 0bca77c

Browse files
committed
feat: Refactored stores to use Svelte Context. Added SignedIn/Out components
1 parent 388f1ef commit 0bca77c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3376
-3098
lines changed

dist/components/Collection.svelte

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>import { collectionStore } from "../stores/firestore.js";
2+
export let ref;
3+
export let startWith = void 0;
4+
let store = collectionStore(ref, startWith);
5+
</script>
6+
7+
{#if $store !== undefined}
8+
<slot data={$store} ref={store.ref} count={$store?.length ?? 0} />
9+
{:else}
10+
<slot name="loading" />
11+
{/if}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { SvelteComponent } from "svelte";
2+
import type { CollectionReference, Query } from 'firebase/firestore';
3+
declare const __propDef: {
4+
props: {
5+
ref: string | CollectionReference | Query;
6+
startWith?: any;
7+
};
8+
events: {
9+
[evt: string]: CustomEvent<any>;
10+
};
11+
slots: {
12+
default: {
13+
data: any[];
14+
ref: CollectionReference | Query | null;
15+
count: number;
16+
};
17+
loading: {};
18+
};
19+
};
20+
export type CollectionProps = typeof __propDef.props;
21+
export type CollectionEvents = typeof __propDef.events;
22+
export type CollectionSlots = typeof __propDef.slots;
23+
export default class Collection extends SvelteComponent<CollectionProps, CollectionEvents, CollectionSlots> {
24+
}
25+
export {};

dist/components/Doc.svelte

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>import { docStore } from "../stores/firestore.js";
2+
export let ref;
3+
export let startWith = void 0;
4+
let store = docStore(ref, startWith);
5+
</script>
6+
7+
{#if $store !== undefined}
8+
<slot data={$store} ref={store.ref} />
9+
{:else}
10+
<slot name="loading" />
11+
{/if}

dist/components/Doc.svelte.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { SvelteComponent } from "svelte";
2+
import type { DocumentReference } from 'firebase/firestore';
3+
declare const __propDef: {
4+
props: {
5+
ref: string | DocumentReference;
6+
startWith?: any;
7+
};
8+
events: {
9+
[evt: string]: CustomEvent<any>;
10+
};
11+
slots: {
12+
default: {
13+
data: any;
14+
ref: DocumentReference | null;
15+
};
16+
loading: {};
17+
};
18+
};
19+
export type DocProps = typeof __propDef.props;
20+
export type DocEvents = typeof __propDef.events;
21+
export type DocSlots = typeof __propDef.slots;
22+
export default class Doc extends SvelteComponent<DocProps, DocEvents, DocSlots> {
23+
}
24+
export {};

dist/components/FirebaseApp.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>import { setFirebaseContext } from "../stores/sdk.js";
2+
export let firestore;
3+
export let auth;
4+
setFirebaseContext({ firestore, auth });
5+
</script>
6+
7+
8+
<slot />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { SvelteComponent } from "svelte";
2+
import type { Auth } from 'firebase/auth';
3+
import type { Firestore } from 'firebase/firestore';
4+
declare const __propDef: {
5+
props: {
6+
firestore: Firestore;
7+
auth: Auth;
8+
};
9+
events: {
10+
[evt: string]: CustomEvent<any>;
11+
};
12+
slots: {
13+
default: {};
14+
};
15+
};
16+
export type FirebaseAppProps = typeof __propDef.props;
17+
export type FirebaseAppEvents = typeof __propDef.events;
18+
export type FirebaseAppSlots = typeof __propDef.slots;
19+
export default class FirebaseApp extends SvelteComponent<FirebaseAppProps, FirebaseAppEvents, FirebaseAppSlots> {
20+
}
21+
export {};

dist/components/SignedIn.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>import { userStore } from "../stores/auth.js";
2+
import { getFirebaseContext } from "../stores/sdk.js";
3+
import { signOut } from "firebase/auth";
4+
const auth = getFirebaseContext().auth;
5+
const user = userStore();
6+
</script>
7+
8+
{#if $user}
9+
<slot user={$user} signOut={() => signOut(auth)} />
10+
{/if}

dist/components/SignedIn.svelte.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { SvelteComponent } from "svelte";
2+
import { signOut, type User } from "firebase/auth";
3+
declare const __propDef: {
4+
props: Record<string, never>;
5+
events: {
6+
[evt: string]: CustomEvent<any>;
7+
};
8+
slots: {
9+
default: {
10+
user: User;
11+
signOut: () => Promise<void>;
12+
};
13+
};
14+
};
15+
export type SignedInProps = typeof __propDef.props;
16+
export type SignedInEvents = typeof __propDef.events;
17+
export type SignedInSlots = typeof __propDef.slots;
18+
export default class SignedIn extends SvelteComponent<SignedInProps, SignedInEvents, SignedInSlots> {
19+
}
20+
export {};

dist/components/SignedOut.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>import { userStore } from "../stores/auth.js";
2+
const user = userStore();
3+
</script>
4+
5+
{#if !$user}
6+
<slot />
7+
{/if}

dist/components/SignedOut.svelte.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { SvelteComponent } from "svelte";
2+
declare const __propDef: {
3+
props: Record<string, never>;
4+
events: {
5+
[evt: string]: CustomEvent<any>;
6+
};
7+
slots: {
8+
default: {};
9+
};
10+
};
11+
export type SignedOutProps = typeof __propDef.props;
12+
export type SignedOutEvents = typeof __propDef.events;
13+
export type SignedOutSlots = typeof __propDef.slots;
14+
export default class SignedOut extends SvelteComponent<SignedOutProps, SignedOutEvents, SignedOutSlots> {
15+
}
16+
export {};

0 commit comments

Comments
 (0)