@molecule/app-svelte 3.5.1 → 3.6.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 +226 -72
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/live-store.d.ts +0 -8
- package/dist/hooks/live-store.d.ts.map +1 -1
- package/dist/hooks/live-store.js +0 -13
- package/dist/hooks/maybe-readable.d.ts +36 -0
- package/dist/hooks/maybe-readable.d.ts.map +1 -0
- package/dist/hooks/maybe-readable.js +36 -0
- package/dist/hooks/useAIModels.d.ts +8 -2
- package/dist/hooks/useAIModels.d.ts.map +1 -1
- package/dist/hooks/useAIModels.js +44 -17
- package/dist/hooks/useAuth.d.ts +10 -4
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +39 -13
- package/dist/hooks/useForm.d.ts +11 -3
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/hooks/useForm.js +89 -57
- package/dist/hooks/useHttp.d.ts +28 -22
- package/dist/hooks/useHttp.d.ts.map +1 -1
- package/dist/hooks/useHttp.js +67 -96
- package/dist/hooks/useOAuth.d.ts +23 -7
- package/dist/hooks/useOAuth.d.ts.map +1 -1
- package/dist/hooks/useOAuth.js +51 -18
- package/dist/hooks/useOptimisticValue.d.ts +11 -4
- package/dist/hooks/useOptimisticValue.d.ts.map +1 -1
- package/dist/hooks/useOptimisticValue.js +40 -49
- package/dist/hooks/usePush.d.ts +7 -3
- package/dist/hooks/usePush.d.ts.map +1 -1
- package/dist/hooks/usePush.js +26 -6
- package/dist/hooks/useRouter.d.ts +13 -7
- package/dist/hooks/useRouter.d.ts.map +1 -1
- package/dist/hooks/useRouter.js +39 -18
- package/dist/hooks/useStorage.d.ts +22 -9
- package/dist/hooks/useStorage.d.ts.map +1 -1
- package/dist/hooks/useStorage.js +146 -69
- package/dist/hooks/useStore.d.ts +14 -7
- package/dist/hooks/useStore.d.ts.map +1 -1
- package/dist/hooks/useStore.js +46 -9
- package/dist/hooks/useTranslation.d.ts +6 -2
- package/dist/hooks/useTranslation.d.ts.map +1 -1
- package/dist/hooks/useTranslation.js +11 -6
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/link/Link.svelte +33 -0
- package/dist/link/Link.svelte.d.ts +12 -0
- package/dist/link/Link.svelte.d.ts.map +1 -0
- package/dist/link/index.d.ts +23 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +22 -0
- package/dist/link/types.d.ts +26 -0
- package/dist/link/types.d.ts.map +1 -0
- package/dist/link/types.js +6 -0
- package/dist/stores/chat.d.ts +4 -3
- package/dist/stores/chat.d.ts.map +1 -1
- package/dist/stores/chat.js +14 -15
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Link`: an in-app anchor for Svelte, the counterpart of react-router's `<Link>`.
|
|
3
|
+
*
|
|
4
|
+
* Use it for every internal link instead of an anchor with a click handler that
|
|
5
|
+
* calls `navigate()`. It reads the router from `setMoleculeContext`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```svelte
|
|
9
|
+
* <script lang="ts">
|
|
10
|
+
* import { Link } from '@molecule/app-svelte'
|
|
11
|
+
* </script>
|
|
12
|
+
*
|
|
13
|
+
* <nav>
|
|
14
|
+
* <Link to="/projects" class="nav-link">Projects</Link>
|
|
15
|
+
* <Link to="/login" replace state={{ from: '/projects' }}>Log in</Link>
|
|
16
|
+
* </nav>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
export { default as Link } from './Link.svelte';
|
|
22
|
+
export * from './types.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props of the Svelte `Link` component.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
8
|
+
/**
|
|
9
|
+
* Props for `Link`. Every other anchor attribute (`class`, `target`, `rel`,
|
|
10
|
+
* `aria-*`, `data-*`, `onclick`) goes on the anchor.
|
|
11
|
+
*/
|
|
12
|
+
export interface LinkProps extends Omit<HTMLAnchorAttributes, 'href' | 'children'> {
|
|
13
|
+
/** Destination: an app path (`/settings?tab=billing#plan`) or a URL. Rendered as the anchor's `href`. */
|
|
14
|
+
to: string;
|
|
15
|
+
/**
|
|
16
|
+
* Replace the current history entry instead of pushing one. When omitted, a
|
|
17
|
+
* link to the location already shown replaces it and any other link pushes,
|
|
18
|
+
* as with react-router's `<Link>`.
|
|
19
|
+
*/
|
|
20
|
+
replace?: boolean;
|
|
21
|
+
/** State stored with the new history entry (read back with `useLocation()`). */
|
|
22
|
+
state?: unknown;
|
|
23
|
+
/** The link's content. */
|
|
24
|
+
children?: Snippet;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/link/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE3D;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,UAAU,CAAC;IAChF,yGAAyG;IACzG,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB"}
|
package/dist/stores/chat.d.ts
CHANGED
|
@@ -46,9 +46,10 @@ export declare const resetChatStoresForTests: typeof coreResetChatStoresForTests
|
|
|
46
46
|
* the controls (send, abort, queue edits, history). Call it during component
|
|
47
47
|
* init.
|
|
48
48
|
*
|
|
49
|
-
* The options may be a readable store
|
|
50
|
-
*
|
|
51
|
-
*
|
|
49
|
+
* The options may be a plain value or a readable store of one (a store holding
|
|
50
|
+
* `undefined` means no options): a new `endpoint` switches conversation and a
|
|
51
|
+
* new `projectId` moves to that project's transcript, on the same component,
|
|
52
|
+
* the way React re-renders `useChat`.
|
|
52
53
|
*
|
|
53
54
|
* @param options - Chat options (or a store of them): endpoint, project id, history loading, callbacks.
|
|
54
55
|
* @returns Each state field as a readable store, and the chat controls.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/stores/chat.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAgB,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,eAAe,IAAI,mBAAmB,EAEtC,iBAAiB,IAAI,qBAAqB,EAC1C,uBAAuB,IAAI,2BAA2B,EACvD,MAAM,uBAAuB,CAAA;AAK9B,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAA;AAE/C,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAA;AAEhD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,CAAC,IAAI,MAAM,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CACtE,GAAG,mBAAmB,CAAA;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,mBAAyC,CAAA;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,qBAA6C,CAAA;AAEpF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,2BAChB,CAAA;AAE7B
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/stores/chat.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAgB,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,eAAe,IAAI,mBAAmB,EAEtC,iBAAiB,IAAI,qBAAqB,EAC1C,uBAAuB,IAAI,2BAA2B,EACvD,MAAM,uBAAuB,CAAA;AAK9B,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAA;AAE/C,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAA;AAEhD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,CAAC,IAAI,MAAM,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CACtE,GAAG,mBAAmB,CAAA;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,mBAAyC,CAAA;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,qBAA6C,CAAA;AAEpF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,2BAChB,CAAA;AAE7B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,aAAa,CA2BzF"}
|
package/dist/stores/chat.js
CHANGED
|
@@ -8,7 +8,7 @@ import { onDestroy, onMount } from 'svelte';
|
|
|
8
8
|
import { derived, get, writable } from 'svelte/store';
|
|
9
9
|
import { convergeHistory as coreConvergeHistory, createChatSession, localOnlyMessages as coreLocalOnlyMessages, resetChatStoresForTests as coreResetChatStoresForTests, } from '@molecule/app-ai-chat';
|
|
10
10
|
import { useChatProvider } from '../context.js';
|
|
11
|
-
import {
|
|
11
|
+
import { toReadable } from '../hooks/maybe-readable.js';
|
|
12
12
|
/**
|
|
13
13
|
* Converges the local transcript with authoritative server history. See
|
|
14
14
|
* `convergeHistory` in `@molecule/app-ai-chat`.
|
|
@@ -37,9 +37,10 @@ export const resetChatStoresForTests = coreResetChatStoresForTests;
|
|
|
37
37
|
* the controls (send, abort, queue edits, history). Call it during component
|
|
38
38
|
* init.
|
|
39
39
|
*
|
|
40
|
-
* The options may be a readable store
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* The options may be a plain value or a readable store of one (a store holding
|
|
41
|
+
* `undefined` means no options): a new `endpoint` switches conversation and a
|
|
42
|
+
* new `projectId` moves to that project's transcript, on the same component,
|
|
43
|
+
* the way React re-renders `useChat`.
|
|
43
44
|
*
|
|
44
45
|
* @param options - Chat options (or a store of them): endpoint, project id, history loading, callbacks.
|
|
45
46
|
* @returns Each state field as a readable store, and the chat controls.
|
|
@@ -57,25 +58,23 @@ export const resetChatStoresForTests = coreResetChatStoresForTests;
|
|
|
57
58
|
*/
|
|
58
59
|
export function useChat(options) {
|
|
59
60
|
const provider = useChatProvider();
|
|
60
|
-
|
|
61
|
+
const optionsStore = toReadable(options);
|
|
62
|
+
let current = get(optionsStore);
|
|
61
63
|
const session = createChatSession({ ...current, provider });
|
|
62
64
|
const state = writable(session.getState());
|
|
63
65
|
const unsubscribe = session.subscribe(() => state.set(session.getState()));
|
|
64
66
|
// New options reach the session as React's re-render does; a changed
|
|
65
67
|
// endpoint is a conversation change, which the session loads. The store
|
|
66
68
|
// calls back at once with the options the session was created with.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
session.update({ ...next, provider });
|
|
74
|
-
});
|
|
75
|
-
}
|
|
69
|
+
const stopOptions = optionsStore.subscribe((next) => {
|
|
70
|
+
if (next === current)
|
|
71
|
+
return;
|
|
72
|
+
current = next;
|
|
73
|
+
session.update({ ...current, provider });
|
|
74
|
+
});
|
|
76
75
|
onMount(() => session.connect());
|
|
77
76
|
onDestroy(() => {
|
|
78
|
-
stopOptions
|
|
77
|
+
stopOptions();
|
|
79
78
|
unsubscribe();
|
|
80
79
|
});
|
|
81
80
|
const fields = Object.fromEntries(Object.keys(session.getState()).map((key) => [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-svelte",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Svelte framework bindings for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"@molecule/app-logger": "^1.0.1",
|
|
47
47
|
"@molecule/app-platform": "^1.0.1",
|
|
48
48
|
"@molecule/app-push": "^1.0.1",
|
|
49
|
-
"@molecule/app-routing": "^1.
|
|
49
|
+
"@molecule/app-routing": "^1.3.0",
|
|
50
50
|
"@molecule/app-state": "^1.2.0",
|
|
51
51
|
"@molecule/app-storage": "^1.1.1",
|
|
52
52
|
"@molecule/app-theme": "^1.0.1",
|
|
53
53
|
"@molecule/app-ui": "^1.0.1",
|
|
54
54
|
"@molecule/app-utilities": "^1.0.1",
|
|
55
55
|
"@molecule/app-version": "^1.0.1",
|
|
56
|
-
"svelte": "^5.
|
|
56
|
+
"svelte": "^5.7.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@molecule/app-code-editor": {
|