@genesislcap/ai-assistant 15.35.4 → 15.36.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/ai-assistant.api.json +23 -0
- package/dist/ai-assistant.d.ts +46 -0
- package/dist/custom-elements.json +930 -826
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts +18 -0
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
- package/dist/dts/components/chat-bubble/chat-bubble.template.d.ts.map +1 -1
- package/dist/dts/components/chat-markdown/chat-markdown.d.ts +29 -0
- package/dist/dts/components/chat-markdown/chat-markdown.d.ts.map +1 -1
- package/dist/dts/components/halo-overlay.d.ts +30 -0
- package/dist/dts/components/halo-overlay.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.template.d.ts +15 -0
- package/dist/dts/main/main.template.d.ts.map +1 -1
- package/dist/dts/suggestions/chat-suggestions.d.ts +7 -0
- package/dist/dts/suggestions/chat-suggestions.d.ts.map +1 -1
- package/dist/esm/components/chat-bubble/chat-bubble.js +27 -0
- package/dist/esm/components/chat-bubble/chat-bubble.template.js +5 -3
- package/dist/esm/components/chat-markdown/chat-markdown.js +132 -1
- package/dist/esm/components/halo-overlay.js +96 -8
- package/dist/esm/index.js +3 -1
- package/dist/esm/main/main.template.js +110 -45
- package/dist/esm/suggestions/chat-suggestions.js +11 -3
- package/docs/styling.md +153 -0
- package/package.json +18 -18
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
2
|
+
/**
|
|
3
|
+
* Whether `el` still has an animation that will fire `animationend`.
|
|
4
|
+
*
|
|
5
|
+
* `dialog` is an exposed part, so an app's rules reach it and can leave the close waiting on an
|
|
6
|
+
* event that never arrives. Two shapes of that, both plausible customisations:
|
|
7
|
+
*
|
|
8
|
+
* - `::part(dialog) { animation: none }` to drop the bounce — no animation at all.
|
|
9
|
+
* - `::part(dialog) { animation: my-in 0.3s both }` to swap in its own entrance — that beats
|
|
10
|
+
* `.closing` in the cascade, so the exit never runs, and the entrance stays in `getAnimations()`
|
|
11
|
+
* as a finished animation held in effect by its fill mode.
|
|
12
|
+
*
|
|
13
|
+
* So presence in `getAnimations()` is not the question — whether anything is still going is.
|
|
14
|
+
* Tested for `running` rather than against `finished` so a paused animation, which will not fire
|
|
15
|
+
* either, is also treated as nothing to wait for.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasRunningAnimation(el: Element): boolean;
|
|
2
20
|
/**
|
|
3
21
|
* Floating chat bubble component that provides a draggable orb and dialog panel
|
|
4
22
|
* for embedding an AI assistant without a full-page layout.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-bubble.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-bubble/chat-bubble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAoB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-bubble.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-bubble/chat-bubble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAoB,MAAM,uBAAuB,CAAC;AAK9F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAExD;AAkCD;;;;;;;;;GASG;AACH,qBAOa,YAAa,SAAQ,cAAc;IAChB,KAAK,EAAE,MAAM,CAAkB;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IACP,kBAAkB,EAAE,MAAM,CAAW;IAElF,gBAAgB;IACJ,aAAa,EAAE,WAAW,EAAE,CAAM;IAC9C,gBAAgB;IACJ,oBAAoB,EAAE,MAAM,CAAK;IAC7C,iFAAiF;IACrE,UAAU,EAAE,MAAM,CAAK;IACnC,+EAA+E;IACnE,SAAS,EAAE,MAAM,CAAK;IAClC,mFAAmF;IACvE,UAAU,EAAE,MAAM,CAAK;IACnC,iFAAiF;IACrE,SAAS,EAAE,MAAM,CAAK;IAClC,iEAAiE;IACrD,WAAW,EAAE,MAAM,CAAwB;IACvD,kEAAkE;IACtD,YAAY,EAAE,MAAM,CAAyB;IACzD,4DAA4D;IAChD,UAAU,EAAE,OAAO,CAAS;IACxC,6DAA6D;IACjD,OAAO,EAAE,OAAO,CAAS;IAErC,gBAAgB;IAChB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,gBAAgB;IAChB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,WAAW,CAAC;IAEvB,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,gBAAgB,CAAC,CAAU;IACnC,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,iBAAiB;IAoCjB,kBAAkB;IAWlB,kBAAkB;IAIlB,oBAAoB;IAmBpB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO;IAoC3C,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;IAc1D,OAAO,CAAC,iBAAiB;IAczB,iBAAiB,CAAC,CAAC,EAAE,UAAU;IAa/B,uBAAuB,CAAC,CAAC,EAAE,WAAW,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAkB5E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA8B;IAO9D,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,gBAAgB;IAkCxB,OAAO,CAAC,cAAc,CAOpB;IASF,OAAO,CAAC,cAAc,CAuBpB;IAMF,OAAO,CAAC,YAAY,CA0ClB;IAEF,QAAQ;IAIR,aAAa;IAiBb,IAAI,YAAY,IAAI,MAAM,CAazB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-bubble.template.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-bubble/chat-bubble.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,EAAQ,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAgBlD,eAAO,MAAM,oBAAoB,QAAO,YAAY,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"chat-bubble.template.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-bubble/chat-bubble.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,EAAQ,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAgBlD,eAAO,MAAM,oBAAoB,QAAO,YAAY,CAAC,YAAY,CAmDhE,CAAC"}
|
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
2
|
+
/**
|
|
3
|
+
* Every part this component exposes, as an `exportparts` value.
|
|
4
|
+
*
|
|
5
|
+
* `::part()` crosses exactly one shadow boundary, so a host that renders `<ai-chat-markdown>` in
|
|
6
|
+
* its own shadow root has to forward these for an app to reach them at all. Built from the map
|
|
7
|
+
* above rather than written out, so the forwarded list cannot drift from what is emitted.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MARKDOWN_EXPORTPARTS: string;
|
|
2
10
|
export declare class AiChatMarkdown extends GenesisElement {
|
|
3
11
|
/** The markdown string to render. */
|
|
4
12
|
content: string;
|
|
5
13
|
/** @internal */
|
|
6
14
|
renderMarkdown(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Tag the generated elements with shadow parts so an embedding app can style them.
|
|
17
|
+
*
|
|
18
|
+
* Takes the tree DOMPurify built rather than re-parsing its serialised output: `content` changes
|
|
19
|
+
* on every streamed chunk, so a second parse/serialise round trip would run per chunk over the
|
|
20
|
+
* whole message, and the string the browser finally parses is then serialised straight from the
|
|
21
|
+
* tree DOMPurify checked. Parse/serialise mismatches are where mXSS bypasses have historically
|
|
22
|
+
* lived, and this walk has no need to introduce one.
|
|
23
|
+
*
|
|
24
|
+
* Only ever *adds* attributes, to DOM that has already been cleared - so it is not itself
|
|
25
|
+
* sanitiser surface.
|
|
26
|
+
*
|
|
27
|
+
* Lists additionally carry a level: a top-level list is `md-ul md-ul-level-1`, a list nested
|
|
28
|
+
* inside it is `md-ul-level-2`, and an `li` takes the level of the list holding it. Levels are
|
|
29
|
+
* clamped at `MAX_LIST_LEVEL`, so a list deeper than that answers to the deepest level
|
|
30
|
+
* rather than to a name no host forwards. Chat markdown rarely nests, so this is a safety valve
|
|
31
|
+
* rather than a feature - without it, every list at every depth would answer to one selector and
|
|
32
|
+
* there would be no way to tell them apart afterwards. Depth comes from walking the tree rather
|
|
33
|
+
* than from marked's renderers, which are invoked innermost-first and so cannot count downwards.
|
|
34
|
+
*/
|
|
35
|
+
private annotateParts;
|
|
7
36
|
}
|
|
8
37
|
//# sourceMappingURL=chat-markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-markdown/chat-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAoB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-markdown/chat-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAoB,MAAM,uBAAuB,CAAC;AA0I7F;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAOvB,CAAC;AAWb,qBAOa,cAAe,SAAQ,cAAc;IAChD,qCAAqC;IACzB,OAAO,EAAE,MAAM,CAAM;IAEjC,gBAAgB;IAChB,cAAc;IAed;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,aAAa;CAmBtB"}
|
|
@@ -31,8 +31,38 @@ export declare class AiHaloOverlay extends GenesisElement {
|
|
|
31
31
|
private angle;
|
|
32
32
|
private lastTime?;
|
|
33
33
|
private animFrame?;
|
|
34
|
+
private stopTimer?;
|
|
35
|
+
/** Whether the loop should keep rescheduling itself — see {@link AiHaloOverlay.tick}. */
|
|
36
|
+
private running;
|
|
37
|
+
/**
|
|
38
|
+
* Start/stop with `active`, so an idle overlay costs nothing.
|
|
39
|
+
*
|
|
40
|
+
* Guarded on `isConnected` because FAST invokes attribute-changed callbacks during
|
|
41
|
+
* initialisation, before the element is in the document — `connectedCallback` is what decides
|
|
42
|
+
* for an element that mounts already-active.
|
|
43
|
+
*/
|
|
44
|
+
activeChanged(): void;
|
|
34
45
|
connectedCallback(): void;
|
|
35
46
|
disconnectedCallback(): void;
|
|
47
|
+
private startAnimation;
|
|
48
|
+
/**
|
|
49
|
+
* Keep spinning until the host has finished fading out.
|
|
50
|
+
*
|
|
51
|
+
* Deactivating only drops the host's opacity — the overlay is still on screen for the length of
|
|
52
|
+
* the transition, so stopping the instant `active` flips would freeze the rotation mid-fade.
|
|
53
|
+
*
|
|
54
|
+
* Timed rather than driven by `transitionend`, which never fires if the host is hidden or an app
|
|
55
|
+
* overrides the transition away, and a stop that never arrives is exactly the idle-tick bug this
|
|
56
|
+
* gating exists to prevent.
|
|
57
|
+
*
|
|
58
|
+
* The timer re-reads `active` rather than trusting that it was cancelled. FAST reflects the
|
|
59
|
+
* property to the attribute on a queued update, so `activeChanged` can run again, out of order,
|
|
60
|
+
* after a rapid toggle — and a stale stop landing on a re-activated overlay would leave it
|
|
61
|
+
* frozen for good, which is worse than the idle ticking this gate removes.
|
|
62
|
+
*/
|
|
63
|
+
private scheduleStop;
|
|
64
|
+
private cancelPendingStop;
|
|
65
|
+
private stopAnimation;
|
|
36
66
|
private tick;
|
|
37
67
|
}
|
|
38
68
|
//# sourceMappingURL=halo-overlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo-overlay.d.ts","sourceRoot":"","sources":["../../../src/components/halo-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAQ,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"halo-overlay.d.ts","sourceRoot":"","sources":["../../../src/components/halo-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAQ,MAAM,uBAAuB,CAAC;AAgCvF;;;;;;;;;;;;GAYG;AACH,qBA0Ea,aAAc,SAAQ,cAAc;IACpB,MAAM,EAAE,OAAO,CAAS;IACnD,+FAA+F;IACpC,KAAK,EAAE,MAAM,CAAsB;IAC9F,qDAAqD;IAC/C,SAAS,EAAE,IAAI,GAAG,KAAK,CAAQ;IACrC,0CAA0C;IAE1C,UAAU,EAAE,MAAM,CAA4B;IAC9C,+CAA+C;IAE/C,WAAW,EAAE,MAAM,CAA6B;IAChD,2GAA2G;IAE3G,UAAU,EAAE,MAAM,CAA4B;IAE9C,iBAAiB;IAIjB,kBAAkB;IAIlB,iBAAiB;IAejB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAEhD,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,yFAAyF;IACzF,OAAO,CAAC,OAAO,CAAS;IAExB;;;;;;OAMG;IACH,aAAa;IAUb,iBAAiB;IAKjB,oBAAoB;IAMpB,OAAO,CAAC,cAAc;IAQtB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,IAAI;CAyBb"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -27,5 +27,5 @@ export type { ResolvedDebugLogNoteConfig } from './utils/resolve-debug-log-note'
|
|
|
27
27
|
export type { ModelTagAppearance } from '@genesislcap/foundation-ai';
|
|
28
28
|
export type { AiChatInteraction, AiChatWidget } from './types/ai-chat-widget';
|
|
29
29
|
export type { InteractionContext } from './types/interaction-context';
|
|
30
|
-
export { AiChatMarkdown } from './components/chat-markdown/chat-markdown';
|
|
30
|
+
export { AiChatMarkdown, MARKDOWN_EXPORTPARTS } from './components/chat-markdown/chat-markdown';
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EACV,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,gEAAgE,CAAC;AACxE,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AAGpC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,mCAAmC,EAAE,MAAM,2BAA2B,CAAC;AAChF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,YAAY,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACjF,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EACV,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,gEAAgE,CAAC;AACxE,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AAGpC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,mCAAmC,EAAE,MAAM,2BAA2B,CAAC;AAChF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,YAAY,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACjF,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC"}
|
|
@@ -17,6 +17,21 @@
|
|
|
17
17
|
import type { ChatMessage } from '@genesislcap/foundation-ai';
|
|
18
18
|
import { ViewTemplate } from '@genesislcap/web-core';
|
|
19
19
|
import type { FoundationAiAssistant } from './main';
|
|
20
|
+
/**
|
|
21
|
+
* Part names for one avatar element: the bare name, a role-level name, and — on the assistant
|
|
22
|
+
* side, whose rows vary — the message type.
|
|
23
|
+
*
|
|
24
|
+
* The role-level name is the one an app usually wants. `messageType` splits the assistant across
|
|
25
|
+
* `ai`, `ai-thinking`, `ai-function` and `interaction`, so without it "style the assistant's
|
|
26
|
+
* avatar, not the user's" takes four selectors and silently misses any type added later.
|
|
27
|
+
* `::part()` names cannot be chained, so each has to be a name of its own rather than a
|
|
28
|
+
* combination. The user side needs no extra name — its role and its type are both `user`.
|
|
29
|
+
*
|
|
30
|
+
* Exported for the unit test that pins the vocabulary; not part of the element API.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export declare const avatarPartsFor: (base: string, type: string) => string;
|
|
20
35
|
/**
|
|
21
36
|
* The timestamp shown beside the sender name (GENC-1257).
|
|
22
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.template.d.ts","sourceRoot":"","sources":["../../../src/main/main.template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,WAAW,EAGZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAuC,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"main.template.d.ts","sourceRoot":"","sources":["../../../src/main/main.template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,WAAW,EAGZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAuC,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAU1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAkDpD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAC4B,CAAC;AAsGzF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,kDAWpC,CAAC;AAoJF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,qBAAqB,KAAG,MAYlD,CAAC;AAEf;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,qBAAqB,KAAG,MAAM,GAAG,IACpB,CAAC;AAyJrD,eAAO,MAAM,6BAA6B,GACxC,oBAAoB,MAAM,KACzB,YAAY,CAAC,qBAAqB,CAisBpC,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
2
2
|
import type { SuggestionsState } from '../main/main.types';
|
|
3
|
+
/**
|
|
4
|
+
* Every part this component exposes, as an `exportparts` value.
|
|
5
|
+
*
|
|
6
|
+
* `::part()` crosses exactly one shadow boundary, so a host rendering `<chat-suggestions>` in its
|
|
7
|
+
* own shadow root has to forward these for an embedding app to reach them at all.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SUGGESTIONS_EXPORTPARTS = "suggestions-container, suggestion-placeholder, suggestion-pill";
|
|
3
10
|
export declare class ChatSuggestions extends GenesisElement {
|
|
4
11
|
state: SuggestionsState;
|
|
5
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-suggestions.d.ts","sourceRoot":"","sources":["../../../src/suggestions/chat-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EAMf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-suggestions.d.ts","sourceRoot":"","sources":["../../../src/suggestions/chat-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EAMf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,mEAC8B,CAAC;AAoJnE,qBAKa,eAAgB,SAAQ,cAAc;IAEjD,KAAK,EAAE,gBAAgB,CAAsB;IAE7C;;;;OAIG;IACkD,UAAU,UAAS;IAExE,YAAY,IAAI,IAAI;IAKpB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;CAGhD"}
|
|
@@ -3,6 +3,26 @@ import { attr, customElement, GenesisElement, html, observable } from '@genesisl
|
|
|
3
3
|
import { agenticActivityBus } from '../../channel/ai-activity-bus';
|
|
4
4
|
import { styles } from './chat-bubble.styles';
|
|
5
5
|
import { AiChatBubbleTemplate } from './chat-bubble.template';
|
|
6
|
+
/**
|
|
7
|
+
* Whether `el` still has an animation that will fire `animationend`.
|
|
8
|
+
*
|
|
9
|
+
* `dialog` is an exposed part, so an app's rules reach it and can leave the close waiting on an
|
|
10
|
+
* event that never arrives. Two shapes of that, both plausible customisations:
|
|
11
|
+
*
|
|
12
|
+
* - `::part(dialog) { animation: none }` to drop the bounce — no animation at all.
|
|
13
|
+
* - `::part(dialog) { animation: my-in 0.3s both }` to swap in its own entrance — that beats
|
|
14
|
+
* `.closing` in the cascade, so the exit never runs, and the entrance stays in `getAnimations()`
|
|
15
|
+
* as a finished animation held in effect by its fill mode.
|
|
16
|
+
*
|
|
17
|
+
* So presence in `getAnimations()` is not the question — whether anything is still going is.
|
|
18
|
+
* Tested for `running` rather than against `finished` so a paused animation, which will not fire
|
|
19
|
+
* either, is also treated as nothing to wait for.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export function hasRunningAnimation(el) {
|
|
24
|
+
return el.getAnimations().some((a) => a.playState === 'running');
|
|
25
|
+
}
|
|
6
26
|
/** Default dimensions of the dialog panel */
|
|
7
27
|
const DIALOG_DEFAULT_WIDTH = 400;
|
|
8
28
|
const DIALOG_DEFAULT_HEIGHT = 520;
|
|
@@ -329,6 +349,13 @@ let AiChatBubble = class AiChatBubble extends GenesisElement {
|
|
|
329
349
|
}
|
|
330
350
|
this.closeAbort = new AbortController();
|
|
331
351
|
this.dialogEl.classList.add('closing');
|
|
352
|
+
// Nothing running means nothing will fire `animationend`, so close now rather than wait for
|
|
353
|
+
// an event that is not coming. getAnimations() flushes style, so the class added above is
|
|
354
|
+
// already accounted for.
|
|
355
|
+
if (!hasRunningAnimation(this.dialogEl)) {
|
|
356
|
+
this.dialogOpen = false;
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
332
359
|
this.dialogEl.addEventListener('animationend', () => {
|
|
333
360
|
this.dialogOpen = false;
|
|
334
361
|
}, {
|
|
@@ -17,6 +17,7 @@ export const AiChatBubbleTemplate = () => {
|
|
|
17
17
|
${when((x) => !x.dialogOpen, html `
|
|
18
18
|
<div
|
|
19
19
|
class="bubble ${(x) => (x.hovered ? 'hovered' : '')}"
|
|
20
|
+
part="bubble"
|
|
20
21
|
style="${(x) => `translate: ${x.bubbleLeft}px ${x.bubbleTop}px`}"
|
|
21
22
|
${ref('bubbleEl')}
|
|
22
23
|
@mousedown="${(x, c) => x.onBubbleMouseDown(c.event)}"
|
|
@@ -27,8 +28,8 @@ export const AiChatBubbleTemplate = () => {
|
|
|
27
28
|
<img src="${(x) => x.imageSrc}" alt="AI" draggable="false" />
|
|
28
29
|
`)}
|
|
29
30
|
${when((x) => !x.imageSrc, genesisIconTemplate)}
|
|
30
|
-
<div class="pulse-ring"></div>
|
|
31
|
-
<div class="tooltip" style="${(x) => x.tooltipStyle}" ${ref('tooltipEl')}>
|
|
31
|
+
<div class="pulse-ring" part="pulse-ring"></div>
|
|
32
|
+
<div class="tooltip" part="tooltip" style="${(x) => x.tooltipStyle}" ${ref('tooltipEl')}>
|
|
32
33
|
${(x) => x.title}
|
|
33
34
|
</div>
|
|
34
35
|
</div>
|
|
@@ -41,11 +42,12 @@ export const AiChatBubbleTemplate = () => {
|
|
|
41
42
|
(x) => (x.dialogOpen ? [x] : []), html `
|
|
42
43
|
<div
|
|
43
44
|
class="dialog"
|
|
45
|
+
part="dialog"
|
|
44
46
|
style="${(x) => `translate: ${x.dialogLeft}px ${x.dialogTop}px; width: ${x.dialogWidth}px; height: ${x.dialogHeight}px`}"
|
|
45
47
|
@chat-header-mousedown="${(x, c) => x.onDialogHeaderMouseDown(c.event)}"
|
|
46
48
|
${ref('dialogEl')}
|
|
47
49
|
>
|
|
48
|
-
<div class="dialog-content">
|
|
50
|
+
<div class="dialog-content" part="dialog-content">
|
|
49
51
|
<slot name="dialog-content" ${slotted('dialogContent')}></slot>
|
|
50
52
|
</div>
|
|
51
53
|
</div>
|
|
@@ -68,6 +68,92 @@ const styles = css `
|
|
|
68
68
|
font-weight: 600;
|
|
69
69
|
}
|
|
70
70
|
`;
|
|
71
|
+
/**
|
|
72
|
+
* Element tag -> the shadow part it is exposed as.
|
|
73
|
+
*
|
|
74
|
+
* Markdown is rendered from a string at runtime, so there is no template on which to author
|
|
75
|
+
* `part=` attributes - which is why this component previously exposed nothing at all and an
|
|
76
|
+
* embedding app could only reach it through whichever global design tokens the rules below happen
|
|
77
|
+
* to use. Annotating the generated DOM gives an app ordinary CSS over each element type
|
|
78
|
+
* (`ai-chat-markdown::part(md-li) { ... }`) instead of a per-property token API that would have to
|
|
79
|
+
* grow every time someone wants to style something new.
|
|
80
|
+
*
|
|
81
|
+
* The vocabulary is deliberately a fixed list of element kinds rather than anything derived from
|
|
82
|
+
* the content: it is a public API surface, so it should change only when this map does. That also
|
|
83
|
+
* makes it enumerable, which {@link MARKDOWN_EXPORTPARTS} relies on.
|
|
84
|
+
*/
|
|
85
|
+
const MARKDOWN_PARTS = {
|
|
86
|
+
P: 'md-p',
|
|
87
|
+
UL: 'md-ul',
|
|
88
|
+
OL: 'md-ol',
|
|
89
|
+
LI: 'md-li',
|
|
90
|
+
PRE: 'md-pre',
|
|
91
|
+
CODE: 'md-code',
|
|
92
|
+
A: 'md-link',
|
|
93
|
+
BLOCKQUOTE: 'md-quote',
|
|
94
|
+
TABLE: 'md-table',
|
|
95
|
+
THEAD: 'md-thead',
|
|
96
|
+
TBODY: 'md-tbody',
|
|
97
|
+
TR: 'md-tr',
|
|
98
|
+
TH: 'md-th',
|
|
99
|
+
TD: 'md-td',
|
|
100
|
+
HR: 'md-hr',
|
|
101
|
+
IMG: 'md-img',
|
|
102
|
+
STRONG: 'md-strong',
|
|
103
|
+
EM: 'md-em',
|
|
104
|
+
H1: 'md-h1',
|
|
105
|
+
H2: 'md-h2',
|
|
106
|
+
H3: 'md-h3',
|
|
107
|
+
H4: 'md-h4',
|
|
108
|
+
H5: 'md-h5',
|
|
109
|
+
H6: 'md-h6',
|
|
110
|
+
};
|
|
111
|
+
/** Tags whose part is also emitted with a nesting level (see {@link AiChatMarkdown.annotateParts}). */
|
|
112
|
+
const DEPTH_TAGGED = ['UL', 'OL', 'LI'];
|
|
113
|
+
const DEPTH_TAGGED_SET = new Set(DEPTH_TAGGED);
|
|
114
|
+
/**
|
|
115
|
+
* Deepest list level with a part of its own; anything deeper is tagged as this level.
|
|
116
|
+
*
|
|
117
|
+
* `exportparts` has no wildcard, so every level a host forwards has to be named. An uncapped
|
|
118
|
+
* scheme would therefore have a forwarding list that can never be complete, and any list deeper
|
|
119
|
+
* than it happened to enumerate would be silently unstyleable. Capping keeps the exported
|
|
120
|
+
* vocabulary finite and makes the deepest level mean "this deep or deeper", which is a contract
|
|
121
|
+
* that can actually be honoured.
|
|
122
|
+
*/
|
|
123
|
+
const MAX_LIST_LEVEL = 3;
|
|
124
|
+
/**
|
|
125
|
+
* The two `code` flavours, emitted alongside `md-code`.
|
|
126
|
+
*
|
|
127
|
+
* `::part()` takes no descendant combinators, so `md-code` alone cannot distinguish inline code
|
|
128
|
+
* from the `code` inside a `pre`: an app giving it a background for inline spans would paint every
|
|
129
|
+
* code block too, and the `pre code` reset in this component's own styles loses to an outer
|
|
130
|
+
* `::part` rule in the cascade, so there would be nothing to undo it with.
|
|
131
|
+
*/
|
|
132
|
+
const CODE_BLOCK_PART = 'md-code-block';
|
|
133
|
+
const CODE_INLINE_PART = 'md-code-inline';
|
|
134
|
+
/**
|
|
135
|
+
* Every part this component exposes, as an `exportparts` value.
|
|
136
|
+
*
|
|
137
|
+
* `::part()` crosses exactly one shadow boundary, so a host that renders `<ai-chat-markdown>` in
|
|
138
|
+
* its own shadow root has to forward these for an app to reach them at all. Built from the map
|
|
139
|
+
* above rather than written out, so the forwarded list cannot drift from what is emitted.
|
|
140
|
+
*/
|
|
141
|
+
export const MARKDOWN_EXPORTPARTS = [
|
|
142
|
+
...Object.values(MARKDOWN_PARTS),
|
|
143
|
+
CODE_BLOCK_PART,
|
|
144
|
+
CODE_INLINE_PART,
|
|
145
|
+
...DEPTH_TAGGED.flatMap((tag) => Array.from({ length: MAX_LIST_LEVEL }, (_, i) => `${MARKDOWN_PARTS[tag]}-level-${i + 1}`)),
|
|
146
|
+
].join(', ');
|
|
147
|
+
/** The part attribute for one generated element, given the list depth it sits at. */
|
|
148
|
+
function partFor(el, base, listDepth) {
|
|
149
|
+
var _a;
|
|
150
|
+
if (DEPTH_TAGGED_SET.has(el.tagName))
|
|
151
|
+
return `${base} ${base}-level-${listDepth}`;
|
|
152
|
+
if (el.tagName === 'CODE') {
|
|
153
|
+
return `${base} ${((_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === 'PRE' ? CODE_BLOCK_PART : CODE_INLINE_PART}`;
|
|
154
|
+
}
|
|
155
|
+
return base;
|
|
156
|
+
}
|
|
71
157
|
let AiChatMarkdown = class AiChatMarkdown extends GenesisElement {
|
|
72
158
|
constructor() {
|
|
73
159
|
super(...arguments);
|
|
@@ -79,7 +165,52 @@ let AiChatMarkdown = class AiChatMarkdown extends GenesisElement {
|
|
|
79
165
|
if (!this.content)
|
|
80
166
|
return '';
|
|
81
167
|
const rawHtml = marked.parse(this.content);
|
|
82
|
-
|
|
168
|
+
// `part`/`exportparts` are on DOMPurify's default allow-list, so a model emitting
|
|
169
|
+
// `<span part="md-link">` would otherwise land a name in this component's part namespace that
|
|
170
|
+
// MARKDOWN_PARTS never granted. Forbidding them keeps the vocabulary exactly what this file
|
|
171
|
+
// says it is, whatever the content claims.
|
|
172
|
+
return this.annotateParts(DOMPurify.sanitize(rawHtml, {
|
|
173
|
+
FORBID_ATTR: ['part', 'exportparts'],
|
|
174
|
+
RETURN_DOM_FRAGMENT: true,
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Tag the generated elements with shadow parts so an embedding app can style them.
|
|
179
|
+
*
|
|
180
|
+
* Takes the tree DOMPurify built rather than re-parsing its serialised output: `content` changes
|
|
181
|
+
* on every streamed chunk, so a second parse/serialise round trip would run per chunk over the
|
|
182
|
+
* whole message, and the string the browser finally parses is then serialised straight from the
|
|
183
|
+
* tree DOMPurify checked. Parse/serialise mismatches are where mXSS bypasses have historically
|
|
184
|
+
* lived, and this walk has no need to introduce one.
|
|
185
|
+
*
|
|
186
|
+
* Only ever *adds* attributes, to DOM that has already been cleared - so it is not itself
|
|
187
|
+
* sanitiser surface.
|
|
188
|
+
*
|
|
189
|
+
* Lists additionally carry a level: a top-level list is `md-ul md-ul-level-1`, a list nested
|
|
190
|
+
* inside it is `md-ul-level-2`, and an `li` takes the level of the list holding it. Levels are
|
|
191
|
+
* clamped at `MAX_LIST_LEVEL`, so a list deeper than that answers to the deepest level
|
|
192
|
+
* rather than to a name no host forwards. Chat markdown rarely nests, so this is a safety valve
|
|
193
|
+
* rather than a feature - without it, every list at every depth would answer to one selector and
|
|
194
|
+
* there would be no way to tell them apart afterwards. Depth comes from walking the tree rather
|
|
195
|
+
* than from marked's renderers, which are invoked innermost-first and so cannot count downwards.
|
|
196
|
+
*/
|
|
197
|
+
annotateParts(fragment) {
|
|
198
|
+
const walk = (parent, listDepth) => {
|
|
199
|
+
for (const el of Array.from(parent.children)) {
|
|
200
|
+
const base = MARKDOWN_PARTS[el.tagName];
|
|
201
|
+
// A list opens the next level; everything else sits at its parent list's level.
|
|
202
|
+
const depth = el.tagName === 'UL' || el.tagName === 'OL'
|
|
203
|
+
? Math.min(listDepth + 1, MAX_LIST_LEVEL)
|
|
204
|
+
: listDepth;
|
|
205
|
+
if (base)
|
|
206
|
+
el.setAttribute('part', partFor(el, base, depth));
|
|
207
|
+
walk(el, depth);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
walk(fragment, 0);
|
|
211
|
+
const container = document.createElement('div');
|
|
212
|
+
container.append(fragment);
|
|
213
|
+
return container.innerHTML;
|
|
83
214
|
}
|
|
84
215
|
};
|
|
85
216
|
__decorate([
|
|
@@ -17,6 +17,14 @@ const BASELINE_FPS = 60;
|
|
|
17
17
|
* dropped frames.
|
|
18
18
|
*/
|
|
19
19
|
const FRAME_MS = MS_PER_SECOND / BASELINE_FPS;
|
|
20
|
+
/**
|
|
21
|
+
* How long the host takes to fade in/out, in ms.
|
|
22
|
+
*
|
|
23
|
+
* Interpolated into the stylesheet as well as used to time the deferred stop, so the animation
|
|
24
|
+
* cannot outlive the fade or be cut short by it.
|
|
25
|
+
*/
|
|
26
|
+
const HALO_FADE_MS = 400;
|
|
27
|
+
const HALO_FADE_DURATION = `${HALO_FADE_MS}ms`;
|
|
20
28
|
/**
|
|
21
29
|
* Animated halo overlay — rotating conic-gradient border with an inward glow.
|
|
22
30
|
*
|
|
@@ -45,6 +53,8 @@ let AiHaloOverlay = AiHaloOverlay_1 = class AiHaloOverlay extends GenesisElement
|
|
|
45
53
|
/** Transparent stop of the radial glow mask as a percentage (0–100). Higher = less spread. Default: 70. */
|
|
46
54
|
this.glowSpread = HALO_DEFAULT_GLOW_SPREAD;
|
|
47
55
|
this.angle = 0;
|
|
56
|
+
/** Whether the loop should keep rescheduling itself — see {@link AiHaloOverlay.tick}. */
|
|
57
|
+
this.running = false;
|
|
48
58
|
}
|
|
49
59
|
borderSizeChanged() {
|
|
50
60
|
this.style.setProperty('--halo-border-size', `${this.borderSize}px`);
|
|
@@ -55,20 +65,93 @@ let AiHaloOverlay = AiHaloOverlay_1 = class AiHaloOverlay extends GenesisElement
|
|
|
55
65
|
glowSpreadChanged() {
|
|
56
66
|
this.style.setProperty('--halo-glow-spread', `${this.glowSpread}%`);
|
|
57
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Start/stop with `active`, so an idle overlay costs nothing.
|
|
70
|
+
*
|
|
71
|
+
* Guarded on `isConnected` because FAST invokes attribute-changed callbacks during
|
|
72
|
+
* initialisation, before the element is in the document — `connectedCallback` is what decides
|
|
73
|
+
* for an element that mounts already-active.
|
|
74
|
+
*/
|
|
75
|
+
activeChanged() {
|
|
76
|
+
if (!this.isConnected)
|
|
77
|
+
return;
|
|
78
|
+
if (this.active) {
|
|
79
|
+
this.cancelPendingStop();
|
|
80
|
+
this.startAnimation();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.scheduleStop();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
58
86
|
connectedCallback() {
|
|
59
87
|
super.connectedCallback();
|
|
60
|
-
this.
|
|
88
|
+
if (this.active)
|
|
89
|
+
this.startAnimation();
|
|
61
90
|
}
|
|
62
91
|
disconnectedCallback() {
|
|
63
92
|
super.disconnectedCallback();
|
|
93
|
+
this.cancelPendingStop();
|
|
94
|
+
this.stopAnimation();
|
|
95
|
+
}
|
|
96
|
+
startAnimation() {
|
|
97
|
+
// Re-entrant: `activeChanged` can fire for a value that is already applied, and a second
|
|
98
|
+
// scheduled frame would double the rotation speed and leak the first handle.
|
|
99
|
+
if (this.running)
|
|
100
|
+
return;
|
|
101
|
+
this.running = true;
|
|
102
|
+
this.tick();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Keep spinning until the host has finished fading out.
|
|
106
|
+
*
|
|
107
|
+
* Deactivating only drops the host's opacity — the overlay is still on screen for the length of
|
|
108
|
+
* the transition, so stopping the instant `active` flips would freeze the rotation mid-fade.
|
|
109
|
+
*
|
|
110
|
+
* Timed rather than driven by `transitionend`, which never fires if the host is hidden or an app
|
|
111
|
+
* overrides the transition away, and a stop that never arrives is exactly the idle-tick bug this
|
|
112
|
+
* gating exists to prevent.
|
|
113
|
+
*
|
|
114
|
+
* The timer re-reads `active` rather than trusting that it was cancelled. FAST reflects the
|
|
115
|
+
* property to the attribute on a queued update, so `activeChanged` can run again, out of order,
|
|
116
|
+
* after a rapid toggle — and a stale stop landing on a re-activated overlay would leave it
|
|
117
|
+
* frozen for good, which is worse than the idle ticking this gate removes.
|
|
118
|
+
*/
|
|
119
|
+
scheduleStop() {
|
|
120
|
+
if (this.stopTimer !== undefined || !this.running)
|
|
121
|
+
return;
|
|
122
|
+
this.stopTimer = window.setTimeout(() => {
|
|
123
|
+
this.stopTimer = undefined;
|
|
124
|
+
if (this.active)
|
|
125
|
+
return;
|
|
126
|
+
this.stopAnimation();
|
|
127
|
+
}, HALO_FADE_MS);
|
|
128
|
+
}
|
|
129
|
+
cancelPendingStop() {
|
|
130
|
+
if (this.stopTimer === undefined)
|
|
131
|
+
return;
|
|
132
|
+
clearTimeout(this.stopTimer);
|
|
133
|
+
this.stopTimer = undefined;
|
|
134
|
+
}
|
|
135
|
+
stopAnimation() {
|
|
136
|
+
this.running = false;
|
|
64
137
|
if (this.animFrame !== undefined) {
|
|
65
138
|
cancelAnimationFrame(this.animFrame);
|
|
66
139
|
this.animFrame = undefined;
|
|
67
140
|
}
|
|
68
|
-
// Reset the clock so a later
|
|
141
|
+
// Reset the clock so a later restart doesn't apply one huge time delta. `angle` is
|
|
142
|
+
// deliberately NOT reset: the halo fades out on opacity, so resuming from where it stopped
|
|
143
|
+
// avoids a visible jump when it comes back.
|
|
69
144
|
this.lastTime = undefined;
|
|
70
145
|
}
|
|
71
146
|
tick(now) {
|
|
147
|
+
// Defensive: a frame already dequeued for this tick cannot be cancelled, so without this a
|
|
148
|
+
// stop landing earlier in the same frame would be undone by the reschedule below and the loop
|
|
149
|
+
// would revive with no owner. Keyed on `running` rather than on `active`, which goes false
|
|
150
|
+
// while the fade — and so the rotation — is still meant to be running.
|
|
151
|
+
if (!this.isConnected || !this.running) {
|
|
152
|
+
this.animFrame = undefined;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
72
155
|
// Advance by elapsed wall-clock time (expressed in 60fps-equivalent frames)
|
|
73
156
|
// rather than a fixed step per callback, so the rotation runs at a constant
|
|
74
157
|
// real-world speed regardless of the display's refresh rate or dropped
|
|
@@ -86,11 +169,16 @@ let AiHaloOverlay = AiHaloOverlay_1 = class AiHaloOverlay extends GenesisElement
|
|
|
86
169
|
this.animFrame = requestAnimationFrame((t) => this.tick(t));
|
|
87
170
|
}
|
|
88
171
|
};
|
|
89
|
-
// TODO: The rAF loop is fine for demos but
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
172
|
+
// TODO: The rAF loop is fine for demos but runs on the main thread, so heavy JS work can cause
|
|
173
|
+
// the animation to stutter. Once @property inside Shadow DOM has solid cross-browser support,
|
|
174
|
+
// consider switching back to a CSS @keyframes approach and removing
|
|
175
|
+
// connectedCallback/disconnectedCallback/tick().
|
|
176
|
+
//
|
|
177
|
+
// The loop is gated on `active` (see startAnimation/stopAnimation): every tick writes
|
|
178
|
+
// `--halo-angle` as an inline style, and hosts mount these permanently while only toggling
|
|
179
|
+
// `active`, so an idle overlay must not tick. Beyond the wasted work, a style attribute
|
|
180
|
+
// rewritten ~60x a second repaints the devtools Elements panel on every mutation, which makes
|
|
181
|
+
// inspecting anywhere in the tree impractical.
|
|
94
182
|
AiHaloOverlay.FULL_ROTATION_DEG = 360;
|
|
95
183
|
__decorate([
|
|
96
184
|
attr({ mode: 'boolean' })
|
|
@@ -125,7 +213,7 @@ AiHaloOverlay = AiHaloOverlay_1 = __decorate([
|
|
|
125
213
|
pointer-events: none;
|
|
126
214
|
z-index: 1000;
|
|
127
215
|
opacity: 0;
|
|
128
|
-
transition: opacity
|
|
216
|
+
transition: opacity ${HALO_FADE_DURATION} ease;
|
|
129
217
|
}
|
|
130
218
|
|
|
131
219
|
:host([active]) {
|
package/dist/esm/index.js
CHANGED
|
@@ -18,4 +18,6 @@ export * from './provider/tiered-provider-switcher';
|
|
|
18
18
|
export * from './provider/assistant-app-settings';
|
|
19
19
|
export * from './utils/tool-fold';
|
|
20
20
|
export { assistantSettingsSectionTitleStyles } from './styles/settings-section';
|
|
21
|
-
|
|
21
|
+
// MARKDOWN_EXPORTPARTS travels with the component: a host rendering `<ai-chat-markdown>` in its
|
|
22
|
+
// own shadow root has to forward its parts, and hand-copying the list is how it drifts.
|
|
23
|
+
export { AiChatMarkdown, MARKDOWN_EXPORTPARTS } from './components/chat-markdown/chat-markdown';
|