svelte-firekit 0.0.1 → 0.0.3
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/README.md +82 -34
- 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/public/footer-main.svelte +0 -0
- package/dist/components/public/footer-main.svelte.d.ts +26 -0
- package/dist/components/public/nav-main.svelte +136 -0
- package/dist/components/public/nav-main.svelte.d.ts +18 -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,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.3",
|
|
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();
|
package/dist/auth.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handles Google Sign-In.
|
|
3
|
-
*/
|
|
4
|
-
export declare function signInWithGoogle(): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Signs in with email and password.
|
|
7
|
-
*/
|
|
8
|
-
export declare function signInWithEmail(email: string, password: string): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Registers a new user and updates Firestore.
|
|
11
|
-
*/
|
|
12
|
-
export declare function registerWithEmail(email: string, password: string, displayName: string): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Signs out the user and redirects.
|
|
15
|
-
*/
|
|
16
|
-
export declare function logOut(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Sends a password reset email.
|
|
19
|
-
*/
|
|
20
|
-
export declare function sendPasswordReset(email: string): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Verifies email for current user.
|
|
23
|
-
*/
|
|
24
|
-
export declare function sendEmailVerificationToUser(): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Updates user profile with display name and photo URL.
|
|
27
|
-
*/
|
|
28
|
-
export declare function updateUserProfile(profile: {
|
|
29
|
-
displayName?: string;
|
|
30
|
-
photoURL?: string;
|
|
31
|
-
}): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Updates password for current user.
|
|
34
|
-
*/
|
|
35
|
-
export declare function updateUserPassword(newPassword: string): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Checks onboarding completion by verifying profile data.
|
|
38
|
-
*/
|
|
39
|
-
export declare function checkOnboardingCompletion(uid: string): Promise<void>;
|
package/dist/auth.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// firebaseAuthService.ts
|
|
2
|
-
import { GoogleAuthProvider, sendPasswordResetEmail, signInWithEmailAndPassword, signInWithPopup, signOut, createUserWithEmailAndPassword, sendEmailVerification, updateProfile, updatePassword } from 'firebase/auth';
|
|
3
|
-
import { doc, getDoc, setDoc } from 'firebase/firestore';
|
|
4
|
-
import { getAuthInstance, getDb } from './firebase.js';
|
|
5
|
-
import { goto } from '$app/navigation';
|
|
6
|
-
const auth = getAuthInstance();
|
|
7
|
-
const firestore = getDb();
|
|
8
|
-
/**
|
|
9
|
-
* Handles Google Sign-In.
|
|
10
|
-
*/
|
|
11
|
-
export async function signInWithGoogle() {
|
|
12
|
-
const provider = new GoogleAuthProvider();
|
|
13
|
-
const result = await signInWithPopup(auth, provider);
|
|
14
|
-
await updateUserInFirestore(result.user);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Signs in with email and password.
|
|
18
|
-
*/
|
|
19
|
-
export async function signInWithEmail(email, password) {
|
|
20
|
-
const result = await signInWithEmailAndPassword(auth, email, password);
|
|
21
|
-
await updateUserInFirestore(result.user);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Registers a new user and updates Firestore.
|
|
25
|
-
*/
|
|
26
|
-
export async function registerWithEmail(email, password, displayName) {
|
|
27
|
-
const result = await createUserWithEmailAndPassword(auth, email, password);
|
|
28
|
-
const user = result.user;
|
|
29
|
-
if (user) {
|
|
30
|
-
await updateProfile(user, { displayName });
|
|
31
|
-
await updateUserInFirestore(user);
|
|
32
|
-
await sendEmailVerification(user);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Updates Firestore with user data.
|
|
37
|
-
*/
|
|
38
|
-
async function updateUserInFirestore(user) {
|
|
39
|
-
const ref = doc(firestore, 'users', user.uid);
|
|
40
|
-
const userData = {
|
|
41
|
-
uid: user.uid,
|
|
42
|
-
email: user.email,
|
|
43
|
-
emailVerified: user.emailVerified,
|
|
44
|
-
displayName: user.displayName,
|
|
45
|
-
photoURL: user.photoURL,
|
|
46
|
-
isAnonymous: user.isAnonymous,
|
|
47
|
-
providerId: user.providerId,
|
|
48
|
-
phoneNumber: user.phoneNumber,
|
|
49
|
-
providerData: user.providerData
|
|
50
|
-
};
|
|
51
|
-
await setDoc(ref, userData, { merge: true });
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Signs out the user and redirects.
|
|
55
|
-
*/
|
|
56
|
-
export async function logOut() {
|
|
57
|
-
await signOut(auth);
|
|
58
|
-
goto('/sign-in');
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Sends a password reset email.
|
|
62
|
-
*/
|
|
63
|
-
export async function sendPasswordReset(email) {
|
|
64
|
-
await sendPasswordResetEmail(auth, email);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Verifies email for current user.
|
|
68
|
-
*/
|
|
69
|
-
export async function sendEmailVerificationToUser() {
|
|
70
|
-
if (auth.currentUser) {
|
|
71
|
-
await sendEmailVerification(auth.currentUser);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Updates user profile with display name and photo URL.
|
|
76
|
-
*/
|
|
77
|
-
export async function updateUserProfile(profile) {
|
|
78
|
-
if (auth.currentUser) {
|
|
79
|
-
await updateProfile(auth.currentUser, profile);
|
|
80
|
-
await updateUserInFirestore(auth.currentUser);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Updates password for current user.
|
|
85
|
-
*/
|
|
86
|
-
export async function updateUserPassword(newPassword) {
|
|
87
|
-
if (auth.currentUser) {
|
|
88
|
-
await updatePassword(auth.currentUser, newPassword);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Checks onboarding completion by verifying profile data.
|
|
93
|
-
*/
|
|
94
|
-
export async function checkOnboardingCompletion(uid) {
|
|
95
|
-
const profileDoc = await getDoc(doc(firestore, 'profiles', uid));
|
|
96
|
-
if (!profileDoc.exists() || !profileDoc.data()?.username) {
|
|
97
|
-
alert("Please complete onboarding");
|
|
98
|
-
goto('/onboarding');
|
|
99
|
-
}
|
|
100
|
-
}
|
package/dist/config.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { PUBLIC_FIREBASE_API_KEY, PUBLIC_FIREBASE_AUTH_DOMAIN, PUBLIC_FIREBASE_PROJECT_ID, PUBLIC_FIREBASE_STORAGE_BUCKET, PUBLIC_FIREBASE_MESSAGING_SENDER_ID, PUBLIC_FIREBASE_APP_ID, PUBLIC_FIREBASE_MEASUREMENT_ID } from '$env/static/public';
|
|
2
|
-
/**
|
|
3
|
-
* Checks for any missing Firebase environment variables and returns an array of missing variables.
|
|
4
|
-
* @returns {string[]} An array of missing variable names. Empty if none are missing.
|
|
5
|
-
*/
|
|
6
|
-
function getMissingFirebaseConfigVars() {
|
|
7
|
-
const missingVars = [];
|
|
8
|
-
// Check each Firebase config variable and add to missingVars array if undefined
|
|
9
|
-
if (!PUBLIC_FIREBASE_API_KEY)
|
|
10
|
-
missingVars.push('PUBLIC_FIREBASE_API_KEY');
|
|
11
|
-
if (!PUBLIC_FIREBASE_AUTH_DOMAIN)
|
|
12
|
-
missingVars.push('PUBLIC_FIREBASE_AUTH_DOMAIN');
|
|
13
|
-
if (!PUBLIC_FIREBASE_PROJECT_ID)
|
|
14
|
-
missingVars.push('PUBLIC_FIREBASE_PROJECT_ID');
|
|
15
|
-
if (!PUBLIC_FIREBASE_STORAGE_BUCKET)
|
|
16
|
-
missingVars.push('PUBLIC_FIREBASE_STORAGE_BUCKET');
|
|
17
|
-
if (!PUBLIC_FIREBASE_MESSAGING_SENDER_ID)
|
|
18
|
-
missingVars.push('PUBLIC_FIREBASE_MESSAGING_SENDER_ID');
|
|
19
|
-
if (!PUBLIC_FIREBASE_APP_ID)
|
|
20
|
-
missingVars.push('PUBLIC_FIREBASE_APP_ID');
|
|
21
|
-
if (!PUBLIC_FIREBASE_MEASUREMENT_ID)
|
|
22
|
-
missingVars.push('PUBLIC_FIREBASE_MEASUREMENT_ID'); // Optional but included for clarity
|
|
23
|
-
return missingVars;
|
|
24
|
-
}
|
|
25
|
-
// Use the function to check for missing variables and throw an error if any are missing
|
|
26
|
-
const missingVars = getMissingFirebaseConfigVars();
|
|
27
|
-
if (missingVars.length > 0) {
|
|
28
|
-
throw Error(`The following Firebase configuration variables are missing: ${missingVars.join(', ')}`);
|
|
29
|
-
}
|
|
30
|
-
// Define Firebase configuration
|
|
31
|
-
export const firebaseConfig = {
|
|
32
|
-
apiKey: PUBLIC_FIREBASE_API_KEY,
|
|
33
|
-
authDomain: PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
34
|
-
projectId: PUBLIC_FIREBASE_PROJECT_ID,
|
|
35
|
-
storageBucket: PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
36
|
-
messagingSenderId: PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
37
|
-
appId: PUBLIC_FIREBASE_APP_ID,
|
|
38
|
-
measurementId: PUBLIC_FIREBASE_MEASUREMENT_ID
|
|
39
|
-
};
|
package/dist/firebase.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type FirebaseApp } from 'firebase/app';
|
|
2
|
-
import { type Firestore } from 'firebase/firestore';
|
|
3
|
-
import { type Auth } from 'firebase/auth';
|
|
4
|
-
import { type Functions } from 'firebase/functions';
|
|
5
|
-
import { type Database } from 'firebase/database';
|
|
6
|
-
import { type FirebaseStorage } from 'firebase/storage';
|
|
7
|
-
/**
|
|
8
|
-
* Initializes and returns the Firebase app instance.
|
|
9
|
-
* Ensures only one app instance is created and reused across invocations.
|
|
10
|
-
* @returns {FirebaseApp} The initialized Firebase application.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getFirebaseApp(): FirebaseApp;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves the Firestore database instance.
|
|
15
|
-
* Calls `getFirebaseApp` to ensure the app and Firestore are initialized.
|
|
16
|
-
* @returns {Firestore} The Firestore instance.
|
|
17
|
-
*/
|
|
18
|
-
export declare function getDb(): Firestore;
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves the Auth instance, initializing it if needed.
|
|
21
|
-
* @returns {Auth} The Auth instance.
|
|
22
|
-
*/
|
|
23
|
-
export declare function getAuthInstance(): Auth;
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the Functions instance, initializing it if needed.
|
|
26
|
-
* @returns {Functions} The Functions instance.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getFunctionsInstance(): Functions;
|
|
29
|
-
/**
|
|
30
|
-
* Retrieves the Database instance, initializing it if needed.
|
|
31
|
-
* @returns {Database} The Database instance.
|
|
32
|
-
*/
|
|
33
|
-
export declare function getDatabaseInstance(): Database;
|
|
34
|
-
/**
|
|
35
|
-
* Retrieves the Storage instance, initializing it if needed.
|
|
36
|
-
* @returns {FirebaseStorage} The Storage instance.
|
|
37
|
-
*/
|
|
38
|
-
export declare function getStorageInstance(): FirebaseStorage;
|
|
39
|
-
/**
|
|
40
|
-
* Creates a new Firestore batch instance for performing atomic writes.
|
|
41
|
-
* @returns {WriteBatch} A new write batch instance.
|
|
42
|
-
*/
|
|
43
|
-
export declare function getBatch(): import("@firebase/firestore").WriteBatch;
|