@aparte/core 1.13.0 → 1.14.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/aparte-client.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/chat/aparte-chat.d.ts +3 -0
- package/dist/components/chat/aparte-chat.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts +5 -0
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +12 -0
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/config/error-renderer.d.ts +5 -0
- package/dist/config/error-renderer.d.ts.map +1 -1
- package/dist/custom-elements.json +43 -3
- package/dist/{defer-hydration-Dm6F4kq6.js → defer-hydration-Bin9IdKc.js} +6 -3
- package/dist/defer-hydration-Bin9IdKc.js.map +1 -0
- package/dist/generated/element-attributes.d.ts +5 -1
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/index.node.js +1 -1
- package/dist/primitives/icon/aparte-icon.d.ts +10 -2
- package/dist/primitives/icon/aparte-icon.d.ts.map +1 -1
- package/dist/renderers/segments/error.d.ts.map +1 -1
- package/dist/types/events.d.ts +5 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/segments.d.ts +8 -0
- package/dist/types/segments.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/defer-hydration-Dm6F4kq6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as deferHydrationOf, al as resolveConfig, at as subscribeConfigChange, ao as runWithConfig, o as AparteElicitationAbortError, x as buildApprovalPanel, y as buildElicitationPanel, z as chatIdOf, az as gateGlide, T as escapeAttr, aq as segmentTiming, aA as chatBoundaryOf, aB as relabelCodeLanguages, aC as relabelCitations, aD as toolCallRenderer, aE as activityRenderer, t as aparteGlobalConfig, aF as isMountedRenderer, aG as renderingVersionOf, a8 as onRenderersChange, aH as renderSourceList, aI as mergeSegmentUpdate, w as authorTypeOf, a6 as isSegmentSettled, ac as pluralize, Y as formatDuration, aJ as toolNameOf, U as escapeHtml, aK as writeStreamedMarkdown, aL as replaceHighlighted, a5 as isSafeUrl, R as dispatchChatEvent, aM as openConversationOf, E as copyText, _ as getSegmentRenderer, a0 as installDefaultRenderersOnce, aN as toolRendererThatDrew, aO as activityRendererThatDrew, r as AparteMessageRepository, aP as CheckpointStateWatcher, aQ as stampSegmentActivity, aR as stampSegmentOnInsert, aS as stampSegmentOnUpdate, aT as renumberSegments, aU as openSegmentIds, aV as isTerminalStatus, a2 as isAwaitingReply, aW as adoptMessageSegments, ad as populateBubbleFromMessage, ax as uuid, am as revokeAttachmentUrls, a4 as isModelReply, ab as parseMarkdownToSegments, aX as APARTE_DERIVED_SEGMENTS, aY as rememberConversationStatus, aZ as tellConversationStatus, a_ as conversationStatusOf, e as APARTE_DEFAULT_LOCALE, a$ as visibleReply, b0 as usageTokens, q as AparteErrorCode, a7 as measureContext, b1 as inRenderedContent, g as APARTE_HOST_ATTR, a1 as installDialogTriggersOnce } from "./defer-hydration-
|
|
2
|
-
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v, B, C, D, F, G, H, I, J, K, L, M, O, P, Q, V, W, X, Z, $, a3, a9, aa, ae, af, ag, ah, ai, aj, ak, an, ap, ar, as, au, av, aw, ay } from "./defer-hydration-
|
|
1
|
+
import { N as deferHydrationOf, al as resolveConfig, at as subscribeConfigChange, ao as runWithConfig, o as AparteElicitationAbortError, x as buildApprovalPanel, y as buildElicitationPanel, z as chatIdOf, az as gateGlide, T as escapeAttr, aq as segmentTiming, aA as chatBoundaryOf, aB as relabelCodeLanguages, aC as relabelCitations, aD as toolCallRenderer, aE as activityRenderer, t as aparteGlobalConfig, aF as isMountedRenderer, aG as renderingVersionOf, a8 as onRenderersChange, aH as renderSourceList, aI as mergeSegmentUpdate, w as authorTypeOf, a6 as isSegmentSettled, ac as pluralize, Y as formatDuration, aJ as toolNameOf, U as escapeHtml, aK as writeStreamedMarkdown, aL as replaceHighlighted, a5 as isSafeUrl, R as dispatchChatEvent, aM as openConversationOf, E as copyText, _ as getSegmentRenderer, a0 as installDefaultRenderersOnce, aN as toolRendererThatDrew, aO as activityRendererThatDrew, r as AparteMessageRepository, aP as CheckpointStateWatcher, aQ as stampSegmentActivity, aR as stampSegmentOnInsert, aS as stampSegmentOnUpdate, aT as renumberSegments, aU as openSegmentIds, aV as isTerminalStatus, a2 as isAwaitingReply, aW as adoptMessageSegments, ad as populateBubbleFromMessage, ax as uuid, am as revokeAttachmentUrls, a4 as isModelReply, ab as parseMarkdownToSegments, aX as APARTE_DERIVED_SEGMENTS, aY as rememberConversationStatus, aZ as tellConversationStatus, a_ as conversationStatusOf, e as APARTE_DEFAULT_LOCALE, a$ as visibleReply, b0 as usageTokens, q as AparteErrorCode, a7 as measureContext, b1 as inRenderedContent, g as APARTE_HOST_ATTR, a1 as installDialogTriggersOnce } from "./defer-hydration-Bin9IdKc.js";
|
|
2
|
+
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v, B, C, D, F, G, H, I, J, K, L, M, O, P, Q, V, W, X, Z, $, a3, a9, aa, ae, af, ag, ah, ai, aj, ak, an, ap, ar, as, au, av, aw, ay } from "./defer-hydration-Bin9IdKc.js";
|
|
3
3
|
import { d as eventOrigin, f as activeElementIn, c as cssEscape, a as enhanceMenu, e as enhanceContextMenu, p as placeFloating, r as rootOf } from "./kit-keyboard-BUSLQ5i4.js";
|
|
4
4
|
import { b as b2 } from "./kit-keyboard-BUSLQ5i4.js";
|
|
5
5
|
function presenceOn(value) {
|
|
@@ -793,8 +793,26 @@ class AparteIcon extends HTMLElement {
|
|
|
793
793
|
const glyph = name ? resolveConfig(this).getIcon(name) : null;
|
|
794
794
|
this.innerHTML = glyph ?? "";
|
|
795
795
|
this.firstElementChild?.setAttribute("aria-hidden", "true");
|
|
796
|
+
if (name && glyph === void 0 && !warnedNames.has(name)) this._warnLater(name);
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* The gap alone went unnoticed: a host named `plus` and `panel`, glyphs that exist only
|
|
800
|
+
* in `@aparte/core/icons` until registered, and found out from screenshots. Said once per
|
|
801
|
+
* name, and only if the name is still unknown a moment later: an icon set registered
|
|
802
|
+
* just after the element mounted redraws it, and that is no mistake.
|
|
803
|
+
*/
|
|
804
|
+
_warnLater(name) {
|
|
805
|
+
setTimeout(() => {
|
|
806
|
+
if (warnedNames.has(name) || !this.isConnected || this.getAttribute("name") !== name) return;
|
|
807
|
+
if (resolveConfig(this).getIcon(name) !== void 0) return;
|
|
808
|
+
warnedNames.add(name);
|
|
809
|
+
console.warn(
|
|
810
|
+
`[aparte] <aparte-icon name="${name}"> draws nothing: no icon has that name. A glyph of @aparte/core/icons is named once registered: aparteGlobalConfig.registerIcons({ ${JSON.stringify(name)}: () => svg }). Core's own names: https://apartejs.dev/reference/icons/`
|
|
811
|
+
);
|
|
812
|
+
}, 0);
|
|
796
813
|
}
|
|
797
814
|
}
|
|
815
|
+
const warnedNames = /* @__PURE__ */ new Set();
|
|
798
816
|
deferHydrationOf(AparteIcon);
|
|
799
817
|
if (!customElements.get("aparte-icon")) {
|
|
800
818
|
customElements.define("aparte-icon", AparteIcon);
|
|
@@ -1152,7 +1170,7 @@ function isTranscriptEmpty(viewport) {
|
|
|
1152
1170
|
}
|
|
1153
1171
|
class AparteChat extends HTMLElement {
|
|
1154
1172
|
static get observedAttributes() {
|
|
1155
|
-
return ["placeholder", "disabled", "submit-on-enter", "attachments", "type-to-focus"];
|
|
1173
|
+
return ["placeholder", "disabled", "submit-on-enter", "attachments", "type-to-focus", "stop-key"];
|
|
1156
1174
|
}
|
|
1157
1175
|
_observer = null;
|
|
1158
1176
|
_loadingObserver = null;
|
|
@@ -1176,6 +1194,7 @@ class AparteChat extends HTMLElement {
|
|
|
1176
1194
|
this._forwardAttr("disabled");
|
|
1177
1195
|
this._forwardAttr("submit-on-enter");
|
|
1178
1196
|
this._forwardAttr("type-to-focus");
|
|
1197
|
+
this._forwardAttr("stop-key");
|
|
1179
1198
|
this._syncEmptyWatch();
|
|
1180
1199
|
this._syncLoadingWatch();
|
|
1181
1200
|
this._watchForViewport();
|
|
@@ -1198,7 +1217,7 @@ class AparteChat extends HTMLElement {
|
|
|
1198
1217
|
this._syncAttachments();
|
|
1199
1218
|
return;
|
|
1200
1219
|
}
|
|
1201
|
-
if (name === "type-to-focus") {
|
|
1220
|
+
if (name === "type-to-focus" || name === "stop-key") {
|
|
1202
1221
|
const composer2 = this.querySelector("aparte-composer");
|
|
1203
1222
|
if (newValue !== null) composer2?.setAttribute(name, newValue);
|
|
1204
1223
|
else composer2?.removeAttribute(name);
|
|
@@ -2574,6 +2593,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2574
2593
|
if (event.key !== "Escape" || !this._confirmingRestore) return;
|
|
2575
2594
|
const separator = event.target?.closest?.(".aparte-checkpoint");
|
|
2576
2595
|
if (!separator || separator.parentElement !== this) return;
|
|
2596
|
+
event.preventDefault();
|
|
2577
2597
|
event.stopPropagation();
|
|
2578
2598
|
this._confirmingRestore = false;
|
|
2579
2599
|
this._updateCheckpoint("restore");
|
|
@@ -5809,7 +5829,22 @@ class AparteComposer extends HTMLElement {
|
|
|
5809
5829
|
this._applyDirection();
|
|
5810
5830
|
this._offTypeToFocus?.();
|
|
5811
5831
|
this._offTypeToFocus = installTypeToFocus(this);
|
|
5832
|
+
this.addEventListener("keydown", this._onStopKey);
|
|
5812
5833
|
}
|
|
5834
|
+
/**
|
|
5835
|
+
* `stop-key`. Bubble phase, on this element: what of aparté's sits inside and takes the
|
|
5836
|
+
* key (the `/` menu, a select, a panel's options) has run by then, and said so by
|
|
5837
|
+
* cancelling it. Element listeners above (a launcher closing its card) run after, and read
|
|
5838
|
+
* this cancel the same way, so the first Escape stops the reply and the next one closes.
|
|
5839
|
+
*/
|
|
5840
|
+
_onStopKey = (event) => {
|
|
5841
|
+
const key = this.getAttribute("stop-key");
|
|
5842
|
+
if (!key || event.key !== key || !this._streaming || this._panelActive) return;
|
|
5843
|
+
if (event.defaultPrevented || event.isComposing || event.keyCode === 229) return;
|
|
5844
|
+
if (event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) return;
|
|
5845
|
+
event.preventDefault();
|
|
5846
|
+
this.cancel();
|
|
5847
|
+
};
|
|
5813
5848
|
disconnectedCallback() {
|
|
5814
5849
|
window.removeEventListener("aparte-message-start", this._onMessageStart);
|
|
5815
5850
|
window.removeEventListener("aparte-message-done", this._onMessageDone);
|
|
@@ -5820,6 +5855,7 @@ class AparteComposer extends HTMLElement {
|
|
|
5820
5855
|
this._listeners.clear();
|
|
5821
5856
|
this._offTypeToFocus?.();
|
|
5822
5857
|
this._offTypeToFocus = null;
|
|
5858
|
+
this.removeEventListener("keydown", this._onStopKey);
|
|
5823
5859
|
}
|
|
5824
5860
|
attributeChangedCallback(name, _old, value) {
|
|
5825
5861
|
if (_old === value) return;
|
|
@@ -6615,6 +6651,11 @@ class AparteComposerInput extends HTMLElement {
|
|
|
6615
6651
|
/**
|
|
6616
6652
|
* Replace a range of the draft with a token, followed by a space for the caret to land
|
|
6617
6653
|
* on: a caret cannot rest after something that is not editable at the end of a line.
|
|
6654
|
+
*
|
|
6655
|
+
* An offset past the end of the draft is its end, so a control outside the field adds a
|
|
6656
|
+
* pill after what was written with `insertToken(Infinity, Infinity, token)`. Like every
|
|
6657
|
+
* edit here, it takes the focus: it goes through the browser's edit commands, so Undo
|
|
6658
|
+
* knows it.
|
|
6618
6659
|
*/
|
|
6619
6660
|
insertToken(from, to, token) {
|
|
6620
6661
|
const id = String(++this._lastTokenId);
|