@molecule/app-svelte 3.3.0 → 3.5.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.
- package/README.md +2393 -220
- package/dist/agent-identity.js +0 -1
- package/dist/context.d.ts +101 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +199 -3
- package/dist/hooks/external-store.d.ts +28 -0
- package/dist/hooks/external-store.d.ts.map +1 -0
- package/dist/hooks/external-store.js +95 -0
- package/dist/hooks/index.d.ts +37 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +36 -0
- package/dist/hooks/live-store.d.ts +68 -0
- package/dist/hooks/live-store.d.ts.map +1 -0
- package/dist/hooks/live-store.js +76 -0
- package/dist/hooks/useAIModels.d.ts +58 -0
- package/dist/hooks/useAIModels.d.ts.map +1 -0
- package/dist/hooks/useAIModels.js +155 -0
- package/dist/hooks/useAsyncState.d.ts +52 -0
- package/dist/hooks/useAsyncState.d.ts.map +1 -0
- package/dist/hooks/useAsyncState.js +80 -0
- package/dist/hooks/useAuth.d.ts +99 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/hooks/useAuth.js +88 -0
- package/dist/hooks/useCapacitorApp.d.ts +51 -0
- package/dist/hooks/useCapacitorApp.d.ts.map +1 -0
- package/dist/hooks/useCapacitorApp.js +57 -0
- package/dist/hooks/useChangePassword.d.ts +41 -0
- package/dist/hooks/useChangePassword.d.ts.map +1 -0
- package/dist/hooks/useChangePassword.js +40 -0
- package/dist/hooks/useDevice.d.ts +48 -0
- package/dist/hooks/useDevice.d.ts.map +1 -0
- package/dist/hooks/useDevice.js +37 -0
- package/dist/hooks/useEditor.d.ts +65 -0
- package/dist/hooks/useEditor.d.ts.map +1 -0
- package/dist/hooks/useEditor.js +86 -0
- package/dist/hooks/useForm.d.ts +137 -0
- package/dist/hooks/useForm.d.ts.map +1 -0
- package/dist/hooks/useForm.js +221 -0
- package/dist/hooks/useHttp.d.ts +122 -0
- package/dist/hooks/useHttp.d.ts.map +1 -0
- package/dist/hooks/useHttp.js +220 -0
- package/dist/hooks/useLogger.d.ts +52 -0
- package/dist/hooks/useLogger.d.ts.map +1 -0
- package/dist/hooks/useLogger.js +64 -0
- package/dist/hooks/useLogin.d.ts +47 -0
- package/dist/hooks/useLogin.d.ts.map +1 -0
- package/dist/hooks/useLogin.js +44 -0
- package/dist/hooks/useOAuth.d.ts +96 -0
- package/dist/hooks/useOAuth.d.ts.map +1 -0
- package/dist/hooks/useOAuth.js +363 -0
- package/dist/hooks/useOptimisticValue.d.ts +58 -0
- package/dist/hooks/useOptimisticValue.d.ts.map +1 -0
- package/dist/hooks/useOptimisticValue.js +98 -0
- package/dist/hooks/usePasswordReset.d.ts +50 -0
- package/dist/hooks/usePasswordReset.d.ts.map +1 -0
- package/dist/hooks/usePasswordReset.js +50 -0
- package/dist/hooks/usePlatform.d.ts +45 -0
- package/dist/hooks/usePlatform.d.ts.map +1 -0
- package/dist/hooks/usePlatform.js +35 -0
- package/dist/hooks/usePreview.d.ts +54 -0
- package/dist/hooks/usePreview.d.ts.map +1 -0
- package/dist/hooks/usePreview.js +61 -0
- package/dist/hooks/useProfileForm.d.ts +100 -0
- package/dist/hooks/useProfileForm.d.ts.map +1 -0
- package/dist/hooks/useProfileForm.js +267 -0
- package/dist/hooks/usePromise.d.ts +62 -0
- package/dist/hooks/usePromise.d.ts.map +1 -0
- package/dist/hooks/usePromise.js +105 -0
- package/dist/hooks/usePush.d.ts +68 -0
- package/dist/hooks/usePush.d.ts.map +1 -0
- package/dist/hooks/usePush.js +79 -0
- package/dist/hooks/useRouter.d.ts +169 -0
- package/dist/hooks/useRouter.d.ts.map +1 -0
- package/dist/hooks/useRouter.js +212 -0
- package/dist/hooks/useSignup.d.ts +52 -0
- package/dist/hooks/useSignup.d.ts.map +1 -0
- package/dist/hooks/useSignup.js +42 -0
- package/dist/hooks/useStorage.d.ts +133 -0
- package/dist/hooks/useStorage.d.ts.map +1 -0
- package/dist/hooks/useStorage.js +228 -0
- package/dist/hooks/useStore.d.ts +69 -0
- package/dist/hooks/useStore.d.ts.map +1 -0
- package/dist/hooks/useStore.js +82 -0
- package/dist/hooks/useTheme.d.ts +55 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +102 -0
- package/dist/hooks/useTranslation.d.ts +106 -0
- package/dist/hooks/useTranslation.d.ts.map +1 -0
- package/dist/hooks/useTranslation.js +159 -0
- package/dist/hooks/useVerifyPaymentReturn.d.ts +91 -0
- package/dist/hooks/useVerifyPaymentReturn.d.ts.map +1 -0
- package/dist/hooks/useVerifyPaymentReturn.js +189 -0
- package/dist/hooks/useVersion.d.ts +53 -0
- package/dist/hooks/useVersion.d.ts.map +1 -0
- package/dist/hooks/useVersion.js +70 -0
- package/dist/hooks/useWorkspace.d.ts +47 -0
- package/dist/hooks/useWorkspace.d.ts.map +1 -0
- package/dist/hooks/useWorkspace.js +68 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/session-ready/SessionReady.svelte +20 -0
- package/dist/session-ready/SessionReady.svelte.d.ts +5 -0
- package/dist/session-ready/SessionReady.svelte.d.ts.map +1 -0
- package/dist/session-ready/index.d.ts +7 -0
- package/dist/session-ready/index.d.ts.map +1 -0
- package/dist/session-ready/index.js +6 -0
- package/dist/stores/async-state.js +0 -1
- package/dist/stores/auth.js +0 -1
- package/dist/stores/capacitor-app.js +0 -1
- package/dist/stores/change-password.js +0 -1
- package/dist/stores/chat.d.ts.map +1 -1
- package/dist/stores/chat.js +3 -10
- package/dist/stores/device.js +0 -1
- package/dist/stores/forms.js +0 -1
- package/dist/stores/http.js +0 -1
- package/dist/stores/i18n.d.ts +3 -2
- package/dist/stores/i18n.d.ts.map +1 -1
- package/dist/stores/i18n.js +2 -3
- package/dist/stores/index.js +0 -1
- package/dist/stores/logger.js +0 -1
- package/dist/stores/login.js +0 -1
- package/dist/stores/oauth.js +0 -1
- package/dist/stores/password-reset.js +0 -1
- package/dist/stores/platform.js +0 -1
- package/dist/stores/promise.js +0 -1
- package/dist/stores/push.js +0 -1
- package/dist/stores/router.js +0 -1
- package/dist/stores/signup.js +0 -1
- package/dist/stores/state.js +0 -1
- package/dist/stores/storage.js +0 -1
- package/dist/stores/theme.js +0 -1
- package/dist/stores/version.js +0 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/package.json +13 -8
- package/dist/agent-identity.js.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/stores/async-state.js.map +0 -1
- package/dist/stores/auth.js.map +0 -1
- package/dist/stores/capacitor-app.js.map +0 -1
- package/dist/stores/change-password.js.map +0 -1
- package/dist/stores/chat.js.map +0 -1
- package/dist/stores/device.js.map +0 -1
- package/dist/stores/forms.js.map +0 -1
- package/dist/stores/http.js.map +0 -1
- package/dist/stores/i18n.js.map +0 -1
- package/dist/stores/index.js.map +0 -1
- package/dist/stores/logger.js.map +0 -1
- package/dist/stores/login.js.map +0 -1
- package/dist/stores/oauth.js.map +0 -1
- package/dist/stores/password-reset.js.map +0 -1
- package/dist/stores/platform.js.map +0 -1
- package/dist/stores/promise.js.map +0 -1
- package/dist/stores/push.js.map +0 -1
- package/dist/stores/router.js.map +0 -1
- package/dist/stores/signup.js.map +0 -1
- package/dist/stores/state.js.map +0 -1
- package/dist/stores/storage.js.map +0 -1
- package/dist/stores/theme.js.map +0 -1
- package/dist/stores/version.js.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/agent-identity.js
CHANGED
package/dist/context.d.ts
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ChatProvider } from '@molecule/app-ai-chat';
|
|
7
7
|
import type { AuthClient, RegisterExtraShape } from '@molecule/app-auth';
|
|
8
|
+
import type { EditorProvider } from '@molecule/app-code-editor';
|
|
8
9
|
import type { HttpClient } from '@molecule/app-http';
|
|
9
10
|
import type { I18nProvider } from '@molecule/app-i18n';
|
|
11
|
+
import type { WorkspaceProvider } from '@molecule/app-ide';
|
|
12
|
+
import type { PreviewProvider } from '@molecule/app-live-preview';
|
|
10
13
|
import type { LoggerProvider } from '@molecule/app-logger';
|
|
11
14
|
import type { Router } from '@molecule/app-routing';
|
|
12
15
|
import type { StateProvider } from '@molecule/app-state';
|
|
@@ -33,7 +36,7 @@ import type { MoleculeConfig } from './types.js';
|
|
|
33
36
|
*
|
|
34
37
|
* <slot />
|
|
35
38
|
* ```
|
|
36
|
-
* @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger, chat).
|
|
39
|
+
* @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger, chat, workspace, editor, preview).
|
|
37
40
|
*/
|
|
38
41
|
export declare function setMoleculeContext(config: MoleculeConfig): void;
|
|
39
42
|
/**
|
|
@@ -81,6 +84,21 @@ export declare function setLoggerContext(provider: LoggerProvider): void;
|
|
|
81
84
|
* @param provider - The chat provider to store in Svelte context.
|
|
82
85
|
*/
|
|
83
86
|
export declare function setChatContext(provider: ChatProvider): void;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the IDE workspace context.
|
|
89
|
+
* @param provider - The workspace provider to store in Svelte context.
|
|
90
|
+
*/
|
|
91
|
+
export declare function setWorkspaceContext(provider: WorkspaceProvider): void;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the code editor context.
|
|
94
|
+
* @param provider - The editor provider to store in Svelte context.
|
|
95
|
+
*/
|
|
96
|
+
export declare function setEditorContext(provider: EditorProvider): void;
|
|
97
|
+
/**
|
|
98
|
+
* Sets the live preview context.
|
|
99
|
+
* @param provider - The preview provider to store in Svelte context.
|
|
100
|
+
*/
|
|
101
|
+
export declare function setPreviewContext(provider: PreviewProvider): void;
|
|
84
102
|
/**
|
|
85
103
|
* Gets the state provider from Svelte context.
|
|
86
104
|
* @returns The state provider instance.
|
|
@@ -135,4 +153,86 @@ export declare function getLoggerProvider(): LoggerProvider;
|
|
|
135
153
|
* @throws {Error} If no chat provider has been set in context.
|
|
136
154
|
*/
|
|
137
155
|
export declare function useChatProvider(): ChatProvider;
|
|
156
|
+
/**
|
|
157
|
+
* Gets the IDE workspace provider from Svelte context
|
|
158
|
+
* (`setMoleculeContext({ workspace })`).
|
|
159
|
+
* @returns The workspace provider instance.
|
|
160
|
+
* @throws {Error} If no workspace provider has been set in context.
|
|
161
|
+
*/
|
|
162
|
+
export declare function useWorkspaceProvider(): WorkspaceProvider;
|
|
163
|
+
/**
|
|
164
|
+
* Gets the code editor provider from Svelte context
|
|
165
|
+
* (`setMoleculeContext({ editor })`).
|
|
166
|
+
* @returns The editor provider instance.
|
|
167
|
+
* @throws {Error} If no editor provider has been set in context.
|
|
168
|
+
*/
|
|
169
|
+
export declare function useEditorProvider(): EditorProvider;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the live preview provider from Svelte context
|
|
172
|
+
* (`setMoleculeContext({ preview })`).
|
|
173
|
+
* @returns The preview provider instance.
|
|
174
|
+
* @throws {Error} If no preview provider has been set in context.
|
|
175
|
+
*/
|
|
176
|
+
export declare function usePreviewProvider(): PreviewProvider;
|
|
177
|
+
/**
|
|
178
|
+
* Gets the auth client from Svelte context under the React hook's name
|
|
179
|
+
* (`setMoleculeContext({ auth })`).
|
|
180
|
+
*
|
|
181
|
+
* @param T - The user profile the API returns.
|
|
182
|
+
* @param TRegister - The app's own registration fields.
|
|
183
|
+
* @returns The auth client instance.
|
|
184
|
+
* @throws {Error} If no auth client has been set in context.
|
|
185
|
+
*/
|
|
186
|
+
export declare function useAuthClient<T = unknown, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>(): AuthClient<T, TRegister>;
|
|
187
|
+
/**
|
|
188
|
+
* Gets the i18n provider: the one the nearest `setMoleculeContext({ i18n })`
|
|
189
|
+
* supplies, otherwise the bonded `@molecule/app-i18n` provider, which is the
|
|
190
|
+
* one the static `t` reads — React's `useI18nProvider` contract. A component
|
|
191
|
+
* can therefore translate through {@link useTranslation} wherever the static
|
|
192
|
+
* `t` works, and it re-renders when the locale changes.
|
|
193
|
+
*
|
|
194
|
+
* @returns The i18n provider from context, or the bonded provider.
|
|
195
|
+
*/
|
|
196
|
+
export declare function useI18nProvider(): I18nProvider;
|
|
197
|
+
/**
|
|
198
|
+
* Gets the theme provider from Svelte context under the React hook's name.
|
|
199
|
+
* @returns The theme provider instance.
|
|
200
|
+
* @throws {Error} If no theme provider has been set in context.
|
|
201
|
+
*/
|
|
202
|
+
export declare function useThemeProvider(): ThemeProvider;
|
|
203
|
+
/**
|
|
204
|
+
* Gets the router from Svelte context under the React hook's name.
|
|
205
|
+
* @returns The router instance.
|
|
206
|
+
* @throws {Error} If no router has been set in context.
|
|
207
|
+
*/
|
|
208
|
+
export declare function useRouterInstance(): Router;
|
|
209
|
+
/**
|
|
210
|
+
* Gets the HTTP client from Svelte context under the React hook's name.
|
|
211
|
+
* @returns The HTTP client instance.
|
|
212
|
+
* @throws {Error} If no HTTP client has been set in context.
|
|
213
|
+
*/
|
|
214
|
+
export declare function useHttpClient(): HttpClient;
|
|
215
|
+
/**
|
|
216
|
+
* Gets the storage provider from Svelte context under the React hook's name.
|
|
217
|
+
* @returns The storage provider instance.
|
|
218
|
+
* @throws {Error} If no storage provider has been set in context.
|
|
219
|
+
*/
|
|
220
|
+
export declare function useStorageProvider(): StorageProvider;
|
|
221
|
+
/**
|
|
222
|
+
* Gets the logger provider from Svelte context under the React hook's name.
|
|
223
|
+
* @returns The logger provider instance.
|
|
224
|
+
* @throws {Error} If no logger provider has been set in context.
|
|
225
|
+
*/
|
|
226
|
+
export declare function useLoggerProvider(): LoggerProvider;
|
|
227
|
+
/**
|
|
228
|
+
* Gets the state provider from Svelte context under the React hook's name.
|
|
229
|
+
*
|
|
230
|
+
* Only hooks that read the context call this; `useStore(store)` takes its
|
|
231
|
+
* store as an argument and works with no provider at all.
|
|
232
|
+
*
|
|
233
|
+
* @returns The state provider instance.
|
|
234
|
+
* @throws {Error} when no state provider is in context — the message names the
|
|
235
|
+
* fix (which composition root to use, and the import for it).
|
|
236
|
+
*/
|
|
237
|
+
export declare function useStateProvider(): StateProvider;
|
|
138
238
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,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,EAAE,KAAK,CAAC,KACnE,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC,CAS5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAShD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAS1C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAS1C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CASpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD;AAiBD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAShD"}
|
package/dist/context.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { getContext, setContext } from 'svelte';
|
|
7
|
-
import { t } from '@molecule/app-i18n';
|
|
7
|
+
import { getProvider as getBondedI18nProvider, t } from '@molecule/app-i18n';
|
|
8
8
|
// Context keys
|
|
9
9
|
const STATE_KEY = Symbol('molecule-state');
|
|
10
10
|
const AUTH_KEY = Symbol('molecule-auth');
|
|
@@ -15,6 +15,9 @@ const HTTP_KEY = Symbol('molecule-http');
|
|
|
15
15
|
const STORAGE_KEY = Symbol('molecule-storage');
|
|
16
16
|
const LOGGER_KEY = Symbol('molecule-logger');
|
|
17
17
|
const CHAT_KEY = Symbol('molecule-chat');
|
|
18
|
+
const WORKSPACE_KEY = Symbol('molecule-workspace');
|
|
19
|
+
const EDITOR_KEY = Symbol('molecule-editor');
|
|
20
|
+
const PREVIEW_KEY = Symbol('molecule-preview');
|
|
18
21
|
/**
|
|
19
22
|
* Set all molecule providers in Svelte context.
|
|
20
23
|
*
|
|
@@ -35,7 +38,7 @@ const CHAT_KEY = Symbol('molecule-chat');
|
|
|
35
38
|
*
|
|
36
39
|
* <slot />
|
|
37
40
|
* ```
|
|
38
|
-
* @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger, chat).
|
|
41
|
+
* @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger, chat, workspace, editor, preview).
|
|
39
42
|
*/
|
|
40
43
|
export function setMoleculeContext(config) {
|
|
41
44
|
if (config.state)
|
|
@@ -56,6 +59,12 @@ export function setMoleculeContext(config) {
|
|
|
56
59
|
setContext(LOGGER_KEY, config.logger);
|
|
57
60
|
if (config.chat)
|
|
58
61
|
setContext(CHAT_KEY, config.chat);
|
|
62
|
+
if (config.workspace)
|
|
63
|
+
setContext(WORKSPACE_KEY, config.workspace);
|
|
64
|
+
if (config.editor)
|
|
65
|
+
setContext(EDITOR_KEY, config.editor);
|
|
66
|
+
if (config.preview)
|
|
67
|
+
setContext(PREVIEW_KEY, config.preview);
|
|
59
68
|
}
|
|
60
69
|
// Individual setters
|
|
61
70
|
/**
|
|
@@ -121,6 +130,27 @@ export function setLoggerContext(provider) {
|
|
|
121
130
|
export function setChatContext(provider) {
|
|
122
131
|
setContext(CHAT_KEY, provider);
|
|
123
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Sets the IDE workspace context.
|
|
135
|
+
* @param provider - The workspace provider to store in Svelte context.
|
|
136
|
+
*/
|
|
137
|
+
export function setWorkspaceContext(provider) {
|
|
138
|
+
setContext(WORKSPACE_KEY, provider);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Sets the code editor context.
|
|
142
|
+
* @param provider - The editor provider to store in Svelte context.
|
|
143
|
+
*/
|
|
144
|
+
export function setEditorContext(provider) {
|
|
145
|
+
setContext(EDITOR_KEY, provider);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Sets the live preview context.
|
|
149
|
+
* @param provider - The preview provider to store in Svelte context.
|
|
150
|
+
*/
|
|
151
|
+
export function setPreviewContext(provider) {
|
|
152
|
+
setContext(PREVIEW_KEY, provider);
|
|
153
|
+
}
|
|
124
154
|
// Getters
|
|
125
155
|
/**
|
|
126
156
|
* Gets the state provider from Svelte context.
|
|
@@ -237,4 +267,170 @@ export function useChatProvider() {
|
|
|
237
267
|
}));
|
|
238
268
|
return provider;
|
|
239
269
|
}
|
|
240
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Gets the IDE workspace provider from Svelte context
|
|
272
|
+
* (`setMoleculeContext({ workspace })`).
|
|
273
|
+
* @returns The workspace provider instance.
|
|
274
|
+
* @throws {Error} If no workspace provider has been set in context.
|
|
275
|
+
*/
|
|
276
|
+
export function useWorkspaceProvider() {
|
|
277
|
+
const provider = getContext(WORKSPACE_KEY);
|
|
278
|
+
if (!provider)
|
|
279
|
+
throw new Error(t('svelte.error.useWorkspaceOutsideProvider', undefined, {
|
|
280
|
+
defaultValue: 'useWorkspaceProvider must be used within a WorkspaceProvider',
|
|
281
|
+
}));
|
|
282
|
+
return provider;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Gets the code editor provider from Svelte context
|
|
286
|
+
* (`setMoleculeContext({ editor })`).
|
|
287
|
+
* @returns The editor provider instance.
|
|
288
|
+
* @throws {Error} If no editor provider has been set in context.
|
|
289
|
+
*/
|
|
290
|
+
export function useEditorProvider() {
|
|
291
|
+
const provider = getContext(EDITOR_KEY);
|
|
292
|
+
if (!provider)
|
|
293
|
+
throw new Error(t('svelte.error.useEditorOutsideProvider', undefined, {
|
|
294
|
+
defaultValue: 'useEditorProvider must be used within an EditorProvider',
|
|
295
|
+
}));
|
|
296
|
+
return provider;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Gets the live preview provider from Svelte context
|
|
300
|
+
* (`setMoleculeContext({ preview })`).
|
|
301
|
+
* @returns The preview provider instance.
|
|
302
|
+
* @throws {Error} If no preview provider has been set in context.
|
|
303
|
+
*/
|
|
304
|
+
export function usePreviewProvider() {
|
|
305
|
+
const provider = getContext(PREVIEW_KEY);
|
|
306
|
+
if (!provider)
|
|
307
|
+
throw new Error(t('svelte.error.usePreviewOutsideProvider', undefined, {
|
|
308
|
+
defaultValue: 'usePreviewProvider must be used within a PreviewProvider',
|
|
309
|
+
}));
|
|
310
|
+
return provider;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Gets the auth client from Svelte context under the React hook's name
|
|
314
|
+
* (`setMoleculeContext({ auth })`).
|
|
315
|
+
*
|
|
316
|
+
* @param T - The user profile the API returns.
|
|
317
|
+
* @param TRegister - The app's own registration fields.
|
|
318
|
+
* @returns The auth client instance.
|
|
319
|
+
* @throws {Error} If no auth client has been set in context.
|
|
320
|
+
*/
|
|
321
|
+
export function useAuthClient() {
|
|
322
|
+
const client = getContext(AUTH_KEY);
|
|
323
|
+
if (!client)
|
|
324
|
+
throw new Error(t('svelte.error.useAuthOutsideProvider', undefined, {
|
|
325
|
+
defaultValue: 'useAuthClient must be used within an AuthProvider',
|
|
326
|
+
}));
|
|
327
|
+
return client;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Gets the i18n provider: the one the nearest `setMoleculeContext({ i18n })`
|
|
331
|
+
* supplies, otherwise the bonded `@molecule/app-i18n` provider, which is the
|
|
332
|
+
* one the static `t` reads — React's `useI18nProvider` contract. A component
|
|
333
|
+
* can therefore translate through {@link useTranslation} wherever the static
|
|
334
|
+
* `t` works, and it re-renders when the locale changes.
|
|
335
|
+
*
|
|
336
|
+
* @returns The i18n provider from context, or the bonded provider.
|
|
337
|
+
*/
|
|
338
|
+
export function useI18nProvider() {
|
|
339
|
+
return getContext(I18N_KEY) ?? getBondedI18nProvider();
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Gets the theme provider from Svelte context under the React hook's name.
|
|
343
|
+
* @returns The theme provider instance.
|
|
344
|
+
* @throws {Error} If no theme provider has been set in context.
|
|
345
|
+
*/
|
|
346
|
+
export function useThemeProvider() {
|
|
347
|
+
const provider = getContext(THEME_KEY);
|
|
348
|
+
if (!provider)
|
|
349
|
+
throw new Error(t('svelte.error.useThemeOutsideProvider', undefined, {
|
|
350
|
+
defaultValue: 'useThemeProvider must be used within a ThemeProvider',
|
|
351
|
+
}));
|
|
352
|
+
return provider;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Gets the router from Svelte context under the React hook's name.
|
|
356
|
+
* @returns The router instance.
|
|
357
|
+
* @throws {Error} If no router has been set in context.
|
|
358
|
+
*/
|
|
359
|
+
export function useRouterInstance() {
|
|
360
|
+
const router = getContext(ROUTER_KEY);
|
|
361
|
+
if (!router)
|
|
362
|
+
throw new Error(t('svelte.error.useRouterOutsideProvider', undefined, {
|
|
363
|
+
defaultValue: 'useRouterInstance must be used within a RouterProvider',
|
|
364
|
+
}));
|
|
365
|
+
return router;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Gets the HTTP client from Svelte context under the React hook's name.
|
|
369
|
+
* @returns The HTTP client instance.
|
|
370
|
+
* @throws {Error} If no HTTP client has been set in context.
|
|
371
|
+
*/
|
|
372
|
+
export function useHttpClient() {
|
|
373
|
+
const client = getContext(HTTP_KEY);
|
|
374
|
+
if (!client)
|
|
375
|
+
throw new Error(t('svelte.error.useHttpOutsideProvider', undefined, {
|
|
376
|
+
defaultValue: 'useHttpClient must be used within an HttpProvider',
|
|
377
|
+
}));
|
|
378
|
+
return client;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Gets the storage provider from Svelte context under the React hook's name.
|
|
382
|
+
* @returns The storage provider instance.
|
|
383
|
+
* @throws {Error} If no storage provider has been set in context.
|
|
384
|
+
*/
|
|
385
|
+
export function useStorageProvider() {
|
|
386
|
+
const provider = getContext(STORAGE_KEY);
|
|
387
|
+
if (!provider)
|
|
388
|
+
throw new Error(t('svelte.error.useStorageOutsideProvider', undefined, {
|
|
389
|
+
defaultValue: 'useStorageProvider must be used within a StorageProvider',
|
|
390
|
+
}));
|
|
391
|
+
return provider;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Gets the logger provider from Svelte context under the React hook's name.
|
|
395
|
+
* @returns The logger provider instance.
|
|
396
|
+
* @throws {Error} If no logger provider has been set in context.
|
|
397
|
+
*/
|
|
398
|
+
export function useLoggerProvider() {
|
|
399
|
+
const provider = getContext(LOGGER_KEY);
|
|
400
|
+
if (!provider)
|
|
401
|
+
throw new Error(t('svelte.error.useLoggerOutsideProvider', undefined, {
|
|
402
|
+
defaultValue: 'useLoggerProvider must be used within a LoggerProvider',
|
|
403
|
+
}));
|
|
404
|
+
return provider;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* The fix, appended to the missing-provider error below — this accessor is
|
|
408
|
+
* the one place that READS the state context, so it is the one place that has
|
|
409
|
+
* to say where the context comes from. The sentences are code (an import, a
|
|
410
|
+
* call, a bond), so they are appended in English rather than translated.
|
|
411
|
+
*/
|
|
412
|
+
const STATE_CONTEXT_FIX = ' To fix: call setMoleculeContext({ state }) in your root layout — ' +
|
|
413
|
+
"`import { setMoleculeContext } from '@molecule/app-svelte'`; " +
|
|
414
|
+
'setMoleculeContext also passes the provider bonded under `@molecule/app-state` ' +
|
|
415
|
+
'(bond one with `setProvider(provider)` from `@molecule/app-state`), and ' +
|
|
416
|
+
'`setStateContext(provider)` passes one you hold. ' +
|
|
417
|
+
'To read a store you already have, call useStore(store) instead — it subscribes to the ' +
|
|
418
|
+
'store it is given and needs no provider.';
|
|
419
|
+
/**
|
|
420
|
+
* Gets the state provider from Svelte context under the React hook's name.
|
|
421
|
+
*
|
|
422
|
+
* Only hooks that read the context call this; `useStore(store)` takes its
|
|
423
|
+
* store as an argument and works with no provider at all.
|
|
424
|
+
*
|
|
425
|
+
* @returns The state provider instance.
|
|
426
|
+
* @throws {Error} when no state provider is in context — the message names the
|
|
427
|
+
* fix (which composition root to use, and the import for it).
|
|
428
|
+
*/
|
|
429
|
+
export function useStateProvider() {
|
|
430
|
+
const provider = getContext(STATE_KEY);
|
|
431
|
+
if (!provider)
|
|
432
|
+
throw new Error(t('svelte.error.useStoreOutsideProvider', undefined, {
|
|
433
|
+
defaultValue: 'useStateProvider must be used within a StateProvider',
|
|
434
|
+
}) + STATE_CONTEXT_FIX);
|
|
435
|
+
return provider;
|
|
436
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared snapshot engine of the hooks that mirror React's
|
|
3
|
+
* `useSyncExternalStore`: a readable store fed by a service subscription, whose
|
|
4
|
+
* snapshot getter runs with React's exact read cadence.
|
|
5
|
+
*
|
|
6
|
+
* React re-reads its snapshot around every render — once for the value, once
|
|
7
|
+
* more for its dev "cached getSnapshot" check (skipped after the read has
|
|
8
|
+
* proved uncached), and once after committing to catch a store that changed
|
|
9
|
+
* mid-render. Notifications run a change check first, and the re-render they
|
|
10
|
+
* cause happens on the scheduler, so two notifications inside one task coalesce
|
|
11
|
+
* into a single render. A recording snapshot getter (one the conformance kit
|
|
12
|
+
* counts, or one that logs) therefore observes the same calls it would from
|
|
13
|
+
* React's binding.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import { type Readable } from 'svelte/store';
|
|
18
|
+
/**
|
|
19
|
+
* A readable store of `getSnapshot()`'s value, subscribed for the component's
|
|
20
|
+
* lifetime, with React's `useSyncExternalStore` read cadence.
|
|
21
|
+
*
|
|
22
|
+
* @param subscribe - Subscribes the service; called with the change callback,
|
|
23
|
+
* returns the unsubscribe.
|
|
24
|
+
* @param getSnapshot - Reads the service's current snapshot.
|
|
25
|
+
* @returns A readable store of the snapshot.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useSyncExternalStore<T>(subscribe: (onChange: () => void) => () => void, getSnapshot: () => T): Readable<T>;
|
|
28
|
+
//# sourceMappingURL=external-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-store.d.ts","sourceRoot":"","sources":["../../src/hooks/external-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,EAC/C,WAAW,EAAE,MAAM,CAAC,GACnB,QAAQ,CAAC,CAAC,CAAC,CAmEb"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared snapshot engine of the hooks that mirror React's
|
|
3
|
+
* `useSyncExternalStore`: a readable store fed by a service subscription, whose
|
|
4
|
+
* snapshot getter runs with React's exact read cadence.
|
|
5
|
+
*
|
|
6
|
+
* React re-reads its snapshot around every render — once for the value, once
|
|
7
|
+
* more for its dev "cached getSnapshot" check (skipped after the read has
|
|
8
|
+
* proved uncached), and once after committing to catch a store that changed
|
|
9
|
+
* mid-render. Notifications run a change check first, and the re-render they
|
|
10
|
+
* cause happens on the scheduler, so two notifications inside one task coalesce
|
|
11
|
+
* into a single render. A recording snapshot getter (one the conformance kit
|
|
12
|
+
* counts, or one that logs) therefore observes the same calls it would from
|
|
13
|
+
* React's binding.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import { onDestroy } from 'svelte';
|
|
18
|
+
import { writable } from 'svelte/store';
|
|
19
|
+
/**
|
|
20
|
+
* A readable store of `getSnapshot()`'s value, subscribed for the component's
|
|
21
|
+
* lifetime, with React's `useSyncExternalStore` read cadence.
|
|
22
|
+
*
|
|
23
|
+
* @param subscribe - Subscribes the service; called with the change callback,
|
|
24
|
+
* returns the unsubscribe.
|
|
25
|
+
* @param getSnapshot - Reads the service's current snapshot.
|
|
26
|
+
* @returns A readable store of the snapshot.
|
|
27
|
+
*/
|
|
28
|
+
export function useSyncExternalStore(subscribe, getSnapshot) {
|
|
29
|
+
// React's didWarnUncachedGetSnapshot: after the dev check has proved the
|
|
30
|
+
// getter uncached, React stops repeating that second read.
|
|
31
|
+
let warnedUncached = false;
|
|
32
|
+
// The value the app renders (React's memoizedState) and the value the
|
|
33
|
+
// subscription's change checks compare against (React's inst.value). They
|
|
34
|
+
// differ only while a scheduled render is pending.
|
|
35
|
+
let renderedSnapshot;
|
|
36
|
+
let committedSnapshot;
|
|
37
|
+
let scheduled = false;
|
|
38
|
+
let destroyed = false;
|
|
39
|
+
/** React's dev uncached-getSnapshot check: a second read, compared. */
|
|
40
|
+
const checkUncached = (rendered) => {
|
|
41
|
+
if (warnedUncached)
|
|
42
|
+
return;
|
|
43
|
+
if (!Object.is(rendered, getSnapshot())) {
|
|
44
|
+
console.error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
45
|
+
warnedUncached = true;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const result = writable(undefined);
|
|
49
|
+
/**
|
|
50
|
+
* One render pass: read the snapshot (and its cached check), publish it, set
|
|
51
|
+
* it as committed, and re-check after "committing" it the way React's
|
|
52
|
+
* updateStoreInstance effect does.
|
|
53
|
+
*/
|
|
54
|
+
const render = () => {
|
|
55
|
+
scheduled = false;
|
|
56
|
+
if (destroyed)
|
|
57
|
+
return;
|
|
58
|
+
const rendered = getSnapshot();
|
|
59
|
+
checkUncached(rendered);
|
|
60
|
+
if (!Object.is(renderedSnapshot, rendered)) {
|
|
61
|
+
renderedSnapshot = rendered;
|
|
62
|
+
result.set(rendered);
|
|
63
|
+
}
|
|
64
|
+
committedSnapshot = rendered;
|
|
65
|
+
if (!Object.is(committedSnapshot, getSnapshot()))
|
|
66
|
+
scheduleRender();
|
|
67
|
+
};
|
|
68
|
+
/** React renders on the scheduler, so notifications inside one task coalesce. */
|
|
69
|
+
const scheduleRender = () => {
|
|
70
|
+
if (scheduled)
|
|
71
|
+
return;
|
|
72
|
+
scheduled = true;
|
|
73
|
+
queueMicrotask(render);
|
|
74
|
+
};
|
|
75
|
+
const first = getSnapshot();
|
|
76
|
+
checkUncached(first);
|
|
77
|
+
renderedSnapshot = first;
|
|
78
|
+
committedSnapshot = first;
|
|
79
|
+
result.set(first);
|
|
80
|
+
const unsubscribe = subscribe(() => {
|
|
81
|
+
if (destroyed)
|
|
82
|
+
return;
|
|
83
|
+
if (!Object.is(committedSnapshot, getSnapshot()))
|
|
84
|
+
scheduleRender();
|
|
85
|
+
});
|
|
86
|
+
// React's mount consistency check (updateStoreInstance): the store may have
|
|
87
|
+
// changed between the read above and the subscription settling.
|
|
88
|
+
if (!Object.is(committedSnapshot, getSnapshot()))
|
|
89
|
+
scheduleRender();
|
|
90
|
+
onDestroy(() => {
|
|
91
|
+
destroyed = true;
|
|
92
|
+
unsubscribe();
|
|
93
|
+
});
|
|
94
|
+
return { subscribe: result.subscribe };
|
|
95
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte hooks for molecule.dev, React's `@molecule/app-react` hooks under the
|
|
3
|
+
* same names: each is called during component init under
|
|
4
|
+
* `setMoleculeContext`, value fields are readable stores and methods are plain
|
|
5
|
+
* functions.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export * from './useAIModels.js';
|
|
10
|
+
export * from './useAsyncState.js';
|
|
11
|
+
export * from './useAuth.js';
|
|
12
|
+
export * from './useCapacitorApp.js';
|
|
13
|
+
export * from './useChangePassword.js';
|
|
14
|
+
export * from './useDevice.js';
|
|
15
|
+
export * from './useEditor.js';
|
|
16
|
+
export * from './useForm.js';
|
|
17
|
+
export * from './useHttp.js';
|
|
18
|
+
export * from './useLogger.js';
|
|
19
|
+
export * from './useLogin.js';
|
|
20
|
+
export * from './useOAuth.js';
|
|
21
|
+
export * from './useOptimisticValue.js';
|
|
22
|
+
export * from './usePasswordReset.js';
|
|
23
|
+
export * from './usePlatform.js';
|
|
24
|
+
export * from './usePreview.js';
|
|
25
|
+
export * from './useProfileForm.js';
|
|
26
|
+
export * from './usePromise.js';
|
|
27
|
+
export * from './usePush.js';
|
|
28
|
+
export * from './useRouter.js';
|
|
29
|
+
export * from './useSignup.js';
|
|
30
|
+
export * from './useStorage.js';
|
|
31
|
+
export * from './useStore.js';
|
|
32
|
+
export * from './useTheme.js';
|
|
33
|
+
export * from './useTranslation.js';
|
|
34
|
+
export * from './useVerifyPaymentReturn.js';
|
|
35
|
+
export * from './useVersion.js';
|
|
36
|
+
export * from './useWorkspace.js';
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte hooks for molecule.dev, React's `@molecule/app-react` hooks under the
|
|
3
|
+
* same names: each is called during component init under
|
|
4
|
+
* `setMoleculeContext`, value fields are readable stores and methods are plain
|
|
5
|
+
* functions.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export * from './useAIModels.js';
|
|
10
|
+
export * from './useAsyncState.js';
|
|
11
|
+
export * from './useAuth.js';
|
|
12
|
+
export * from './useCapacitorApp.js';
|
|
13
|
+
export * from './useChangePassword.js';
|
|
14
|
+
export * from './useDevice.js';
|
|
15
|
+
export * from './useEditor.js';
|
|
16
|
+
export * from './useForm.js';
|
|
17
|
+
export * from './useHttp.js';
|
|
18
|
+
export * from './useLogger.js';
|
|
19
|
+
export * from './useLogin.js';
|
|
20
|
+
export * from './useOAuth.js';
|
|
21
|
+
export * from './useOptimisticValue.js';
|
|
22
|
+
export * from './usePasswordReset.js';
|
|
23
|
+
export * from './usePlatform.js';
|
|
24
|
+
export * from './usePreview.js';
|
|
25
|
+
export * from './useProfileForm.js';
|
|
26
|
+
export * from './usePromise.js';
|
|
27
|
+
export * from './usePush.js';
|
|
28
|
+
export * from './useRouter.js';
|
|
29
|
+
export * from './useSignup.js';
|
|
30
|
+
export * from './useStorage.js';
|
|
31
|
+
export * from './useStore.js';
|
|
32
|
+
export * from './useTheme.js';
|
|
33
|
+
export * from './useTranslation.js';
|
|
34
|
+
export * from './useVerifyPaymentReturn.js';
|
|
35
|
+
export * from './useVersion.js';
|
|
36
|
+
export * from './useWorkspace.js';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared reactive scaffolding of the React-named hooks: a readable store
|
|
3
|
+
* that always holds a service's current value, subscribed eagerly at creation
|
|
4
|
+
* (during component init) and torn down when the owning component is destroyed.
|
|
5
|
+
*
|
|
6
|
+
* A `readable()` store only subscribes its service when someone subscribes the
|
|
7
|
+
* store, so a value read after an update with no live subscriber goes stale;
|
|
8
|
+
* these hooks subscribe the service for the whole component lifetime instead,
|
|
9
|
+
* the way a component's `$store` read does.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { type Readable } from 'svelte/store';
|
|
14
|
+
import type { PromiseStatus } from '@molecule/app-utilities';
|
|
15
|
+
import type { UsePromiseStore } from './usePromise.js';
|
|
16
|
+
/**
|
|
17
|
+
* A readable store that always holds `read()`'s value.
|
|
18
|
+
*
|
|
19
|
+
* The store subscribes `subscribe` eagerly (at creation, during component
|
|
20
|
+
* init), re-reads whenever it notifies and ends the subscription when the
|
|
21
|
+
* owning component is destroyed, so its value is current whether or not a
|
|
22
|
+
* subscriber is attached right now.
|
|
23
|
+
*
|
|
24
|
+
* @param read - Reads the service's current value.
|
|
25
|
+
* @param subscribe - Subscribes the service; returns its unsubscribe.
|
|
26
|
+
* @returns A readable store of the current value.
|
|
27
|
+
*/
|
|
28
|
+
export declare function liveStore<T>(read: () => T, subscribe: (notify: () => void) => () => void): Readable<T>;
|
|
29
|
+
/**
|
|
30
|
+
* One picked field of a state store, as its own readable store.
|
|
31
|
+
*
|
|
32
|
+
* @param state - The store holding the whole state object.
|
|
33
|
+
* @param key - The field to project out.
|
|
34
|
+
* @returns A readable store of that field's current value.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fieldStore<T, K extends keyof T>(state: Readable<T>, key: K): Readable<T[K]>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a hook's options were passed as a readable store (options that change
|
|
39
|
+
* without a remount) rather than as a plain value.
|
|
40
|
+
*
|
|
41
|
+
* @param value - The options, or a store of them.
|
|
42
|
+
* @returns True for a store.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isReadableStore<T>(value: T | Readable<T>): value is Readable<T>;
|
|
45
|
+
/** The field-by-field view of a `usePromise` tracker, for hooks built on it. */
|
|
46
|
+
export interface PromiseTrackerFields<T, A extends unknown[]> {
|
|
47
|
+
/** The latest call's status. */
|
|
48
|
+
status: Readable<PromiseStatus>;
|
|
49
|
+
/** The latest call's resolved value (kept while a newer call is pending). */
|
|
50
|
+
value: Readable<T | null>;
|
|
51
|
+
/** The latest call's rejection. */
|
|
52
|
+
error: Readable<Error | null>;
|
|
53
|
+
/** The tracked function (one identity for the component's life). */
|
|
54
|
+
call: (...args: A) => Promise<T>;
|
|
55
|
+
/** Returns the tracker to idle. */
|
|
56
|
+
reset: () => void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reads a `usePromise` tracker's fields as individual stores and functions,
|
|
60
|
+
* for hooks built on it (`useLogin`, `useSignup`, …).
|
|
61
|
+
*
|
|
62
|
+
* @param T - The resolved value type.
|
|
63
|
+
* @param A - The argument tuple.
|
|
64
|
+
* @param tracker - The tracker store from `usePromise`.
|
|
65
|
+
* @returns The status, value and error as stores, and the call and reset functions.
|
|
66
|
+
*/
|
|
67
|
+
export declare function promiseFields<T, A extends unknown[]>(tracker: UsePromiseStore<T, A>): PromiseTrackerFields<T, A>;
|
|
68
|
+
//# sourceMappingURL=live-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-store.d.ts","sourceRoot":"","sources":["../../src/hooks/live-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAgB,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,IAAI,EAAE,MAAM,CAAC,EACb,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,GAC5C,QAAQ,CAAC,CAAC,CAAC,CAKb;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,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