@aparte/svelte 0.23.0 → 0.25.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 +5 -0
- package/dist/AparteChat.svelte +301 -226
- package/dist/AparteChat.svelte.d.ts +136 -133
- package/dist/AparteUi.svelte +82 -52
- package/dist/AparteUi.svelte.d.ts +36 -33
- package/dist/elements.d.ts +44 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +1 -0
- package/dist/index.d.ts +1 -38
- package/dist/index.d.ts.map +1 -1
- package/dist/runes/AparteChat.svelte +304 -0
- package/dist/runes/AparteChat.svelte.d.ts +32 -0
- package/dist/runes/AparteSegmentUI.svelte +35 -0
- package/dist/runes/AparteSegmentUI.svelte.d.ts +38 -0
- package/dist/runes/AparteToolUI.svelte +44 -0
- package/dist/runes/AparteToolUI.svelte.d.ts +44 -0
- package/dist/runes/AparteUi.svelte +68 -0
- package/dist/runes/AparteUi.svelte.d.ts +16 -0
- package/dist/runes/SnippetHost.svelte +11 -0
- package/dist/runes/SnippetHost.svelte.d.ts +32 -0
- package/dist/runes/conversations.svelte.d.ts +42 -0
- package/dist/runes/conversations.svelte.d.ts.map +1 -0
- package/dist/runes/conversations.svelte.js +66 -0
- package/dist/runes/index.d.ts +18 -0
- package/dist/runes/index.d.ts.map +1 -0
- package/dist/runes/index.js +12 -0
- package/dist/runes/mount-snippet.svelte.d.ts +10 -0
- package/dist/runes/mount-snippet.svelte.d.ts.map +1 -0
- package/dist/runes/mount-snippet.svelte.js +24 -0
- package/dist/runes/types.d.ts +68 -0
- package/dist/runes/types.d.ts.map +1 -0
- package/dist/runes/types.js +1 -0
- package/dist/stores/aparteChat.d.ts +4 -0
- package/dist/stores/aparteChat.d.ts.map +1 -1
- package/dist/stores/aparteChat.js +4 -0
- package/dist/stores/aparteClient.d.ts +5 -0
- package/dist/stores/aparteClient.d.ts.map +1 -1
- package/dist/stores/aparteClient.js +5 -0
- package/dist/stores/conversationManager.d.ts +4 -0
- package/dist/stores/conversationManager.d.ts.map +1 -1
- package/dist/stores/conversationManager.js +4 -0
- package/package.json +19 -8
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type AparteConfig, AparteConversationManager, type AparteConversation, type AparteStorageAdapter, type ConversationManagerOptions } from '@aparte/core';
|
|
2
|
+
import type { AparteMessage } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Saved conversations as reactive state, for Svelte 5: read `conversations`,
|
|
5
|
+
* `activeConversations`, `activeId`… straight in a template — no stores, no `$` prefix.
|
|
6
|
+
*
|
|
7
|
+
* `init(adapter)` creates the `AparteConversationManager` on your storage adapter and
|
|
8
|
+
* registers it on the config (the global one unless you pass the chat's own), which is what
|
|
9
|
+
* lets `<AparteChat conversationId>` load and save through it. The methods are the manager's.
|
|
10
|
+
* Create it with {@link createConversations} inside a component to have it disposed with the
|
|
11
|
+
* component, or construct it yourself and call `dispose()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AparteConversations {
|
|
14
|
+
#private;
|
|
15
|
+
/** Every conversation, as the manager reports them. */
|
|
16
|
+
conversations: AparteConversation[];
|
|
17
|
+
/** The active conversation's id, or null. */
|
|
18
|
+
activeId: string | null;
|
|
19
|
+
/** The ones not archived, most recent first. */
|
|
20
|
+
readonly activeConversations: AparteConversation[];
|
|
21
|
+
/** The archived ones, most recent first. */
|
|
22
|
+
readonly archivedConversations: AparteConversation[];
|
|
23
|
+
/** The active conversation, or null. */
|
|
24
|
+
readonly activeConversation: AparteConversation | null;
|
|
25
|
+
/** The manager, once `init` has run. */
|
|
26
|
+
get manager(): AparteConversationManager | null;
|
|
27
|
+
init(adapter: AparteStorageAdapter, config?: AparteConfig, options?: ConversationManagerOptions): Promise<void>;
|
|
28
|
+
/** Stop following the manager. */
|
|
29
|
+
dispose(): void;
|
|
30
|
+
createNew(title?: string): Promise<AparteConversation>;
|
|
31
|
+
addMessage(convId: string, message: AparteMessage): Promise<void>;
|
|
32
|
+
updateMessages(convId: string, messages: AparteMessage[]): Promise<void>;
|
|
33
|
+
delete(id: string): Promise<void>;
|
|
34
|
+
archive(id: string): Promise<void>;
|
|
35
|
+
unarchive(id: string): Promise<void>;
|
|
36
|
+
pin(id: string): Promise<void>;
|
|
37
|
+
unpin(id: string): Promise<void>;
|
|
38
|
+
updateTitle(id: string, title: string): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/** An {@link AparteConversations} disposed with the component that creates it. Call from a component's script. */
|
|
41
|
+
export declare function createConversations(): AparteConversations;
|
|
42
|
+
//# sourceMappingURL=conversations.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/runes/conversations.svelte.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,YAAY,EACjB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;;IAC5B,uDAAuD;IACvD,aAAa,uBAAwC;IACrD,6CAA6C;IAC7C,QAAQ,gBAA+B;IACvC,gDAAgD;IAChD,QAAQ,CAAC,mBAAmB,uBAA6E;IACzG,4CAA4C;IAC5C,QAAQ,CAAC,qBAAqB,uBAA8E;IAC5G,wCAAwC;IACxC,QAAQ,CAAC,kBAAkB,4BAAmG;IAK9H,wCAAwC;IACxC,IAAI,OAAO,IAAI,yBAAyB,GAAG,IAAI,CAA0B;IAEnE,IAAI,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,GAAE,YAAiC,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAazI,kCAAkC;IAClC,OAAO,IAAI,IAAI;IAUf,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM;IACxB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IACjD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE;IACxD,MAAM,CAAC,EAAE,EAAE,MAAM;IACjB,OAAO,CAAC,EAAE,EAAE,MAAM;IAClB,SAAS,CAAC,EAAE,EAAE,MAAM;IACpB,GAAG,CAAC,EAAE,EAAE,MAAM;IACd,KAAK,CAAC,EAAE,EAAE,MAAM;IAChB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CACxC;AAED,kHAAkH;AAClH,wBAAgB,mBAAmB,IAAI,mBAAmB,CAIzD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { onDestroy } from 'svelte';
|
|
2
|
+
import { aparteGlobalConfig, AparteConversationManager, } from '@aparte/core';
|
|
3
|
+
const byRecency = (a, b) => b.updatedAt - a.updatedAt;
|
|
4
|
+
/**
|
|
5
|
+
* Saved conversations as reactive state, for Svelte 5: read `conversations`,
|
|
6
|
+
* `activeConversations`, `activeId`… straight in a template — no stores, no `$` prefix.
|
|
7
|
+
*
|
|
8
|
+
* `init(adapter)` creates the `AparteConversationManager` on your storage adapter and
|
|
9
|
+
* registers it on the config (the global one unless you pass the chat's own), which is what
|
|
10
|
+
* lets `<AparteChat conversationId>` load and save through it. The methods are the manager's.
|
|
11
|
+
* Create it with {@link createConversations} inside a component to have it disposed with the
|
|
12
|
+
* component, or construct it yourself and call `dispose()`.
|
|
13
|
+
*/
|
|
14
|
+
export class AparteConversations {
|
|
15
|
+
/** Every conversation, as the manager reports them. */
|
|
16
|
+
conversations = $state.raw([]);
|
|
17
|
+
/** The active conversation's id, or null. */
|
|
18
|
+
activeId = $state(null);
|
|
19
|
+
/** The ones not archived, most recent first. */
|
|
20
|
+
activeConversations = $derived(this.conversations.filter((c) => !c.archivedAt).sort(byRecency));
|
|
21
|
+
/** The archived ones, most recent first. */
|
|
22
|
+
archivedConversations = $derived(this.conversations.filter((c) => !!c.archivedAt).sort(byRecency));
|
|
23
|
+
/** The active conversation, or null. */
|
|
24
|
+
activeConversation = $derived(this.activeId ? this.conversations.find((c) => c.id === this.activeId) ?? null : null);
|
|
25
|
+
#manager = null;
|
|
26
|
+
#unsubscribe = null;
|
|
27
|
+
/** The manager, once `init` has run. */
|
|
28
|
+
get manager() { return this.#manager; }
|
|
29
|
+
async init(adapter, config = aparteGlobalConfig, options) {
|
|
30
|
+
const manager = new AparteConversationManager(adapter, options);
|
|
31
|
+
this.#manager = manager;
|
|
32
|
+
this.#unsubscribe?.();
|
|
33
|
+
this.#unsubscribe = manager.subscribe((all) => {
|
|
34
|
+
this.conversations = [...all];
|
|
35
|
+
this.activeId = manager.activeId;
|
|
36
|
+
});
|
|
37
|
+
await manager.init();
|
|
38
|
+
this.activeId = manager.activeId;
|
|
39
|
+
config.setConversationManager(manager);
|
|
40
|
+
}
|
|
41
|
+
/** Stop following the manager. */
|
|
42
|
+
dispose() {
|
|
43
|
+
this.#unsubscribe?.();
|
|
44
|
+
this.#unsubscribe = null;
|
|
45
|
+
}
|
|
46
|
+
#assert() {
|
|
47
|
+
if (!this.#manager)
|
|
48
|
+
throw new Error('[AparteConversations] Not initialised. Call init(adapter) first.');
|
|
49
|
+
return this.#manager;
|
|
50
|
+
}
|
|
51
|
+
createNew(title) { return this.#assert().createNew(title); }
|
|
52
|
+
addMessage(convId, message) { return this.#assert().addMessage(convId, message); }
|
|
53
|
+
updateMessages(convId, messages) { return this.#assert().updateMessages(convId, messages); }
|
|
54
|
+
delete(id) { return this.#assert().delete(id); }
|
|
55
|
+
archive(id) { return this.#assert().archive(id); }
|
|
56
|
+
unarchive(id) { return this.#assert().unarchive(id); }
|
|
57
|
+
pin(id) { return this.#assert().pin(id); }
|
|
58
|
+
unpin(id) { return this.#assert().unpin(id); }
|
|
59
|
+
updateTitle(id, title) { return this.#assert().updateTitle(id, title); }
|
|
60
|
+
}
|
|
61
|
+
/** An {@link AparteConversations} disposed with the component that creates it. Call from a component's script. */
|
|
62
|
+
export function createConversations() {
|
|
63
|
+
const conversations = new AparteConversations();
|
|
64
|
+
onDestroy(() => conversations.dispose());
|
|
65
|
+
return conversations;
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@aparte/svelte/runes` — the Svelte 5 components: runes, snippets, a bindable `messages`,
|
|
3
|
+
* callback props. The entry 0.26.0 makes `@aparte/svelte` itself; the Svelte 4 components stay
|
|
4
|
+
* at the package root until then, and move to `@aparte/svelte/legacy`.
|
|
5
|
+
*/
|
|
6
|
+
export { default as AparteChat } from './AparteChat.svelte';
|
|
7
|
+
export { default as AparteUi } from './AparteUi.svelte';
|
|
8
|
+
export { default as AparteToolUI } from './AparteToolUI.svelte';
|
|
9
|
+
export { default as AparteSegmentUI } from './AparteSegmentUI.svelte';
|
|
10
|
+
export type { AparteToolCallView } from '@aparte/core';
|
|
11
|
+
export { AparteConversations, createConversations } from './conversations.svelte.js';
|
|
12
|
+
export type { AparteUiProps, AparteUiHandle } from '../types.js';
|
|
13
|
+
export type { AparteChatProps } from './types.js';
|
|
14
|
+
export type { AparteChatImperativeApi } from '@aparte/core';
|
|
15
|
+
export { createAparteClient } from '../stores/aparteClient.js';
|
|
16
|
+
export type { AparteMessage, AparteSendEventDetail, AparteActionEventDetail, AparteSegment, AparteTextSegment, AparteCodeSegment, AparteThinkingSegment, } from '../types.js';
|
|
17
|
+
export type { AparteSvelteElements } from '../elements.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/runes/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrF,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EACR,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,GACxB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@aparte/svelte/runes` — the Svelte 5 components: runes, snippets, a bindable `messages`,
|
|
3
|
+
* callback props. The entry 0.26.0 makes `@aparte/svelte` itself; the Svelte 4 components stay
|
|
4
|
+
* at the package root until then, and move to `@aparte/svelte/legacy`.
|
|
5
|
+
*/
|
|
6
|
+
export { default as AparteChat } from './AparteChat.svelte';
|
|
7
|
+
export { default as AparteUi } from './AparteUi.svelte';
|
|
8
|
+
// Your components in tool calls and segments: a snippet, mounted with your contexts.
|
|
9
|
+
export { default as AparteToolUI } from './AparteToolUI.svelte';
|
|
10
|
+
export { default as AparteSegmentUI } from './AparteSegmentUI.svelte';
|
|
11
|
+
export { AparteConversations, createConversations } from './conversations.svelte.js';
|
|
12
|
+
export { createAparteClient } from '../stores/aparteClient.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { AparteMountedView } from '@aparte/core';
|
|
3
|
+
/**
|
|
4
|
+
* Mount `snippet` into `host`, with the contexts of the component that declared it.
|
|
5
|
+
*
|
|
6
|
+
* The value is raw state behind a getter, so `update` re-renders the mounted snippet in place
|
|
7
|
+
* (its components keep their state) and the view object is never wrapped in a proxy.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mountSnippet<V>(host: HTMLElement, snippet: () => Snippet<[V]>, view: V, context: Map<unknown, unknown>): AparteMountedView<V>;
|
|
10
|
+
//# sourceMappingURL=mount-snippet.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-snippet.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/runes/mount-snippet.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC1B,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GAC/B,iBAAiB,CAAC,CAAC,CAAC,CAetB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mount, unmount } from 'svelte';
|
|
2
|
+
import SnippetHost from './SnippetHost.svelte';
|
|
3
|
+
/**
|
|
4
|
+
* Mount `snippet` into `host`, with the contexts of the component that declared it.
|
|
5
|
+
*
|
|
6
|
+
* The value is raw state behind a getter, so `update` re-renders the mounted snippet in place
|
|
7
|
+
* (its components keep their state) and the view object is never wrapped in a proxy.
|
|
8
|
+
*/
|
|
9
|
+
export function mountSnippet(host, snippet, view, context) {
|
|
10
|
+
let value = $state.raw(view);
|
|
11
|
+
const instance = mount(SnippetHost, {
|
|
12
|
+
target: host,
|
|
13
|
+
props: {
|
|
14
|
+
// `mount` cannot carry the host's type parameter: it sees `Snippet<[unknown]>`.
|
|
15
|
+
get snippet() { return snippet(); },
|
|
16
|
+
get value() { return value; },
|
|
17
|
+
},
|
|
18
|
+
context,
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
update: (next) => { value = next; },
|
|
22
|
+
destroy: () => { void unmount(instance); },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { AparteConfig } from '@aparte/core';
|
|
3
|
+
import type { AparteActionEventDetail, AparteMessage, AparteSendEventDetail } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The props of the Svelte 5 `<AparteChat>`: the same surface as the other three wrappers,
|
|
6
|
+
* in runes — `messages` is bindable, the five places for your own markup are snippets, and
|
|
7
|
+
* every event is a callback prop.
|
|
8
|
+
*/
|
|
9
|
+
export interface AparteChatProps {
|
|
10
|
+
/** The host element's `id`, and therefore the `targetId` every event this chat carries. Generated when omitted. */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** The messages on the active path. Bindable: `bind:messages` keeps yours in step with what the chat does. */
|
|
13
|
+
messages?: AparteMessage[];
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** A waiting line you drive yourself; the chat turns it off on the first streamed token. */
|
|
17
|
+
isTyping?: boolean;
|
|
18
|
+
typingText?: string;
|
|
19
|
+
/** When false, Shift+Enter submits and a bare Enter inserts a newline. */
|
|
20
|
+
submitOnEnter?: boolean;
|
|
21
|
+
/** Freeze viewport spacer recalculation for this many ms after a conversation swap. */
|
|
22
|
+
layoutTransitionMs?: number;
|
|
23
|
+
/** The composer sits centred, with `emptyState` above it, until the first message. */
|
|
24
|
+
centerWhenEmpty?: boolean;
|
|
25
|
+
/** A wait of your own: skeleton turns, no empty state, composer disabled. */
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
/** Overlay the composer on the transcript. Read when the viewport mounts. */
|
|
28
|
+
overlayComposer?: boolean;
|
|
29
|
+
/** The file picker and the chips strip in the default composer. Off by default: your loop must read `files`. */
|
|
30
|
+
attachments?: boolean;
|
|
31
|
+
/** The presenter for questions to the person (approvals, `ask_user`). On by default. */
|
|
32
|
+
elicitation?: boolean;
|
|
33
|
+
/** Extra class names for the root element (`[data-aparte-chat]`). */
|
|
34
|
+
class?: string;
|
|
35
|
+
/** Inline style for the root element. */
|
|
36
|
+
style?: string;
|
|
37
|
+
/** Active conversation id (loads and persists through the registered conversation manager). */
|
|
38
|
+
conversationId?: string | null;
|
|
39
|
+
/** An instance config for this chat; read once, when the host mounts. */
|
|
40
|
+
config?: AparteConfig;
|
|
41
|
+
/** The chat before the first message. */
|
|
42
|
+
emptyState?: Snippet;
|
|
43
|
+
/** The space above the composer. */
|
|
44
|
+
aboveComposer?: Snippet;
|
|
45
|
+
/** The composer, replaced by yours. */
|
|
46
|
+
composer?: Snippet;
|
|
47
|
+
/** The composer's bottom row; not drawn when you fill `composer`. */
|
|
48
|
+
toolbar?: Snippet;
|
|
49
|
+
/** Each message, drawn by you. */
|
|
50
|
+
bubble?: Snippet<[AparteMessage]>;
|
|
51
|
+
/** The person sent a message. It is already in the thread: do not add it again. */
|
|
52
|
+
onmessageSent?: (detail: AparteSendEventDetail) => void;
|
|
53
|
+
/** A custom bubble action was clicked. */
|
|
54
|
+
onaction?: (detail: AparteActionEventDetail) => void;
|
|
55
|
+
/**
|
|
56
|
+
* The active path changed. With `bind:messages` you rarely need it. Without `bind:`, a parent
|
|
57
|
+
* that keeps the list writes it back here — `onmessagesChange={(m) => (msgs = m)}` — in the
|
|
58
|
+
* callback itself: a write-back after an `await` arrives later, as the parent's own word.
|
|
59
|
+
*/
|
|
60
|
+
onmessagesChange?: (messages: AparteMessage[]) => void;
|
|
61
|
+
/** One message was appended. */
|
|
62
|
+
onmessageAppended?: (message: AparteMessage) => void;
|
|
63
|
+
/** The waiting line toggled. */
|
|
64
|
+
ontypingChange?: (typing: boolean) => void;
|
|
65
|
+
/** The chat created a conversation (persistence). */
|
|
66
|
+
onconversationCreated?: (id: string) => void;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/runes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEjG;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,mHAAmH;IACnH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uFAAuF;IACvF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sFAAsF;IACtF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gHAAgH;IAChH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,yEAAyE;IACzE,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;IAElC,mFAAmF;IACnF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxD,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACrD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IACvD,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IACrD,gCAAgC;IAChC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,qDAAqD;IACrD,qBAAqB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -51,6 +51,10 @@ export interface AparteChatStore {
|
|
|
51
51
|
* $: chat.connect(comp);
|
|
52
52
|
* // <AparteChat bind:this={comp} messages={$messages}
|
|
53
53
|
* // on:messagesChange={(e) => chat.onMessagesChange(e.detail)} />
|
|
54
|
+
*
|
|
55
|
+
* @deprecated On Svelte 5, use `bind:messages` on the `<AparteChat>` from `@aparte/svelte/runes`.
|
|
56
|
+
* In 0.26.0 this helper leaves the package root for `@aparte/svelte/legacy`, beside the Svelte 4
|
|
57
|
+
* component.
|
|
54
58
|
*/
|
|
55
59
|
export declare function createAparteChat(initial?: AparteMessage[]): AparteChatStore;
|
|
56
60
|
//# sourceMappingURL=aparteChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aparteChat.d.ts","sourceRoot":"","sources":["../../src/lib/stores/aparteChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC5B,kFAAkF;IAClF,QAAQ,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IACpC,uDAAuD;IACvD,OAAO,CAAC,SAAS,EAAE,uBAAuB,GAAG,IAAI,GAAG,IAAI,CAAC;IACzD,4EAA4E;IAC5E,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAClD,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IACxE,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACzE,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACzC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IACxE,aAAa,CAAC,SAAS,EAAE,MA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iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnF,eAAe,IAAI,IAAI,CAAC;IACxB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,WAAW,IAAI,OAAO,CAAC;IACvB,cAAc,IAAI,IAAI,CAAC;IACvB,UAAU,IAAI,IAAI,CAAC;IACnB,iFAAiF;IACjF,WAAW,IAAI,WAAW,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,aAAa,EAAO,GAAG,eAAe,CA4B/E"}
|
|
@@ -10,6 +10,10 @@ import { get, writable } from 'svelte/store';
|
|
|
10
10
|
* $: chat.connect(comp);
|
|
11
11
|
* // <AparteChat bind:this={comp} messages={$messages}
|
|
12
12
|
* // on:messagesChange={(e) => chat.onMessagesChange(e.detail)} />
|
|
13
|
+
*
|
|
14
|
+
* @deprecated On Svelte 5, use `bind:messages` on the `<AparteChat>` from `@aparte/svelte/runes`.
|
|
15
|
+
* In 0.26.0 this helper leaves the package root for `@aparte/svelte/legacy`, beside the Svelte 4
|
|
16
|
+
* component.
|
|
13
17
|
*/
|
|
14
18
|
export function createAparteChat(initial = []) {
|
|
15
19
|
const messages = writable([...initial]);
|
|
@@ -3,6 +3,11 @@ import { AparteClient, type AparteClientOptions } from '@aparte/core';
|
|
|
3
3
|
* Mounts an `AparteClient` that bridges `aparte-send` events to the configured AI
|
|
4
4
|
* providers. Starts on mount, stops on destroy. Call from a component's script.
|
|
5
5
|
* Svelte equivalent of Angular's `AparteAiService`.
|
|
6
|
+
*
|
|
7
|
+
* The stop is an `onDestroy` on purpose: Svelte runs it on the server too, at the end of a
|
|
8
|
+
* render, and that is the only place a server render can take back the `keyResolver` the
|
|
9
|
+
* client put on the config when it was constructed — the global config every request the
|
|
10
|
+
* process serves shares. `stop()` releases it there and touches nothing of the browser.
|
|
6
11
|
*/
|
|
7
12
|
export declare function createAparteClient(options?: AparteClientOptions): {
|
|
8
13
|
client: AparteClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aparteClient.d.ts","sourceRoot":"","sources":["../../src/lib/stores/aparteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"aparteClient.d.ts","sourceRoot":"","sources":["../../src/lib/stores/aparteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB;;;EAK/D"}
|
|
@@ -4,6 +4,11 @@ import { AparteClient } from '@aparte/core';
|
|
|
4
4
|
* Mounts an `AparteClient` that bridges `aparte-send` events to the configured AI
|
|
5
5
|
* providers. Starts on mount, stops on destroy. Call from a component's script.
|
|
6
6
|
* Svelte equivalent of Angular's `AparteAiService`.
|
|
7
|
+
*
|
|
8
|
+
* The stop is an `onDestroy` on purpose: Svelte runs it on the server too, at the end of a
|
|
9
|
+
* render, and that is the only place a server render can take back the `keyResolver` the
|
|
10
|
+
* client put on the config when it was constructed — the global config every request the
|
|
11
|
+
* process serves shares. `stop()` releases it there and touches nothing of the browser.
|
|
7
12
|
*/
|
|
8
13
|
export function createAparteClient(options) {
|
|
9
14
|
const client = new AparteClient(options ?? {});
|
|
@@ -5,6 +5,10 @@ import type { AparteMessage } from '../types.js';
|
|
|
5
5
|
* conversation is owned by the chat component's controller; switch by binding
|
|
6
6
|
* `conversationId` on `<AparteChat>`. Call from a component's script. Svelte
|
|
7
7
|
* equivalent of Angular's `ConversationManagerService`.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated On Svelte 5, use `createConversations()` from `@aparte/svelte/runes`, whose lists
|
|
10
|
+
* are reactive state rather than stores. In 0.26.0 this helper leaves the package root for
|
|
11
|
+
* `@aparte/svelte/legacy`, beside the Svelte 4 component.
|
|
8
12
|
*/
|
|
9
13
|
export declare function createConversationManager(): {
|
|
10
14
|
conversations: import("svelte/store").Writable<AparteConversation[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversationManager.d.ts","sourceRoot":"","sources":["../../src/lib/stores/conversationManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,YAAY,EACjB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"conversationManager.d.ts","sourceRoot":"","sources":["../../src/lib/stores/conversationManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,YAAY,EACjB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB;;;;;;oBAgCR,oBAAoB,WAAU,YAAY,YAAiC,0BAA0B,KAAG,OAAO,CAAC,IAAI,CAAC;IAmB9I,wMAAwM;sBACzL,yBAAyB,GAAG,IAAI;wBAC3B,MAAM;yBACL,MAAM,WAAW,aAAa;6BAC1B,MAAM,YAAY,aAAa,EAAE;iBAC7C,MAAM;kBACL,MAAM;oBACJ,MAAM;cACZ,MAAM;gBACJ,MAAM;sBACA,MAAM,SAAS,MAAM;EAE9C"}
|
|
@@ -6,6 +6,10 @@ import { aparteGlobalConfig, AparteConversationManager, } from '@aparte/core';
|
|
|
6
6
|
* conversation is owned by the chat component's controller; switch by binding
|
|
7
7
|
* `conversationId` on `<AparteChat>`. Call from a component's script. Svelte
|
|
8
8
|
* equivalent of Angular's `ConversationManagerService`.
|
|
9
|
+
*
|
|
10
|
+
* @deprecated On Svelte 5, use `createConversations()` from `@aparte/svelte/runes`, whose lists
|
|
11
|
+
* are reactive state rather than stores. In 0.26.0 this helper leaves the package root for
|
|
12
|
+
* `@aparte/svelte/legacy`, beside the Svelte 4 component.
|
|
9
13
|
*/
|
|
10
14
|
export function createConversationManager() {
|
|
11
15
|
let manager = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aparte/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"homepage": "https://apartejs.dev/frameworks/svelte/",
|
|
5
5
|
"description": "Svelte wrapper for aparté — an ergonomic <AparteChat> component plus stores over the framework-agnostic web components. Works on Svelte 4 and 5.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./runes": {
|
|
23
|
+
"@aparte-workspace/source": "./src/lib/runes/index.ts",
|
|
24
|
+
"svelte": {
|
|
25
|
+
"types": "./dist/runes/index.d.ts",
|
|
26
|
+
"default": "./dist/runes/index.js"
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/runes/index.d.ts",
|
|
29
|
+
"import": "./dist/runes/index.js",
|
|
30
|
+
"default": "./dist/runes/index.js"
|
|
21
31
|
}
|
|
22
32
|
},
|
|
23
33
|
"files": [
|
|
@@ -47,20 +57,21 @@
|
|
|
47
57
|
"package: a wrong AparteChat prop now errors."
|
|
48
58
|
],
|
|
49
59
|
"peerDependencies": {
|
|
50
|
-
"@aparte/core": ">=0.
|
|
51
|
-
"svelte": "^4.0.0 || ^5.
|
|
60
|
+
"@aparte/core": ">=0.25.0 <1.0.0",
|
|
61
|
+
"svelte": "^4.0.0 || ^5.20.0"
|
|
52
62
|
},
|
|
53
63
|
"devDependencies": {
|
|
54
64
|
"@sveltejs/package": "^2.5.8",
|
|
55
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
65
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.4",
|
|
56
66
|
"@testing-library/svelte": "^5.2.0",
|
|
57
67
|
"jsdom": "^22.1.0",
|
|
58
|
-
"svelte": "^
|
|
59
|
-
"svelte-check": "^
|
|
60
|
-
"svelte2tsx": "^0.7.
|
|
68
|
+
"svelte": "^5.56.10",
|
|
69
|
+
"svelte-check": "^4.7.6",
|
|
70
|
+
"svelte2tsx": "^0.7.62",
|
|
61
71
|
"typescript": "^5.4.0",
|
|
62
72
|
"vite": "^6.0.0",
|
|
63
|
-
"@aparte/core": "0.
|
|
73
|
+
"@aparte/core": "0.25.0",
|
|
74
|
+
"@aparte/provider-scenario": "0.25.0"
|
|
64
75
|
},
|
|
65
76
|
"keywords": [
|
|
66
77
|
"svelte",
|