@molecule/app-svelte 3.2.4 → 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.
Files changed (169) hide show
  1. package/README.md +2522 -194
  2. package/dist/agent-identity.d.ts +31 -0
  3. package/dist/agent-identity.d.ts.map +1 -0
  4. package/dist/agent-identity.js +22 -0
  5. package/dist/context.d.ts +113 -1
  6. package/dist/context.d.ts.map +1 -1
  7. package/dist/context.js +222 -3
  8. package/dist/hooks/external-store.d.ts +28 -0
  9. package/dist/hooks/external-store.d.ts.map +1 -0
  10. package/dist/hooks/external-store.js +95 -0
  11. package/dist/hooks/index.d.ts +37 -0
  12. package/dist/hooks/index.d.ts.map +1 -0
  13. package/dist/hooks/index.js +36 -0
  14. package/dist/hooks/live-store.d.ts +68 -0
  15. package/dist/hooks/live-store.d.ts.map +1 -0
  16. package/dist/hooks/live-store.js +76 -0
  17. package/dist/hooks/useAIModels.d.ts +58 -0
  18. package/dist/hooks/useAIModels.d.ts.map +1 -0
  19. package/dist/hooks/useAIModels.js +155 -0
  20. package/dist/hooks/useAsyncState.d.ts +52 -0
  21. package/dist/hooks/useAsyncState.d.ts.map +1 -0
  22. package/dist/hooks/useAsyncState.js +80 -0
  23. package/dist/hooks/useAuth.d.ts +99 -0
  24. package/dist/hooks/useAuth.d.ts.map +1 -0
  25. package/dist/hooks/useAuth.js +88 -0
  26. package/dist/hooks/useCapacitorApp.d.ts +51 -0
  27. package/dist/hooks/useCapacitorApp.d.ts.map +1 -0
  28. package/dist/hooks/useCapacitorApp.js +57 -0
  29. package/dist/hooks/useChangePassword.d.ts +41 -0
  30. package/dist/hooks/useChangePassword.d.ts.map +1 -0
  31. package/dist/hooks/useChangePassword.js +40 -0
  32. package/dist/hooks/useDevice.d.ts +48 -0
  33. package/dist/hooks/useDevice.d.ts.map +1 -0
  34. package/dist/hooks/useDevice.js +37 -0
  35. package/dist/hooks/useEditor.d.ts +65 -0
  36. package/dist/hooks/useEditor.d.ts.map +1 -0
  37. package/dist/hooks/useEditor.js +86 -0
  38. package/dist/hooks/useForm.d.ts +137 -0
  39. package/dist/hooks/useForm.d.ts.map +1 -0
  40. package/dist/hooks/useForm.js +221 -0
  41. package/dist/hooks/useHttp.d.ts +122 -0
  42. package/dist/hooks/useHttp.d.ts.map +1 -0
  43. package/dist/hooks/useHttp.js +220 -0
  44. package/dist/hooks/useLogger.d.ts +52 -0
  45. package/dist/hooks/useLogger.d.ts.map +1 -0
  46. package/dist/hooks/useLogger.js +64 -0
  47. package/dist/hooks/useLogin.d.ts +47 -0
  48. package/dist/hooks/useLogin.d.ts.map +1 -0
  49. package/dist/hooks/useLogin.js +44 -0
  50. package/dist/hooks/useOAuth.d.ts +96 -0
  51. package/dist/hooks/useOAuth.d.ts.map +1 -0
  52. package/dist/hooks/useOAuth.js +363 -0
  53. package/dist/hooks/useOptimisticValue.d.ts +58 -0
  54. package/dist/hooks/useOptimisticValue.d.ts.map +1 -0
  55. package/dist/hooks/useOptimisticValue.js +98 -0
  56. package/dist/hooks/usePasswordReset.d.ts +50 -0
  57. package/dist/hooks/usePasswordReset.d.ts.map +1 -0
  58. package/dist/hooks/usePasswordReset.js +50 -0
  59. package/dist/hooks/usePlatform.d.ts +45 -0
  60. package/dist/hooks/usePlatform.d.ts.map +1 -0
  61. package/dist/hooks/usePlatform.js +35 -0
  62. package/dist/hooks/usePreview.d.ts +54 -0
  63. package/dist/hooks/usePreview.d.ts.map +1 -0
  64. package/dist/hooks/usePreview.js +61 -0
  65. package/dist/hooks/useProfileForm.d.ts +100 -0
  66. package/dist/hooks/useProfileForm.d.ts.map +1 -0
  67. package/dist/hooks/useProfileForm.js +267 -0
  68. package/dist/hooks/usePromise.d.ts +62 -0
  69. package/dist/hooks/usePromise.d.ts.map +1 -0
  70. package/dist/hooks/usePromise.js +105 -0
  71. package/dist/hooks/usePush.d.ts +68 -0
  72. package/dist/hooks/usePush.d.ts.map +1 -0
  73. package/dist/hooks/usePush.js +79 -0
  74. package/dist/hooks/useRouter.d.ts +169 -0
  75. package/dist/hooks/useRouter.d.ts.map +1 -0
  76. package/dist/hooks/useRouter.js +212 -0
  77. package/dist/hooks/useSignup.d.ts +52 -0
  78. package/dist/hooks/useSignup.d.ts.map +1 -0
  79. package/dist/hooks/useSignup.js +42 -0
  80. package/dist/hooks/useStorage.d.ts +133 -0
  81. package/dist/hooks/useStorage.d.ts.map +1 -0
  82. package/dist/hooks/useStorage.js +228 -0
  83. package/dist/hooks/useStore.d.ts +69 -0
  84. package/dist/hooks/useStore.d.ts.map +1 -0
  85. package/dist/hooks/useStore.js +82 -0
  86. package/dist/hooks/useTheme.d.ts +55 -0
  87. package/dist/hooks/useTheme.d.ts.map +1 -0
  88. package/dist/hooks/useTheme.js +102 -0
  89. package/dist/hooks/useTranslation.d.ts +106 -0
  90. package/dist/hooks/useTranslation.d.ts.map +1 -0
  91. package/dist/hooks/useTranslation.js +159 -0
  92. package/dist/hooks/useVerifyPaymentReturn.d.ts +91 -0
  93. package/dist/hooks/useVerifyPaymentReturn.d.ts.map +1 -0
  94. package/dist/hooks/useVerifyPaymentReturn.js +189 -0
  95. package/dist/hooks/useVersion.d.ts +53 -0
  96. package/dist/hooks/useVersion.d.ts.map +1 -0
  97. package/dist/hooks/useVersion.js +70 -0
  98. package/dist/hooks/useWorkspace.d.ts +47 -0
  99. package/dist/hooks/useWorkspace.d.ts.map +1 -0
  100. package/dist/hooks/useWorkspace.js +68 -0
  101. package/dist/index.d.ts +3 -0
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +3 -1
  104. package/dist/session-ready/SessionReady.svelte +20 -0
  105. package/dist/session-ready/SessionReady.svelte.d.ts +5 -0
  106. package/dist/session-ready/SessionReady.svelte.d.ts.map +1 -0
  107. package/dist/session-ready/index.d.ts +7 -0
  108. package/dist/session-ready/index.d.ts.map +1 -0
  109. package/dist/session-ready/index.js +6 -0
  110. package/dist/stores/async-state.d.ts.map +1 -1
  111. package/dist/stores/async-state.js +12 -5
  112. package/dist/stores/auth.js +0 -1
  113. package/dist/stores/capacitor-app.js +1 -2
  114. package/dist/stores/change-password.js +0 -1
  115. package/dist/stores/chat.d.ts +68 -0
  116. package/dist/stores/chat.d.ts.map +1 -0
  117. package/dist/stores/chat.js +86 -0
  118. package/dist/stores/device.js +0 -1
  119. package/dist/stores/forms.js +0 -1
  120. package/dist/stores/http.js +0 -1
  121. package/dist/stores/i18n.d.ts +3 -2
  122. package/dist/stores/i18n.d.ts.map +1 -1
  123. package/dist/stores/i18n.js +2 -3
  124. package/dist/stores/index.d.ts +1 -0
  125. package/dist/stores/index.d.ts.map +1 -1
  126. package/dist/stores/index.js +1 -1
  127. package/dist/stores/logger.js +0 -1
  128. package/dist/stores/login.js +0 -1
  129. package/dist/stores/oauth.d.ts.map +1 -1
  130. package/dist/stores/oauth.js +6 -3
  131. package/dist/stores/password-reset.js +0 -1
  132. package/dist/stores/platform.js +0 -1
  133. package/dist/stores/promise.js +0 -1
  134. package/dist/stores/push.js +0 -1
  135. package/dist/stores/router.js +0 -1
  136. package/dist/stores/signup.js +0 -1
  137. package/dist/stores/state.js +0 -1
  138. package/dist/stores/storage.js +0 -1
  139. package/dist/stores/theme.js +0 -1
  140. package/dist/stores/version.js +0 -1
  141. package/dist/types.d.ts +23 -0
  142. package/dist/types.d.ts.map +1 -1
  143. package/dist/types.js +0 -1
  144. package/package.json +33 -8
  145. package/dist/context.js.map +0 -1
  146. package/dist/index.js.map +0 -1
  147. package/dist/stores/async-state.js.map +0 -1
  148. package/dist/stores/auth.js.map +0 -1
  149. package/dist/stores/capacitor-app.js.map +0 -1
  150. package/dist/stores/change-password.js.map +0 -1
  151. package/dist/stores/device.js.map +0 -1
  152. package/dist/stores/forms.js.map +0 -1
  153. package/dist/stores/http.js.map +0 -1
  154. package/dist/stores/i18n.js.map +0 -1
  155. package/dist/stores/index.js.map +0 -1
  156. package/dist/stores/logger.js.map +0 -1
  157. package/dist/stores/login.js.map +0 -1
  158. package/dist/stores/oauth.js.map +0 -1
  159. package/dist/stores/password-reset.js.map +0 -1
  160. package/dist/stores/platform.js.map +0 -1
  161. package/dist/stores/promise.js.map +0 -1
  162. package/dist/stores/push.js.map +0 -1
  163. package/dist/stores/router.js.map +0 -1
  164. package/dist/stores/signup.js.map +0 -1
  165. package/dist/stores/state.js.map +0 -1
  166. package/dist/stores/storage.js.map +0 -1
  167. package/dist/stores/theme.js.map +0 -1
  168. package/dist/stores/version.js.map +0 -1
  169. package/dist/types.js.map +0 -1
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Neutral, app-agnostic identity for the AI coding agent and the host product.
3
+ *
4
+ * Defined once in `@molecule/app-ai-chat` (the chat session interpolates the
5
+ * agent name into its own copy) and re-exported here under the same names as
6
+ * `@molecule/app-react`. Shared UI strings interpolate the i18n tokens
7
+ * `{{agentName}}` / `{{productName}}`, and the host supplies its own values via
8
+ * `useChat({ agentName })`; these NEUTRAL defaults apply when it passes nothing.
9
+ *
10
+ * @module
11
+ */
12
+ import type { AgentIdentity as ChatAgentIdentity } from '@molecule/app-ai-chat';
13
+ import { DEFAULT_AGENT_NAME as CHAT_DEFAULT_AGENT_NAME, DEFAULT_PRODUCT_NAME as CHAT_DEFAULT_PRODUCT_NAME } from '@molecule/app-ai-chat';
14
+ /**
15
+ * Display identity for the AI coding agent and the host product, used to
16
+ * interpolate the `{{agentName}}` / `{{productName}}` tokens in shared chat/IDE
17
+ * copy. A consuming app sets these to its own agent + product brand names; the
18
+ * shared packages fall back to {@link DEFAULT_AGENT_IDENTITY} when it does not.
19
+ */
20
+ export type AgentIdentity = ChatAgentIdentity;
21
+ /** Neutral, product-agnostic agent name used when the host supplies none. */
22
+ export declare const DEFAULT_AGENT_NAME: typeof CHAT_DEFAULT_AGENT_NAME;
23
+ /** Neutral, product-agnostic product/IDE name used when the host supplies none. */
24
+ export declare const DEFAULT_PRODUCT_NAME: typeof CHAT_DEFAULT_PRODUCT_NAME;
25
+ /**
26
+ * The neutral default identity ({@link DEFAULT_AGENT_NAME} +
27
+ * {@link DEFAULT_PRODUCT_NAME}) the shared packages use until a consuming app
28
+ * passes its own.
29
+ */
30
+ export declare const DEFAULT_AGENT_IDENTITY: AgentIdentity;
31
+ //# sourceMappingURL=agent-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-identity.d.ts","sourceRoot":"","sources":["../src/agent-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,EAEL,kBAAkB,IAAI,uBAAuB,EAC7C,oBAAoB,IAAI,yBAAyB,EAClD,MAAM,uBAAuB,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAA;AAE7C,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,EAAE,OAAO,uBAAiD,CAAA;AAEzF,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,EAAE,OAAO,yBAAqD,CAAA;AAE/F;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAA2C,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Neutral, app-agnostic identity for the AI coding agent and the host product.
3
+ *
4
+ * Defined once in `@molecule/app-ai-chat` (the chat session interpolates the
5
+ * agent name into its own copy) and re-exported here under the same names as
6
+ * `@molecule/app-react`. Shared UI strings interpolate the i18n tokens
7
+ * `{{agentName}}` / `{{productName}}`, and the host supplies its own values via
8
+ * `useChat({ agentName })`; these NEUTRAL defaults apply when it passes nothing.
9
+ *
10
+ * @module
11
+ */
12
+ import { DEFAULT_AGENT_IDENTITY as CHAT_DEFAULT_AGENT_IDENTITY, DEFAULT_AGENT_NAME as CHAT_DEFAULT_AGENT_NAME, DEFAULT_PRODUCT_NAME as CHAT_DEFAULT_PRODUCT_NAME, } from '@molecule/app-ai-chat';
13
+ /** Neutral, product-agnostic agent name used when the host supplies none. */
14
+ export const DEFAULT_AGENT_NAME = CHAT_DEFAULT_AGENT_NAME;
15
+ /** Neutral, product-agnostic product/IDE name used when the host supplies none. */
16
+ export const DEFAULT_PRODUCT_NAME = CHAT_DEFAULT_PRODUCT_NAME;
17
+ /**
18
+ * The neutral default identity ({@link DEFAULT_AGENT_NAME} +
19
+ * {@link DEFAULT_PRODUCT_NAME}) the shared packages use until a consuming app
20
+ * passes its own.
21
+ */
22
+ export const DEFAULT_AGENT_IDENTITY = CHAT_DEFAULT_AGENT_IDENTITY;
package/dist/context.d.ts CHANGED
@@ -3,9 +3,13 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ import type { ChatProvider } from '@molecule/app-ai-chat';
6
7
  import type { AuthClient, RegisterExtraShape } from '@molecule/app-auth';
