@molecule/app-svelte 3.14.1 → 3.18.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 (66) hide show
  1. package/README.md +246 -284
  2. package/dist/ai-models.d.ts +2 -0
  3. package/dist/ai-models.d.ts.map +1 -0
  4. package/dist/ai-models.js +1 -0
  5. package/dist/chat/index.d.ts +6 -0
  6. package/dist/chat/index.d.ts.map +1 -0
  7. package/dist/chat/index.js +5 -0
  8. package/dist/chat-context.d.ts +13 -0
  9. package/dist/chat-context.d.ts.map +1 -0
  10. package/dist/chat-context.js +23 -0
  11. package/dist/chat-provider.d.ts +5 -0
  12. package/dist/chat-provider.d.ts.map +1 -0
  13. package/dist/chat-provider.js +5 -0
  14. package/dist/chat-types.d.ts +9 -0
  15. package/dist/chat-types.d.ts.map +1 -0
  16. package/dist/chat-types.js +1 -0
  17. package/dist/context.d.ts +59 -13
  18. package/dist/context.d.ts.map +1 -1
  19. package/dist/context.js +44 -26
  20. package/dist/hooks/index.d.ts +0 -2
  21. package/dist/hooks/index.d.ts.map +1 -1
  22. package/dist/hooks/index.js +0 -2
  23. package/dist/hooks/useAIModels.d.ts +1 -1
  24. package/dist/hooks/useAIModels.js +1 -1
  25. package/dist/hooks/usePush.d.ts +1 -1
  26. package/dist/hooks/usePush.js +1 -1
  27. package/dist/hooks/useTranslation.d.ts +9 -4
  28. package/dist/hooks/useTranslation.d.ts.map +1 -1
  29. package/dist/hooks/useTranslation.js +10 -1
  30. package/dist/index.d.ts +7 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +7 -1
  33. package/dist/legacy-ai-models.d.ts +17 -0
  34. package/dist/legacy-ai-models.d.ts.map +1 -0
  35. package/dist/legacy-ai-models.js +11 -0
  36. package/dist/legacy-chat.d.ts +77 -0
  37. package/dist/legacy-chat.d.ts.map +1 -0
  38. package/dist/legacy-chat.js +51 -0
  39. package/dist/legacy-push.d.ts +22 -0
  40. package/dist/legacy-push.d.ts.map +1 -0
  41. package/dist/legacy-push.js +11 -0
  42. package/dist/link/Link.svelte +18 -8
  43. package/dist/link/Link.svelte.d.ts +7 -1
  44. package/dist/link/Link.svelte.d.ts.map +1 -1
  45. package/dist/link/types.d.ts +5 -1
  46. package/dist/link/types.d.ts.map +1 -1
  47. package/dist/providers/ChatProvider.svelte +1 -1
  48. package/dist/providers/ChatProvider.svelte.d.ts +1 -1
  49. package/dist/providers/ChatProvider.svelte.d.ts.map +1 -1
  50. package/dist/providers/providers.d.ts +0 -4
  51. package/dist/providers/providers.d.ts.map +1 -1
  52. package/dist/providers/providers.js +0 -5
  53. package/dist/providers/services.js +2 -1
  54. package/dist/push.d.ts +3 -0
  55. package/dist/push.d.ts.map +1 -0
  56. package/dist/push.js +2 -0
  57. package/dist/stores/chat.d.ts +1 -1
  58. package/dist/stores/chat.js +2 -2
  59. package/dist/stores/index.d.ts +0 -2
  60. package/dist/stores/index.d.ts.map +1 -1
  61. package/dist/stores/index.js +0 -2
  62. package/dist/stores/push.d.ts +1 -1
  63. package/dist/stores/push.js +1 -1
  64. package/dist/types.d.ts +0 -6
  65. package/dist/types.d.ts.map +1 -1
  66. package/package.json +20 -5
