@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,62 @@
1
+ /**
2
+ * Svelte stores for state management.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Readable } from 'svelte/store';
7
+ import type { Store as MoleculeStore } from '@molecule/app-state';
8
+ /**
9
+ * Create a readable Svelte store from a molecule store.
10
+ *
11
+ * @param store - The molecule store
12
+ * @returns Readable Svelte store
13
+ *
14
+ * @example
15
+ * ```svelte
16
+ * <script>
17
+ * import { createStoreReadable } from '@molecule/app-svelte'
18
+ * import { counterStore } from './stores/counter'
19
+ *
20
+ * const count = createStoreReadable(counterStore)
21
+ * </script>
22
+ *
23
+ * <p>Count: {$count}</p>
24
+ * ```
25
+ */
26
+ export declare function createStoreReadable<T>(store: MoleculeStore<T>): Readable<T>;
27
+ /**
28
+ * Create a derived Svelte store with a selector.
29
+ *
30
+ * @param store - The molecule store
31
+ * @param selector - Selector function
32
+ * @returns Derived Svelte store
33
+ *
34
+ * @example
35
+ * ```svelte
36
+ * <script>
37
+ * import { createStoreSelector } from '@molecule/app-svelte'
38
+ * import { userStore } from './stores/user'
39
+ *
40
+ * const userName = createStoreSelector(userStore, s => s.name)
41
+ * </script>
42
+ *
43
+ * <p>Hello, {$userName}!</p>
44
+ * ```
45
+ */
46
+ export declare function createStoreSelector<T, S>(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>;
47
+ /**
48
+ * Get the setState function from a molecule store.
49
+ *
50
+ * @param store - The molecule store
51
+ * @returns setState function
52
+ */
53
+ export declare function getSetStore<T>(store: MoleculeStore<T>): MoleculeStore<T>['setState'];
54
+ /**
55
+ * Create a bound action for a store.
56
+ *
57
+ * @param store - The store
58
+ * @param action - Action creator function
59
+ * @returns Bound action
60
+ */
61
+ export declare function createStoreAction<T, Args extends unknown[], R>(store: MoleculeStore<T>, action: (setState: MoleculeStore<T>['setState'], getState: MoleculeStore<T>['getState']) => (...args: Args) => R): (...args: Args) => R;
62
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/stores/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAM3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GACxB,QAAQ,CAAC,CAAC,CAAC,CAGb;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAEpF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EAC5D,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,MAAM,EAAE,CACN,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EACtC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KACnC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GACxB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAEtB"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Svelte stores for state management.
3
+ *
4
+ * @module
5
+ */
6
+ import { derived, readable } from 'svelte/store';
7
+ /**
8
+ * Create a readable Svelte store from a molecule store.
9
+ *
10
+ * @param store - The molecule store
11
+ * @returns Readable Svelte store
12
+ *
13
+ * @example
14
+ * ```svelte
15
+ * <script>
16
+ * import { createStoreReadable } from '@molecule/app-svelte'
17
+ * import { counterStore } from './stores/counter'
18
+ *
19
+ * const count = createStoreReadable(counterStore)
20
+ * </script>
21
+ *
22
+ * <p>Count: {$count}</p>
23
+ * ```
24
+ */
25
+ export function createStoreReadable(store) {
26
+ return readable(store.getState(), (set) => {
27
+ return store.subscribe(() => {
28
+ set(store.getState());
29
+ });
30
+ });
31
+ }
32
+ /**
33
+ * Create a derived Svelte store with a selector.
34
+ *
35
+ * @param store - The molecule store
36
+ * @param selector - Selector function
37
+ * @returns Derived Svelte store
38
+ *
39
+ * @example
40
+ * ```svelte
41
+ * <script>
42
+ * import { createStoreSelector } from '@molecule/app-svelte'
43
+ * import { userStore } from './stores/user'
44
+ *
45
+ * const userName = createStoreSelector(userStore, s => s.name)
46
+ * </script>
47
+ *
48
+ * <p>Hello, {$userName}!</p>
49
+ * ```
50
+ */
51
+ export function createStoreSelector(store, selector) {
52
+ const storeReadable = createStoreReadable(store);
53
+ return derived(storeReadable, selector);
54
+ }
55
+ /**
56
+ * Get the setState function from a molecule store.
57
+ *
58
+ * @param store - The molecule store
59
+ * @returns setState function
60
+ */
61
+ export function getSetStore(store) {
62
+ return store.setState;
63
+ }
64
+ /**
65
+ * Create a bound action for a store.
66
+ *
67
+ * @param store - The store
68
+ * @param action - Action creator function
69
+ * @returns Bound action
70
+ */
71
+ export function createStoreAction(store, action) {
72
+ return (...args) => action(store.setState, store.getState)(...args);
73
+ }
74
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/stores/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAuB;IAC5D,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAuB,EAAE,EAAE;QAC5D,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YAC1B,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;QACvB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAuB,EACvB,QAAyB;IAEzB,MAAM,aAAa,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAChD,OAAO,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAI,KAAuB;IACpD,OAAO,KAAK,CAAC,QAAQ,CAAA;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAuB,EACvB,MAGyB;IAEzB,OAAO,CAAC,GAAG,IAAU,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;AAC3E,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Svelte stores for storage.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Subscriber, type Unsubscriber } from 'svelte/store';
7
+ import type { StorageProvider } from '@molecule/app-storage';
8
+ import type { StorageValueState } from '../types.js';
9
+ /**
10
+ * A storage value store with subscribe, load, set, and remove.
11
+ */
12
+ interface StorageStore<T> {
13
+ subscribe: (run: Subscriber<StorageValueState<T>>, invalidate?: () => void) => Unsubscriber;
14
+ load: () => Promise<T | undefined>;
15
+ set: (value: T) => Promise<void>;
16
+ remove: () => Promise<void>;
17
+ }
18
+ /**
19
+ * Storage helper functions.
20
+ */
21
+ interface StorageHelpers {
22
+ get: <T>(key: string) => Promise<T | null>;
23
+ set: <T>(key: string, value: T) => Promise<void>;
24
+ remove: (key: string) => Promise<void>;
25
+ clear: () => Promise<void>;
26
+ keys: () => Promise<string[]>;
27
+ }
28
+ /**
29
+ * Create a storage value store.
30
+ *
31
+ * @param key - Storage key
32
+ * @param defaultValue - Default value if not found
33
+ * @returns Store with value and actions
34
+ *
35
+ * @example
36
+ * ```svelte
37
+ * <script>
38
+ * import { createStorageStore } from '@molecule/app-svelte'
39
+ *
40
+ * const theme = createStorageStore('theme', 'light')
41
+ *
42
+ * // Load on mount
43
+ * onMount(() => theme.load())
44
+ * </script>
45
+ *
46
+ * {#if $theme.loading}
47
+ * <p>Loading...</p>
48
+ * {:else}
49
+ * <select
50
+ * value={$theme.value}
51
+ * on:change={(e) => theme.set(e.target.value)}
52
+ * >
53
+ * <option value="light">Light</option>
54
+ * <option value="dark">Dark</option>
55
+ * </select>
56
+ * {/if}
57
+ * ```
58
+ */
59
+ export declare function createStorageStore<T>(key: string, defaultValue?: T): StorageStore<T>;
60
+ /**
61
+ * Create storage helper functions from context.
62
+ *
63
+ * @returns Storage functions
64
+ */
65
+ export declare function createStorageHelpers(): StorageHelpers;
66
+ /**
67
+ * Create storage store from a specific provider.
68
+ *
69
+ * @param storage - Storage provider
70
+ * @param key - Storage key
71
+ * @param defaultValue - Default value
72
+ * @returns Store with value and actions
73
+ */
74
+ export declare function createStorageStoreFromProvider<T>(storage: StorageProvider, key: string, defaultValue?: T): StorageStore<T>;
75
+ export {};
76
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/stores/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAY,MAAM,cAAc,CAAA;AAE3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD;;GAEG;AACH,UAAU,YAAY,CAAC,CAAC;IACtB,SAAS,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,IAAI,KAAK,YAAY,CAAA;IAC3F,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAClC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAC1C,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAChD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CA2DpF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAUrD;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,EAC9C,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,CAAC,GACf,YAAY,CAAC,CAAC,CAAC,CAwCjB"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Svelte stores for storage.
3
+ *
4
+ * @module
5
+ */
6
+ import { writable } from 'svelte/store';
7
+ import { getStorageProvider } from '../context.js';
8
+ /**
9
+ * Create a storage value store.
10
+ *
11
+ * @param key - Storage key
12
+ * @param defaultValue - Default value if not found
13
+ * @returns Store with value and actions
14
+ *
15
+ * @example
16
+ * ```svelte
17
+ * <script>
18
+ * import { createStorageStore } from '@molecule/app-svelte'
19
+ *
20
+ * const theme = createStorageStore('theme', 'light')
21
+ *
22
+ * // Load on mount
23
+ * onMount(() => theme.load())
24
+ * </script>
25
+ *
26
+ * {#if $theme.loading}
27
+ * <p>Loading...</p>
28
+ * {:else}
29
+ * <select
30
+ * value={$theme.value}
31
+ * on:change={(e) => theme.set(e.target.value)}
32
+ * >
33
+ * <option value="light">Light</option>
34
+ * <option value="dark">Dark</option>
35
+ * </select>
36
+ * {/if}
37
+ * ```
38
+ */
39
+ export function createStorageStore(key, defaultValue) {
40
+ const storage = getStorageProvider();
41
+ const store = writable({
42
+ value: defaultValue,
43
+ loading: true,
44
+ error: null,
45
+ });
46
+ const load = async () => {
47
+ store.update((s) => ({ ...s, loading: true, error: null }));
48
+ try {
49
+ const value = await storage.get(key);
50
+ store.set({
51
+ value: value ?? defaultValue,
52
+ loading: false,
53
+ error: null,
54
+ });
55
+ return value ?? defaultValue;
56
+ }
57
+ catch (error) {
58
+ const err = error instanceof Error ? error : new Error(String(error));
59
+ store.set({
60
+ value: defaultValue,
61
+ loading: false,
62
+ error: err,
63
+ });
64
+ return defaultValue;
65
+ }
66
+ };
67
+ const set = async (value) => {
68
+ try {
69
+ await storage.set(key, value);
70
+ store.update((s) => ({ ...s, value, error: null }));
71
+ }
72
+ catch (error) {
73
+ const err = error instanceof Error ? error : new Error(String(error));
74
+ store.update((s) => ({ ...s, error: err }));
75
+ throw err;
76
+ }
77
+ };
78
+ const remove = async () => {
79
+ try {
80
+ await storage.remove(key);
81
+ store.update((s) => ({ ...s, value: defaultValue, error: null }));
82
+ }
83
+ catch (error) {
84
+ const err = error instanceof Error ? error : new Error(String(error));
85
+ store.update((s) => ({ ...s, error: err }));
86
+ throw err;
87
+ }
88
+ };
89
+ return {
90
+ subscribe: store.subscribe,
91
+ load,
92
+ set,
93
+ remove,
94
+ };
95
+ }
96
+ /**
97
+ * Create storage helper functions from context.
98
+ *
99
+ * @returns Storage functions
100
+ */
101
+ export function createStorageHelpers() {
102
+ const storage = getStorageProvider();
103
+ return {
104
+ get: (key) => storage.get(key),
105
+ set: (key, value) => storage.set(key, value),
106
+ remove: (key) => storage.remove(key),
107
+ clear: () => storage.clear(),
108
+ keys: () => storage.keys(),
109
+ };
110
+ }
111
+ /**
112
+ * Create storage store from a specific provider.
113
+ *
114
+ * @param storage - Storage provider
115
+ * @param key - Storage key
116
+ * @param defaultValue - Default value
117
+ * @returns Store with value and actions
118
+ */
119
+ export function createStorageStoreFromProvider(storage, key, defaultValue) {
120
+ const store = writable({
121
+ value: defaultValue,
122
+ loading: true,
123
+ error: null,
124
+ });
125
+ const load = async () => {
126
+ store.update((s) => ({ ...s, loading: true, error: null }));
127
+ try {
128
+ const value = await storage.get(key);
129
+ store.set({ value: value ?? defaultValue, loading: false, error: null });
130
+ return value ?? defaultValue;
131
+ }
132
+ catch (error) {
133
+ const err = error instanceof Error ? error : new Error(String(error));
134
+ store.set({ value: defaultValue, loading: false, error: err });
135
+ return defaultValue;
136
+ }
137
+ };
138
+ const set = async (value) => {
139
+ try {
140
+ await storage.set(key, value);
141
+ store.update((s) => ({ ...s, value, error: null }));
142
+ }
143
+ catch (error) {
144
+ const err = error instanceof Error ? error : new Error(String(error));
145
+ store.update((s) => ({ ...s, error: err }));
146
+ throw err;
147
+ }
148
+ };
149
+ return {
150
+ subscribe: store.subscribe,
151
+ load,
152
+ set,
153
+ remove: async () => {
154
+ await storage.remove(key);
155
+ store.update((s) => ({ ...s, value: defaultValue, error: null }));
156
+ },
157
+ };
158
+ }
159
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/stores/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsC,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAwBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,kBAAkB,CAAI,GAAW,EAAE,YAAgB;IACjE,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAA;IAEpC,MAAM,KAAK,GAAG,QAAQ,CAAuB;QAC3C,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,KAAK,IAA4B,EAAE;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAC,CAAuB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAEjF,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC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CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAC3E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;YACrE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAuB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YACjE,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC,CAAA;IAED,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI;QACJ,GAAG;QACH,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACzB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAuB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACzF,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Svelte stores for theming.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Readable } from 'svelte/store';
7
+ import type { Theme, ThemeProvider } from '@molecule/app-theme';
8
+ /**
9
+ * Theme stores and actions.
10
+ */
11
+ interface ThemeStores {
12
+ theme: Readable<Theme>;
13
+ themeName: Readable<string>;
14
+ mode: Readable<Theme['mode']>;
15
+ themes: Theme[];
16
+ setTheme: (name: string) => void;
17
+ toggleTheme: () => void;
18
+ }
19
+ /**
20
+ * Create theme stores from the theme provider in context.
21
+ *
22
+ * @returns Theme stores and actions
23
+ *
24
+ * @example
25
+ * ```svelte
26
+ * <script>
27
+ * import { createThemeStores } from '@molecule/app-svelte'
28
+ *
29
+ * const { theme, themeName, mode, setTheme, toggleTheme } = createThemeStores()
30
+ * </script>
31
+ *
32
+ * <div style:background={$theme.colors.background}>
33
+ * <p>Theme: {$themeName}</p>
34
+ * <button on:click={toggleTheme}>Toggle ({$mode})</button>
35
+ * </div>
36
+ * ```
37
+ */
38
+ export declare function createThemeStores(): ThemeStores & {
39
+ colors: Readable<Theme['colors']>;
40
+ };
41
+ /**
42
+ * Create a derived store that returns just the theme colors.
43
+ *
44
+ * @param theme - A readable theme store (from createThemeStores or createThemeStoresFromProvider)
45
+ * @returns Readable store of theme colors
46
+ *
47
+ * @example
48
+ * ```svelte
49
+ * <script>
50
+ * import { createThemeStores, createThemeColorsStore } from '@molecule/app-svelte'
51
+ *
52
+ * const { theme } = createThemeStores()
53
+ * const colors = createThemeColorsStore(theme)
54
+ * </script>
55
+ *
56
+ * <div style:color={$colors.text.primary}>Hello</div>
57
+ * ```
58
+ */
59
+ export declare function createThemeColorsStore(theme: Readable<Theme>): Readable<Theme['colors']>;
60
+ /**
61
+ * Create theme stores from a specific theme provider.
62
+ *
63
+ * @param provider - Theme provider
64
+ * @returns Theme stores and actions
65
+ */
66
+ export declare function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores;
67
+ export {};
68
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/stores/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAI/D;;GAEG;AACH,UAAU,WAAW;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;CAAE,CAgDvF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAExF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CA+BlF"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Svelte stores for theming.
3
+ *
4
+ * @module
5
+ */
6
+ import { derived, readable } from 'svelte/store';
7
+ import { getThemeProvider } from '../context.js';
8
+ /**
9
+ * Create theme stores from the theme provider in context.
10
+ *
11
+ * @returns Theme stores and actions
12
+ *
13
+ * @example
14
+ * ```svelte
15
+ * <script>
16
+ * import { createThemeStores } from '@molecule/app-svelte'
17
+ *
18
+ * const { theme, themeName, mode, setTheme, toggleTheme } = createThemeStores()
19
+ * </script>
20
+ *
21
+ * <div style:background={$theme.colors.background}>
22
+ * <p>Theme: {$themeName}</p>
23
+ * <button on:click={toggleTheme}>Toggle ({$mode})</button>
24
+ * </div>
25
+ * ```
26
+ */
27
+ export function createThemeStores() {
28
+ const provider = getThemeProvider();
29
+ // Main theme store
30
+ const theme = readable(provider.getTheme(), (set) => {
31
+ return provider.subscribe(() => {
32
+ set(provider.getTheme());
33
+ });
34
+ });
35
+ // Theme name store
36
+ const themeName = readable(provider.getTheme().name, (set) => {
37
+ return provider.subscribe(() => {
38
+ set(provider.getTheme().name);
39
+ });
40
+ });
41
+ // Derived stores
42
+ const mode = derived(theme, ($theme) => $theme.mode);
43
+ const colors = derived(theme, ($theme) => $theme.colors);
44
+ // Get available themes
45
+ const themes = provider.getThemes?.() ?? [];
46
+ // Actions
47
+ const setTheme = (name) => {
48
+ provider.setTheme(name);
49
+ };
50
+ const toggleTheme = () => {
51
+ const currentName = provider.getTheme().name;
52
+ const currentIndex = themes.findIndex((t) => t.name === currentName);
53
+ const nextIndex = (currentIndex + 1) % themes.length;
54
+ provider.setTheme(themes[nextIndex]);
55
+ };
56
+ return {
57
+ theme,
58
+ themeName,
59
+ mode,
60
+ colors,
61
+ themes,
62
+ setTheme,
63
+ toggleTheme,
64
+ };
65
+ }
66
+ /**
67
+ * Create a derived store that returns just the theme colors.
68
+ *
69
+ * @param theme - A readable theme store (from createThemeStores or createThemeStoresFromProvider)
70
+ * @returns Readable store of theme colors
71
+ *
72
+ * @example
73
+ * ```svelte
74
+ * <script>
75
+ * import { createThemeStores, createThemeColorsStore } from '@molecule/app-svelte'
76
+ *
77
+ * const { theme } = createThemeStores()
78
+ * const colors = createThemeColorsStore(theme)
79
+ * </script>
80
+ *
81
+ * <div style:color={$colors.text.primary}>Hello</div>
82
+ * ```
83
+ */
84
+ export function createThemeColorsStore(theme) {
85
+ return derived(theme, ($theme) => $theme.colors);
86
+ }
87
+ /**
88
+ * Create theme stores from a specific theme provider.
89
+ *
90
+ * @param provider - Theme provider
91
+ * @returns Theme stores and actions
92
+ */
93
+ export function createThemeStoresFromProvider(provider) {
94
+ const theme = readable(provider.getTheme(), (set) => {
95
+ return provider.subscribe(() => {
96
+ set(provider.getTheme());
97
+ });
98
+ });
99
+ const themeName = readable(provider.getTheme().name, (set) => {
100
+ return provider.subscribe(() => {
101
+ set(provider.getTheme().name);
102
+ });
103
+ });
104
+ const mode = derived(theme, ($theme) => $theme.mode);
105
+ const themes = provider.getThemes?.() ?? [];
106
+ return {
107
+ theme,
108
+ themeName,
109
+ mode,
110
+ themes,
111
+ setTheme: (name) => provider.setTheme(name),
112
+ toggleTheme: () => {
113
+ const currentName = provider.getTheme().name;
114
+ const idx = themes.findIndex((t) => t.name === currentName);
115
+ provider.setTheme(themes[(idx + 1) % themes.length]);
116
+ },
117
+ };
118
+ }
119
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/stores/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAchD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAA;IAEnC,mBAAmB;IACnB,MAAM,KAAK,GAAoB,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,GAA2B,EAAE,EAAE;QAC3F,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE;YAC7B,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,mBAAmB;IACnB,MAAM,SAAS,GAAqB,QAAQ,CAC1C,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EACxB,CAAC,GAA4B,EAAE,EAAE;QAC/B,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE;YAC7B,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAA;IACJ,CAAC,CACF,CAAA;IAED,iBAAiB;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,MAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,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AA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,MAAM,SAAS,GAAqB,QAAQ,CAC1C,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EACxB,CAAC,GAA4B,EAAE,EAAE;QAC/B,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE;YAC7B,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAA;IACJ,CAAC,CACF,CAAA;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,MAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAA;IAE3C,OAAO;QACL,KAAK;QACL,SAAS;QACT,IAAI;QACJ,MAAM;QACN,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnD,WAAW,EAAE,GAAG,EAAE;YAChB,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAA;YAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAA;YAClE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QACtD,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Svelte stores for version and update management.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Readable } from 'svelte/store';
7
+ import type { UpdateCheckOptions, VersionState } from '@molecule/app-version';
8
+ /**
9
+ * Create version stores from the module-level version provider.
10
+ *
11
+ * @returns Version stores and actions
12
+ *
13
+ * @example
14
+ * ```svelte
15
+ * <script>
16
+ * import { createVersionStores } from '@molecule/app-svelte'
17
+ *
18
+ * const { state, isUpdateAvailable, applyUpdate, dismissUpdate } = createVersionStores()
19
+ * </script>
20
+ *
21
+ * {#if $isUpdateAvailable}
22
+ * <div>
23
+ * <p>New version available: {$newVersion}</p>
24
+ * <button on:click={() => applyUpdate()}>Update</button>
25
+ * <button on:click={dismissUpdate}>Dismiss</button>
26
+ * </div>
27
+ * {/if}
28
+ * ```
29
+ */
30
+ export declare function createVersionStores(): {
31
+ state: Readable<VersionState>;
32
+ isUpdateAvailable: Readable<boolean>;
33
+ isChecking: Readable<boolean>;
34
+ isServiceWorkerWaiting: Readable<boolean>;
35
+ newVersion: Readable<string | undefined>;
36
+ checkForUpdates: () => Promise<boolean>;
37
+ applyUpdate: (options?: {
38
+ force?: boolean;
39
+ }) => void;
40
+ dismissUpdate: () => void;
41
+ startPeriodicChecks: (options?: UpdateCheckOptions) => void;
42
+ stopPeriodicChecks: () => void;
43
+ };
44
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/stores/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAgB,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAG3F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,IAAI;IACrC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAA;IAC7B,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC7B,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACzC,UAAU,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACxC,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IACpD,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC3D,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,CAyDA"}