@aparte/core 1.8.0 → 1.9.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/client/agent-runner.d.ts +8 -3
- package/dist/client/agent-runner.d.ts.map +1 -1
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +13 -3
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/chat/aparte-chat.d.ts +64 -0
- package/dist/components/chat/aparte-chat.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts +3 -1
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-send.d.ts +11 -0
- package/dist/components/composer/aparte-composer-send.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +84 -10
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/link-target.d.ts +39 -0
- package/dist/config/link-target.d.ts.map +1 -0
- package/dist/config/sanitize.d.ts +22 -3
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/step-label.d.ts +22 -0
- package/dist/config/step-label.d.ts.map +1 -0
- package/dist/conversations/conversation-controller.d.ts +14 -0
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/open-conversation.d.ts +28 -0
- package/dist/conversations/open-conversation.d.ts.map +1 -0
- package/dist/custom-elements.json +1273 -521
- package/dist/{defer-hydration-BE2ToXC_.js → defer-hydration-Ch3TOEJC.js} +372 -79
- package/dist/defer-hydration-Ch3TOEJC.js.map +1 -0
- package/dist/generated/element-attributes.d.ts +11 -4
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -9
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +1 -1
- package/dist/index.node.js.map +1 -1
- package/dist/renderers/citations.d.ts.map +1 -1
- package/dist/transport/agent-handler.d.ts +6 -0
- package/dist/transport/agent-handler.d.ts.map +1 -1
- package/dist/types/element-attributes.d.ts +5 -2
- package/dist/types/element-attributes.d.ts.map +1 -1
- package/dist/types/events.d.ts +4 -3
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/imperative-api.d.ts +15 -0
- package/dist/types/imperative-api.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tools.d.ts +9 -0
- package/dist/types/tools.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/defer-hydration-BE2ToXC_.js.map +0 -1
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
* Registering DOMPurify alone replaces this one, and its defaults keep what a
|
|
18
18
|
* chat must refuse — measured on DOMPurify 3.4: inline layout styles, `aparte-`
|
|
19
19
|
* classes, `--aparte-*` properties, `<form>`/`<button>`, a password `<input>`,
|
|
20
|
-
* `id
|
|
20
|
+
* and `id`. Where a link opens is not one of them: `AparteConfig.sanitizeHtml` applies
|
|
21
|
+
* the link target (`link-target.ts`) and the image policy after whichever sanitizer is
|
|
22
|
+
* set, since DOMPurify drops `target` and an external link then navigated the chat's frame.
|
|
21
23
|
*/
|
|
22
24
|
export type AparteSanitizer = (html: string) => string;
|
|
23
25
|
/**
|
|
@@ -29,6 +31,12 @@ export type AparteSanitizer = (html: string) => string;
|
|
|
29
31
|
* a contract.
|
|
30
32
|
*/
|
|
31
33
|
export declare const DANGEROUS_TAGS: Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Whitespace + C0 control chars, used to obfuscate a scheme (e.g. " javascript:" or "java\tscript:").
|
|
36
|
+
* Exported for the link target's pass (`link-target.ts`), which reads an address the same way; not
|
|
37
|
+
* from the package barrel.
|
|
38
|
+
*/
|
|
39
|
+
export declare const CONTROL_WS: RegExp;
|
|
32
40
|
/**
|
|
33
41
|
* The attributes core READS, as a command or as a boundary, on an element it finds by
|
|
34
42
|
* walking the DOM: a delegated click listener (`data-aparte-dialog-open`, the sidebar
|
|
@@ -51,6 +59,16 @@ export declare const RESERVED_ATTRIBUTE_PREFIXES: string[];
|
|
|
51
59
|
/** True when `name` (lower case) is an attribute core reads, so model markup may not carry it. */
|
|
52
60
|
export declare function isReservedAttribute(name: string): boolean;
|
|
53
61
|
export declare function isSafeUrl(value: string, tag: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The `target` and `rel` an `<a>` gets. The model's `target` is read as a WISH and clamped;
|
|
64
|
+
* `rel` is never copied. `href` is the one that was kept ('' when it was dropped).
|
|
65
|
+
*
|
|
66
|
+
* This is the floor, and the whole of `setLinkTarget('external-only')`: the config's link pass
|
|
67
|
+
* (`link-target.ts`) applies it again after whichever sanitizer is set, and under the default,
|
|
68
|
+
* `'new-tab'`, opens a same-site link in a new tab on top of it. Exported for that pass; not
|
|
69
|
+
* from the package barrel.
|
|
70
|
+
*/
|
|
71
|
+
export declare function linkAttributes(href: string, targetWish: string): Array<[string, string]>;
|
|
54
72
|
/**
|
|
55
73
|
* One tag read from `nameAt` (the first letter of its name) the way a browser's tokenizer reads
|
|
56
74
|
* it: a quote ends where its match is, an unquoted value at a space or `>`, `/` and a closing
|
|
@@ -58,8 +76,9 @@ export declare function isSafeUrl(value: string, tag: string): boolean;
|
|
|
58
76
|
* entities that can spell a checked character decoded. `end` is the index past its `>`, or `-1`
|
|
59
77
|
* when the text ends inside the tag.
|
|
60
78
|
*
|
|
61
|
-
* Exported for the
|
|
62
|
-
* tags in the same text this scrub wrote; not
|
|
79
|
+
* Exported for the DOM-free passes of the image policy (`image-policy.ts`) and the link target
|
|
80
|
+
* (`link-target.ts`), which have to find the same tags in the same text this scrub wrote; not
|
|
81
|
+
* from the package barrel.
|
|
63
82
|
*/
|
|
64
83
|
export declare function readTag(html: string, nameAt: number): {
|
|
65
84
|
tag: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/config/sanitize.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/config/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,aAKzB,CAAC;AA8DH;;;;GAIG;AAEH,eAAO,MAAM,UAAU,QAAsB,CAAC;AAoC9C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,aAM9B,CAAC;AAEH,6GAA6G;AAC7G,eAAO,MAAM,2BAA2B,UAAsE,CAAC;AAE/G,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAqDD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAQ7D;AA4HD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0BxF;AAoID;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAoClH;AAgFD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAY9B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a step is called on screen: the words shown for the name a run announced.
|
|
3
|
+
*
|
|
4
|
+
* A server that streams `step-start { name }` sends a stable key (`slot-wait`, `restore`,
|
|
5
|
+
* `reread`), and the page knows the person's language. The app maps one to the other with
|
|
6
|
+
* {@link AparteConfig.registerStepLabel}; core never makes a label up.
|
|
7
|
+
*/
|
|
8
|
+
import type { AparteLocale } from './locale.js';
|
|
9
|
+
/** What a step label function is told when the page asks for its words. */
|
|
10
|
+
export interface AparteStepLabelContext {
|
|
11
|
+
/** The step's name, as the run announced it: the key the label stands for. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** The config's locale as it is now. The function is asked again when the locale changes. */
|
|
14
|
+
locale: AparteLocale;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The words shown for a step: plain text, never HTML — or a function of the locale, asked at
|
|
18
|
+
* every draw, so a language switch changes what a step that is open says. A label that says
|
|
19
|
+
* nothing, or a function that throws, leaves the name itself.
|
|
20
|
+
*/
|
|
21
|
+
export type AparteStepLabel = string | ((context: AparteStepLabelContext) => string);
|
|
22
|
+
//# sourceMappingURL=step-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-label.d.ts","sourceRoot":"","sources":["../../src/config/step-label.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACnC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,MAAM,EAAE,YAAY,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,sBAAsB,KAAK,MAAM,CAAC,CAAC"}
|
|
@@ -76,6 +76,8 @@ export interface AparteConversationControllerOptions {
|
|
|
76
76
|
* - Lazily create a conversation on the first user `aparte-send` if none active.
|
|
77
77
|
* - Persist updates triggered by `aparte-path-changed` (branch nav, retry, edit).
|
|
78
78
|
* - Dispatch `aparte-abort` when the active conversation changes mid-stream.
|
|
79
|
+
* - Leave the open conversation readable on the host while bound, so `AparteClient` can say
|
|
80
|
+
* which conversation each turn belongs to (`StreamRunOptions.conversationId`).
|
|
79
81
|
*
|
|
80
82
|
* Usage:
|
|
81
83
|
* ```ts
|
|
@@ -123,6 +125,16 @@ export declare class AparteConversationController {
|
|
|
123
125
|
constructor(binding: AparteChatBinding, options?: AparteConversationControllerOptions);
|
|
124
126
|
/** The current active conversation id (null when none selected). */
|
|
125
127
|
get activeId(): string | null;
|
|
128
|
+
/**
|
|
129
|
+
* The conversation a message sent now belongs to: the open one, or — for the first
|
|
130
|
+
* message of a chat — the one that send is creating. `createNew()` makes it the
|
|
131
|
+
* manager's active conversation synchronously, so the client, which hears the send
|
|
132
|
+
* right after this controller does, already finds it there; this controller's own id
|
|
133
|
+
* follows once the conversation is saved. `_ensureConversationAndPersist` reads the
|
|
134
|
+
* same two places to decide where the message is saved, so a turn is carried to the
|
|
135
|
+
* conversation its message was written in.
|
|
136
|
+
*/
|
|
137
|
+
private _openId;
|
|
126
138
|
/**
|
|
127
139
|
* Lazily resolve the conversation manager. Returns `undefined` if none is
|
|
128
140
|
* registered — the controller then runs in degraded mode: optimistic UI
|
|
@@ -161,6 +173,8 @@ export declare class AparteConversationController {
|
|
|
161
173
|
* Attach event listeners to the binding host. Returns an unbind function.
|
|
162
174
|
*/
|
|
163
175
|
bind(): () => void;
|
|
176
|
+
/** Takes the open-conversation reader off the host (see `bind`). */
|
|
177
|
+
private _withdrawOpenConversation;
|
|
164
178
|
/** Detach event listeners. */
|
|
165
179
|
/** Release handle for the hydration-retry subscription (see setConversationId). */
|
|
166
180
|
private _stopHydrationRetry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-controller.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-controller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,a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OAQG;IACH,OAAO,CAAC,OAAO;IAIf;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAqBhB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,4BAA4B;IAWpC;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAgBhB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,IAAI,IAAI,MAAM,IAAI;IAwJlB,oEAAoE;IACpE,OAAO,CAAC,yBAAyB,CAA6B;IAE9D,8BAA8B;IAC9B,mFAAmF;IACnF,OAAO,CAAC,mBAAmB,CAA6B;IAExD,MAAM,IAAI,IAAI;IAsEd;;;;;;;;;;OAUG;IACG,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBzD,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,KAAK,SAAS,GAIpB;IAED,OAAO,CAAC,WAAW;IAWnB,gGAAgG;IAChG,OAAO,CAAC,YAAY;IAOpB,0DAA0D;IAC1D,OAAO,CAAC,UAAU;YAQJ,aAAa;IAc3B,OAAO,CAAC,aAAa;YAKP,iBAAiB;IAqL/B;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAUjB;;;;;;;;;OASG;IACH;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,cAAc;YA+BR,6BAA6B;CAwE9C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which conversation a chat has open, readable from outside the chat.
|
|
3
|
+
*
|
|
4
|
+
* The conversation controller is the one that knows: it opens, switches and creates a
|
|
5
|
+
* chat's conversation. `AparteClient` does not live in the chat, it lives beside it — it
|
|
6
|
+
* finds the element it renders into by id — so the controller leaves a reader on the
|
|
7
|
+
* chat's host element, and the client climbs from the element it renders into until it
|
|
8
|
+
* finds one.
|
|
9
|
+
*
|
|
10
|
+
* A symbol slot on the element, as `attachConfig` leaves an instance config: no attribute
|
|
11
|
+
* written into a DOM a framework owns, and no method on the element for an app to take as
|
|
12
|
+
* API. `Symbol.for`, so two copies of core on one page still agree on the slot.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Leave `read` on `host`, the chat's element, for {@link openConversationOf}. Returns what
|
|
16
|
+
* takes it away again — and only if it is still the one that was left, so the teardown of a
|
|
17
|
+
* controller a framework has already replaced on the same element undoes nothing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function offerOpenConversation(host: HTMLElement, read: () => string | null): () => void;
|
|
20
|
+
/**
|
|
21
|
+
* The id of the conversation open in the chat `el` is in, as of this moment — `null` when
|
|
22
|
+
* the chat has none open, or when nothing manages the chat's conversations at all.
|
|
23
|
+
*
|
|
24
|
+
* Read when the person acts, not before: it answers for now, and a conversation the person
|
|
25
|
+
* opens a moment later is another answer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function openConversationOf(el: Element | null | undefined): string | null;
|
|
28
|
+
//# sourceMappingURL=open-conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-conversation.d.ts","sourceRoot":"","sources":["../../src/conversations/open-conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,MAAM,IAAI,CAM9F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAMhF"}
|