@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.
- package/README.md +2522 -194
- package/dist/agent-identity.d.ts +31 -0
- package/dist/agent-identity.d.ts.map +1 -0
- package/dist/agent-identity.js +22 -0
- package/dist/context.d.ts +113 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +222 -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 +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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.d.ts.map +1 -1
- package/dist/stores/async-state.js +12 -5
- package/dist/stores/auth.js +0 -1
- package/dist/stores/capacitor-app.js +1 -2
- package/dist/stores/change-password.js +0 -1
- package/dist/stores/chat.d.ts +68 -0
- package/dist/stores/chat.d.ts.map +1 -0
- package/dist/stores/chat.js +86 -0
- 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.d.ts +1 -0
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/stores/logger.js +0 -1
- package/dist/stores/login.js +0 -1
- package/dist/stores/oauth.d.ts.map +1 -1
- package/dist/stores/oauth.js +6 -3
- 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 +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/package.json +33 -8
- 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/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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte hook for IDE workspace management, porting React's `useWorkspace`.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { useWorkspaceProvider } from '../context.js';
|
|
7
|
+
import { useSyncExternalStore } from './external-store.js';
|
|
8
|
+
import { fieldStore } from './live-store.js';
|
|
9
|
+
/**
|
|
10
|
+
* IDE workspace layout management, React's `useWorkspace` in Svelte's idiom:
|
|
11
|
+
* call it during component init under `setMoleculeContext({ workspace })`.
|
|
12
|
+
*
|
|
13
|
+
* The state is a snapshot store over `provider.subscribe`, cached the way
|
|
14
|
+
* React's `useSyncExternalStore` snapshot is (a provider without `getState`
|
|
15
|
+
* fabricates the non-layout fields from `getLayout()` until its first
|
|
16
|
+
* emission supplies the real ones).
|
|
17
|
+
*
|
|
18
|
+
* @returns The workspace state stores and management methods.
|
|
19
|
+
* @example
|
|
20
|
+
* ```svelte
|
|
21
|
+
* <script>
|
|
22
|
+
* import { useWorkspace } from '@molecule/app-svelte'
|
|
23
|
+
* const { layout, togglePanel } = useWorkspace()
|
|
24
|
+
* </script>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function useWorkspace() {
|
|
28
|
+
const provider = useWorkspaceProvider();
|
|
29
|
+
// Cached previous state (React's cachedRef): a snapshot equal to the
|
|
30
|
+
// provider's keeps the previous object.
|
|
31
|
+
let cached = null;
|
|
32
|
+
const getSnapshot = () => {
|
|
33
|
+
// A bond with getState answers with the full state, the same object until it changes.
|
|
34
|
+
const full = provider.getState?.();
|
|
35
|
+
if (full)
|
|
36
|
+
return full;
|
|
37
|
+
const layout = provider.getLayout();
|
|
38
|
+
// Without getState, only the layout is readable before the first subscribe
|
|
39
|
+
// callback; the rest starts at the core's initial values.
|
|
40
|
+
const prev = cached;
|
|
41
|
+
if (prev && prev.layout === layout) {
|
|
42
|
+
return prev;
|
|
43
|
+
}
|
|
44
|
+
const next = {
|
|
45
|
+
layout,
|
|
46
|
+
activePanel: null,
|
|
47
|
+
collapsedPanels: new Set(),
|
|
48
|
+
isFullscreen: false,
|
|
49
|
+
};
|
|
50
|
+
cached = next;
|
|
51
|
+
return next;
|
|
52
|
+
};
|
|
53
|
+
const state = useSyncExternalStore((onStoreChange) => {
|
|
54
|
+
return provider.subscribe((next) => {
|
|
55
|
+
cached = next;
|
|
56
|
+
onStoreChange();
|
|
57
|
+
});
|
|
58
|
+
}, getSnapshot);
|
|
59
|
+
return {
|
|
60
|
+
layout: fieldStore(state, 'layout'),
|
|
61
|
+
activePanel: fieldStore(state, 'activePanel'),
|
|
62
|
+
collapsedPanels: fieldStore(state, 'collapsedPanels'),
|
|
63
|
+
togglePanel: (panelId) => provider.togglePanel(panelId),
|
|
64
|
+
resizePanel: (panelId, size) => provider.resizePanel(panelId, size),
|
|
65
|
+
setActivePanel: (panelId) => provider.setActivePanel(panelId),
|
|
66
|
+
resetLayout: () => provider.resetLayout(),
|
|
67
|
+
};
|
|
68
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,10 @@
|
|
|
54
54
|
*
|
|
55
55
|
* @module
|
|
56
56
|
*/
|
|
57
|
+
export * from './agent-identity.js';
|
|
57
58
|
export * from './context.js';
|
|
59
|
+
export * from './hooks/index.js';
|
|
60
|
+
export * from './session-ready/index.js';
|
|
58
61
|
export * from './stores/index.js';
|
|
59
62
|
export * from './types.js';
|
|
60
63
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
*
|
|
55
55
|
* @module
|
|
56
56
|
*/
|
|
57
|
+
export * from './agent-identity.js';
|
|
57
58
|
export * from './context.js';
|
|
59
|
+
export * from './hooks/index.js';
|
|
60
|
+
export * from './session-ready/index.js';
|
|
58
61
|
export * from './stores/index.js';
|
|
59
62
|
export * from './types.js';
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Hold rendering until the auth client has decided the session: the children
|
|
3
|
+
once `useAuth().status` has left 'loading', the fallback until then. React's
|
|
4
|
+
SessionReady component, as a Svelte component with children/fallback
|
|
5
|
+
snippets.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { useAuth } from '../hooks/useAuth.js'
|
|
9
|
+
import type { SessionReadyProps } from '../types.js'
|
|
10
|
+
|
|
11
|
+
let { children, fallback }: SessionReadyProps = $props()
|
|
12
|
+
|
|
13
|
+
const { status } = useAuth()
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if $status === 'loading'}
|
|
17
|
+
{@render fallback?.()}
|
|
18
|
+
{:else}
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
{/if}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SessionReadyProps } from '../types.js';
|
|
2
|
+
declare const SessionReady: import("svelte").Component<SessionReadyProps, {}, "">;
|
|
3
|
+
type SessionReady = ReturnType<typeof SessionReady>;
|
|
4
|
+
export default SessionReady;
|
|
5
|
+
//# sourceMappingURL=SessionReady.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionReady.svelte.d.ts","sourceRoot":"","sources":["../../src/session-ready/SessionReady.svelte"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoBrD,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session-ready/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-state.d.ts","sourceRoot":"","sources":["../../src/stores/async-state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"async-state.d.ts","sourceRoot":"","sources":["../../src/stores/async-state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAMtD;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACrD,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IAC/E,WAAW,EAAE,CACX,OAAO,EACL,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KACvF,IAAI,CAAA;CACV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,cAAc,CAAC,KAAG,eAAe,CAAC,CAAC,CAmEtE,CAAA"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { writable } from 'svelte/store';
|
|
7
|
+
import { getLogger } from '@molecule/app-logger';
|
|
8
|
+
const logger = getLogger('svelte-async-state');
|
|
7
9
|
/**
|
|
8
10
|
* Creates a writable store with async-capable setState and extendState.
|
|
9
11
|
*
|
|
@@ -47,8 +49,12 @@ export const createAsyncState = (initialValue) => {
|
|
|
47
49
|
else {
|
|
48
50
|
store.set(resolved);
|
|
49
51
|
}
|
|
50
|
-
}, () => {
|
|
51
|
-
//
|
|
52
|
+
}, (error) => {
|
|
53
|
+
// A rejected state promise leaves the previous state in place; record the
|
|
54
|
+
// failure so the stale state is traceable instead of silently stuck.
|
|
55
|
+
logger.warn('createAsyncState: setState promise rejected; state keeps its previous value', {
|
|
56
|
+
error,
|
|
57
|
+
});
|
|
52
58
|
});
|
|
53
59
|
}
|
|
54
60
|
else if (typeof value === 'function') {
|
|
@@ -67,8 +73,10 @@ export const createAsyncState = (initialValue) => {
|
|
|
67
73
|
else {
|
|
68
74
|
store.update((prev) => ({ ...prev, ...resolved }));
|
|
69
75
|
}
|
|
70
|
-
}, () => {
|
|
71
|
-
//
|
|
76
|
+
}, (error) => {
|
|
77
|
+
// A rejected partial-update promise leaves the previous state in place;
|
|
78
|
+
// record the failure so the stale state is traceable instead of silently stuck.
|
|
79
|
+
logger.warn('createAsyncState: extendState promise rejected; state keeps its previous value', { error });
|
|
72
80
|
});
|
|
73
81
|
}
|
|
74
82
|
else if (typeof partial === 'function') {
|
|
@@ -86,4 +94,3 @@ export const createAsyncState = (initialValue) => {
|
|
|
86
94
|
extendState,
|
|
87
95
|
};
|
|
88
96
|
};
|
|
89
|
-
//# sourceMappingURL=async-state.js.map
|
package/dist/stores/auth.js
CHANGED
|
@@ -43,7 +43,7 @@ export function createCapacitorAppStore(options) {
|
|
|
43
43
|
set(state);
|
|
44
44
|
});
|
|
45
45
|
// Auto-initialize
|
|
46
|
-
app.initialize().catch(() => {
|
|
46
|
+
app.initialize().catch((_error) => {
|
|
47
47
|
// Errors are captured in state.error via the coordinator
|
|
48
48
|
});
|
|
49
49
|
return () => {
|
|
@@ -56,4 +56,3 @@ export function createCapacitorAppStore(options) {
|
|
|
56
56
|
initialize: () => app.initialize(),
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
//# sourceMappingURL=capacitor-app.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte stores for AI chat, backed by the shared chat session of
|
|
3
|
+
* `@molecule/app-ai-chat` (the same session React's `useChat` wraps).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type Readable } from 'svelte/store';
|
|
8
|
+
import type { ChatSendOptions, ChatSessionControls, ChatSessionOptions, ChatSessionState } from '@molecule/app-ai-chat';
|
|
9
|
+
import { convergeHistory as coreConvergeHistory, localOnlyMessages as coreLocalOnlyMessages, resetChatStoresForTests as coreResetChatStoresForTests } from '@molecule/app-ai-chat';
|
|
10
|
+
/** Options for {@link useChat} (the shared chat session's options). */
|
|
11
|
+
export type UseChatOptions = ChatSessionOptions;
|
|
12
|
+
/** Options for one `sendMessage` call. */
|
|
13
|
+
export type SendMessageOptions = ChatSendOptions;
|
|
14
|
+
/**
|
|
15
|
+
* What {@link useChat} returns: each chat state field as a readable store,
|
|
16
|
+
* and the session's controls as plain functions (stable for the component's life).
|
|
17
|
+
*/
|
|
18
|
+
export type UseChatResult = {
|
|
19
|
+
readonly [K in keyof ChatSessionState]: Readable<ChatSessionState[K]>;
|
|
20
|
+
} & ChatSessionControls;
|
|
21
|
+
/**
|
|
22
|
+
* Converges the local transcript with authoritative server history. See
|
|
23
|
+
* `convergeHistory` in `@molecule/app-ai-chat`.
|
|
24
|
+
*
|
|
25
|
+
* @param prev - The local transcript.
|
|
26
|
+
* @param history - The server's history.
|
|
27
|
+
* @returns The converged transcript.
|
|
28
|
+
*/
|
|
29
|
+
export declare const convergeHistory: typeof coreConvergeHistory;
|
|
30
|
+
/**
|
|
31
|
+
* The local messages server history does not carry yet. See
|
|
32
|
+
* `localOnlyMessages` in `@molecule/app-ai-chat`.
|
|
33
|
+
*
|
|
34
|
+
* @param prev - The local transcript.
|
|
35
|
+
* @param history - The server's history.
|
|
36
|
+
* @returns The local-only messages.
|
|
37
|
+
*/
|
|
38
|
+
export declare const localOnlyMessages: typeof coreLocalOnlyMessages;
|
|
39
|
+
/**
|
|
40
|
+
* Clears every chat session store. Tests only: each test starts with no
|
|
41
|
+
* transcript, queue or stream left by the previous one.
|
|
42
|
+
*/
|
|
43
|
+
export declare const resetChatStoresForTests: typeof coreResetChatStoresForTests;
|
|
44
|
+
/**
|
|
45
|
+
* AI chat with streaming: the transcript, loading and error state, mode, and
|
|
46
|
+
* the controls (send, abort, queue edits, history). Call it during component
|
|
47
|
+
* init.
|
|
48
|
+
*
|
|
49
|
+
* The options may be a readable store: a new `endpoint` switches conversation
|
|
50
|
+
* and a new `projectId` moves to that project's transcript, on the same
|
|
51
|
+
* component, the way React re-renders `useChat`.
|
|
52
|
+
*
|
|
53
|
+
* @param options - Chat options (or a store of them): endpoint, project id, history loading, callbacks.
|
|
54
|
+
* @returns Each state field as a readable store, and the chat controls.
|
|
55
|
+
* @example
|
|
56
|
+
* ```svelte
|
|
57
|
+
* <script>
|
|
58
|
+
* import { useChat } from '@molecule/app-svelte'
|
|
59
|
+
*
|
|
60
|
+
* const chat = useChat({ endpoint: '/projects/p1/chat', projectId: 'p1' })
|
|
61
|
+
* const { messages, sendMessage } = chat
|
|
62
|
+
* </script>
|
|
63
|
+
*
|
|
64
|
+
* {#each $messages as message}<p>{message.content}</p>{/each}
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function useChat(options: UseChatOptions | Readable<UseChatOptions>): UseChatResult;
|
|
68
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,aAAa,CA6BzF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte stores for AI chat, backed by the shared chat session of
|
|
3
|
+
* `@molecule/app-ai-chat` (the same session React's `useChat` wraps).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { onDestroy, onMount } from 'svelte';
|
|
8
|
+
import { derived, get, writable } from 'svelte/store';
|
|
9
|
+
import { convergeHistory as coreConvergeHistory, createChatSession, localOnlyMessages as coreLocalOnlyMessages, resetChatStoresForTests as coreResetChatStoresForTests, } from '@molecule/app-ai-chat';
|
|
10
|
+
import { useChatProvider } from '../context.js';
|
|
11
|
+
import { isReadableStore } from '../hooks/live-store.js';
|
|
12
|
+
/**
|
|
13
|
+
* Converges the local transcript with authoritative server history. See
|
|
14
|
+
* `convergeHistory` in `@molecule/app-ai-chat`.
|
|
15
|
+
*
|
|
16
|
+
* @param prev - The local transcript.
|
|
17
|
+
* @param history - The server's history.
|
|
18
|
+
* @returns The converged transcript.
|
|
19
|
+
*/
|
|
20
|
+
export const convergeHistory = coreConvergeHistory;
|
|
21
|
+
/**
|
|
22
|
+
* The local messages server history does not carry yet. See
|
|
23
|
+
* `localOnlyMessages` in `@molecule/app-ai-chat`.
|
|
24
|
+
*
|
|
25
|
+
* @param prev - The local transcript.
|
|
26
|
+
* @param history - The server's history.
|
|
27
|
+
* @returns The local-only messages.
|
|
28
|
+
*/
|
|
29
|
+
export const localOnlyMessages = coreLocalOnlyMessages;
|
|
30
|
+
/**
|
|
31
|
+
* Clears every chat session store. Tests only: each test starts with no
|
|
32
|
+
* transcript, queue or stream left by the previous one.
|
|
33
|
+
*/
|
|
34
|
+
export const resetChatStoresForTests = coreResetChatStoresForTests;
|
|
35
|
+
/**
|
|
36
|
+
* AI chat with streaming: the transcript, loading and error state, mode, and
|
|
37
|
+
* the controls (send, abort, queue edits, history). Call it during component
|
|
38
|
+
* init.
|
|
39
|
+
*
|
|
40
|
+
* The options may be a readable store: a new `endpoint` switches conversation
|
|
41
|
+
* and a new `projectId` moves to that project's transcript, on the same
|
|
42
|
+
* component, the way React re-renders `useChat`.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Chat options (or a store of them): endpoint, project id, history loading, callbacks.
|
|
45
|
+
* @returns Each state field as a readable store, and the chat controls.
|
|
46
|
+
* @example
|
|
47
|
+
* ```svelte
|
|
48
|
+
* <script>
|
|
49
|
+
* import { useChat } from '@molecule/app-svelte'
|
|
50
|
+
*
|
|
51
|
+
* const chat = useChat({ endpoint: '/projects/p1/chat', projectId: 'p1' })
|
|
52
|
+
* const { messages, sendMessage } = chat
|
|
53
|
+
* </script>
|
|
54
|
+
*
|
|
55
|
+
* {#each $messages as message}<p>{message.content}</p>{/each}
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function useChat(options) {
|
|
59
|
+
const provider = useChatProvider();
|
|
60
|
+
let current = isReadableStore(options) ? get(options) : options;
|
|
61
|
+
const session = createChatSession({ ...current, provider });
|
|
62
|
+
const state = writable(session.getState());
|
|
63
|
+
const unsubscribe = session.subscribe(() => state.set(session.getState()));
|
|
64
|
+
// New options reach the session as React's re-render does; a changed
|
|
65
|
+
// endpoint is a conversation change, which the session loads. The store
|
|
66
|
+
// calls back at once with the options the session was created with.
|
|
67
|
+
let stopOptions = null;
|
|
68
|
+
if (isReadableStore(options)) {
|
|
69
|
+
stopOptions = options.subscribe((next) => {
|
|
70
|
+
if (next === current)
|
|
71
|
+
return;
|
|
72
|
+
current = next;
|
|
73
|
+
session.update({ ...next, provider });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
onMount(() => session.connect());
|
|
77
|
+
onDestroy(() => {
|
|
78
|
+
stopOptions?.();
|
|
79
|
+
unsubscribe();
|
|
80
|
+
});
|
|
81
|
+
const fields = Object.fromEntries(Object.keys(session.getState()).map((key) => [
|
|
82
|
+
key,
|
|
83
|
+
derived(state, (current) => current[key]),
|
|
84
|
+
]));
|
|
85
|
+
return { ...fields, ...session.controls };
|
|
86
|
+
}
|
package/dist/stores/device.js
CHANGED
package/dist/stores/forms.js
CHANGED
|
@@ -176,4 +176,3 @@ export function createFieldStore(controller, name) {
|
|
|
176
176
|
export function createWatchStore(controller, name) {
|
|
177
177
|
return readable(controller.getValue(name), (set) => subscribeAndRefresh(controller, () => controller.getValue(name), set));
|
|
178
178
|
}
|
|
179
|
-
//# sourceMappingURL=forms.js.map
|
package/dist/stores/http.js
CHANGED
package/dist/stores/i18n.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { type Readable } from 'svelte/store';
|
|
7
|
-
import type { DateFormatOptions, I18nProvider,
|
|
7
|
+
import type { DateFormatOptions, I18nProvider, LocaleConfig, NumberFormatOptions } from '@molecule/app-i18n';
|
|
8
8
|
/**
|
|
9
9
|
* I18n stores and actions.
|
|
10
10
|
*/
|
|
@@ -12,7 +12,8 @@ interface I18nStores {
|
|
|
12
12
|
locale: Readable<string>;
|
|
13
13
|
direction: Readable<'ltr' | 'rtl'>;
|
|
14
14
|
locales: Readable<LocaleConfig[]>;
|
|
15
|
-
|
|
15
|
+
/** Translates a key; re-derived on every locale or translation change, so `$t(…)` follows a switch. */
|
|
16
|
+
t: Readable<I18nProvider['t']>;
|
|
16
17
|
setLocale: (code: string) => Promise<void>;
|
|
17
18
|
formatNumber: (value: number, options?: NumberFormatOptions) => string;
|
|
18
19
|
formatDate: (value: Date | number | string, options?: DateFormatOptions) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/stores/i18n.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/stores/i18n.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EAEZ,YAAY,EACZ,mBAAmB,EAEpB,MAAM,oBAAoB,CAAA;AAI3B;;GAEG;AACH,UAAU,UAAU;IAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACxB,SAAS,EAAE,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA;IAClC,OAAO,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAA;IACjC,uGAAuG;IACvG,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9B,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IACtE,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,MAAM,CAAA;CACnF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAwB7C;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,YAAY,GAAG,UAAU,CAqB/E"}
|
package/dist/stores/i18n.js
CHANGED
|
@@ -37,7 +37,7 @@ export function createI18nStores() {
|
|
|
37
37
|
locale: derived(_version, () => provider.getLocale()),
|
|
38
38
|
direction: derived(_version, () => provider.getDirection()),
|
|
39
39
|
locales: derived(_version, () => provider.getLocales()),
|
|
40
|
-
t: derived(_version, () => (key, values) => provider.t(key, values)),
|
|
40
|
+
t: derived(_version, () => (key, values, options) => provider.t(key, values, options)),
|
|
41
41
|
setLocale: (code) => provider.setLocale(code),
|
|
42
42
|
formatNumber: (value, options) => provider.formatNumber(value, options),
|
|
43
43
|
formatDate: (value, options) => provider.formatDate(value, options),
|
|
@@ -58,10 +58,9 @@ export function createI18nStoresFromProvider(provider) {
|
|
|
58
58
|
locale: derived(_version, () => provider.getLocale()),
|
|
59
59
|
direction: derived(_version, () => provider.getDirection()),
|
|
60
60
|
locales: derived(_version, () => provider.getLocales()),
|
|
61
|
-
t: derived(_version, () => (key, values) => provider.t(key, values)),
|
|
61
|
+
t: derived(_version, () => (key, values, options) => provider.t(key, values, options)),
|
|
62
62
|
setLocale: (code) => provider.setLocale(code),
|
|
63
63
|
formatNumber: (value, options) => provider.formatNumber(value, options),
|
|
64
64
|
formatDate: (value, options) => provider.formatDate(value, options),
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
//# sourceMappingURL=i18n.js.map
|
package/dist/stores/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
|
package/dist/stores/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from './async-state.js';
|
|
|
7
7
|
export * from './auth.js';
|
|
8
8
|
export * from './capacitor-app.js';
|
|
9
9
|
export * from './change-password.js';
|
|
10
|
+
export * from './chat.js';
|
|
10
11
|
export * from './device.js';
|
|
11
12
|
export * from './forms.js';
|
|
12
13
|
export * from './http.js';
|
|
@@ -24,4 +25,3 @@ export * from './state.js';
|
|
|
24
25
|
export * from './storage.js';
|
|
25
26
|
export * from './theme.js';
|
|
26
27
|
export * from './version.js';
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
package/dist/stores/logger.js
CHANGED
package/dist/stores/login.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/stores/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIpD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAC7B,sDAAsD;IACtD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,sEAAsE;IACtE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/stores/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIpD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAC7B,sDAAsD;IACtD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,sEAAsE;IACtE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CAmKvE"}
|
package/dist/stores/oauth.js
CHANGED
|
@@ -123,11 +123,15 @@ export function createOAuthHelpers(options) {
|
|
|
123
123
|
}),
|
|
124
124
|
});
|
|
125
125
|
if (!response.ok) {
|
|
126
|
-
|
|
126
|
+
// The error body may not be JSON; the fallback error and onError below
|
|
127
|
+
// already carry the failure, so the parse error is intentionally ignored.
|
|
128
|
+
const data = await response.json().catch((_error) => ({ error: 'OAuth login failed' }));
|
|
127
129
|
options?.onError?.(data.error || 'OAuth login failed');
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
130
|
-
|
|
132
|
+
// A non-JSON success body leaves `user` null; the token comes from the
|
|
133
|
+
// response headers either way, so the parse error is intentionally ignored.
|
|
134
|
+
const data = await response.json().catch((_error) => null);
|
|
131
135
|
// Store the token from the response
|
|
132
136
|
const authHeader = response.headers.get('authorization') || response.headers.get('set-authorization');
|
|
133
137
|
const token = authHeader ? authHeader.replace('Bearer ', '') : null;
|
|
@@ -180,4 +184,3 @@ export function createOAuthHelpers(options) {
|
|
|
180
184
|
handleCallback,
|
|
181
185
|
};
|
|
182
186
|
}
|
|
183
|
-
//# sourceMappingURL=oauth.js.map
|
package/dist/stores/platform.js
CHANGED
package/dist/stores/promise.js
CHANGED
package/dist/stores/push.js
CHANGED
package/dist/stores/router.js
CHANGED
package/dist/stores/signup.js
CHANGED
package/dist/stores/state.js
CHANGED
package/dist/stores/storage.js
CHANGED
package/dist/stores/theme.js
CHANGED
package/dist/stores/version.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
6
7
|
import type { Readable, Writable } from 'svelte/store';
|
|
8
|
+
import type { ChatProvider } from '@molecule/app-ai-chat';
|
|
7
9
|
import type { AuthClient, AuthState } from '@molecule/app-auth';
|
|
10
|
+
import type { EditorProvider } from '@molecule/app-code-editor';
|
|
8
11
|
import type { FormController, FormOptions } from '@molecule/app-forms';
|
|
9
12
|
import type { HttpClient } from '@molecule/app-http';
|
|
10
13
|
import type { I18nProvider } from '@molecule/app-i18n';
|
|
14
|
+
import type { WorkspaceProvider } from '@molecule/app-ide';
|
|
15
|
+
import type { PreviewProvider } from '@molecule/app-live-preview';
|
|
11
16
|
import type { Logger, LoggerProvider } from '@molecule/app-logger';
|
|
12
17
|
import type { QueryParams, RouteLocation, RouteParams, Router } from '@molecule/app-routing';
|
|
13
18
|
import type { StateProvider, Store as MoleculeStore, StoreConfig } from '@molecule/app-state';
|
|
@@ -25,6 +30,24 @@ export interface MoleculeConfig {
|
|
|
25
30
|
http?: HttpClient;
|
|
26
31
|
storage?: StorageProvider;
|
|
27
32
|
logger?: LoggerProvider;
|
|
33
|
+
/** The AI chat provider useChat and useChatProvider use. */
|
|
34
|
+
chat?: ChatProvider;
|
|
35
|
+
/** The IDE workspace provider useWorkspace and useWorkspaceProvider use. */
|
|
36
|
+
workspace?: WorkspaceProvider;
|
|
37
|
+
/** The code editor provider useEditor and useEditorProvider use. */
|
|
38
|
+
editor?: EditorProvider;
|
|
39
|
+
/** The live preview provider usePreview and usePreviewProvider use. */
|
|
40
|
+
preview?: PreviewProvider;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Props for the `SessionReady` component: its `children` snippet renders once
|
|
44
|
+
* the auth client has decided the session, `fallback` until then.
|
|
45
|
+
*/
|
|
46
|
+
export interface SessionReadyProps {
|
|
47
|
+
/** What renders once the initial restore settles — signed in, signed out, or unavailable. */
|
|
48
|
+
children?: Snippet;
|
|
49
|
+
/** What renders while the session restore is still undecided; default nothing. */
|
|
50
|
+
fallback?: Snippet;
|
|
28
51
|
}
|
|
29
52
|
/**
|
|
30
53
|
* State for async HTTP operations.
|