@@ -0,0 +1,2 @@
1
+ export * from './hooks/useAIModels.js';
2
+ //# sourceMappingURL=ai-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-models.d.ts","sourceRoot":"","sources":["../src/ai-models.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './hooks/useAIModels.js';
@@ -0,0 +1,6 @@
1
+ export * from '../agent-identity.js';
2
+ export * from '../chat-context.js';
3
+ export * from '../chat-provider.js';
4
+ export * from '../chat-types.js';
5
+ export * from '../stores/chat.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from '../agent-identity.js';
2
+ export * from '../chat-context.js';
3
+ export * from '../chat-provider.js';
4
+ export * from '../chat-types.js';
5
+ export * from '../stores/chat.js';
@@ -0,0 +1,13 @@
1
+ import type { ChatProvider } from '@molecule/app-ai-chat';
2
+ /**
3
+ * Sets the AI chat context.
4
+ * @param provider - The chat provider to store in Svelte context.
5
+ */
6
+ export declare function setChatContext(provider: ChatProvider): void;
7
+ /**
8
+ * Gets the AI chat provider from Svelte context (`setMoleculeContext({ chat })`).
9
+ * @returns The chat provider instance.
10
+ * @throws {Error} If no chat provider has been set in context.
11
+ */
12
+ export declare function useChatProvider(): ChatProvider;
13
+ //# sourceMappingURL=chat-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-context.d.ts","sourceRoot":"","sources":["../src/chat-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAKzD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAS9C"}
@@ -0,0 +1,23 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ import { t } from '@molecule/app-i18n';
3
+ const CHAT_KEY = Symbol('molecule-chat');
4
+ /**
5
+ * Sets the AI chat context.
6
+ * @param provider - The chat provider to store in Svelte context.
7
+ */
8
+ export function setChatContext(provider) {
9
+ setContext(CHAT_KEY, provider);
10
+ }
11
+ /**
12
+ * Gets the AI chat provider from Svelte context (`setMoleculeContext({ chat })`).
13
+ * @returns The chat provider instance.
14
+ * @throws {Error} If no chat provider has been set in context.
15
+ */
16
+ export function useChatProvider() {
17
+ const provider = getContext(CHAT_KEY);
18
+ if (!provider)
19
+ throw new Error(t('svelte.error.useChatOutsideProvider', undefined, {
20
+ defaultValue: 'useChatProvider must be used within a ChatProvider',
21
+ }));
22
+ return provider;
23
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Provider for AI chat, as `@molecule/app-react`'s `ChatProvider`.
3
+ */
4
+ export declare const ChatProvider: import("svelte").Component<import("./chat-types.js").ChatProviderProps, {}, "">;
5
+ //# sourceMappingURL=chat-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-provider.d.ts","sourceRoot":"","sources":["../src/chat-provider.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,YAAY,iFAAwB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import ChatProviderComponent from './providers/ChatProvider.svelte';
2
+ /**
3
+ * Provider for AI chat, as `@molecule/app-react`'s `ChatProvider`.
4
+ */
5
+ export const ChatProvider = ChatProviderComponent;
@@ -0,0 +1,9 @@
1
+ import type { ChatProvider } from '@molecule/app-ai-chat';
2
+ import type { ProviderProps } from './types.js';
3
+ /**
4
+ * Props for the `ChatProvider` component.
5
+ */
6
+ export interface ChatProviderProps extends ProviderProps {
7
+ provider: ChatProvider;
8
+ }
9
+ //# sourceMappingURL=chat-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-types.d.ts","sourceRoot":"","sources":["../src/chat-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,QAAQ,EAAE,YAAY,CAAA;CACvB"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/context.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  import type { Component } from 'svelte';
7
- import type { ChatProvider } from '@molecule/app-ai-chat';
7
+ import { type Readable } from 'svelte/store';
8
8
  import type { AuthClient, RegisterExtraShape } from '@molecule/app-auth';
9
9
  import type { EditorProvider } from '@molecule/app-code-editor';
10
10
  import type { HttpClient } from '@molecule/app-http';
@@ -12,10 +12,11 @@ import type { I18nProvider } from '@molecule/app-i18n';
12
12
  import type { WorkspaceProvider } from '@molecule/app-ide';
13
13
  import type { PreviewProvider } from '@molecule/app-live-preview';
14
14
  import type { LoggerProvider } from '@molecule/app-logger';
15
- import type { Router } from '@molecule/app-routing';
15
+ import { type Router } from '@molecule/app-routing';
16
16
  import { type StateProvider } from '@molecule/app-state';
17
17
  import type { StorageProvider } from '@molecule/app-storage';
18
18
  import type { ThemeProvider } from '@molecule/app-theme';
19
+ import { type MaybeReadable } from './hooks/maybe-readable.js';
19
20
  import type { MoleculeConfig } from './types.js';
20
21
  /**
21
22
  * Set all molecule providers in Svelte context.
@@ -89,11 +90,6 @@ export declare function setStorageContext(provider: StorageProvider): void;
89
90
  * @param provider - The logger provider to store in Svelte context.
90
91
  */
91
92
  export declare function setLoggerContext(provider: LoggerProvider): void;
92
- /**
93
- * Sets the AI chat context.
94
- * @param provider - The chat provider to store in Svelte context.
95
- */
96
- export declare function setChatContext(provider: ChatProvider): void;
97
93
  /**
98
94
  * Sets the IDE workspace context.
99
95
  * @param provider - The workspace provider to store in Svelte context.
@@ -158,12 +154,6 @@ export declare function getStorageProvider(): StorageProvider;
158
154
  * @throws {Error} If no logger provider has been set in context.
159
155
  */
160
156
  export declare function getLoggerProvider(): LoggerProvider;
161
- /**
162
- * Gets the AI chat provider from Svelte context (`setMoleculeContext({ chat })`).
163
- * @returns The chat provider instance.
164
- * @throws {Error} If no chat provider has been set in context.
165
- */
166
- export declare function useChatProvider(): ChatProvider;
167
157
  /**
168
158
  * Gets the IDE workspace provider from Svelte context
169
159
  * (`setMoleculeContext({ workspace })`).
@@ -218,6 +208,62 @@ export declare function useThemeProvider(): ThemeProvider;
218
208
  * `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
219
209
  */
220
210
  export declare function useRouterInstance(): Router;
211
+ /**
212
+ * The router a link navigates through, under React's hook name: the router set
213
+ * in context, or `null` for a URL outside the app when none is. The browser, or
214
+ * on a device the URL handler, opens such a URL, so a link to it renders in an
215
+ * app with no router (a widget, a static page). A link to an app path still
216
+ * fails without one: that is how an app that forgot to mount its router finds
217
+ * out.
218
+ *
219
+ * `Link` uses it. With a destination it answers for that one and follows it
220
+ * while the component lives. Without one (the destination is a `$state` prop of
221
+ * a runes component, which is no store) it returns a function to call with the
222
+ * destination wherever it is known; call it during component initialisation,
223
+ * which reads the context once.
224
+ *
225
+ * @param path - The link's destination: an app path or a URL, or a readable store of one.
226
+ * @returns A readable store of the router the link navigates through, or `null` for a URL
227
+ * outside the app with no router in context.
228
+ * @throws {I18nError} When `path` is an app path and no router is in context: the error
229
+ * {@link useRouterInstance} throws, with the same fix.
230
+ *
231
+ * @example
232
+ * ```svelte
233
+ * <script lang="ts">
234
+ * import type { Snippet } from 'svelte'
235
+ * import { writable } from 'svelte/store'
236
+ *
237
+ * import { routerLinkHref } from '@molecule/app-routing'
238
+ * import { useLinkRouter } from '@molecule/app-svelte'
239
+ *
240
+ * let { children }: { children?: Snippet } = $props()
241
+ * const to = writable('/settings')
242
+ * const router = useLinkRouter(to)
243
+ * </script>
244
+ *
245
+ * <a href={$router === null ? $to : routerLinkHref($to, $router)}>{@render children?.()}</a>
246
+ * ```
247
+ */
248
+ export declare function useLinkRouter(path: MaybeReadable<string>): Readable<Router | null>;
249
+ /**
250
+ * Reads the router without a destination yet.
251
+ *
252
+ * @returns A function that takes a link's destination and gives the router it
253
+ * navigates through, or `null` for a URL outside the app with no router in context.
254
+ * @throws {I18nError} Never here: the returned function throws for an app path with no router in
255
+ * context, the error {@link useRouterInstance} throws.
256
+ *
257
+ * @example
258
+ * ```svelte
259
+ * <script lang="ts">
260
+ * const linkRouter = useLinkRouter()
261
+ * let { to } = $props()
262
+ * const router = $derived(linkRouter(to))
263
+ * </script>
264
+ * ```
265
+ */
266
+ export declare function useLinkRouter(): (to: string) => Router | null;
221
267
  /**
222
268
  * Gets the HTTP client from Svelte context under the React hook's name.
223
269
  * @returns The HTTP client instance.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGvC,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,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAgBhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAgB/D;AAGD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CA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wBAAgB,gBAAgB,IAAI,aAAa,CAShD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,CASlC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAS9C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAS1C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CASpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAS9C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CASxD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CASpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,CAAC,GAAG,OAAO,EACX,SAAS,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,KAAK,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;;;;;GAKG;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"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,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cAAc,CASlD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CASxD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CASpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,CAAC,GAAG,OAAO,EACX,SAAS,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,KAAK,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;AAsBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;AACnF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,IAAI,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;AAc9D;;;;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
@@ -3,9 +3,13 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { getContext, setContext } from 'svelte';
6
+ import { getContext, onDestroy, setContext } from 'svelte';
7
+ import { get, writable } from 'svelte/store';
7
8
  import { getProvider as getBondedI18nProvider, I18nError, t } from '@molecule/app-i18n';
9
+ import { resolveLinkPath } from '@molecule/app-routing';
8
10
  import { getProvider as getBondedStateProvider, hasProvider as hasBondedStateProvider, } from '@molecule/app-state';
11
+ import { setChatContext } from './chat-context.js';
12
+ import { toReadable } from './hooks/maybe-readable.js';
9
13
  import { setRoutedViewContext } from './routed-view-context.js';
10
14
  // Context keys
11
15
  const STATE_KEY = Symbol('molecule-state');
@@ -16,7 +20,6 @@ const I18N_KEY = Symbol('molecule-i18n');
16
20
  const HTTP_KEY = Symbol('molecule-http');
17
21
  const STORAGE_KEY = Symbol('molecule-storage');
18
22
  const LOGGER_KEY = Symbol('molecule-logger');
19
- const CHAT_KEY = Symbol('molecule-chat');
20
23
  const WORKSPACE_KEY = Symbol('molecule-workspace');
21
24
  const EDITOR_KEY = Symbol('molecule-editor');
22
25
  const PREVIEW_KEY = Symbol('molecule-preview');
@@ -67,7 +70,7 @@ export function setMoleculeContext(config) {
67
70
  if (config.logger)
68
71
  setContext(LOGGER_KEY, config.logger);
69
72
  if (config.chat)
70
- setContext(CHAT_KEY, config.chat);
73
+ setChatContext(config.chat);
71
74
  if (config.workspace)
72
75
  setContext(WORKSPACE_KEY, config.workspace);
73
76
  if (config.editor)
@@ -137,13 +140,6 @@ export function setStorageContext(provider) {
137
140
  export function setLoggerContext(provider) {
138
141
  setContext(LOGGER_KEY, provider);
139
142
  }
140
- /**
141
- * Sets the AI chat context.
142
- * @param provider - The chat provider to store in Svelte context.
143
- */
144
- export function setChatContext(provider) {
145
- setContext(CHAT_KEY, provider);
146
- }
147
143
  /**
148
144
  * Sets the IDE workspace context.
149
145
  * @param provider - The workspace provider to store in Svelte context.
@@ -269,19 +265,6 @@ export function getLoggerProvider() {
269
265
  }));
270
266
  return provider;
271
267
  }
272
- /**
273
- * Gets the AI chat provider from Svelte context (`setMoleculeContext({ chat })`).
274
- * @returns The chat provider instance.
275
- * @throws {Error} If no chat provider has been set in context.
276
- */
277
- export function useChatProvider() {
278
- const provider = getContext(CHAT_KEY);
279
- if (!provider)
280
- throw new Error(t('svelte.error.useChatOutsideProvider', undefined, {
281
- defaultValue: 'useChatProvider must be used within a ChatProvider',
282
- }));
283
- return provider;
284
- }
285
268
  /**
286
269
  * Gets the IDE workspace provider from Svelte context
287
270
  * (`setMoleculeContext({ workspace })`).
@@ -366,6 +349,21 @@ export function useThemeProvider() {
366
349
  }));
367
350
  return provider;
368
351
  }
352
+ /**
353
+ * The router the router-reading functions and `Link` navigate through: the one
354
+ * set in context. Both {@link useRouterInstance} and {@link useLinkRouter} fail
355
+ * through this one function, so the error and its text live in one place.
356
+ *
357
+ * @param router - The router read from context, or `undefined` with none set.
358
+ * @returns The router.
359
+ * @throws {I18nError} If no router has been set in context: mount the routing bond's
360
+ * `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
361
+ */
362
+ function requireRouter(router) {
363
+ if (!router)
364
+ throw new I18nError('svelte.error.useRouterOutsideProvider', undefined, 'No router here. Mount `MoleculeRouterProvider` from the routing bond (`@molecule/app-routing-sveltekit`) in the root `+layout.svelte`, or call `setMoleculeContext({ router })` there. If the app already does this, its routing bond is older than this binding: update it (`npm install @molecule/app-routing-sveltekit@latest`).');
365
+ return router;
366
+ }
369
367
  /**
370
368
  * Gets the router from Svelte context under the React hook's name.
371
369
  * @returns The router instance.
@@ -373,9 +371,29 @@ export function useThemeProvider() {
373
371
  * `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
374
372
  */
375
373
  export function useRouterInstance() {
376
- const router = getContext(ROUTER_KEY);
377
- if (!router)
378
- throw new I18nError('svelte.error.useRouterOutsideProvider', undefined, 'No router here. Mount `MoleculeRouterProvider` from the routing bond (`@molecule/app-routing-sveltekit`) in the root `+layout.svelte`, or call `setMoleculeContext({ router })` there. If the app already does this, its routing bond is older than this binding: update it (`npm install @molecule/app-routing-sveltekit@latest`).');
374
+ return requireRouter(getContext(ROUTER_KEY));
375
+ }
376
+ /**
377
+ * The router a link to `to` navigates through, among the routers in context.
378
+ *
379
+ * @param mounted - The router read from context, or `undefined` with none set.
380
+ * @param to - The link's destination: an app path or a URL.
381
+ * @returns The router, or `null` for a URL outside the app with none set.
382
+ * @throws {I18nError} When `to` is an app path and no router is in context.
383
+ */
384
+ function linkRouter(mounted, to) {
385
+ // A URL outside the app opens through the browser or the device's URL handler: no router navigates it.
386
+ return resolveLinkPath(to) === null ? (mounted ?? null) : requireRouter(mounted);
387
+ }
388
+ export function useLinkRouter(path) {
389
+ const mounted = getContext(ROUTER_KEY);
390
+ if (path === undefined)
391
+ return (to) => linkRouter(mounted, to);
392
+ const pathStore = toReadable(path);
393
+ // Read now, so an app path with no router in context fails during initialisation, as a hook that needs a provider does.
394
+ const router = writable(linkRouter(mounted, get(pathStore)));
395
+ const stop = pathStore.subscribe((to) => router.set(linkRouter(mounted, to)));
396
+ onDestroy(stop);
379
397
  return router;
380
398
  }
381
399
  /**
@@ -7,7 +7,6 @@
7
7
  * @module
8
8
  */
9
9
  export * from './maybe-readable.js';
10
- export * from './useAIModels.js';
11
10
  export * from './useAsyncState.js';
12
11
  export * from './useAuth.js';
13
12
  export * from './useCapacitorApp.js';
@@ -26,7 +25,6 @@ export * from './usePlatform.js';
26
25
  export * from './usePreview.js';
27
26
  export * from './useProfileForm.js';
28
27
  export * from './usePromise.js';
29
- export * from './usePush.js';
30
28
  export * from './useRouter.js';
31
29
  export * from './useSignup.js';
32
30
  export * from './useStorage.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,qBAAqB,CAAA;AACnC,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,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c,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"}
@@ -7,7 +7,6 @@
7
7
  * @module
8
8
  */
9
9
  export * from './maybe-readable.js';
10
- export * from './useAIModels.js';
11
10
  export * from './useAsyncState.js';
12
11
  export * from './useAuth.js';
13
12
  export * from './useCapacitorApp.js';
@@ -26,7 +25,6 @@ export * from './usePlatform.js';
26
25
  export * from './usePreview.js';
27
26
  export * from './useProfileForm.js';
28
27
  export * from './usePromise.js';
29
- export * from './usePush.js';
30
28
  export * from './useRouter.js';
31
29
  export * from './useSignup.js';
32
30
  export * from './useStorage.js';
@@ -58,7 +58,7 @@ export interface UseAIModelsResult {
58
58
  * @example
59
59
  * ```svelte
60
60
  * <script>
61
- * import { useAIModels } from '@molecule/app-svelte'
61
+ * import { useAIModels } from '@molecule/app-svelte/ai-models'
62
62
  * const { models, freeTierModel, loading } = useAIModels()
63
63
  * </script>
64
64
  * ```
@@ -129,7 +129,7 @@ export function resetAIModelsCache() {
129
129
  * @example
130
130
  * ```svelte
131
131
  * <script>
132
- * import { useAIModels } from '@molecule/app-svelte'
132
+ * import { useAIModels } from '@molecule/app-svelte/ai-models'
133
133
  * const { models, freeTierModel, loading } = useAIModels()
134
134
  * </script>
135
135
  * ```
@@ -59,7 +59,7 @@ export interface UsePushOptions {
59
59
  * @example
60
60
  * ```svelte
61
61
  * <script>
62
- * import { usePush } from '@molecule/app-svelte'
62
+ * import { usePush } from '@molecule/app-svelte/push'
63
63
  * const { permission, requestPermission, register } = usePush({ checkOnMount: true })
64
64
  * </script>
65
65
  *
@@ -24,7 +24,7 @@ import { toReadable } from './maybe-readable.js';
24
24
  * @example
25
25
  * ```svelte
26
26
  * <script>
27
- * import { usePush } from '@molecule/app-svelte'
27
+ * import { usePush } from '@molecule/app-svelte/push'
28
28
  * const { permission, requestPermission, register } = usePush({ checkOnMount: true })
29
29
  * </script>
30
30
  *
@@ -6,8 +6,15 @@
6
6
  * @module
7
7
  */
8
8
  import { type Readable } from 'svelte/store';
9
- import type { I18nProvider, TranslateOptions } from '@molecule/app-i18n';
9
+ import type { I18nProvider, RichTranslateFunction, TranslateFunctionWithFallback, TranslateOptions } from '@molecule/app-i18n';
10
10
  import { type MaybeReadable } from './maybe-readable.js';
11
+ /**
12
+ * Reads rich catalog messages from the active provider. Call the returned
13
+ * translation function in render so it follows locale and catalog changes.
14
+ *
15
+ * @returns The locale-reactive rich translation function.
16
+ */
17
+ export declare function useRichTranslation(): RichTranslateFunction;
11
18
  /**
12
19
  * Options for the shorthand form of {@link UseTFunction}: the fallback text
13
20
  * is passed positionally, so only `count` remains here.
@@ -21,9 +28,7 @@ export type UseTShorthandOptions = Omit<TranslateOptions, 'defaultValue'>;
21
28
  * - `t(key, fallback, options?)` — a string second argument is the inline
22
29
  * English `defaultValue`, with optional `count` for pluralization.
23
30
  */
24
- export type UseTFunction = I18nProvider['t'] & {
25
- (key: string, fallback: string, options?: UseTShorthandOptions): string;
26
- };
31
+ export type UseTFunction = TranslateFunctionWithFallback;
27
32
  /**
28
33
  * What {@link useTranslation} returns: the locale-reactive values as readable
29
34
  * stores and the provider's functions as plain functions.
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../../src/hooks/useTranslation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAsB,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE1E,OAAO,KAAK,EAEV,YAAY,EAGZ,gBAAgB,EACjB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAAE,KAAK,aAAa,EAAc,MAAM,qBAAqB,CAAA;AAEpE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;AAEzE;;;;;;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AG5C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,CAGtD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,GAC7C,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAazB"}
@@ -7,9 +7,18 @@
7
7
  */
8
8
  import { onDestroy } from 'svelte';
9
9
  import { derived, fromStore, writable } from 'svelte/store';
10
- import { I18nError } from '@molecule/app-i18n';
10
+ import { createRichTranslator, I18nError } from '@molecule/app-i18n';
11
11
  import { useI18nProvider } from '../context.js';
12
12
  import { toReadable } from './maybe-readable.js';
13
+ /**
14
+ * Reads rich catalog messages from the active provider. Call the returned
15
+ * translation function in render so it follows locale and catalog changes.
16
+ *
17
+ * @returns The locale-reactive rich translation function.
18
+ */
19
+ export function useRichTranslation() {
20
+ return createRichTranslator(useT());
21
+ }
13
22
  /**
14
23
  * Subscribes the calling component to the provider's locale notifications,
15
24
  * like React's `useLocaleSnapshot`.
package/dist/index.d.ts CHANGED
@@ -153,13 +153,19 @@
153
153
  * placed it. Nothing renders on the server; `target` replaces the body and `null` renders
154
154
  * nothing until a target exists.
155
155
  *
156
+ * Use `@molecule/app-svelte/chat`, `@molecule/app-svelte/ai-models`, and
157
+ * `@molecule/app-svelte/push` for those features. The corresponding exports at the
158
+ * package root are deprecated.
159
+ *
156
160
  * @module
157
161
  */
158
- export * from './agent-identity.js';
159
162
  export * from './components/index.js';
160
163
  export * from './content.js';
161
164
  export * from './context.js';
162
165
  export * from './hooks/index.js';
166
+ export * from './legacy-ai-models.js';
167
+ export * from './legacy-chat.js';
168
+ export * from './legacy-push.js';
163
169
  export * from './link/index.js';
164
170
  export * from './providers/index.js';
165
171
  export * from './routed-view/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4JG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgKG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -153,13 +153,19 @@
153
153
  * placed it. Nothing renders on the server; `target` replaces the body and `null` renders
154
154
  * nothing until a target exists.
155
155
  *
156
+ * Use `@molecule/app-svelte/chat`, `@molecule/app-svelte/ai-models`, and
157
+ * `@molecule/app-svelte/push` for those features. The corresponding exports at the
158
+ * package root are deprecated.
159
+ *
156
160
  * @module
157
161
  */
158
- export * from './agent-identity.js';
159
162
  export * from './components/index.js';
160
163
  export * from './content.js';
161
164
  export * from './context.js';
162
165
  export * from './hooks/index.js';
166
+ export * from './legacy-ai-models.js';
167
+ export * from './legacy-chat.js';
168
+ export * from './legacy-push.js';
163
169
  export * from './link/index.js';
164
170
  export * from './providers/index.js';
165
171
  export * from './routed-view/index.js';
@@ -0,0 +1,17 @@
1
+ import * as feature from './ai-models.js';
2
+ /**
3
+ * Compatibility alias for `UseAIModelsResult`.
4
+ * @deprecated Import UseAIModelsResult from `@molecule/app-svelte/ai-models`.
5
+ */
6
+ export type UseAIModelsResult = feature.UseAIModelsResult;
7
+ /**
8
+ * Compatibility alias for `resetAIModelsCache`.
9
+ * @deprecated Import resetAIModelsCache from `@molecule/app-svelte/ai-models`.
10
+ */
11
+ export declare const resetAIModelsCache: typeof feature.resetAIModelsCache;
12
+ /**
13
+ * Compatibility alias for `useAIModels`.
14
+ * @deprecated Import useAIModels from `@molecule/app-svelte/ai-models`.
15
+ */
16
+ export declare const useAIModels: typeof feature.useAIModels;
17
+ //# sourceMappingURL=legacy-ai-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-ai-models.d.ts","sourceRoot":"","sources":["../src/legacy-ai-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,OAAO,CAAC,kBAA+C,CAAA;AAE/F;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,OAAO,CAAC,WAAiC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import * as feature from './ai-models.js';
2
+ /**
3
+ * Compatibility alias for `resetAIModelsCache`.
4
+ * @deprecated Import resetAIModelsCache from `@molecule/app-svelte/ai-models`.
5
+ */
6
+ export const resetAIModelsCache = feature.resetAIModelsCache;
7
+ /**
8
+ * Compatibility alias for `useAIModels`.
9
+ * @deprecated Import useAIModels from `@molecule/app-svelte/ai-models`.
10
+ */
11
+ export const useAIModels = feature.useAIModels;