Skip to content

Commit ae98719

Browse files
authored
Merge branch 'master' into feature/storage-list-and-download
2 parents 80b4690 + c326e17 commit ae98719

File tree

16 files changed

+114
-117
lines changed

16 files changed

+114
-117
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
node-version: 18
1818
- run: npm ci
19-
- run: npx playwright install --with-deps
19+
- run: npx playwright install --with-deps chromium
2020
- run: npx playwright test
2121
- uses: actions/upload-artifact@v3
2222
if: always()

dist/components/Collection.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script>import { collectionStore } from "../stores/firestore.js";
1+
<script generics="Data extends DocumentData">import { collectionStore } from "../stores/firestore.js";
22
import { getFirebaseContext } from "../stores/sdk.js";
33
export let ref;
44
export let startWith = void 0;
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import { SvelteComponent } from "svelte";
2-
import type { CollectionReference, Firestore, Query } from 'firebase/firestore';
3-
declare const __propDef: {
4-
props: {
5-
ref: string | CollectionReference | Query;
6-
startWith?: any;
2+
import type { CollectionReference, DocumentData, Firestore, Query } from "firebase/firestore";
3+
declare class __sveltets_Render<Data extends DocumentData> {
4+
props(): {
5+
ref: string | CollectionReference<Data> | Query<Data>;
6+
startWith?: Data[] | undefined;
77
};
8-
events: {
8+
events(): {} & {
99
[evt: string]: CustomEvent<any>;
1010
};
11-
slots: {
11+
slots(): {
1212
default: {
13-
data: any[];
14-
ref: CollectionReference | Query | null;
13+
data: Data[];
14+
ref: CollectionReference<Data[]> | Query<Data[]> | null;
1515
count: number;
1616
firestore?: Firestore | undefined;
1717
};
1818
loading: {};
1919
};
20-
};
21-
export type CollectionProps = typeof __propDef.props;
22-
export type CollectionEvents = typeof __propDef.events;
23-
export type CollectionSlots = typeof __propDef.slots;
24-
export default class Collection extends SvelteComponent<CollectionProps, CollectionEvents, CollectionSlots> {
20+
}
21+
export type CollectionProps<Data extends DocumentData> = ReturnType<__sveltets_Render<Data>['props']>;
22+
export type CollectionEvents<Data extends DocumentData> = ReturnType<__sveltets_Render<Data>['events']>;
23+
export type CollectionSlots<Data extends DocumentData> = ReturnType<__sveltets_Render<Data>['slots']>;
24+
export default class Collection<Data extends DocumentData> extends SvelteComponent<CollectionProps<Data>, CollectionEvents<Data>, CollectionSlots<Data>> {
2525
}
2626
export {};

dist/components/Doc.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script>import { docStore } from "../stores/firestore.js";
1+
<script generics="Data extends DocumentData">import { docStore } from "../stores/firestore.js";
22
import { getFirebaseContext } from "../stores/sdk.js";
33
export let ref;
44
export let startWith = void 0;
55
const { firestore } = getFirebaseContext();
66
let store = docStore(firestore, ref, startWith);
77
</script>
88

9-
{#if $store !== undefined}
9+
{#if $store !== undefined && $store !== null}
1010
<slot data={$store} ref={store.ref} {firestore} />
1111
{:else}
1212
<slot name="loading" />

dist/components/Doc.svelte.d.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { SvelteComponent } from "svelte";
2-
import type { DocumentReference, Firestore } from 'firebase/firestore';
3-
declare const __propDef: {
4-
props: {
5-
ref: string | DocumentReference;
6-
startWith?: any;
2+
import type { DocumentData, DocumentReference, Firestore } from "firebase/firestore";
3+
declare class __sveltets_Render<Data extends DocumentData> {
4+
props(): {
5+
ref: string | DocumentReference<Data>;
6+
startWith?: Data | undefined;
77
};
8-
events: {
8+
events(): {} & {
99
[evt: string]: CustomEvent<any>;
1010
};
11-
slots: {
11+
slots(): {
1212
default: {
13-
data: any;
14-
ref: DocumentReference | null;
13+
data: Data;
14+
ref: DocumentReference<Data> | null;
1515
firestore?: Firestore | undefined;
1616
};
1717
loading: {};
1818
};
19-
};
20-
export type DocProps = typeof __propDef.props;
21-
export type DocEvents = typeof __propDef.events;
22-
export type DocSlots = typeof __propDef.slots;
23-
export default class Doc extends SvelteComponent<DocProps, DocEvents, DocSlots> {
19+
}
20+
export type DocProps<Data extends DocumentData> = ReturnType<__sveltets_Render<Data>['props']>;
21+
export type DocEvents<Data extends DocumentData> = ReturnType<__sveltets_Render<Data>['events']>;
22+
export type DocSlots<Data extends DocumentData> = ReturnType<__sveltets_Render<Data>['slots']>;
23+
export default class Doc<Data extends DocumentData> extends SvelteComponent<DocProps<Data>, DocEvents<Data>, DocSlots<Data>> {
2424
}
2525
export {};

dist/stores/firestore.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ interface DocStore<T> {
1313
export declare function docStore<T = any>(firestore: Firestore, ref: string | DocumentReference<T>, startWith?: T): DocStore<T>;
1414
interface CollectionStore<T> {
1515
subscribe: (cb: (value: T | []) => void) => void | (() => void);
16-
ref: CollectionReference | Query | null;
16+
ref: CollectionReference<T> | Query<T> | null;
1717
}
1818
/**
1919
* @param {Firestore} firestore firebase firestore instance
2020
* @param {string|Query|CollectionReference} ref collection path, reference, or query
2121
* @param {[]} startWith optional default data
2222
* @returns a store with realtime updates on collection data
2323
*/
24-
export declare function collectionStore<T>(firestore: Firestore, ref: string | Query | CollectionReference, startWith?: T[]): CollectionStore<T[]>;
24+
export declare function collectionStore<T>(firestore: Firestore, ref: string | Query<T> | CollectionReference<T>, startWith?: T[]): CollectionStore<T[]>;
2525
export {};

dist/stores/firestore.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export function docStore(firestore, ref, startWith) {
2727
id: "",
2828
};
2929
}
30-
const docRef = typeof ref === 'string' ? doc(firestore, ref) : ref;
30+
const docRef = typeof ref === "string"
31+
? doc(firestore, ref)
32+
: ref;
3133
const { subscribe } = writable(startWith, (set) => {
3234
unsubscribe = onSnapshot(docRef, (snapshot) => {
3335
set(snapshot.data() ?? null);

docs/src/pages/firestore/collection-store.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layout: ../../layouts/MainLayout.astro
77

88
# collectionStore
99

10-
Subscribes to Firestore collection data and listens to realtime updates.
10+
Subscribes to Firestore collection data and listens to real-time updates.
1111

1212
### Parameters
1313

@@ -22,10 +22,10 @@ Subscribes to Firestore collection data and listens to realtime updates.
2222
import { collectionStore } from 'sveltefire';
2323
import { firestore } from '$lib/firebase'; // your firestore instance
2424
25-
const post = collectionStore(firestore, 'posts');
25+
const posts = collectionStore(firestore, 'posts');
2626
</script>
2727
28-
{#each $post as post}
28+
{#each $posts as post}
2929
<p>{post.title}</p>
3030
{/each}
3131
```
@@ -56,8 +56,10 @@ With TypeScript:
5656
content?: string;
5757
}
5858
59-
const post = collectionStore<Post>(firestore, 'posts');
59+
const posts = collectionStore<Post[]>(firestore, 'posts');
6060
</script>
6161
62-
{$post?.title}
63-
```
62+
{#each $posts as post}
63+
<p>{post.title}</p>
64+
{/each}
65+
```

docs/src/pages/guide/start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ npm i sveltefire firebase
1818

1919
### 2. Initialize
2020

21-
Initialize Firebase and add the `FirebaseApp` component to the component tree. Typically, this is done in the root `+layout.svelte` file to access Firebase in all pages.
21+
Initialize Firebase and add the `FirebaseApp` component to the component tree. Typically, this is done in the root `+layout.svelte` file to access Firebase on all pages.
2222

2323
#### +layout.svelte
2424
```svelte
@@ -30,7 +30,7 @@ Initialize Firebase and add the `FirebaseApp` component to the component tree. T
3030
3131
// Initialize Firebase
3232
const app = initializeApp(/* your firebase config */);
33-
const db = getFirestore(app);
33+
const firestore = getFirestore(app);
3434
const auth = getAuth(app);
3535
</script>
3636

playwright.config.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import type { PlaywrightTestConfig } from '@playwright/test';
1+
import { defineConfig } from '@playwright/test';
22

3-
const config: PlaywrightTestConfig = {
3+
export default defineConfig({
44
webServer: {
55
command: 'npm run build && npm run preview',
66
port: 4173
77
},
88
testDir: 'tests',
99
testMatch: /(.+\.)?(test|spec)\.[jt]s/
10-
};
11-
12-
export default config;
10+
});

0 commit comments

Comments
 (0)