8
+ import type { EditorProvider } from '@molecule/app-code-editor';
7
9
  import type { HttpClient } from '@molecule/app-http';
8
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';
9
13
  import type { LoggerProvider } from '@molecule/app-logger';
10
14
  import type { Router } from '@molecule/app-routing';
11
15
  import type { StateProvider } from '@molecule/app-state';
@@ -32,7 +36,7 @@ import type { MoleculeConfig } from './types.js';
32
36
  *
33
37
  * <slot />
34
38
  * ```
35
- * @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
39
+ * @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger, chat, workspace, editor, preview).
36
40
  */
37
41
  export declare function setMoleculeContext(config: MoleculeConfig): void;
38
42
  /**
@@ -75,6 +79,26 @@ export declare function setStorageContext(provider: StorageProvider): void;
75
79
  * @param provider - The logger provider to store in Svelte context.
76
80
  */
77
81
  export declare function setLoggerContext(provider: LoggerProvider): void;
82
+ /**
83
+ * Sets the AI chat context.
84
+ * @param provider - The chat provider to store in Svelte context.
85
+ */
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;
78
102
  /**
79
103
  * Gets the state provider from Svelte context.
80
104
  * @returns The state provider instance.
@@ -123,4 +147,92 @@ export declare function getStorageProvider(): StorageProvider;
123
147
  * @throws {Error} If no logger provider has been set in context.
124
148
  */
125
149
  export declare function getLoggerProvider(): LoggerProvider;
150
+ /**
151
+ * Gets the AI chat provider from Svelte context (`setMoleculeContext({ chat })`).
152
+ * @returns The chat provider instance.
153
+ * @throws {Error} If no chat provider has been set in context.
154
+ */
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;
126
238
  //# sourceMapp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;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');
@@ -14,6 +14,10 @@ const I18N_KEY = Symbol('molecule-i18n');
14
14
  const HTTP_KEY = Symbol('molecule-http');
15
15
  const STORAGE_KEY = Symbol('molecule-storage');
16
16
  const LOGGER_KEY = Symbol('molecule-logger');
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');
17
21
  /**
18
22
  * Set all molecule providers in Svelte context.
19
23
  *
@@ -34,7 +38,7 @@ const LOGGER_KEY = Symbol('molecule-logger');
34
38
  *
35
39
  * <slot />
36
40
  * ```
