@molecule/app-svelte 1.0.0

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 (103) hide show
  1. package/LICENSE +115 -0
  2. package/README.md +2032 -0
  3. package/dist/context.d.ts +126 -0
  4. package/dist/context.d.ts.map +1 -0
  5. package/dist/context.js +217 -0
  6. package/dist/context.js.map +1 -0
  7. package/dist/index.d.ts +60 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +60 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/stores/async-state.d.ts +47 -0
  12. package/dist/stores/async-state.d.ts.map +1 -0
  13. package/dist/stores/async-state.js +89 -0
  14. package/dist/stores/async-state.js.map +1 -0
  15. package/dist/stores/auth.d.ts +54 -0
  16. package/dist/stores/auth.d.ts.map +1 -0
  17. package/dist/stores/auth.js +93 -0
  18. package/dist/stores/auth.js.map +1 -0
  19. package/dist/stores/capacitor-app.d.ts +46 -0
  20. package/dist/stores/capacitor-app.d.ts.map +1 -0
  21. package/dist/stores/capacitor-app.js +59 -0
  22. package/dist/stores/capacitor-app.js.map +1 -0
  23. package/dist/stores/change-password.d.ts +17 -0
  24. package/dist/stores/change-password.d.ts.map +1 -0
  25. package/dist/stores/change-password.js +17 -0
  26. package/dist/stores/change-password.js.map +1 -0
  27. package/dist/stores/device.d.ts +39 -0
  28. package/dist/stores/device.d.ts.map +1 -0
  29. package/dist/stores/device.js +51 -0
  30. package/dist/stores/device.js.map +1 -0
  31. package/dist/stores/forms.d.ts +121 -0
  32. package/dist/stores/forms.d.ts.map +1 -0
  33. package/dist/stores/forms.js +178 -0
  34. package/dist/stores/forms.js.map +1 -0
  35. package/dist/stores/http.d.ts +119 -0
  36. package/dist/stores/http.d.ts.map +1 -0
  37. package/dist/stores/http.js +206 -0
  38. package/dist/stores/http.js.map +1 -0
  39. package/dist/stores/i18n.d.ts +50 -0
  40. package/dist/stores/i18n.d.ts.map +1 -0
  41. package/dist/stores/i18n.js +67 -0
  42. package/dist/stores/i18n.js.map +1 -0
  43. package/dist/stores/index.d.ts +27 -0
  44. package/dist/stores/index.d.ts.map +1 -0
  45. package/dist/stores/index.js +27 -0
  46. package/dist/stores/index.js.map +1 -0
  47. package/dist/stores/logger.d.ts +83 -0
  48. package/dist/stores/logger.d.ts.map +1 -0
  49. package/dist/stores/logger.js +104 -0
  50. package/dist/stores/logger.js.map +1 -0
  51. package/dist/stores/login.d.ts +33 -0
  52. package/dist/stores/login.d.ts.map +1 -0
  53. package/dist/stores/login.js +32 -0
  54. package/dist/stores/login.js.map +1 -0
  55. package/dist/stores/oauth.d.ts +74 -0
  56. package/dist/stores/oauth.d.ts.map +1 -0
  57. package/dist/stores/oauth.js +183 -0
  58. package/dist/stores/oauth.js.map +1 -0
  59. package/dist/stores/password-reset.d.ts +31 -0
  60. package/dist/stores/password-reset.d.ts.map +1 -0
  61. package/dist/stores/password-reset.js +26 -0
  62. package/dist/stores/password-reset.js.map +1 -0
  63. package/dist/stores/platform.d.ts +41 -0
  64. package/dist/stores/platform.d.ts.map +1 -0
  65. package/dist/stores/platform.js +44 -0
  66. package/dist/stores/platform.js.map +1 -0
  67. package/dist/stores/promise.d.ts +41 -0
  68. package/dist/stores/promise.d.ts.map +1 -0
  69. package/dist/stores/promise.js +76 -0
  70. package/dist/stores/promise.js.map +1 -0
  71. package/dist/stores/push.d.ts +41 -0
  72. package/dist/stores/push.d.ts.map +1 -0
  73. package/dist/stores/push.js +73 -0
  74. package/dist/stores/push.js.map +1 -0
  75. package/dist/stores/router.d.ts +74 -0
  76. package/dist/stores/router.d.ts.map +1 -0
  77. package/dist/stores/router.js +131 -0
  78. package/dist/stores/router.js.map +1 -0
  79. package/dist/stores/signup.d.ts +18 -0
  80. package/dist/stores/signup.d.ts.map +1 -0
  81. package/dist/stores/signup.js +17 -0
  82. package/dist/stores/signup.js.map +1 -0
  83. package/dist/stores/state.d.ts +62 -0
  84. package/dist/stores/state.d.ts.map +1 -0
  85. package/dist/stores/state.js +74 -0
  86. package/dist/stores/state.js.map +1 -0
  87. package/dist/stores/storage.d.ts +76 -0
  88. package/dist/stores/storage.d.ts.map +1 -0
  89. package/dist/stores/storage.js +159 -0
  90. package/dist/stores/storage.js.map +1 -0
  91. package/dist/stores/theme.d.ts +68 -0
  92. package/dist/stores/theme.d.ts.map +1 -0
  93. package/dist/stores/theme.js +119 -0
  94. package/dist/stores/theme.js.map +1 -0
  95. package/dist/stores/version.d.ts +44 -0
  96. package/dist/stores/version.d.ts.map +1 -0
  97. package/dist/stores/version.js +73 -0
  98. package/dist/stores/version.js.map +1 -0
  99. package/dist/types.d.ts +46 -0
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +7 -0
  102. package/dist/types.js.map +1 -0
  103. package/package.json +59 -0
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Svelte stores for authentication.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Readable } from 'svelte/store';
7
+ import type { AuthClient, AuthResult, AuthState, LoginCredentials, RegisterData } from '@molecule/app-auth';
8
+ /**
9
+ * Auth stores and actions.
10
+ */
11
+ interface AuthStores<T> {
12
+ state: Readable<AuthState<T>>;
13
+ user: Readable<T | null>;
14
+ isAuthenticated: Readable<boolean>;
15
+ isLoading: Readable<boolean>;
16
+ error?: Readable<string | null>;
17
+ login: (credentials: LoginCredentials) => Promise<AuthResult<T>>;
18
+ logout: () => Promise<void>;
19
+ register: (data: RegisterData) => Promise<AuthResult<T>>;
20
+ refresh: () => Promise<AuthResult<T>>;
21
+ }
22
+ /**
23
+ * Create auth stores from the auth client in context.
24
+ *
25
+ * @returns Auth stores and actions
26
+ *
27
+ * @example
28
+ * ```svelte
29
+ * <script>
30
+ * import { createAuthStores } from '@molecule/app-svelte'
31
+ *
32
+ * const { state, user, isAuthenticated, login, logout } = createAuthStores()
33
+ * </script>
34
+ *
35
+ * {#if $isAuthenticated}
36
+ * <p>Welcome, {$user?.name}!</p>
37
+ * <button on:click={logout}>Logout</button>
38
+ * {/if}
39
+ * ```
40
+ */
41
+ export declare function createAuthStores<T = unknown>(): AuthStores<T> & {
42
+ error: Readable<string | null>;
43
+ };
44
+ /**
45
+ * Create auth stores from a specific auth client.
46
+ *
47
+ * Use this when you don't want to use context.
48
+ *
49
+ * @param client - Auth client
50
+ * @returns Auth stores and actions
51
+ */
52
+ export declare function createAuthStoresFromClient<T = unknown>(client: AuthClient<T>): AuthStores<T>;
53
+ export {};
54
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/stores/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACb,MAAM,oBAAoB,CAAA;AAI3B;;GAEG;AACH,UAAU,UAAU,CAAC,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7B,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IACxB,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAClC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC5B,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAC/B,KAAK,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAChE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACxD,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;CACtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG;IAC/D,KAAK,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;CAC/B,CA+CA;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAwB5F"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Svelte stores for authentication.
3
+ *
4
+ * @module
5
+ */
6
+ import { derived, readable } from 'svelte/store';
7
+ import { getAuthClient } from '../context.js';
8
+ /**
9
+ * Create auth stores from the auth client in context.
10
+ *
11
+ * @returns Auth stores and actions
12
+ *
13
+ * @example
14
+ * ```svelte
15
+ * <script>
16
+ * import { createAuthStores } from '@molecule/app-svelte'
17
+ *
18
+ * const { state, user, isAuthenticated, login, logout } = createAuthStores()
19
+ * </script>
20
+ *
21
+ * {#if $isAuthenticated}
22
+ * <p>Welcome, {$user?.name}!</p>
23
+ * <button on:click={logout}>Logout</button>
24
+ * {/if}
25
+ * ```
26
+ */
27
+ export function createAuthStores() {
28
+ const client = getAuthClient();
29
+ // Main state store
30
+ const state = readable(client.getState(), (set) => {
31
+ return client.onAuthChange(() => {
32
+ set(client.getState());
33
+ });
34
+ });
35
+ // Derived stores
36
+ const user = derived(state, ($state) => $state.user);
37
+ const isAuthenticated = derived(state, ($state) => $state.authenticated);
38
+ const isLoading = derived(state, ($state) => $state.loading);
39
+ const error = derived(state, ($state) => $state.error);
40
+ // Actions
41
+ const login = (credentials) => {
42
+ return client.login(credentials);
43
+ };
44
+ const logout = () => {
45
+ return client.logout();
46
+ };
47
+ const register = (data) => {
48
+ return client.register(data);
49
+ };
50
+ const refresh = () => {
51
+ return client.refresh();
52
+ };
53
+ return {
54
+ state,
55
+ user,
56
+ isAuthenticated,
57
+ isLoading,
58
+ error,
59
+ login,
60
+ logout,
61
+ register,
62
+ refresh,
63
+ };
64
+ }
65
+ /**
66
+ * Create auth stores from a specific auth client.
67
+ *
68
+ * Use this when you don't want to use context.
69
+ *
70
+ * @param client - Auth client
71
+ * @returns Auth stores and actions
72
+ */
73
+ export function createAuthStoresFromClient(client) {
74
+ const state = readable(client.getState(), (set) => {
75
+ return client.onAuthChange(() => {
76
+ set(client.getState());
77
+ });
78
+ });
79
+ const user = derived(state, ($state) => $state.user);
80
+ const isAuthenticated = derived(state, ($state) => $state.authenticated);
81
+ const isLoading = derived(state, ($state) => $state.loading);
82
+ return {
83
+ state,
84
+ user,
85
+ isAuthenticated,
86
+ isLoading,
87
+ login: (credentials) => client.login(credentials),
88
+ logout: () => client.logout(),
89
+ register: (data) => client.register(data),
90
+ refresh: () => client.refresh(),
91
+ };
92
+ }
93
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/stores/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAU/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAiB7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB;IAG9B,MAAM,MAAM,GAAG,aAAa,EAAK,CAAA;IAEjC,mBAAmB;IACnB,MAAM,KAAK,GAA2B,QAAQ,CAC5C,MAAM,CAAC,QAAQ,EAAE,EACjB,CAAC,GAAkC,EAAE,EAAE;QACrC,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;YAC9B,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CACF,CAAA;IAED,iBAAiB;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,MAAoB,E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C,CAAC,CAAA;IACJ,CAAC,CACF,CAAA;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,MAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClE,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,MAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IACtF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,MAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAE1E,OAAO;QACL,KAAK;QACL,IAAI;QACJ,eAAe;QACf,SAAS;QACT,KAAK,EAAE,CAAC,WAA6B,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;QACnE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;QAC7B,QAAQ,EAAE,CAAC,IAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvD,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE;KAChC,CAAA;AACH,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Svelte store for Capacitor app initialization.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Readable } from 'svelte/store';
7
+ import type { CapacitorAppOptions, CapacitorAppState } from '@molecule/app-platform';
8
+ /**
9
+ * Return type for the Capacitor app store.
10
+ */
11
+ export type CapacitorAppStore = Readable<CapacitorAppState> & {
12
+ initialize: () => Promise<void>;
13
+ };
14
+ /**
15
+ * Create a Svelte store wrapping the Capacitor app coordinator.
16
+ *
17
+ * Creates a CapacitorApp instance, subscribes to state changes,
18
+ * and auto-initializes. The returned store is readable and also
19
+ * exposes an `initialize` method for manual re-initialization.
20
+ *
21
+ * @param options - Capacitor app options
22
+ * @returns A readable store of CapacitorAppState with an initialize method
23
+ *
24
+ * @example
25
+ * ```svelte
26
+ * <script>
27
+ * import { createCapacitorAppStore } from '@molecule/app-svelte'
28
+ *
29
+ * const app = createCapacitorAppStore({
30
+ * pushNotifications: true,
31
+ * deepLinks: true,
32
+ * onDeepLink: (url) => console.log('Deep link:', url),
33
+ * })
34
+ * </script>
35
+ *
36
+ * {#if $app.ready}
37
+ * <p>App is ready!</p>
38
+ * {:else if $app.error}
39
+ * <p>Error: {$app.error.message}</p>
40
+ * {:else}
41
+ * <p>Initializing...</p>
42
+ * {/if}
43
+ * ```
44
+ */
45
+ export declare function createCapacitorAppStore(options?: CapacitorAppOptions): CapacitorAppStore;
46
+ //# sourceMappingURL=capacitor-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacitor-app.d.ts","sourceRoot":"","sources":["../../src/stores/capacitor-app.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAGpF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,GAAG;IAC5D,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAChC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CAuBxF"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Svelte store for Capacitor app initialization.
3
+ *
4
+ * @module
5
+ */
6
+ import { readable } from 'svelte/store';
7
+ import { createCapacitorApp } from '@molecule/app-platform';
8
+ /**
9
+ * Create a Svelte store wrapping the Capacitor app coordinator.
10
+ *
11
+ * Creates a CapacitorApp instance, subscribes to state changes,
12
+ * and auto-initializes. The returned store is readable and also
13
+ * exposes an `initialize` method for manual re-initialization.
14
+ *
15
+ * @param options - Capacitor app options
16
+ * @returns A readable store of CapacitorAppState with an initialize method
17
+ *
18
+ * @example
19
+ * ```svelte
20
+ * <script>
21
+ * import { createCapacitorAppStore } from '@molecule/app-svelte'
22
+ *
23
+ * const app = createCapacitorAppStore({
24
+ * pushNotifications: true,
25
+ * deepLinks: true,
26
+ * onDeepLink: (url) => console.log('Deep link:', url),
27
+ * })
28
+ * </script>
29
+ *
30
+ * {#if $app.ready}
31
+ * <p>App is ready!</p>
32
+ * {:else if $app.error}
33
+ * <p>Error: {$app.error.message}</p>
34
+ * {:else}
35
+ * <p>Initializing...</p>
36
+ * {/if}
37
+ * ```
38
+ */
39
+ export function createCapacitorAppStore(options) {
40
+ const app = createCapacitorApp(options);
41
+ const store = readable(app.getState(), (set) => {
42
+ const unsubscribe = app.subscribe((state) => {
43
+ set(state);
44
+ });
45
+ // Auto-initialize
46
+ app.initialize().catch(() => {
47
+ // Errors are captured in state.error via the coordinator
48
+ });
49
+ return () => {
50
+ unsubscribe();
51
+ app.destroy();
52
+ };
53
+ });
54
+ return {
55
+ subscribe: store.subscribe,
56
+ initialize: () => app.initialize(),
57
+ };
58
+ }
59
+ //# sourceMappingURL=capacitor-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacitor-app.js","sourceRoot":"","sources":["../../src/stores/capacitor-app.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAS3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA6B;IACnE,MAAM,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAEvC,MAAM,KAAK,GAAG,QAAQ,CAAoB,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;QAChE,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1C,GAAG,CAAC,KAAK,CAAC,CAAA;QACZ,CAAC,CAAC,CAAA;QAEF,kBAAkB;QAClB,GAAG,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YAC1B,yDAAyD;QAC3D,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,CAAA;YACb,GAAG,CAAC,OAAO,EAAE,CAAA;QACf,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE;KACnC,CAAA;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Svelte store for changing password with async state tracking.
3
+ *
4
+ * @module
5
+ */
6
+ import { type PromiseStore } from './promise.js';
7
+ /**
8
+ * Change password store type.
9
+ */
10
+ export type ChangePasswordStore = PromiseStore<void>;
11
+ /**
12
+ * Creates a change password store with async state tracking.
13
+ *
14
+ * @returns Change password promise store
15
+ */
16
+ export declare function createChangePasswordStore(): ChangePasswordStore;
17
+ //# sourceMappingURL=change-password.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-password.d.ts","sourceRoot":"","sources":["../../src/stores/change-password.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAEpE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,mBAAmB,CAK/D"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Svelte store for changing password with async state tracking.
3
+ *
4
+ * @module
5
+ */
6
+ import { getAuthClient } from '../context.js';
7
+ import { createPromiseStore } from './promise.js';
8
+ /**
9
+ * Creates a change password store with async state tracking.
10
+ *
11
+ * @returns Change password promise store
12
+ */
13
+ export function createChangePasswordStore() {
14
+ const client = getAuthClient();
15
+ return createPromiseStore((oldPassword, newPassword) => client.changePassword(oldPassword, newPassword));
16
+ }
17
+ //# sourceMappingURL=change-password.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-password.js","sourceRoot":"","sources":["../../src/stores/change-password.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAqB,MAAM,cAAc,CAAA;AAOpE;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAA;IAC9B,OAAO,kBAAkB,CAAC,CAAC,WAAmB,EAAE,WAAmB,EAAE,EAAE,CACrE,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,CAChD,CAAA;AACH,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Svelte stores for device information.
3
+ *
4
+ * @module
5
+ */
6
+ import type { DeviceInfo, FeatureSupport, HardwareInfo, ScreenInfo } from '@molecule/app-device';
7
+ /**
8
+ * Create device stores from the module-level device provider.
9
+ *
10
+ * Device information is static (no reactive subscription needed),
11
+ * so this returns plain values rather than Svelte stores.
12
+ *
13
+ * @returns Device information and utility functions
14
+ *
15
+ * @example
16
+ * ```svelte
17
+ * <script>
18
+ * import { createDeviceStores } from '@molecule/app-svelte'
19
+ *
20
+ * const { deviceInfo, screenInfo, supports } = createDeviceStores()
21
+ * </script>
22
+ *
23
+ * <p>Browser: {deviceInfo.browser.name}</p>
24
+ * <p>Screen: {screenInfo.width}x{screenInfo.height}</p>
25
+ * <p>Push supported: {supports('pushNotifications')}</p>
26
+ * ```
27
+ */
28
+ export declare function createDeviceStores(): {
29
+ deviceInfo: DeviceInfo;
30
+ screenInfo: ScreenInfo;
31
+ hardwareInfo: HardwareInfo;
32
+ featureSupport: FeatureSupport;
33
+ supports: (feature: keyof FeatureSupport) => boolean;
34
+ isOnline: () => boolean;
35
+ isStandalone: () => boolean;
36
+ language: string;
37
+ languages: string[];
38
+ };
39
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/stores/device.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,EAAE,YAAY,CAAA;IAC1B,cAAc,EAAE,cAAc,CAAA;IAC9B,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,cAAc,KAAK,OAAO,CAAA;IACpD,QAAQ,EAAE,MAAM,OAAO,CAAA;IACvB,YAAY,EAAE,MAAM,OAAO,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CA0BA"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Svelte stores for device information.
3
+ *
4
+ * @module
5
+ */
6
+ import { getProvider } from '@molecule/app-device';
7
+ /**
8
+ * Create device stores from the module-level device provider.
9
+ *
10
+ * Device information is static (no reactive subscription needed),
11
+ * so this returns plain values rather than Svelte stores.
12
+ *
13
+ * @returns Device information and utility functions
14
+ *
15
+ * @example
16
+ * ```svelte
17
+ * <script>
18
+ * import { createDeviceStores } from '@molecule/app-svelte'
19
+ *
20
+ * const { deviceInfo, screenInfo, supports } = createDeviceStores()
21
+ * </script>
22
+ *
23
+ * <p>Browser: {deviceInfo.browser.name}</p>
24
+ * <p>Screen: {screenInfo.width}x{screenInfo.height}</p>
25
+ * <p>Push supported: {supports('pushNotifications')}</p>
26
+ * ```
27
+ */
28
+ export function createDeviceStores() {
29
+ const provider = getProvider();
30
+ const deviceInfo = provider.getDeviceInfo();
31
+ const screenInfo = provider.getScreenInfo();
32
+ const hardwareInfo = provider.getHardwareInfo();
33
+ const featureSupport = provider.getFeatureSupport();
34
+ const supports = (feature) => provider.supports(feature);
35
+ const isOnline = () => provider.isOnline();
36
+ const isStandalone = () => provider.isStandalone();
37
+ const language = provider.getLanguage();
38
+ const languages = provider.getLanguages();
39
+ return {
40
+ deviceInfo,
41
+ screenInfo,
42
+ hardwareInfo,
43
+ featureSupport,
44
+ supports,
45
+ isOnline,
46
+ isStandalone,
47
+ language,
48
+ languages,
49
+ };
50
+ }
51
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/stores/device.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB;IAWhC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAE9B,MAAM,UAAU,GAAe,QAAQ,CAAC,aAAa,EAAE,CAAA;IACvD,MAAM,UAAU,GAAe,QAAQ,CAAC,aAAa,EAAE,CAAA;IACvD,MAAM,YAAY,GAAiB,QAAQ,CAAC,eAAe,EAAE,CAAA;IAC7D,MAAM,cAAc,GAAmB,QAAQ,CAAC,iBAAiB,EAAE,CAAA;IAEnE,MAAM,QAAQ,GAAG,CAAC,OAA6B,EAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACvF,MAAM,QAAQ,GAAG,GAAY,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;IACnD,MAAM,YAAY,GAAG,GAAY,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAA;IAE3D,MAAM,QAAQ,GAAW,QAAQ,CAAC,WAAW,EAAE,CAAA;IAC/C,MAAM,SAAS,GAAa,QAAQ,CAAC,YAAY,EAAE,CAAA;IAEnD,OAAO;QACL,UAAU;QACV,UAAU;QACV,YAAY;QACZ,cAAc;QACd,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,QAAQ;QACR,SAAS;KACV,CAAA;AACH,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Svelte stores for form management.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Readable } from 'svelte/store';
7
+ import type { FieldRegistration, FieldState, FormController, FormOptions, FormProvider, FormState, RegisterOptions } from '@molecule/app-forms';
8
+ /**
9
+ * Form stores and actions return type.
10
+ */
11
+ interface FormStores<T extends Record<string, unknown>> {
12
+ formState: Readable<FormState<T>>;
13
+ isValid: Readable<boolean>;
14
+ isDirty: Readable<boolean>;
15
+ isSubmitting: Readable<boolean>;
16
+ errors: Readable<Partial<Record<keyof T, string>>>;
17
+ register: (name: string | RegisterOptions, registerOptions?: RegisterOptions) => FieldRegistration;
18
+ getValue: <K extends keyof T>(name: K) => T[K];
19
+ setValue: <K extends keyof T>(name: K, value: T[K], opts?: {
20
+ shouldValidate?: boolean;
21
+ shouldDirty?: boolean;
22
+ shouldTouch?: boolean;
23
+ }) => void;
24
+ getError: <K extends keyof T>(name: K) => string | undefined;
25
+ setError: <K extends keyof T>(name: K, error: string | undefined) => void;
26
+ clearErrors: () => void;
27
+ handleSubmit: (onSubmit: (values: T) => void | Promise<void>, onError?: (errors: Partial<Record<keyof T, string>>) => void) => (event?: {
28
+ preventDefault?: () => void;
29
+ }) => Promise<void>;
30
+ reset: (values?: Partial<T>) => void;
31
+ validate: () => Promise<boolean>;
32
+ destroy: () => void;
33
+ controller: FormController<T>;
34
+ }
35
+ /**
36
+ * Create form stores from a form provider and options.
37
+ *
38
+ * @param provider - Form provider instance
39
+ * @param options - Form creation options
40
+ * @returns Form stores and actions
41
+ *
42
+ * @example
43
+ * ```svelte
44
+ * <script>
45
+ * import { createFormStores } from '@molecule/app-svelte'
46
+ * import { nativeProvider } from '@molecule/app-forms'
47
+ *
48
+ * const {
49
+ * formState, isValid, isDirty, isSubmitting, errors,
50
+ * register, setValue, handleSubmit, reset
51
+ * } = createFormStores(nativeProvider, {
52
+ * defaultValues: { name: '', email: '' },
53
+ * mode: 'onChange',
54
+ * })
55
+ *
56
+ * const nameField = register('name', { required: true })
57
+ * const emailField = register('email', { required: true, email: true })
58
+ *
59
+ * const onSubmit = handleSubmit(async (values) => {
60
+ * console.log('Submitted:', values)
61
+ * })
62
+ * </script>
63
+ *
64
+ * <form on:submit|preventDefault={onSubmit}>
65
+ * <input {...nameField} />
66
+ * {#if $errors.name}<span>{$errors.name}</span>{/if}
67
+ *
68
+ * <input {...emailField} />
69
+ * {#if $errors.email}<span>{$errors.email}</span>{/if}
70
+ *
71
+ * <button type="submit" disabled={!$isValid || $isSubmitting}>Submit</button>
72
+ * </form>
73
+ * ```
74
+ */
75
+ export declare function createFormStores<T extends Record<string, unknown>>(provider: FormProvider, options: FormOptions<T>): FormStores<T>;
76
+ /**
77
+ * Create a readable store that tracks a single field's state.
78
+ *
79
+ * @param controller - Form controller
80
+ * @param name - Field name to track
81
+ * @returns Readable store of the field state
82
+ *
83
+ * @example
84
+ * ```svelte
85
+ * <script>
86
+ * import { createFormStores, createFieldStore } from '@molecule/app-svelte'
87
+ *
88
+ * const { controller } = createFormStores(provider, { defaultValues: { email: '' } })
89
+ * const emailField = createFieldStore(controller, 'email')
90
+ * </script>
91
+ *
92
+ * <p>Value: {$emailField.value}</p>
93
+ * <p>Error: {$emailField.error}</p>
94
+ * <p>Touched: {$emailField.touched}</p>
95
+ * ```
96
+ */
97
+ export declare function createFieldStore<T extends Record<string, unknown>, K extends keyof T>(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>;
98
+ /**
99
+ * Create a readable store that tracks a single field's value.
100
+ *
101
+ * @param controller - Form controller
102
+ * @param name - Field name to watch
103
+ * @returns Readable store of the field value
104
+ *
105
+ * @example
106
+ * ```svelte
107
+ * <script>
108
+ * import { createFormStores, createWatchStore } from '@molecule/app-svelte'
109
+ *
110
+ * const { controller } = createFormStores(provider, { defaultValues: { plan: 'free' } })
111
+ * const plan = createWatchStore(controller, 'plan')
112
+ * </script>
113
+ *
114
+ * {#if $plan === 'pro'}
115
+ * <ProFeatures />
116
+ * {/if}
117
+ * ```
118
+ */
119
+ export declare function createWatchStore<T extends Record<string, unknown>, K extends keyof T>(controller: FormController<T>, name: K): Readable<T[K]>;
120
+ export {};
121
+ //# sourceMappingURL=forms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/stores/forms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAE5B;;GAEG;AACH,UAAU,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpD,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACjC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC/B,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,eAAe,CAAC,EAAE,eAAe,KAAK,iBAAiB,CAAA;IAClG,QAAQ,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAC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