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.
Files changed (178) hide show
  1. package/README.md +82 -34
  2. package/dist/auth/reset-password.svelte +1 -1
  3. package/dist/auth/sign-in.svelte +2 -2
  4. package/dist/auth/sign-in.svelte.d.ts +1 -1
  5. package/dist/components/auth/google-sign-in.svelte +15 -1
  6. package/dist/components/auth/reset-password-form.svelte +16 -17
  7. package/dist/components/auth/sign-in-form.svelte +24 -23
  8. package/dist/components/auth/sign-up-form.svelte +52 -45
  9. package/dist/{auth → components/auth}/user-button.svelte +35 -34
  10. package/dist/{auth → components/auth}/user-button.svelte.d.ts +2 -2
  11. package/dist/components/firestore/collection.svelte +45 -0
  12. package/dist/components/firestore/collection.svelte.d.ts +25 -0
  13. package/dist/components/firestore/doc.svelte +39 -0
  14. package/dist/components/firestore/doc.svelte.d.ts +25 -0
  15. package/dist/components/nav/app-sidebar.svelte +46 -0
  16. package/dist/components/nav/app-sidebar.svelte.d.ts +8 -0
  17. package/dist/components/nav/breadcrumb.svelte +42 -0
  18. package/dist/components/nav/breadcrumb.svelte.d.ts +19 -0
  19. package/dist/components/nav/dark-mode-toggle.svelte +16 -0
  20. package/dist/components/nav/dark-mode-toggle.svelte.d.ts +18 -0
  21. package/dist/components/nav/nav.d.ts +11 -0
  22. package/dist/components/nav/nav.js +157 -0
  23. package/dist/components/nav/search-form.svelte +21 -0
  24. package/dist/components/nav/search-form.svelte.d.ts +4 -0
  25. package/dist/components/nav/version-switcher.svelte +48 -0
  26. package/dist/components/nav/version-switcher.svelte.d.ts +5 -0
  27. package/dist/components/public/footer-main.svelte +0 -0
  28. package/dist/components/public/footer-main.svelte.d.ts +26 -0
  29. package/dist/components/public/nav-main.svelte +136 -0
  30. package/dist/components/public/nav-main.svelte.d.ts +18 -0
  31. package/dist/components/storage/upload.svelte +134 -0
  32. package/dist/components/storage/upload.svelte.d.ts +11 -0
  33. package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte +23 -0
  34. package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte.d.ts +4 -0
  35. package/dist/components/ui/breadcrumb/breadcrumb-item.svelte +16 -0
  36. package/dist/components/ui/breadcrumb/breadcrumb-item.svelte.d.ts +4 -0
  37. package/dist/components/ui/breadcrumb/breadcrumb-link.svelte +31 -0
  38. package/dist/components/ui/breadcrumb/breadcrumb-link.svelte.d.ts +10 -0
  39. package/dist/components/ui/breadcrumb/breadcrumb-list.svelte +23 -0
  40. package/dist/components/ui/breadcrumb/breadcrumb-list.svelte.d.ts +4 -0
  41. package/dist/components/ui/breadcrumb/breadcrumb-page.svelte +23 -0
  42. package/dist/components/ui/breadcrumb/breadcrumb-page.svelte.d.ts +4 -0
  43. package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte +27 -0
  44. package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte.d.ts +4 -0
  45. package/dist/components/ui/breadcrumb/breadcrumb.svelte +15 -0
  46. package/dist/components/ui/breadcrumb/breadcrumb.svelte.d.ts +4 -0
  47. package/dist/components/ui/breadcrumb/index.d.ts +8 -0
  48. package/dist/components/ui/breadcrumb/index.js +10 -0
  49. package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +10 -7
  50. package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +4 -3
  51. package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +1 -0
  52. package/dist/components/ui/input/input.svelte.d.ts +1 -1
  53. package/dist/components/ui/separator/index.d.ts +2 -0
  54. package/dist/components/ui/separator/index.js +4 -0
  55. package/dist/components/ui/separator/separator.svelte +22 -0
  56. package/dist/components/ui/separator/separator.svelte.d.ts +3 -0
  57. package/dist/components/ui/sheet/index.js +14 -0
  58. package/dist/components/ui/sheet/sheet-content.svelte +52 -0
  59. package/dist/components/ui/sheet/sheet-content.svelte.d.ts +59 -0
  60. package/dist/components/ui/sheet/sheet-description.svelte +16 -0
  61. package/dist/components/ui/sheet/sheet-description.svelte.d.ts +3 -0
  62. package/dist/components/ui/sheet/sheet-footer.svelte +20 -0
  63. package/dist/components/ui/sheet/sheet-footer.svelte.d.ts +4 -0
  64. package/dist/components/ui/sheet/sheet-header.svelte +20 -0
  65. package/dist/components/ui/sheet/sheet-header.svelte.d.ts +4 -0
  66. package/dist/components/ui/sheet/sheet-overlay.svelte +19 -0
  67. package/dist/components/ui/sheet/sheet-overlay.svelte.d.ts +3 -0
  68. package/dist/components/ui/sheet/sheet-title.svelte +16 -0
  69. package/dist/components/ui/sheet/sheet-title.svelte.d.ts +3 -0
  70. package/dist/components/ui/sidebar/constants.d.ts +6 -0
  71. package/dist/components/ui/sidebar/constants.js +6 -0
  72. package/dist/components/ui/sidebar/context.svelte.d.ts +42 -0
  73. package/dist/components/ui/sidebar/context.svelte.js +54 -0
  74. package/dist/components/ui/sidebar/index.d.ts +25 -0
  75. package/dist/components/ui/sidebar/index.js +27 -0
  76. package/dist/components/ui/sidebar/sidebar-content.svelte +24 -0
  77. package/dist/components/ui/sidebar/sidebar-content.svelte.d.ts +4 -0
  78. package/dist/components/ui/sidebar/sidebar-footer.svelte +21 -0
  79. package/dist/components/ui/sidebar/sidebar-footer.svelte.d.ts +4 -0
  80. package/dist/components/ui/sidebar/sidebar-group-action.svelte +36 -0
  81. package/dist/components/ui/sidebar/sidebar-group-action.svelte.d.ts +10 -0
  82. package/dist/components/ui/sidebar/sidebar-group-content.svelte +21 -0
  83. package/dist/components/ui/sidebar/sidebar-group-content.svelte.d.ts +4 -0
  84. package/dist/components/ui/sidebar/sidebar-group-label.svelte +34 -0
  85. package/dist/components/ui/sidebar/sidebar-group-label.svelte.d.ts +10 -0
  86. package/dist/components/ui/sidebar/sidebar-group.svelte +21 -0
  87. package/dist/components/ui/sidebar/sidebar-group.svelte.d.ts +4 -0
  88. package/dist/components/ui/sidebar/sidebar-header.svelte +21 -0
  89. package/dist/components/ui/sidebar/sidebar-header.svelte.d.ts +4 -0
  90. package/dist/components/ui/sidebar/sidebar-input.svelte +23 -0
  91. package/dist/components/ui/sidebar/sidebar-input.svelte.d.ts +4 -0
  92. package/dist/components/ui/sidebar/sidebar-inset.svelte +24 -0
  93. package/dist/components/ui/sidebar/sidebar-inset.svelte.d.ts +4 -0
  94. package/dist/components/ui/sidebar/sidebar-menu-action.svelte +43 -0
  95. package/dist/components/ui/sidebar/sidebar-menu-action.svelte.d.ts +11 -0
  96. package/dist/components/ui/sidebar/sidebar-menu-badge.svelte +29 -0
  97. package/dist/components/ui/sidebar/sidebar-menu-badge.svelte.d.ts +4 -0
  98. package/dist/components/ui/sidebar/sidebar-menu-button.svelte +97 -0
  99. package/dist/components/ui/sidebar/sidebar-menu-button.svelte.d.ts +91 -0
  100. package/dist/components/ui/sidebar/sidebar-menu-item.svelte +21 -0
  101. package/dist/components/ui/sidebar/sidebar-menu-item.svelte.d.ts +4 -0
  102. package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte +36 -0
  103. package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte.d.ts +7 -0
  104. package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte +43 -0
  105. package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte.d.ts +12 -0
  106. package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte +14 -0
  107. package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte.d.ts +4 -0
  108. package/dist/components/ui/sidebar/sidebar-menu-sub.svelte +25 -0
  109. package/dist/components/ui/sidebar/sidebar-menu-sub.svelte.d.ts +4 -0
  110. package/dist/components/ui/sidebar/sidebar-menu.svelte +21 -0
  111. package/dist/components/ui/sidebar/sidebar-menu.svelte.d.ts +4 -0
  112. package/dist/components/ui/sidebar/sidebar-provider.svelte +59 -0
  113. package/dist/components/ui/sidebar/sidebar-provider.svelte.d.ts +9 -0
  114. package/dist/components/ui/sidebar/sidebar-rail.svelte +36 -0
  115. package/dist/components/ui/sidebar/sidebar-rail.svelte.d.ts +4 -0
  116. package/dist/components/ui/sidebar/sidebar-separator.svelte +18 -0
  117. package/dist/components/ui/sidebar/sidebar-separator.svelte.d.ts +12 -0
  118. package/dist/components/ui/sidebar/sidebar-trigger.svelte +34 -0
  119. package/dist/components/ui/sidebar/sidebar-trigger.svelte.d.ts +9 -0
  120. package/dist/components/ui/sidebar/sidebar.svelte +98 -0
  121. package/dist/components/ui/sidebar/sidebar.svelte.d.ts +9 -0
  122. package/dist/components/ui/skeleton/index.d.ts +2 -0
  123. package/dist/components/ui/skeleton/index.js +4 -0
  124. package/dist/components/ui/skeleton/skeleton.svelte +17 -0
  125. package/dist/components/ui/skeleton/skeleton.svelte.d.ts +4 -0
  126. package/dist/components/ui/tooltip/index.js +8 -0
  127. package/dist/components/ui/tooltip/tooltip-content.svelte +21 -0
  128. package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +3 -0
  129. package/dist/firebase/auth/auth-guard.svelte.d.ts +25 -0
  130. package/dist/firebase/auth/auth-guard.svelte.js +79 -0
  131. package/dist/firebase/auth/auth.d.ts +21 -0
  132. package/dist/firebase/auth/auth.js +71 -0
  133. package/dist/firebase/auth/user.svelte.d.ts +50 -0
  134. package/dist/firebase/auth/user.svelte.js +115 -0
  135. package/dist/firebase/config.js +44 -0
  136. package/dist/firebase/firebase.d.ts +28 -0
  137. package/dist/firebase/firebase.js +86 -0
  138. package/dist/firebase/firestore/awaitable-doc.svelte.d.ts +15 -0
  139. package/dist/firebase/firestore/awaitable-doc.svelte.js +57 -0
  140. package/dist/firebase/firestore/collection.svelte.d.ts +17 -0
  141. package/dist/firebase/firestore/collection.svelte.js +58 -0
  142. package/dist/firebase/firestore/doc.svelte.d.ts +16 -0
  143. package/dist/firebase/firestore/doc.svelte.js +56 -0
  144. package/dist/firebase/firestore/document-mutations.svelte.d.ts +18 -0
  145. package/dist/firebase/firestore/document-mutations.svelte.js +58 -0
  146. package/dist/firebase/storage/download-url.svelte.d.ts +14 -0
  147. package/dist/firebase/storage/download-url.svelte.js +45 -0
  148. package/dist/firebase/storage/storage-list.svelte.d.ts +17 -0
  149. package/dist/firebase/storage/storage-list.svelte.js +51 -0
  150. package/dist/firebase/storage/upload-task.svelte.d.ts +22 -0
  151. package/dist/firebase/storage/upload-task.svelte.js +65 -0
  152. package/dist/hooks/is-mobile.svelte.d.ts +5 -0
  153. package/dist/hooks/is-mobile.svelte.js +23 -0
  154. package/dist/index.d.ts +22 -2
  155. package/dist/index.js +29 -3
  156. package/dist/types/docs.d.ts +50 -0
  157. package/dist/utils.d.ts +27 -1
  158. package/dist/utils.js +85 -9
  159. package/package.json +9 -7
  160. package/dist/auth/uid.js +0 -7
  161. package/dist/auth/user.svelte.d.ts +0 -10
  162. package/dist/auth/user.svelte.js +0 -21
  163. package/dist/auth.d.ts +0 -39
  164. package/dist/auth.js +0 -100
  165. package/dist/config.js +0 -39
  166. package/dist/firebase.d.ts +0 -43
  167. package/dist/firebase.js +0 -110
  168. package/dist/firestore/Collection.svelte +0 -148
  169. package/dist/firestore/Collection.svelte.d.ts +0 -27
  170. package/dist/firestore/collection.svelte.js +0 -207
  171. package/dist/firestore/doc.svelte.d.ts +0 -1
  172. package/dist/firestore/doc.svelte.js +0 -1
  173. package/dist/firestore/firestore.d.ts +0 -31
  174. package/dist/firestore/firestore.js +0 -100
  175. package/dist/firestore/perf.d.ts +0 -3
  176. package/dist/firestore/perf.js +0 -12
  177. /package/dist/{config.d.ts → firebase/config.d.ts} +0 -0
  178. /package/dist/{auth/uid.d.ts → types/docs.js} +0 -0
@@ -0,0 +1,5 @@
1
+ export declare class IsMobile {
2
+ #private;
3
+ constructor();
4
+ get current(): boolean;
5
+ }
@@ -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 { default as SignIn } from './auth/sign-in.svelte';
2
- export { default as UserButton } from './auth/user-button.svelte';
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
- // Reexport your entry components here
2
- export { default as SignIn } from './auth/sign-in.svelte';
3
- export { default as UserButton } from './auth/user-button.svelte';
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
- export declare function getInitials(name: string | null | undefined): string;
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
- export function getInitials(name) {
7
- if (!name)
8
- return '';
9
- const nameParts = name.trim().split(' ');
10
- if (nameParts.length === 1) {
11
- return nameParts[0].charAt(0).toUpperCase();
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
- const firstInitial = nameParts[0].charAt(0).toUpperCase();
14
- const lastInitial = nameParts[nameParts.length - 1].charAt(0).toUpperCase();
15
- return firstInitial + lastInitial;
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.1",
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
- "svelte": "^5.0.0",
33
- "@sveltejs/kit": "^2.0.0"
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.34",
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
- "lucide-svelte": "^0.454.0"
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;
@@ -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
- };
@@ -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;