@aparte/svelte 0.19.3 → 0.21.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/dist/AparteChat.svelte +12 -3
- package/dist/AparteChat.svelte.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/stores/conversationManager.d.ts +4 -2
- package/dist/stores/conversationManager.d.ts.map +1 -1
- package/dist/stores/conversationManager.js +4 -2
- package/package.json +4 -4
package/dist/AparteChat.svelte
CHANGED
|
@@ -5,14 +5,18 @@ export let messages = [];
|
|
|
5
5
|
export let placeholder = "Type a message...";
|
|
6
6
|
export let disabled = false;
|
|
7
7
|
export let isTyping = false;
|
|
8
|
-
export let typingText =
|
|
8
|
+
export let typingText = void 0;
|
|
9
9
|
export let submitOnEnter = true;
|
|
10
10
|
export let layoutTransitionMs = 0;
|
|
11
11
|
export let centerWhenEmpty = false;
|
|
12
12
|
export let loading = false;
|
|
13
13
|
let hostLoading = false;
|
|
14
14
|
$: waiting = loading || hostLoading;
|
|
15
|
-
|
|
15
|
+
let localeTick = 0;
|
|
16
|
+
let unsubscribeLocale = null;
|
|
17
|
+
const localeText = (_tick, cfg, key) => (cfg ?? aparteGlobalConfig).t(key);
|
|
18
|
+
$: loadingText = localeText(localeTick, config, "loadingConversation");
|
|
19
|
+
$: typingLabel = typingText ?? localeText(localeTick, config, "typing");
|
|
16
20
|
export let overlayComposer = false;
|
|
17
21
|
export let attachments = false;
|
|
18
22
|
export let elicitation = true;
|
|
@@ -81,6 +85,9 @@ function handleAction(event) {
|
|
|
81
85
|
dispatch("action", detail);
|
|
82
86
|
}
|
|
83
87
|
onMount(() => {
|
|
88
|
+
unsubscribeLocale = (config ?? aparteGlobalConfig).subscribe(() => {
|
|
89
|
+
localeTick += 1;
|
|
90
|
+
});
|
|
84
91
|
hostId = id ?? `aparte-chat-${uuid()}`;
|
|
85
92
|
if (rootRef) rootRef.id = hostId;
|
|
86
93
|
const binding = {
|
|
@@ -129,6 +136,8 @@ onMount(() => {
|
|
|
129
136
|
rootRef?.addEventListener("aparte-action", handleAction);
|
|
130
137
|
});
|
|
131
138
|
onDestroy(() => {
|
|
139
|
+
unsubscribeLocale?.();
|
|
140
|
+
unsubscribeLocale = null;
|
|
132
141
|
rootRef?.removeEventListener("aparte-action", handleAction);
|
|
133
142
|
teardown?.();
|
|
134
143
|
teardown = null;
|
|
@@ -260,7 +269,7 @@ function _assertImperativeParity() {
|
|
|
260
269
|
streaming={isAwaitingReply(m) ? '' : null}></aparte-chat-bubble>
|
|
261
270
|
</slot>
|
|
262
271
|
{/each}
|
|
263
|
-
<aparte-chat-status visible={typingActive ? '' : null} text={
|
|
272
|
+
<aparte-chat-status visible={typingActive ? '' : null} text={typingLabel}></aparte-chat-status>
|
|
264
273
|
</aparte-chat-viewport>
|
|
265
274
|
|
|
266
275
|
<!-- The presenter for a request to the human (approval gate, ask_user…). Renders
|
|
@@ -13,7 +13,7 @@ declare const __propDef: {
|
|
|
13
13
|
placeholder?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
isTyping?: boolean;
|
|
16
|
-
typingText?: string;
|
|
16
|
+
typingText?: string | undefined;
|
|
17
17
|
/** When false, Shift+Enter submits and a bare Enter inserts a newline. */ submitOnEnter?: boolean;
|
|
18
18
|
/** Freeze viewport spacer recalculation for this many ms after a conv swap. */ layoutTransitionMs?: number;
|
|
19
19
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ type AparteAnyEventName = AparteEventName | AparteUiEventName;
|
|
|
42
42
|
type AparteEventFor<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent<null>;
|
|
43
43
|
type AparteSvelteHandlers = {
|
|
44
44
|
[K in AparteAnyEventName as `on:${K}`]?: (event: AparteEventFor<K>) => void;
|
|
45
|
+
} & {
|
|
46
|
+
[K in AparteAnyEventName as `on${K}`]?: (event: AparteEventFor<K>) => void;
|
|
45
47
|
};
|
|
46
48
|
type AparteSvelteElements = {
|
|
47
49
|
[K in AparteElementTagName]: HTMLAttributes<HTMLElement> & AparteTemplateAttrs<AparteElementAttributes[K]> & AparteSvelteHandlers;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9D,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE,YAAY,EACR,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACxB,MAAM,YAAY,CAAC;AAiBpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE1H;;;;;;;;;;;;;;;;;;;GAmBG;AACH,KAAK,eAAe,GAAG,OAAO,CAAC,MAAM,mBAAmB,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC;AAC9E,KAAK,kBAAkB,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAE9D,wFAAwF;AACxF,KAAK,cAAc,CAAC,CA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E,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE1H;;;;;;;;;;;;;;;;;;;GAmBG;AACH,KAAK,eAAe,GAAG,OAAO,CAAC,MAAM,mBAAmB,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC;AAC9E,KAAK,kBAAkB,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAE9D,wFAAwF;AACxF,KAAK,cAAc,CAAC,CAAC,SAAS,MAAM,IAChC,CAAC,SAAS,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;AAErF,KAAK,oBAAoB,GAAG;KACvB,CAAC,IAAI,kBAAkB,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI;CAC9E,GAAG;KAGC,CAAC,IAAI,kBAAkB,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI;CAC7E,CAAC;AAEF,KAAK,oBAAoB,GAAG;KACvB,CAAC,IAAI,oBAAoB,GACtB,cAAc,CAAC,WAAW,CAAC,GACzB,mBAAmB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,GAC/C,oBAAoB;CAC7B,CAAC;AAEF,OAAO,QAAQ,iBAAiB,CAAC;IAC7B,UAAU,kBAAmB,SAAQ,oBAAoB;KAAG;CAC/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AparteConfig, type AparteConversation, type AparteStorageAdapter } from '@aparte/core';
|
|
1
|
+
import { type AparteConfig, AparteConversationManager, type AparteConversation, type AparteStorageAdapter, type ConversationManagerOptions } from '@aparte/core';
|
|
2
2
|
import type { AparteMessage } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Svelte-store wrapper around the core `AparteConversationManager`. The active
|
|
@@ -12,7 +12,9 @@ export declare function createConversationManager(): {
|
|
|
12
12
|
archivedConversations: import("svelte/store").Readable<AparteConversation[]>;
|
|
13
13
|
activeId: import("svelte/store").Writable<string | null>;
|
|
14
14
|
activeConversation: import("svelte/store").Readable<AparteConversation | null>;
|
|
15
|
-
init: (adapter: AparteStorageAdapter, config?: AparteConfig) => Promise<void>;
|
|
15
|
+
init: (adapter: AparteStorageAdapter, config?: AparteConfig, options?: ConversationManagerOptions) => Promise<void>;
|
|
16
|
+
/** The core manager, once `init` has run (`null` before): for what this does not mirror. Read it as `cm.manager` after `init` — a destructured copy keeps the `null` it had, and it is not reactive. */
|
|
17
|
+
readonly manager: AparteConversationManager | null;
|
|
16
18
|
createNew: (title?: string) => Promise<AparteConversation>;
|
|
17
19
|
addMessage: (convId: string, message: AparteMessage) => Promise<void>;
|
|
18
20
|
updateMessages: (convId: string, messages: AparteMessage[]) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversationManager.d.ts","sourceRoot":"","sources":["../../src/lib/stores/conversationManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,YAAY,
|
|
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;;;;;GAKG;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"}
|
|
@@ -30,8 +30,8 @@ export function createConversationManager() {
|
|
|
30
30
|
* with its own — persistence silently does nothing while the optimistic UI
|
|
31
31
|
* keeps working.
|
|
32
32
|
*/
|
|
33
|
-
async function init(adapter, config = aparteGlobalConfig) {
|
|
34
|
-
const m = new AparteConversationManager(adapter);
|
|
33
|
+
async function init(adapter, config = aparteGlobalConfig, options) {
|
|
34
|
+
const m = new AparteConversationManager(adapter, options);
|
|
35
35
|
manager = m;
|
|
36
36
|
unsub = m.subscribe((convs) => {
|
|
37
37
|
conversations.set([...convs]);
|
|
@@ -48,6 +48,8 @@ export function createConversationManager() {
|
|
|
48
48
|
activeId,
|
|
49
49
|
activeConversation,
|
|
50
50
|
init,
|
|
51
|
+
/** The core manager, once `init` has run (`null` before): for what this does not mirror. Read it as `cm.manager` after `init` — a destructured copy keeps the `null` it had, and it is not reactive. */
|
|
52
|
+
get manager() { return manager; },
|
|
51
53
|
createNew: (title) => assert().createNew(title),
|
|
52
54
|
addMessage: (convId, message) => assert().addMessage(convId, message),
|
|
53
55
|
updateMessages: (convId, messages) => assert().updateMessages(convId, messages),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aparte/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"package: a wrong AparteChat prop now errors."
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@aparte/core": ">=0.
|
|
50
|
+
"@aparte/core": ">=0.21.0 <1.0.0",
|
|
51
51
|
"svelte": "^4.0.0 || ^5.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"svelte2tsx": "^0.7.61",
|
|
61
61
|
"typescript": "^5.4.0",
|
|
62
62
|
"vite": "^6.0.0",
|
|
63
|
-
"@aparte/core": "0.
|
|
63
|
+
"@aparte/core": "0.21.0"
|
|
64
64
|
},
|
|
65
65
|
"keywords": [
|
|
66
66
|
"svelte",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"scripts": {
|
|
85
85
|
"typecheck:tests": "svelte-check --tsconfig ./tsconfig.check.json --threshold error --output human",
|
|
86
86
|
"dev": "vite",
|
|
87
|
-
"build": "svelte-package -i src/lib -o dist --tsconfig ./tsconfig.dts.json && tsc -b --emitDeclarationOnly --force && node scripts/strip-dist-tests.mjs",
|
|
87
|
+
"build": "svelte-package -i src/lib -o dist --tsconfig ./tsconfig.dts.json && tsc -b --emitDeclarationOnly --force && node scripts/strip-dist-tests.mjs && node ../../../scripts/stamp-dist.mjs",
|
|
88
88
|
"preview": "vite preview",
|
|
89
89
|
"test": "vitest",
|
|
90
90
|
"test:run": "vitest run",
|