svelte-firekit 0.0.1 → 0.0.2
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.
- package/dist/auth/reset-password.svelte +1 -1
- package/dist/auth/sign-in.svelte +2 -2
- package/dist/auth/sign-in.svelte.d.ts +1 -1
- package/dist/components/auth/google-sign-in.svelte +15 -1
- package/dist/components/auth/reset-password-form.svelte +16 -17
- package/dist/components/auth/sign-in-form.svelte +24 -23
- package/dist/components/auth/sign-up-form.svelte +52 -45
- package/dist/{auth → components/auth}/user-button.svelte +35 -34
- package/dist/{auth → components/auth}/user-button.svelte.d.ts +2 -2
- package/dist/components/firestore/collection.svelte +45 -0
- package/dist/components/firestore/collection.svelte.d.ts +25 -0
- package/dist/components/firestore/doc.svelte +39 -0
- package/dist/components/firestore/doc.svelte.d.ts +25 -0
- package/dist/components/nav/app-sidebar.svelte +46 -0
- package/dist/components/nav/app-sidebar.svelte.d.ts +8 -0
- package/dist/components/nav/breadcrumb.svelte +42 -0
- package/dist/components/nav/breadcrumb.svelte.d.ts +19 -0
- package/dist/components/nav/dark-mode-toggle.svelte +16 -0
- package/dist/components/nav/dark-mode-toggle.svelte.d.ts +18 -0
- package/dist/components/nav/nav.d.ts +11 -0
- package/dist/components/nav/nav.js +157 -0
- package/dist/components/nav/search-form.svelte +21 -0
- package/dist/components/nav/search-form.svelte.d.ts +4 -0
- package/dist/components/nav/version-switcher.svelte +48 -0
- package/dist/components/nav/version-switcher.svelte.d.ts +5 -0
- package/dist/components/storage/upload.svelte +134 -0
- package/dist/components/storage/upload.svelte.d.ts +11 -0
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte +23 -0
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-item.svelte +16 -0
- package/dist/components/ui/breadcrumb/breadcrumb-item.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte +31 -0
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte.d.ts +10 -0
- package/dist/components/ui/breadcrumb/breadcrumb-list.svelte +23 -0
- package/dist/components/ui/breadcrumb/breadcrumb-list.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte +23 -0
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte +27 -0
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb.svelte +15 -0
- package/dist/components/ui/breadcrumb/breadcrumb.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/index.d.ts +8 -0
- package/dist/components/ui/breadcrumb/index.js +10 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +10 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +4 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +1 -0
- package/dist/components/ui/input/input.svelte.d.ts +1 -1
- package/dist/components/ui/separator/index.d.ts +2 -0
- package/dist/components/ui/separator/index.js +4 -0
- package/dist/components/ui/separator/separator.svelte +22 -0
- package/dist/components/ui/separator/separator.svelte.d.ts +3 -0
- package/dist/components/ui/sheet/index.js +14 -0
- package/dist/components/ui/sheet/sheet-content.svelte +52 -0
- package/dist/components/ui/sheet/sheet-content.svelte.d.ts +59 -0
- package/dist/components/ui/sheet/sheet-description.svelte +16 -0
- package/dist/components/ui/sheet/sheet-description.svelte.d.ts +3 -0
- package/dist/components/ui/sheet/sheet-footer.svelte +20 -0
- package/dist/components/ui/sheet/sheet-footer.svelte.d.ts +4 -0
- package/dist/components/ui/sheet/sheet-header.svelte +20 -0
- package/dist/components/ui/sheet/sheet-header.svelte.d.ts +4 -0
- package/dist/components/ui/sheet/sheet-overlay.svelte +19 -0
- package/dist/components/ui/sheet/sheet-overlay.svelte.d.ts +3 -0
- package/dist/components/ui/sheet/sheet-title.svelte +16 -0
- package/dist/components/ui/sheet/sheet-title.svelte.d.ts +3 -0
- package/dist/components/ui/sidebar/constants.d.ts +6 -0
- package/dist/components/ui/sidebar/constants.js +6 -0
- package/dist/components/ui/sidebar/context.svelte.d.ts +42 -0
- package/dist/components/ui/sidebar/context.svelte.js +54 -0
- package/dist/components/ui/sidebar/index.d.ts +25 -0
- package/dist/components/ui/sidebar/index.js +27 -0
- package/dist/components/ui/sidebar/sidebar-content.svelte +24 -0
- package/dist/components/ui/sidebar/sidebar-content.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-footer.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-footer.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-group-action.svelte +36 -0
- package/dist/components/ui/sidebar/sidebar-group-action.svelte.d.ts +10 -0
- package/dist/components/ui/sidebar/sidebar-group-content.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-group-content.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-group-label.svelte +34 -0
- package/dist/components/ui/sidebar/sidebar-group-label.svelte.d.ts +10 -0
- package/dist/components/ui/sidebar/sidebar-group.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-group.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-header.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-header.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-input.svelte +23 -0
- package/dist/components/ui/sidebar/sidebar-input.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-inset.svelte +24 -0
- package/dist/components/ui/sidebar/sidebar-inset.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte +43 -0
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte.d.ts +11 -0
- package/dist/components/ui/sidebar/sidebar-menu-badge.svelte +29 -0
- package/dist/components/ui/sidebar/sidebar-menu-badge.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte +97 -0
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte.d.ts +91 -0
- package/dist/components/ui/sidebar/sidebar-menu-item.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-menu-item.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte +36 -0
- package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte.d.ts +7 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte +43 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte +14 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.svelte +25 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-menu.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-provider.svelte +59 -0
- package/dist/components/ui/sidebar/sidebar-provider.svelte.d.ts +9 -0
- package/dist/components/ui/sidebar/sidebar-rail.svelte +36 -0
- package/dist/components/ui/sidebar/sidebar-rail.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-separator.svelte +18 -0
- package/dist/components/ui/sidebar/sidebar-separator.svelte.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-trigger.svelte +34 -0
- package/dist/components/ui/sidebar/sidebar-trigger.svelte.d.ts +9 -0
- package/dist/components/ui/sidebar/sidebar.svelte +98 -0
- package/dist/components/ui/sidebar/sidebar.svelte.d.ts +9 -0
- package/dist/components/ui/skeleton/index.d.ts +2 -0
- package/dist/components/ui/skeleton/index.js +4 -0
- package/dist/components/ui/skeleton/skeleton.svelte +17 -0
- package/dist/components/ui/skeleton/skeleton.svelte.d.ts +4 -0
- package/dist/components/ui/tooltip/index.js +8 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte +21 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +3 -0
- package/dist/firebase/auth/auth-guard.svelte.d.ts +25 -0
- package/dist/firebase/auth/auth-guard.svelte.js +79 -0
- package/dist/firebase/auth/auth.d.ts +21 -0
- package/dist/firebase/auth/auth.js +71 -0
- package/dist/firebase/auth/user.svelte.d.ts +50 -0
- package/dist/firebase/auth/user.svelte.js +115 -0
- package/dist/firebase/config.js +44 -0
- package/dist/firebase/firebase.d.ts +28 -0
- package/dist/firebase/firebase.js +86 -0
- package/dist/firebase/firestore/awaitable-doc.svelte.d.ts +15 -0
- package/dist/firebase/firestore/awaitable-doc.svelte.js +57 -0
- package/dist/firebase/firestore/collection.svelte.d.ts +17 -0
- package/dist/firebase/firestore/collection.svelte.js +58 -0
- package/dist/firebase/firestore/doc.svelte.d.ts +16 -0
- package/dist/firebase/firestore/doc.svelte.js +56 -0
- package/dist/firebase/firestore/document-mutations.svelte.d.ts +18 -0
- package/dist/firebase/firestore/document-mutations.svelte.js +58 -0
- package/dist/firebase/storage/download-url.svelte.d.ts +14 -0
- package/dist/firebase/storage/download-url.svelte.js +45 -0
- package/dist/firebase/storage/storage-list.svelte.d.ts +17 -0
- package/dist/firebase/storage/storage-list.svelte.js +51 -0
- package/dist/firebase/storage/upload-task.svelte.d.ts +22 -0
- package/dist/firebase/storage/upload-task.svelte.js +65 -0
- package/dist/hooks/is-mobile.svelte.d.ts +5 -0
- package/dist/hooks/is-mobile.svelte.js +23 -0
- package/dist/index.d.ts +22 -2
- package/dist/index.js +29 -3
- package/dist/types/docs.d.ts +50 -0
- package/dist/utils.d.ts +27 -1
- package/dist/utils.js +85 -9
- package/package.json +9 -7
- package/dist/auth/uid.js +0 -7
- package/dist/auth/user.svelte.d.ts +0 -10
- package/dist/auth/user.svelte.js +0 -21
- package/dist/auth.d.ts +0 -39
- package/dist/auth.js +0 -100
- package/dist/config.js +0 -39
- package/dist/firebase.d.ts +0 -43
- package/dist/firebase.js +0 -110
- package/dist/firestore/Collection.svelte +0 -148
- package/dist/firestore/Collection.svelte.d.ts +0 -27
- package/dist/firestore/collection.svelte.js +0 -207
- package/dist/firestore/doc.svelte.d.ts +0 -1
- package/dist/firestore/doc.svelte.js +0 -1
- package/dist/firestore/firestore.d.ts +0 -31
- package/dist/firestore/firestore.js +0 -100
- package/dist/firestore/perf.d.ts +0 -3
- package/dist/firestore/perf.js +0 -12
- /package/dist/{config.d.ts → firebase/config.d.ts} +0 -0
- /package/dist/{auth/uid.d.ts → types/docs.js} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { addDoc, setDoc, updateDoc, deleteDoc, doc, getDoc, collection, serverTimestamp } from "firebase/firestore";
|
|
2
|
+
import { firebaseService } from "../firebase.js";
|
|
3
|
+
import { firekitUser } from "../auth/user.svelte.js";
|
|
4
|
+
class FirekitDocumentMutations {
|
|
5
|
+
constructor() { }
|
|
6
|
+
async add(collectionPath, data, options = { timestamps: true }) {
|
|
7
|
+
const firestore = firebaseService.getDb();
|
|
8
|
+
const colRef = collection(firestore, collectionPath);
|
|
9
|
+
const dataToAdd = {
|
|
10
|
+
...data,
|
|
11
|
+
...(options.timestamps && {
|
|
12
|
+
createdAt: serverTimestamp(),
|
|
13
|
+
createdBy: firekitUser.uid,
|
|
14
|
+
updatedAt: serverTimestamp(),
|
|
15
|
+
updatedBy: firekitUser.uid
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
return addDoc(colRef, dataToAdd);
|
|
19
|
+
}
|
|
20
|
+
async set(path, data, options = { merge: false, timestamps: true }) {
|
|
21
|
+
const firestore = firebaseService.getDb();
|
|
22
|
+
const docRef = doc(firestore, path);
|
|
23
|
+
const dataToSet = {
|
|
24
|
+
...data,
|
|
25
|
+
...(options.timestamps && {
|
|
26
|
+
createdAt: serverTimestamp(),
|
|
27
|
+
createdBy: firekitUser.uid,
|
|
28
|
+
updatedAt: serverTimestamp(),
|
|
29
|
+
updatedBy: firekitUser.uid
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
return setDoc(docRef, dataToSet, { merge: options.merge });
|
|
33
|
+
}
|
|
34
|
+
async update(path, data, options = { timestamps: true }) {
|
|
35
|
+
const firestore = firebaseService.getDb();
|
|
36
|
+
const docRef = doc(firestore, path);
|
|
37
|
+
const dataToUpdate = {
|
|
38
|
+
...data,
|
|
39
|
+
...(options.timestamps && {
|
|
40
|
+
updatedAt: serverTimestamp(),
|
|
41
|
+
updatedBy: firekitUser.uid
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
return updateDoc(docRef, dataToUpdate);
|
|
45
|
+
}
|
|
46
|
+
async delete(path) {
|
|
47
|
+
const firestore = firebaseService.getDb();
|
|
48
|
+
const docRef = doc(firestore, path);
|
|
49
|
+
return deleteDoc(docRef);
|
|
50
|
+
}
|
|
51
|
+
async exists(path) {
|
|
52
|
+
const firestore = firebaseService.getDb();
|
|
53
|
+
const docRef = doc(firestore, path);
|
|
54
|
+
const docSnap = await getDoc(docRef);
|
|
55
|
+
return docSnap.exists();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export const firekitDocMutations = new FirekitDocumentMutations();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class FirekitDownloadUrl {
|
|
2
|
+
private _url;
|
|
3
|
+
private _loading;
|
|
4
|
+
private _error;
|
|
5
|
+
private storageRef;
|
|
6
|
+
constructor(path: string);
|
|
7
|
+
private initializeDownload;
|
|
8
|
+
get url(): string | null;
|
|
9
|
+
get loading(): boolean;
|
|
10
|
+
get error(): Error | null;
|
|
11
|
+
refresh(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function firekitDownloadUrl(path: string): FirekitDownloadUrl;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ref, getDownloadURL } from "firebase/storage";
|
|
2
|
+
import { browser } from "$app/environment";
|
|
3
|
+
import { firebaseService } from "../firebase.js";
|
|
4
|
+
class FirekitDownloadUrl {
|
|
5
|
+
_url = $state(null);
|
|
6
|
+
_loading = $state(true);
|
|
7
|
+
_error = $state(null);
|
|
8
|
+
storageRef = null;
|
|
9
|
+
constructor(path) {
|
|
10
|
+
if (browser) {
|
|
11
|
+
this.initializeDownload(path);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async initializeDownload(path) {
|
|
15
|
+
try {
|
|
16
|
+
const storage = firebaseService.getStorageInstance();
|
|
17
|
+
this.storageRef = ref(storage, path);
|
|
18
|
+
this._url = await getDownloadURL(this.storageRef);
|
|
19
|
+
this._loading = false;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
this._error = error;
|
|
23
|
+
this._loading = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
get url() {
|
|
27
|
+
return this._url;
|
|
28
|
+
}
|
|
29
|
+
get loading() {
|
|
30
|
+
return this._loading;
|
|
31
|
+
}
|
|
32
|
+
get error() {
|
|
33
|
+
return this._error;
|
|
34
|
+
}
|
|
35
|
+
refresh() {
|
|
36
|
+
if (this.storageRef) {
|
|
37
|
+
this._loading = true;
|
|
38
|
+
this._error = null;
|
|
39
|
+
this.initializeDownload(this.storageRef.fullPath);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function firekitDownloadUrl(path) {
|
|
44
|
+
return new FirekitDownloadUrl(path);
|
|
45
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type StorageReference } from "firebase/storage";
|
|
2
|
+
declare class FirekitStorageList {
|
|
3
|
+
private _items;
|
|
4
|
+
private _prefixes;
|
|
5
|
+
private _loading;
|
|
6
|
+
private _error;
|
|
7
|
+
private storageRef;
|
|
8
|
+
constructor(path: string);
|
|
9
|
+
private initializeList;
|
|
10
|
+
get items(): StorageReference[];
|
|
11
|
+
get prefixes(): StorageReference[];
|
|
12
|
+
get loading(): boolean;
|
|
13
|
+
get error(): Error | null;
|
|
14
|
+
refresh(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function firekitStorageList(path: string): FirekitStorageList;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ref, listAll } from "firebase/storage";
|
|
2
|
+
import { browser } from "$app/environment";
|
|
3
|
+
import { firebaseService } from "../firebase.js";
|
|
4
|
+
class FirekitStorageList {
|
|
5
|
+
_items = $state([]);
|
|
6
|
+
_prefixes = $state([]);
|
|
7
|
+
_loading = $state(true);
|
|
8
|
+
_error = $state(null);
|
|
9
|
+
storageRef = null;
|
|
10
|
+
constructor(path) {
|
|
11
|
+
if (browser) {
|
|
12
|
+
this.initializeList(path);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async initializeList(path) {
|
|
16
|
+
try {
|
|
17
|
+
const storage = firebaseService.getStorageInstance();
|
|
18
|
+
this.storageRef = ref(storage, path);
|
|
19
|
+
const result = await listAll(this.storageRef);
|
|
20
|
+
this._items = result.items;
|
|
21
|
+
this._prefixes = result.prefixes;
|
|
22
|
+
this._loading = false;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
this._error = error;
|
|
26
|
+
this._loading = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
get items() {
|
|
30
|
+
return this._items;
|
|
31
|
+
}
|
|
32
|
+
get prefixes() {
|
|
33
|
+
return this._prefixes;
|
|
34
|
+
}
|
|
35
|
+
get loading() {
|
|
36
|
+
return this._loading;
|
|
37
|
+
}
|
|
38
|
+
get error() {
|
|
39
|
+
return this._error;
|
|
40
|
+
}
|
|
41
|
+
refresh() {
|
|
42
|
+
if (this.storageRef) {
|
|
43
|
+
this._loading = true;
|
|
44
|
+
this._error = null;
|
|
45
|
+
this.initializeList(this.storageRef.fullPath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function firekitStorageList(path) {
|
|
50
|
+
return new FirekitStorageList(path);
|
|
51
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type UploadTaskSnapshot } from "firebase/storage";
|
|
2
|
+
declare class FirekitUploadTask {
|
|
3
|
+
private _progress;
|
|
4
|
+
private _error;
|
|
5
|
+
private _snapshot;
|
|
6
|
+
private _downloadURL;
|
|
7
|
+
private _completed;
|
|
8
|
+
private uploadTask;
|
|
9
|
+
private storageRef;
|
|
10
|
+
constructor(path: string, file: File);
|
|
11
|
+
private initializeUpload;
|
|
12
|
+
pause(): void;
|
|
13
|
+
resume(): void;
|
|
14
|
+
cancel(): void;
|
|
15
|
+
get progress(): number;
|
|
16
|
+
get error(): Error | null;
|
|
17
|
+
get snapshot(): UploadTaskSnapshot | null;
|
|
18
|
+
get downloadURL(): string | null;
|
|
19
|
+
get completed(): boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function firekitUploadTask(path: string, file: File): FirekitUploadTask;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ref, uploadBytesResumable, getDownloadURL } from "firebase/storage";
|
|
2
|
+
import { browser } from "$app/environment";
|
|
3
|
+
import { firebaseService } from "../firebase.js";
|
|
4
|
+
class FirekitUploadTask {
|
|
5
|
+
_progress = $state(0);
|
|
6
|
+
_error = $state(null);
|
|
7
|
+
_snapshot = $state(null);
|
|
8
|
+
_downloadURL = $state(null);
|
|
9
|
+
_completed = $state(false);
|
|
10
|
+
uploadTask = null;
|
|
11
|
+
storageRef = null;
|
|
12
|
+
constructor(path, file) {
|
|
13
|
+
if (browser) {
|
|
14
|
+
this.initializeUpload(path, file);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
initializeUpload(path, file) {
|
|
18
|
+
try {
|
|
19
|
+
const storage = firebaseService.getStorageInstance();
|
|
20
|
+
this.storageRef = ref(storage, path);
|
|
21
|
+
this.uploadTask = uploadBytesResumable(this.storageRef, file);
|
|
22
|
+
this.uploadTask.on('state_changed', (snapshot) => {
|
|
23
|
+
this._snapshot = snapshot;
|
|
24
|
+
this._progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
|
25
|
+
}, (error) => {
|
|
26
|
+
this._error = error;
|
|
27
|
+
}, async () => {
|
|
28
|
+
if (this.storageRef) {
|
|
29
|
+
this._downloadURL = await getDownloadURL(this.storageRef);
|
|
30
|
+
this._completed = true;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
this._error = error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
pause() {
|
|
39
|
+
this.uploadTask?.pause();
|
|
40
|
+
}
|
|
41
|
+
resume() {
|
|
42
|
+
this.uploadTask?.resume();
|
|
43
|
+
}
|
|
44
|
+
cancel() {
|
|
45
|
+
this.uploadTask?.cancel();
|
|
46
|
+
}
|
|
47
|
+
get progress() {
|
|
48
|
+
return this._progress;
|
|
49
|
+
}
|
|
50
|
+
get error() {
|
|
51
|
+
return this._error;
|
|
52
|
+
}
|
|
53
|
+
get snapshot() {
|
|
54
|
+
return this._snapshot;
|
|
55
|
+
}
|
|
56
|
+
get downloadURL() {
|
|
57
|
+
return this._downloadURL;
|
|
58
|
+
}
|
|
59
|
+
get completed() {
|
|
60
|
+
return this._completed;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function firekitUploadTask(path, file) {
|
|
64
|
+
return new FirekitUploadTask(path, file);
|
|
65
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { untrack } from "svelte";
|
|
2
|
+
const MOBILE_BREAKPOINT = 768;
|
|
3
|
+
export class IsMobile {
|
|
4
|
+
#current = $state(false);
|
|
5
|
+
constructor() {
|
|
6
|
+
$effect(() => {
|
|
7
|
+
return untrack(() => {
|
|
8
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
9
|
+
const onChange = () => {
|
|
10
|
+
this.#current = window.innerWidth < MOBILE_BREAKPOINT;
|
|
11
|
+
};
|
|
12
|
+
mql.addEventListener("change", onChange);
|
|
13
|
+
onChange();
|
|
14
|
+
return () => {
|
|
15
|
+
mql.removeEventListener("change", onChange);
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
get current() {
|
|
21
|
+
return this.#current;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { firebaseConfig } from './firebase/config.js';
|
|
2
|
+
export { firebaseService } from './firebase/firebase.js';
|
|
3
|
+
export { firekitUser } from './firebase/auth/user.svelte.js';
|
|
4
|
+
export { firekitAuth } from './firebase/auth/auth.js';
|
|
5
|
+
export { firekitAuthGuard } from './firebase/auth/auth-guard.svelte.js';
|
|
6
|
+
export { firekitAwaitableDoc } from './firebase/firestore/awaitable-doc.svelte.js';
|
|
7
|
+
export { firekitDocMutations } from './firebase/firestore/document-mutations.svelte';
|
|
8
|
+
export { firekitCollection } from './firebase/firestore/collection.svelte.js';
|
|
9
|
+
export { firekitDoc } from './firebase/firestore/doc.svelte.js';
|
|
10
|
+
export { firekitDownloadUrl } from './firebase/storage/download-url.svelte.js';
|
|
11
|
+
export { firekitStorageList } from './firebase/storage/storage-list.svelte.js';
|
|
12
|
+
export { firekitUploadTask } from './firebase/storage/upload-task.svelte.js';
|
|
13
|
+
export { default as SignInPage } from './auth/sign-in.svelte';
|
|
14
|
+
export { default as SignUpPage } from './auth/sign-up.svelte';
|
|
15
|
+
export { default as ResetPassWordPage } from './auth/reset-password.svelte';
|
|
16
|
+
export { default as ResetPassWordForm } from './components/auth/reset-password-form.svelte';
|
|
17
|
+
export { default as SignInForm } from './components/auth/sign-in-form.svelte';
|
|
18
|
+
export { default as SignUpForm } from './components/auth/sign-up-form.svelte';
|
|
19
|
+
export { default as UserButton } from './components/auth/user-button.svelte';
|
|
20
|
+
export { default as Collection } from './components/firestore/collection.svelte';
|
|
21
|
+
export { default as Doc } from './components/firestore/doc.svelte';
|
|
22
|
+
export { default as Upload } from './components/storage/upload.svelte';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
//
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
// Firebase config
|
|
2
|
+
export { firebaseConfig } from './firebase/config.js';
|
|
3
|
+
export { firebaseService } from './firebase/firebase.js';
|
|
4
|
+
// auth services
|
|
5
|
+
export { firekitUser } from './firebase/auth/user.svelte.js';
|
|
6
|
+
export { firekitAuth } from './firebase/auth/auth.js';
|
|
7
|
+
export { firekitAuthGuard } from './firebase/auth/auth-guard.svelte.js';
|
|
8
|
+
// firestore services
|
|
9
|
+
export { firekitAwaitableDoc } from './firebase/firestore/awaitable-doc.svelte.js';
|
|
10
|
+
export { firekitDocMutations } from './firebase/firestore/document-mutations.svelte';
|
|
11
|
+
export { firekitCollection } from './firebase/firestore/collection.svelte.js';
|
|
12
|
+
export { firekitDoc } from './firebase/firestore/doc.svelte.js';
|
|
13
|
+
// Storage services
|
|
14
|
+
export { firekitDownloadUrl } from './firebase/storage/download-url.svelte.js';
|
|
15
|
+
export { firekitStorageList } from './firebase/storage/storage-list.svelte.js';
|
|
16
|
+
export { firekitUploadTask } from './firebase/storage/upload-task.svelte.js';
|
|
17
|
+
// auth components
|
|
18
|
+
export { default as SignInPage } from './auth/sign-in.svelte';
|
|
19
|
+
export { default as SignUpPage } from './auth/sign-up.svelte';
|
|
20
|
+
export { default as ResetPassWordPage } from './auth/reset-password.svelte';
|
|
21
|
+
export { default as ResetPassWordForm } from './components/auth/reset-password-form.svelte';
|
|
22
|
+
export { default as SignInForm } from './components/auth/sign-in-form.svelte';
|
|
23
|
+
export { default as SignUpForm } from './components/auth/sign-up-form.svelte';
|
|
24
|
+
export { default as UserButton } from './components/auth/user-button.svelte';
|
|
25
|
+
// firestore components
|
|
26
|
+
export { default as Collection } from './components/firestore/collection.svelte';
|
|
27
|
+
export { default as Doc } from './components/firestore/doc.svelte';
|
|
28
|
+
// storage
|
|
29
|
+
export { default as Upload } from './components/storage/upload.svelte';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type Metadata = {
|
|
2
|
+
title: string;
|
|
3
|
+
description: string;
|
|
4
|
+
openGraph: {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
type: 'article';
|
|
8
|
+
url: string;
|
|
9
|
+
images: [
|
|
10
|
+
{
|
|
11
|
+
url: string;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
alt: string;
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
};
|
|
18
|
+
twitter: {
|
|
19
|
+
card: 'summary_large_image';
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
images: string[];
|
|
23
|
+
creator: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type FrontMatter = {
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
slug: string;
|
|
30
|
+
component: boolean;
|
|
31
|
+
source: string;
|
|
32
|
+
external?: {
|
|
33
|
+
project: string;
|
|
34
|
+
url: string;
|
|
35
|
+
};
|
|
36
|
+
bits?: string;
|
|
37
|
+
};
|
|
38
|
+
export type DocFile = {
|
|
39
|
+
default: import('svelte').Component;
|
|
40
|
+
metadata: FrontMatter;
|
|
41
|
+
};
|
|
42
|
+
export type DocResolver = () => Promise<DocFile>;
|
|
43
|
+
export type TableOfContentsItem = {
|
|
44
|
+
title: string;
|
|
45
|
+
url: string;
|
|
46
|
+
items?: TableOfContentsItem[];
|
|
47
|
+
};
|
|
48
|
+
export type TableOfContents = {
|
|
49
|
+
items: TableOfContentsItem[];
|
|
50
|
+
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
import { type ClassValue } from "clsx";
|
|
2
2
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Options for initial generation
|
|
5
|
+
*/
|
|
6
|
+
type InitialsOptions = {
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
fallback?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Extracts initials from a given name string
|
|
12
|
+
* @param name - Full name to extract initials from
|
|
13
|
+
* @param options - Optional configuration for initial generation
|
|
14
|
+
* @returns Generated initials or fallback value
|
|
15
|
+
* @example
|
|
16
|
+
* getInitials("John Doe") // returns "JD"
|
|
17
|
+
* getInitials("Jane") // returns "J"
|
|
18
|
+
* getInitials("") // returns ""
|
|
19
|
+
* getInitials(null, { fallback: "NA" }) // returns "NA"
|
|
20
|
+
*/
|
|
21
|
+
export declare function getInitials(name: string | null | undefined, options?: InitialsOptions): string;
|
|
22
|
+
export declare function slugFromPath(path: string): string;
|
|
23
|
+
export declare function getDoc(slug: string): Promise<{
|
|
24
|
+
component: import("svelte").Component<{}, {}, string>;
|
|
25
|
+
metadata: import("./types/docs.js").FrontMatter;
|
|
26
|
+
title: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function slugFromPathname(pathname: string): string;
|
|
29
|
+
export {};
|
package/dist/utils.js
CHANGED
|
@@ -1,16 +1,92 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { error } from '@sveltejs/kit';
|
|
3
4
|
export function cn(...inputs) {
|
|
4
5
|
return twMerge(clsx(inputs));
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Extracts initials from a given name string
|
|
9
|
+
* @param name - Full name to extract initials from
|
|
10
|
+
* @param options - Optional configuration for initial generation
|
|
11
|
+
* @returns Generated initials or fallback value
|
|
12
|
+
* @example
|
|
13
|
+
* getInitials("John Doe") // returns "JD"
|
|
14
|
+
* getInitials("Jane") // returns "J"
|
|
15
|
+
* getInitials("") // returns ""
|
|
16
|
+
* getInitials(null, { fallback: "NA" }) // returns "NA"
|
|
17
|
+
*/
|
|
18
|
+
export function getInitials(name, options = {}) {
|
|
19
|
+
const { maxLength = 2, fallback = '' } = options;
|
|
20
|
+
try {
|
|
21
|
+
// Handle empty/invalid input
|
|
22
|
+
if (!name?.trim()) {
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
// Split and filter out empty parts
|
|
26
|
+
const nameParts = name
|
|
27
|
+
.trim()
|
|
28
|
+
.split(' ')
|
|
29
|
+
.filter(part => part.length > 0);
|
|
30
|
+
// Handle empty array after filtering
|
|
31
|
+
if (nameParts.length === 0) {
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
// Handle single word
|
|
35
|
+
if (nameParts.length === 1) {
|
|
36
|
+
const initial = nameParts[0].charAt(0).toUpperCase();
|
|
37
|
+
return initial || fallback;
|
|
38
|
+
}
|
|
39
|
+
// Get first and last initials
|
|
40
|
+
const firstInitial = nameParts[0].charAt(0).toUpperCase();
|
|
41
|
+
const lastInitial = nameParts[nameParts.length - 1].charAt(0).toUpperCase();
|
|
42
|
+
// Combine initials and ensure max length
|
|
43
|
+
const initials = (firstInitial + lastInitial).slice(0, maxLength);
|
|
44
|
+
return initials || fallback;
|
|
12
45
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Error generating initials:', error);
|
|
48
|
+
return fallback;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function slugFromPath(path) {
|
|
52
|
+
return path.replace('/src/content/', '').replace('.md', '');
|
|
53
|
+
}
|
|
54
|
+
export async function getDoc(slug) {
|
|
55
|
+
const modules = import.meta.glob(`/src/content/**/*.md`);
|
|
56
|
+
const match = findMatch(slug, modules);
|
|
57
|
+
const doc = await match?.resolver?.();
|
|
58
|
+
if (!doc || !doc.metadata) {
|
|
59
|
+
error(404);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
component: doc.default,
|
|
63
|
+
metadata: doc.metadata,
|
|
64
|
+
title: doc.metadata.title
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function findMatch(slug, modules) {
|
|
68
|
+
let match = {};
|
|
69
|
+
for (const [path, resolver] of Object.entries(modules)) {
|
|
70
|
+
if (slugFromPath(path) === slug) {
|
|
71
|
+
match = { path, resolver: resolver };
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!match.path) {
|
|
76
|
+
match = getIndexDocIfExists(slug, modules);
|
|
77
|
+
}
|
|
78
|
+
return match;
|
|
79
|
+
}
|
|
80
|
+
export function slugFromPathname(pathname) {
|
|
81
|
+
return pathname.split('/').pop() ?? '';
|
|
82
|
+
}
|
|
83
|
+
function getIndexDocIfExists(slug, modules) {
|
|
84
|
+
let match = {};
|
|
85
|
+
for (const [path, resolver] of Object.entries(modules)) {
|
|
86
|
+
if (path.includes(`/${slug}/index.md`)) {
|
|
87
|
+
match = { path, resolver: resolver };
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return match;
|
|
16
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-firekit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -29,18 +29,21 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"@sveltejs/kit": "^2.0.0",
|
|
33
|
+
"firebase": "^11.0.1",
|
|
34
|
+
"svelte": "^5.0.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@sveltejs/adapter-auto": "^3.0.0",
|
|
37
38
|
"@sveltejs/kit": "^2.0.0",
|
|
38
39
|
"@sveltejs/package": "^2.0.0",
|
|
39
40
|
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
41
|
+
"@tailwindcss/typography": "^0.5.15",
|
|
40
42
|
"autoprefixer": "^10.4.20",
|
|
41
|
-
"bits-ui": "^1.0.0-next.
|
|
43
|
+
"bits-ui": "^1.0.0-next.52",
|
|
42
44
|
"clsx": "^2.1.1",
|
|
43
45
|
"formsnap": "^2.0.0-next.1",
|
|
46
|
+
"lucide-svelte": "^0.456.0",
|
|
44
47
|
"mode-watcher": "^0.4.1",
|
|
45
48
|
"publint": "^0.2.0",
|
|
46
49
|
"svelte": "^5.0.0",
|
|
@@ -53,12 +56,11 @@
|
|
|
53
56
|
"tailwindcss": "^3.4.9",
|
|
54
57
|
"tailwindcss-animate": "^1.0.7",
|
|
55
58
|
"typescript": "^5.0.0",
|
|
56
|
-
"vite": "^5.0.11"
|
|
57
|
-
"zod": "^3.23.8"
|
|
59
|
+
"vite": "^5.0.11"
|
|
58
60
|
},
|
|
59
61
|
"dependencies": {
|
|
60
62
|
"firebase": "^11.0.1",
|
|
61
63
|
"lucide": "^0.454.0",
|
|
62
|
-
"
|
|
64
|
+
"mdsvex": "^0.12.3"
|
|
63
65
|
}
|
|
64
66
|
}
|
package/dist/auth/uid.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { get } from "svelte/store";
|
|
3
|
-
// import { authState } from "./user";
|
|
4
|
-
// export const getUid = () => {
|
|
5
|
-
// const u = get(authState);
|
|
6
|
-
// return (u && u.uid) || "anonymous"; // 'anonymous' allows support messages to be saved by non-logged-in users
|
|
7
|
-
// };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type User } from "firebase/auth";
|
|
2
|
-
export declare class FirebaseAuthUser {
|
|
3
|
-
#private;
|
|
4
|
-
constructor();
|
|
5
|
-
get isAuthenticated(): boolean;
|
|
6
|
-
get isAnonymousUser(): boolean | undefined;
|
|
7
|
-
get userId(): string | undefined;
|
|
8
|
-
get currentUser(): User | null | undefined;
|
|
9
|
-
}
|
|
10
|
-
export declare const authUser: FirebaseAuthUser;
|
package/dist/auth/user.svelte.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getAuthInstance } from "../firebase.js";
|
|
2
|
-
import { onAuthStateChanged } from "firebase/auth";
|
|
3
|
-
export class FirebaseAuthUser {
|
|
4
|
-
#currentUser = $state();
|
|
5
|
-
constructor() {
|
|
6
|
-
onAuthStateChanged(getAuthInstance(), (user) => (this.#currentUser = user));
|
|
7
|
-
}
|
|
8
|
-
get isAuthenticated() {
|
|
9
|
-
return this.currentUser !== null;
|
|
10
|
-
}
|
|
11
|
-
get isAnonymousUser() {
|
|
12
|
-
return this.currentUser?.isAnonymous;
|
|
13
|
-
}
|
|
14
|
-
get userId() {
|
|
15
|
-
return this.currentUser?.uid;
|
|
16
|
-
}
|
|
17
|
-
get currentUser() {
|
|
18
|
-
return this.#currentUser;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export const authUser = new FirebaseAuthUser();
|