37
- * @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
41
+ * @param config - Provider instances to register (state, auth, theme, router, i18n, http, storage, logger, chat, workspace, editor, preview).
38
42
  */
39
43
  export function setMoleculeContext(config) {
40
44
  if (config.state)
@@ -53,6 +57,14 @@ export function setMoleculeContext(config) {
53
57
  setContext(STORAGE_KEY, config.storage);
54
58
  if (config.logger)
55
59
  setContext(LOGGER_KEY, config.logger);
60
+ if (config.chat)
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);
56
68
  }
57
69
  // Individual setters
58
70
  /**
@@ -111,6 +123,34 @@ export function setStorageContext(provider) {
111
123
  export function setLoggerContext(provider) {
112
124
  setContext(LOGGER_KEY, provider);
113
125
  }
126
+ /**
127
+ * Sets the AI chat context.
128
+ * @param provider - The chat provider to store in Svelte context.
129
+ */
130
+ export function setChatContext(provider) {
131
+ setContext(CHAT_KEY, provider);
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
+ }
114
154
  // Getters
115
155
  /**
116
156
  * Gets the state provider from Svelte context.
@@ -214,4 +254,183 @@ export function getLoggerProvider() {
214
254
  }));
215
255
  return provider;
216
256
  }
217
- //# sourceMappingURL=context.js.map
257
+ /**
258
+ * Gets the AI chat provider from Svelte context (`setMoleculeContext({ chat })`).
259
+ * @returns The chat provider instance.
260
+ * @throws {Error} If no chat provider has been set in context.
261
+ */
262
+ export function useChatProvider() {
263
+ const provider = getContext(CHAT_KEY);
264
+ if (!provider)
265
+ throw new Error(t('svelte.error.useChatOutsideProvider', undefined, {
266
+ defaultValue: 'useChatProvider must be used within a ChatProvider',
267
+ }));
268
+ return provider;
269
+ }
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"}