@convai/web-sdk 1.8.0 → 1.9.0-beta.1
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 +213 -45
- package/dist/core/CharacterRoster.d.ts +84 -0
- package/dist/core/CharacterRoster.d.ts.map +1 -0
- package/dist/core/CharacterRoster.js +348 -0
- package/dist/core/CharacterRoster.js.map +1 -0
- package/dist/core/CharacterVersionManager.d.ts +100 -0
- package/dist/core/CharacterVersionManager.d.ts.map +1 -0
- package/dist/core/CharacterVersionManager.js +227 -0
- package/dist/core/CharacterVersionManager.js.map +1 -0
- package/dist/core/ConvaiClient.d.ts +190 -1
- package/dist/core/ConvaiClient.d.ts.map +1 -1
- package/dist/core/ConvaiClient.js +1328 -289
- package/dist/core/ConvaiClient.js.map +1 -1
- package/dist/core/ConvaiRoomError.d.ts +48 -0
- package/dist/core/ConvaiRoomError.d.ts.map +1 -0
- package/dist/core/ConvaiRoomError.js +111 -0
- package/dist/core/ConvaiRoomError.js.map +1 -0
- package/dist/core/MessageHandler.d.ts +26 -2
- package/dist/core/MessageHandler.d.ts.map +1 -1
- package/dist/core/MessageHandler.js +397 -32
- package/dist/core/MessageHandler.js.map +1 -1
- package/dist/core/SSESession.d.ts +74 -0
- package/dist/core/SSESession.d.ts.map +1 -0
- package/dist/core/SSESession.js +499 -0
- package/dist/core/SSESession.js.map +1 -0
- package/dist/core/characterReference.d.ts +40 -0
- package/dist/core/characterReference.d.ts.map +1 -0
- package/dist/core/characterReference.js +72 -0
- package/dist/core/characterReference.js.map +1 -0
- package/dist/core/connectRequest.d.ts +17 -4
- package/dist/core/connectRequest.d.ts.map +1 -1
- package/dist/core/connectRequest.js +28 -17
- package/dist/core/connectRequest.js.map +1 -1
- package/dist/core/index.d.ts +10 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +14 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/logicalTurn.d.ts +4 -6
- package/dist/core/logicalTurn.d.ts.map +1 -1
- package/dist/core/logicalTurn.js +29 -4
- package/dist/core/logicalTurn.js.map +1 -1
- package/dist/core/modelOutput.d.ts.map +1 -1
- package/dist/core/modelOutput.js +2 -2
- package/dist/core/modelOutput.js.map +1 -1
- package/dist/core/rosterRequest.d.ts +57 -0
- package/dist/core/rosterRequest.d.ts.map +1 -0
- package/dist/core/rosterRequest.js +210 -0
- package/dist/core/rosterRequest.js.map +1 -0
- package/dist/core/types.d.ts +869 -22
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/embed/ConvaiChatElement.d.ts +77 -1
- package/dist/embed/ConvaiChatElement.d.ts.map +1 -1
- package/dist/embed/ConvaiChatElement.js +433 -54
- package/dist/embed/ConvaiChatElement.js.map +1 -1
- package/dist/embed/chat-embed-v1.js +136 -35
- package/dist/embed/chat-embed-v1.js.map +4 -4
- package/dist/react/components/ConvaiWidget.d.ts.map +1 -1
- package/dist/react/components/ConvaiWidget.js +6 -1
- package/dist/react/components/ConvaiWidget.js.map +1 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.js +28 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.js.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +18 -0
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +132 -63
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -1
- package/dist/react/components/rtc-widget/components/UserMessage.js +1 -1
- package/dist/react/components/rtc-widget/components/UserMessage.js.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +93 -49
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +1 -1
- package/dist/react/hooks/useConvaiClient.d.ts.map +1 -1
- package/dist/react/hooks/useConvaiClient.js +17 -2
- package/dist/react/hooks/useConvaiClient.js.map +1 -1
- package/dist/react/index.d.ts +6 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +9 -1
- package/dist/react/index.js.map +1 -1
- package/dist/utils/inlineMarkdown.d.ts +60 -0
- package/dist/utils/inlineMarkdown.d.ts.map +1 -0
- package/dist/utils/inlineMarkdown.js +183 -0
- package/dist/utils/inlineMarkdown.js.map +1 -0
- package/dist/utils/lightbox.d.ts +16 -0
- package/dist/utils/lightbox.d.ts.map +1 -0
- package/dist/utils/lightbox.js +95 -0
- package/dist/utils/lightbox.js.map +1 -0
- package/dist/utils/linkPresentation.d.ts +69 -0
- package/dist/utils/linkPresentation.d.ts.map +1 -0
- package/dist/utils/linkPresentation.js +358 -0
- package/dist/utils/linkPresentation.js.map +1 -0
- package/dist/vanilla/AudioRenderer.d.ts +3 -1
- package/dist/vanilla/AudioRenderer.d.ts.map +1 -1
- package/dist/vanilla/AudioRenderer.js +8 -2
- package/dist/vanilla/AudioRenderer.js.map +1 -1
- package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
- package/dist/vanilla/ConvaiWidget.js +1162 -315
- package/dist/vanilla/ConvaiWidget.js.map +1 -1
- package/dist/vanilla/WidgetEventSubscriptions.d.ts +1 -1
- package/dist/vanilla/WidgetEventSubscriptions.d.ts.map +1 -1
- package/dist/vanilla/WidgetEventSubscriptions.js +5 -0
- package/dist/vanilla/WidgetEventSubscriptions.js.map +1 -1
- package/dist/vanilla/icons.d.ts.map +1 -1
- package/dist/vanilla/icons.js +62 -15
- package/dist/vanilla/icons.js.map +1 -1
- package/dist/vanilla/index.d.ts +8 -2
- package/dist/vanilla/index.d.ts.map +1 -1
- package/dist/vanilla/index.js +6 -1
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vanilla/styles.d.ts +18 -1
- package/dist/vanilla/styles.d.ts.map +1 -1
- package/dist/vanilla/styles.js +150 -29
- package/dist/vanilla/styles.js.map +1 -1
- package/dist/vanilla/types.d.ts +74 -0
- package/dist/vanilla/types.d.ts.map +1 -1
- package/dist/vanilla/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +44 -17
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface LightboxOptions {
|
|
2
|
+
src: string;
|
|
3
|
+
alt: string;
|
|
4
|
+
/** Shown under the image; normally `describeUrl(src)`. */
|
|
5
|
+
caption: string;
|
|
6
|
+
/** Target of "Open original". */
|
|
7
|
+
href: string;
|
|
8
|
+
root: Document | ShadowRoot;
|
|
9
|
+
/** Where focus goes back to on close. Defaults to whatever was focused on open. */
|
|
10
|
+
returnFocusTo?: HTMLElement | null;
|
|
11
|
+
}
|
|
12
|
+
export interface LightboxHandle {
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function openLightbox(opts: LightboxOptions): LightboxHandle;
|
|
16
|
+
//# sourceMappingURL=lightbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightbox.d.ts","sourceRoot":"","sources":["../../src/utils/lightbox.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC5B,mFAAmF;IACnF,aAAa,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAWD,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAsFlE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The image lightbox — one plain-DOM implementation used by the React
|
|
3
|
+
* renderer and the vanilla widget. Mounted into a Document or a ShadowRoot so
|
|
4
|
+
* `part` hooks and the injected keyframes resolve wherever the widget lives.
|
|
5
|
+
* One at a time: opening a second closes the first.
|
|
6
|
+
*/
|
|
7
|
+
import { glyph, presentationStyles, toCssText } from "./linkPresentation.js";
|
|
8
|
+
import { injectKeyframes } from "../vanilla/styles.js";
|
|
9
|
+
let current = null;
|
|
10
|
+
const el = (tag, part, style) => {
|
|
11
|
+
const node = document.createElement(tag);
|
|
12
|
+
node.setAttribute("part", part);
|
|
13
|
+
node.style.cssText = toCssText(style);
|
|
14
|
+
return node;
|
|
15
|
+
};
|
|
16
|
+
export function openLightbox(opts) {
|
|
17
|
+
current?.close();
|
|
18
|
+
injectKeyframes(opts.root);
|
|
19
|
+
const mount = opts.root instanceof ShadowRoot ? opts.root : opts.root.body;
|
|
20
|
+
const backdrop = el("div", "lightbox-backdrop", presentationStyles.lightboxBackdrop);
|
|
21
|
+
backdrop.setAttribute("role", "dialog");
|
|
22
|
+
backdrop.setAttribute("aria-modal", "true");
|
|
23
|
+
backdrop.setAttribute("aria-label", opts.alt || "Image preview");
|
|
24
|
+
const box = el("div", "lightbox", presentationStyles.lightbox);
|
|
25
|
+
const img = el("img", "lightbox-image", presentationStyles.lightboxImage);
|
|
26
|
+
img.src = opts.src;
|
|
27
|
+
img.alt = opts.alt;
|
|
28
|
+
const caption = el("span", "lightbox-caption", presentationStyles.lightboxCaption);
|
|
29
|
+
caption.textContent = opts.caption;
|
|
30
|
+
const controls = el("div", "lightbox-controls", presentationStyles.lightboxControls);
|
|
31
|
+
const open = el("a", "lightbox-open", presentationStyles.lightboxButton);
|
|
32
|
+
open.href = opts.href;
|
|
33
|
+
open.target = "_blank";
|
|
34
|
+
open.rel = "noopener noreferrer";
|
|
35
|
+
open.innerHTML = `${glyph("external")}<span>Open original</span>`;
|
|
36
|
+
const close = el("button", "lightbox-close", presentationStyles.lightboxButton);
|
|
37
|
+
close.type = "button";
|
|
38
|
+
close.setAttribute("aria-label", "Close image preview");
|
|
39
|
+
close.innerHTML = glyph("close");
|
|
40
|
+
controls.append(open, close);
|
|
41
|
+
// A character can invent a URL; the card already collapsed for that case,
|
|
42
|
+
// but the full-size load can still fail on its own. Keep the way out visible.
|
|
43
|
+
img.addEventListener("error", () => {
|
|
44
|
+
const fallback = el("div", "lightbox-fallback", presentationStyles.lightboxFallback);
|
|
45
|
+
fallback.textContent = "Image could not be loaded";
|
|
46
|
+
img.replaceWith(fallback);
|
|
47
|
+
});
|
|
48
|
+
const previousOverflow = document.body.style.overflow;
|
|
49
|
+
const restoreFocus = opts.returnFocusTo ?? document.activeElement;
|
|
50
|
+
const activeElement = () => opts.root instanceof ShadowRoot ? opts.root.activeElement : document.activeElement;
|
|
51
|
+
const onKey = (e) => {
|
|
52
|
+
if (e.key === "Escape") {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
handle.close();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (e.key === "Tab") {
|
|
58
|
+
// Trap between the two controls; there is nothing else to reach.
|
|
59
|
+
const active = activeElement();
|
|
60
|
+
if (e.shiftKey && active === open) {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
close.focus();
|
|
63
|
+
}
|
|
64
|
+
else if (!e.shiftKey && active === close) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
open.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const handle = {
|
|
71
|
+
close() {
|
|
72
|
+
if (current !== handle)
|
|
73
|
+
return;
|
|
74
|
+
current = null;
|
|
75
|
+
document.removeEventListener("keydown", onKey, true);
|
|
76
|
+
backdrop.remove();
|
|
77
|
+
document.body.style.overflow = previousOverflow;
|
|
78
|
+
restoreFocus?.focus?.();
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
backdrop.addEventListener("click", (e) => {
|
|
82
|
+
if (e.target === backdrop)
|
|
83
|
+
handle.close();
|
|
84
|
+
});
|
|
85
|
+
close.addEventListener("click", () => handle.close());
|
|
86
|
+
document.addEventListener("keydown", onKey, true);
|
|
87
|
+
box.append(controls, img, caption);
|
|
88
|
+
backdrop.appendChild(box);
|
|
89
|
+
mount.appendChild(backdrop);
|
|
90
|
+
document.body.style.overflow = "hidden";
|
|
91
|
+
current = handle;
|
|
92
|
+
close.focus();
|
|
93
|
+
return handle;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=lightbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightbox.js","sourceRoot":"","sources":["../../src/utils/lightbox.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAkBpD,IAAI,OAAO,GAA0B,IAAI,CAAC;AAE1C,MAAM,EAAE,GAAG,CAAwC,GAAM,EAAE,IAAY,EAAE,KAAkB,EAAE,EAAE;IAC7F,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,IAAqB;IAChD,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE3B,MAAM,KAAK,GAAS,IAAI,CAAC,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACjF,MAAM,QAAQ,GAAG,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IACxC,OAAO,GAAG,MAAM,CAAC;IACjB,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * The image lightbox — one plain-DOM implementation used by the React\n * renderer and the vanilla widget. Mounted into a Document or a ShadowRoot so\n * `part` hooks and the injected keyframes resolve wherever the widget lives.\n * One at a time: opening a second closes the first.\n */\nimport { glyph, presentationStyles, toCssText, type StyleObject } from \"./linkPresentation\";\nimport { injectKeyframes } from \"../vanilla/styles\";\n\nexport interface LightboxOptions {\n src: string;\n alt: string;\n /** Shown under the image; normally `describeUrl(src)`. */\n caption: string;\n /** Target of \"Open original\". */\n href: string;\n root: Document | ShadowRoot;\n /** Where focus goes back to on close. Defaults to whatever was focused on open. */\n returnFocusTo?: HTMLElement | null;\n}\n\nexport interface LightboxHandle {\n close(): void;\n}\n\nlet current: LightboxHandle | null = null;\n\nconst el = <K extends keyof HTMLElementTagNameMap>(tag: K, part: string, style: StyleObject) => {\n const node = document.createElement(tag);\n node.setAttribute(\"part\", part);\n node.style.cssText = toCssText(style);\n return node;\n};\n\nexport function openLightbox(opts: LightboxOptions): LightboxHandle {\n current?.close();\n injectKeyframes(opts.root);\n\n const mount: Node = opts.root instanceof ShadowRoot ? opts.root : opts.root.body;\n const backdrop = el(\"div\", \"lightbox-backdrop\", presentationStyles.lightboxBackdrop);\n backdrop.setAttribute(\"role\", \"dialog\");\n backdrop.setAttribute(\"aria-modal\", \"true\");\n backdrop.setAttribute(\"aria-label\", opts.alt || \"Image preview\");\n\n const box = el(\"div\", \"lightbox\", presentationStyles.lightbox);\n const img = el(\"img\", \"lightbox-image\", presentationStyles.lightboxImage);\n img.src = opts.src;\n img.alt = opts.alt;\n const caption = el(\"span\", \"lightbox-caption\", presentationStyles.lightboxCaption);\n caption.textContent = opts.caption;\n\n const controls = el(\"div\", \"lightbox-controls\", presentationStyles.lightboxControls);\n const open = el(\"a\", \"lightbox-open\", presentationStyles.lightboxButton);\n open.href = opts.href;\n open.target = \"_blank\";\n open.rel = \"noopener noreferrer\";\n open.innerHTML = `${glyph(\"external\")}<span>Open original</span>`;\n const close = el(\"button\", \"lightbox-close\", presentationStyles.lightboxButton);\n close.type = \"button\";\n close.setAttribute(\"aria-label\", \"Close image preview\");\n close.innerHTML = glyph(\"close\");\n controls.append(open, close);\n\n // A character can invent a URL; the card already collapsed for that case,\n // but the full-size load can still fail on its own. Keep the way out visible.\n img.addEventListener(\"error\", () => {\n const fallback = el(\"div\", \"lightbox-fallback\", presentationStyles.lightboxFallback);\n fallback.textContent = \"Image could not be loaded\";\n img.replaceWith(fallback);\n });\n\n const previousOverflow = document.body.style.overflow;\n const restoreFocus = opts.returnFocusTo ?? (document.activeElement as HTMLElement | null);\n\n const activeElement = () =>\n opts.root instanceof ShadowRoot ? opts.root.activeElement : document.activeElement;\n\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n handle.close();\n return;\n }\n if (e.key === \"Tab\") {\n // Trap between the two controls; there is nothing else to reach.\n const active = activeElement();\n if (e.shiftKey && active === open) {\n e.preventDefault();\n close.focus();\n } else if (!e.shiftKey && active === close) {\n e.preventDefault();\n open.focus();\n }\n }\n };\n\n const handle: LightboxHandle = {\n close() {\n if (current !== handle) return;\n current = null;\n document.removeEventListener(\"keydown\", onKey, true);\n backdrop.remove();\n document.body.style.overflow = previousOverflow;\n restoreFocus?.focus?.();\n },\n };\n\n backdrop.addEventListener(\"click\", (e) => {\n if (e.target === backdrop) handle.close();\n });\n close.addEventListener(\"click\", () => handle.close());\n document.addEventListener(\"keydown\", onKey, true);\n\n box.append(controls, img, caption);\n backdrop.appendChild(box);\n mount.appendChild(backdrop);\n document.body.style.overflow = \"hidden\";\n current = handle;\n close.focus();\n return handle;\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type LinkKind = "web" | "image" | "video" | "document" | "email" | "phone" | "sms" | "ftp";
|
|
2
|
+
/** How long a card may shimmer before it is treated as failed. */
|
|
3
|
+
export declare const PREVIEW_TIMEOUT_MS = 12000;
|
|
4
|
+
/** Cards beyond this in one message render as plain anchors. */
|
|
5
|
+
export declare const MAX_CARDS_PER_MESSAGE = 6;
|
|
6
|
+
/**
|
|
7
|
+
* The presentation class of a safe URL. Distinct from `mediaKindForUrl`,
|
|
8
|
+
* which stays the embed hint (`image | video | null`) that custom renderers
|
|
9
|
+
* already branch on; this adds the kinds that get a chip or a file card.
|
|
10
|
+
*/
|
|
11
|
+
export declare function linkKindForUrl(url: string): LinkKind;
|
|
12
|
+
/** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */
|
|
13
|
+
export declare function describeUrl(url: string): string;
|
|
14
|
+
/** The last path segment, for captions and aria labels; the whole URL when unparseable. */
|
|
15
|
+
export declare function fileNameOf(url: string): string;
|
|
16
|
+
/** Upper-case extension for the file tile; `FILE` when there is none worth showing. */
|
|
17
|
+
export declare function documentBadge(url: string): string;
|
|
18
|
+
/** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */
|
|
19
|
+
export declare function contactLabel(href: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* The `title` attribute for an anchor of this kind, or nothing when it would
|
|
22
|
+
* only repeat the visible label. For a web link this is how a compacted or
|
|
23
|
+
* labelled URL reveals its real target before anyone clicks.
|
|
24
|
+
*/
|
|
25
|
+
export declare function hoverTitle(kind: LinkKind, href: string, label: string): string | undefined;
|
|
26
|
+
/** An `http:` asset cannot load on an `https:` page; do not even try. */
|
|
27
|
+
export declare function isMixedContent(src: string, pageProtocol?: string): boolean;
|
|
28
|
+
export type GlyphName = "document" | "email" | "phone" | "sms" | "ftp" | "zoom" | "close" | "external";
|
|
29
|
+
/** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */
|
|
30
|
+
export declare function glyph(name: GlyphName): string;
|
|
31
|
+
export type StyleObject = Record<string, string | number>;
|
|
32
|
+
/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */
|
|
33
|
+
export declare function toCssText(style: StyleObject): string;
|
|
34
|
+
/**
|
|
35
|
+
* Every visual the link layer draws, as one style object per element. React
|
|
36
|
+
* spreads these; vanilla serialises them with `toCssText`. Chrome derives from
|
|
37
|
+
* `currentColor` because the widget sits on a host page whose background it
|
|
38
|
+
* cannot know.
|
|
39
|
+
*/
|
|
40
|
+
export declare const presentationStyles: {
|
|
41
|
+
link: StyleObject;
|
|
42
|
+
/** Applied on focus-visible by the renderer; kept here so both agree. */
|
|
43
|
+
linkFocus: StyleObject;
|
|
44
|
+
blocked: StyleObject;
|
|
45
|
+
card: StyleObject;
|
|
46
|
+
cardButton: StyleObject;
|
|
47
|
+
zoom: StyleObject;
|
|
48
|
+
media: StyleObject;
|
|
49
|
+
videoMedia: StyleObject;
|
|
50
|
+
skeleton: StyleObject;
|
|
51
|
+
caption: StyleObject;
|
|
52
|
+
unavailable: StyleObject;
|
|
53
|
+
fileCard: StyleObject;
|
|
54
|
+
fileIcon: StyleObject;
|
|
55
|
+
fileBody: StyleObject;
|
|
56
|
+
fileName: StyleObject;
|
|
57
|
+
fileMeta: StyleObject;
|
|
58
|
+
contact: StyleObject;
|
|
59
|
+
contactGlyph: StyleObject;
|
|
60
|
+
badge: StyleObject;
|
|
61
|
+
lightboxBackdrop: StyleObject;
|
|
62
|
+
lightbox: StyleObject;
|
|
63
|
+
lightboxImage: StyleObject;
|
|
64
|
+
lightboxCaption: StyleObject;
|
|
65
|
+
lightboxControls: StyleObject;
|
|
66
|
+
lightboxButton: StyleObject;
|
|
67
|
+
lightboxFallback: StyleObject;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=linkPresentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPresentation.d.ts","sourceRoot":"","sources":["../../src/utils/linkPresentation.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,QAAQ,GAChB,KAAK,GACL,OAAO,GACP,OAAO,GACP,UAAU,GACV,OAAO,G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AAW;UAYxF,WAAW;gBACqB,WAAW;UAe3C,WAAW;WAQX,WAAW;gBACwB,WAAW;cAS9C,WAAW;aASX,WAAW;iBAUX,WAAW;cAcX,WAAW;cAiBX,WAAW;cAC+D,WAAW;cAOrF,WAAW;cAOX,WAAW;aAeX,WAAW;kBACwD,WAAW;WAY9E,WAAW;sBAaX,WAAW;cAUX,WAAW;mBAQX,WAAW;qBAQX,WAAW;sBAQX,WAAW;oBAaX,WAAW;sBAOX,WAAW;CACjB,CAAC"}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a link the character sent should look and behave — shared by the React
|
|
3
|
+
* `MarkdownRenderer` and the vanilla widget so the two cannot drift.
|
|
4
|
+
*
|
|
5
|
+
* The tokenizer (`inlineMarkdown.ts`) decides what IS a link and keeps
|
|
6
|
+
* unsafe schemes off anchors. This module decides how a safe link is
|
|
7
|
+
* presented: which kind of card or chip, what the hover title says, and the
|
|
8
|
+
* failure budget a preview gets before it collapses. Pure functions and
|
|
9
|
+
* style objects only; no DOM, so it is testable without a renderer.
|
|
10
|
+
*/
|
|
11
|
+
import { compactUrl } from "./inlineMarkdown.js";
|
|
12
|
+
const IMAGE_EXT = /\.(png|jpe?g|gif|webp|avif)$/i;
|
|
13
|
+
const VIDEO_EXT = /\.(mp4|webm|mov|ogg)$/i;
|
|
14
|
+
const DOCUMENT_EXT = /\.(pdf|docx?|xlsx?|csv|pptx?|txt|md|zip)$/i;
|
|
15
|
+
/** How long a card may shimmer before it is treated as failed. */
|
|
16
|
+
export const PREVIEW_TIMEOUT_MS = 12000;
|
|
17
|
+
/** Cards beyond this in one message render as plain anchors. */
|
|
18
|
+
export const MAX_CARDS_PER_MESSAGE = 6;
|
|
19
|
+
/**
|
|
20
|
+
* The presentation class of a safe URL. Distinct from `mediaKindForUrl`,
|
|
21
|
+
* which stays the embed hint (`image | video | null`) that custom renderers
|
|
22
|
+
* already branch on; this adds the kinds that get a chip or a file card.
|
|
23
|
+
*/
|
|
24
|
+
export function linkKindForUrl(url) {
|
|
25
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toLowerCase();
|
|
26
|
+
if (scheme === "mailto")
|
|
27
|
+
return "email";
|
|
28
|
+
if (scheme === "tel")
|
|
29
|
+
return "phone";
|
|
30
|
+
if (scheme === "sms")
|
|
31
|
+
return "sms";
|
|
32
|
+
if (scheme === "ftp" || scheme === "ftps")
|
|
33
|
+
return "ftp";
|
|
34
|
+
let pathname;
|
|
35
|
+
try {
|
|
36
|
+
pathname = new URL(url).pathname;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return "web";
|
|
40
|
+
}
|
|
41
|
+
if (IMAGE_EXT.test(pathname))
|
|
42
|
+
return "image";
|
|
43
|
+
if (VIDEO_EXT.test(pathname))
|
|
44
|
+
return "video";
|
|
45
|
+
if (DOCUMENT_EXT.test(pathname))
|
|
46
|
+
return "document";
|
|
47
|
+
return "web";
|
|
48
|
+
}
|
|
49
|
+
/** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */
|
|
50
|
+
export function describeUrl(url) {
|
|
51
|
+
try {
|
|
52
|
+
const { host, pathname } = new URL(url);
|
|
53
|
+
const file = pathname.split("/").filter(Boolean).pop();
|
|
54
|
+
return file ? `${host} · ${file}` : host;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return compactUrl(url);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** The last path segment, for captions and aria labels; the whole URL when unparseable. */
|
|
61
|
+
export function fileNameOf(url) {
|
|
62
|
+
try {
|
|
63
|
+
return new URL(url).pathname.split("/").filter(Boolean).pop() ?? url;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return url;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Upper-case extension for the file tile; `FILE` when there is none worth showing. */
|
|
70
|
+
export function documentBadge(url) {
|
|
71
|
+
const ext = /\.([a-z0-9]{1,5})$/i.exec(fileNameOf(url))?.[1];
|
|
72
|
+
return ext ? ext.toUpperCase() : "FILE";
|
|
73
|
+
}
|
|
74
|
+
/** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */
|
|
75
|
+
export function contactLabel(href) {
|
|
76
|
+
return href.replace(/^[a-z][a-z0-9+.-]*:/i, "").split("?")[0];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The `title` attribute for an anchor of this kind, or nothing when it would
|
|
80
|
+
* only repeat the visible label. For a web link this is how a compacted or
|
|
81
|
+
* labelled URL reveals its real target before anyone clicks.
|
|
82
|
+
*/
|
|
83
|
+
export function hoverTitle(kind, href, label) {
|
|
84
|
+
switch (kind) {
|
|
85
|
+
case "email":
|
|
86
|
+
return `Send an email to ${contactLabel(href)}`;
|
|
87
|
+
case "phone":
|
|
88
|
+
return `Call ${contactLabel(href)}`;
|
|
89
|
+
case "sms":
|
|
90
|
+
return `Send a text to ${contactLabel(href)}`;
|
|
91
|
+
case "ftp":
|
|
92
|
+
return "FTP link — most browsers no longer open these";
|
|
93
|
+
default:
|
|
94
|
+
return label === href ? undefined : href;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** An `http:` asset cannot load on an `https:` page; do not even try. */
|
|
98
|
+
export function isMixedContent(src, pageProtocol = typeof location === "undefined" ? "https:" : location.protocol) {
|
|
99
|
+
return pageProtocol === "https:" && /^http:/i.test(src);
|
|
100
|
+
}
|
|
101
|
+
const SVG_OPEN = '<svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">';
|
|
102
|
+
const GLYPH_PATHS = {
|
|
103
|
+
document: '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/>',
|
|
104
|
+
email: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/>',
|
|
105
|
+
phone: '<path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8.1 9.7a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.8 2z"/>',
|
|
106
|
+
sms: '<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',
|
|
107
|
+
ftp: '<path d="M4 17V7l8 5 8-5v10"/><path d="M4 7h16"/>',
|
|
108
|
+
zoom: '<circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3M11 8v6M8 11h6"/>',
|
|
109
|
+
close: '<path d="M18 6 6 18M6 6l12 12"/>',
|
|
110
|
+
external: '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6M10 14 21 3"/>',
|
|
111
|
+
};
|
|
112
|
+
/** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */
|
|
113
|
+
export function glyph(name) {
|
|
114
|
+
return `${SVG_OPEN}${GLYPH_PATHS[name]}</svg>`;
|
|
115
|
+
}
|
|
116
|
+
const UNITLESS = new Set([
|
|
117
|
+
"opacity",
|
|
118
|
+
"zIndex",
|
|
119
|
+
"flex",
|
|
120
|
+
"flexGrow",
|
|
121
|
+
"flexShrink",
|
|
122
|
+
"lineHeight",
|
|
123
|
+
"fontWeight",
|
|
124
|
+
"order",
|
|
125
|
+
]);
|
|
126
|
+
/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */
|
|
127
|
+
export function toCssText(style) {
|
|
128
|
+
return Object.entries(style)
|
|
129
|
+
.map(([k, v]) => {
|
|
130
|
+
const prop = k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
131
|
+
const val = typeof v === "number" && !UNITLESS.has(k) ? `${v}px` : String(v);
|
|
132
|
+
return `${prop}: ${val};`;
|
|
133
|
+
})
|
|
134
|
+
.join(" ");
|
|
135
|
+
}
|
|
136
|
+
const RADIUS = 8;
|
|
137
|
+
const ACCENT = "#10b981";
|
|
138
|
+
const chrome = (pct) => `color-mix(in srgb, currentColor ${pct}%, transparent)`;
|
|
139
|
+
/**
|
|
140
|
+
* Every visual the link layer draws, as one style object per element. React
|
|
141
|
+
* spreads these; vanilla serialises them with `toCssText`. Chrome derives from
|
|
142
|
+
* `currentColor` because the widget sits on a host page whose background it
|
|
143
|
+
* cannot know.
|
|
144
|
+
*/
|
|
145
|
+
export const presentationStyles = {
|
|
146
|
+
link: {
|
|
147
|
+
color: ACCENT,
|
|
148
|
+
textDecoration: "underline",
|
|
149
|
+
wordBreak: "break-all",
|
|
150
|
+
borderRadius: 2,
|
|
151
|
+
},
|
|
152
|
+
/** Applied on focus-visible by the renderer; kept here so both agree. */
|
|
153
|
+
linkFocus: { outline: `2px solid ${chrome(60)}`, outlineOffset: 2 },
|
|
154
|
+
blocked: { opacity: 0.75, textDecoration: "underline dotted", cursor: "help" },
|
|
155
|
+
card: {
|
|
156
|
+
display: "block",
|
|
157
|
+
position: "relative",
|
|
158
|
+
marginTop: 6,
|
|
159
|
+
maxWidth: 320,
|
|
160
|
+
aspectRatio: "16 / 10",
|
|
161
|
+
borderRadius: RADIUS,
|
|
162
|
+
overflow: "hidden",
|
|
163
|
+
background: chrome(6),
|
|
164
|
+
boxShadow: `inset 0 0 0 1px ${chrome(10)}`,
|
|
165
|
+
},
|
|
166
|
+
cardButton: { cursor: "zoom-in" },
|
|
167
|
+
zoom: {
|
|
168
|
+
position: "absolute",
|
|
169
|
+
right: 6,
|
|
170
|
+
bottom: 6,
|
|
171
|
+
width: 24,
|
|
172
|
+
height: 24,
|
|
173
|
+
display: "flex",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
justifyContent: "center",
|
|
176
|
+
borderRadius: 6,
|
|
177
|
+
background: "rgba(0,0,0,.55)",
|
|
178
|
+
color: "#fff",
|
|
179
|
+
fontSize: 14,
|
|
180
|
+
pointerEvents: "none",
|
|
181
|
+
},
|
|
182
|
+
media: {
|
|
183
|
+
display: "block",
|
|
184
|
+
width: "100%",
|
|
185
|
+
height: "100%",
|
|
186
|
+
objectFit: "cover",
|
|
187
|
+
borderRadius: RADIUS,
|
|
188
|
+
transition: "opacity .18s ease",
|
|
189
|
+
},
|
|
190
|
+
videoMedia: { objectFit: "contain" },
|
|
191
|
+
skeleton: {
|
|
192
|
+
position: "absolute",
|
|
193
|
+
inset: 0,
|
|
194
|
+
borderRadius: RADIUS,
|
|
195
|
+
background: chrome(8),
|
|
196
|
+
backgroundImage: `linear-gradient(90deg, transparent, ${chrome(12)}, transparent)`,
|
|
197
|
+
backgroundSize: "200% 100%",
|
|
198
|
+
animation: "convai-preview-shimmer 1.4s ease-in-out infinite",
|
|
199
|
+
},
|
|
200
|
+
caption: {
|
|
201
|
+
display: "block",
|
|
202
|
+
marginTop: 4,
|
|
203
|
+
fontSize: 11,
|
|
204
|
+
opacity: 0.7,
|
|
205
|
+
whiteSpace: "nowrap",
|
|
206
|
+
overflow: "hidden",
|
|
207
|
+
textOverflow: "ellipsis",
|
|
208
|
+
},
|
|
209
|
+
unavailable: {
|
|
210
|
+
display: "block",
|
|
211
|
+
marginTop: 6,
|
|
212
|
+
fontSize: 11,
|
|
213
|
+
opacity: 0.55,
|
|
214
|
+
fontStyle: "italic",
|
|
215
|
+
whiteSpace: "nowrap",
|
|
216
|
+
overflow: "hidden",
|
|
217
|
+
textOverflow: "ellipsis",
|
|
218
|
+
},
|
|
219
|
+
fileCard: {
|
|
220
|
+
display: "flex",
|
|
221
|
+
alignItems: "center",
|
|
222
|
+
gap: 10,
|
|
223
|
+
marginTop: 6,
|
|
224
|
+
maxWidth: 320,
|
|
225
|
+
padding: "8px 10px",
|
|
226
|
+
borderRadius: RADIUS,
|
|
227
|
+
background: chrome(6),
|
|
228
|
+
boxShadow: `inset 0 0 0 1px ${chrome(10)}`,
|
|
229
|
+
color: "inherit",
|
|
230
|
+
textDecoration: "none",
|
|
231
|
+
},
|
|
232
|
+
fileIcon: {
|
|
233
|
+
position: "relative",
|
|
234
|
+
flex: "0 0 auto",
|
|
235
|
+
width: 36,
|
|
236
|
+
height: 44,
|
|
237
|
+
display: "flex",
|
|
238
|
+
alignItems: "flex-end",
|
|
239
|
+
justifyContent: "center",
|
|
240
|
+
paddingBottom: 4,
|
|
241
|
+
boxSizing: "border-box",
|
|
242
|
+
borderRadius: 4,
|
|
243
|
+
background: chrome(10),
|
|
244
|
+
color: ACCENT,
|
|
245
|
+
fontSize: 9,
|
|
246
|
+
fontWeight: 700,
|
|
247
|
+
letterSpacing: ".04em",
|
|
248
|
+
},
|
|
249
|
+
fileBody: { minWidth: 0, display: "flex", flexDirection: "column", gap: 2 },
|
|
250
|
+
fileName: {
|
|
251
|
+
fontSize: 13,
|
|
252
|
+
fontWeight: 600,
|
|
253
|
+
whiteSpace: "nowrap",
|
|
254
|
+
overflow: "hidden",
|
|
255
|
+
textOverflow: "ellipsis",
|
|
256
|
+
},
|
|
257
|
+
fileMeta: {
|
|
258
|
+
fontSize: 11,
|
|
259
|
+
opacity: 0.7,
|
|
260
|
+
whiteSpace: "nowrap",
|
|
261
|
+
overflow: "hidden",
|
|
262
|
+
textOverflow: "ellipsis",
|
|
263
|
+
},
|
|
264
|
+
contact: {
|
|
265
|
+
display: "inline-flex",
|
|
266
|
+
alignItems: "center",
|
|
267
|
+
gap: 4,
|
|
268
|
+
padding: "1px 8px 1px 6px",
|
|
269
|
+
borderRadius: 999,
|
|
270
|
+
background: chrome(8),
|
|
271
|
+
color: ACCENT,
|
|
272
|
+
textDecoration: "none",
|
|
273
|
+
fontSize: "0.95em",
|
|
274
|
+
lineHeight: 1.6,
|
|
275
|
+
verticalAlign: "baseline",
|
|
276
|
+
maxWidth: "100%",
|
|
277
|
+
},
|
|
278
|
+
contactGlyph: { display: "inline-flex", fontSize: 13, opacity: 0.9 },
|
|
279
|
+
badge: {
|
|
280
|
+
display: "inline-block",
|
|
281
|
+
marginLeft: 4,
|
|
282
|
+
padding: "0 4px",
|
|
283
|
+
borderRadius: 3,
|
|
284
|
+
fontSize: 9,
|
|
285
|
+
fontWeight: 700,
|
|
286
|
+
letterSpacing: ".04em",
|
|
287
|
+
verticalAlign: "middle",
|
|
288
|
+
background: chrome(10),
|
|
289
|
+
opacity: 0.8,
|
|
290
|
+
},
|
|
291
|
+
lightboxBackdrop: {
|
|
292
|
+
position: "fixed",
|
|
293
|
+
inset: 0,
|
|
294
|
+
zIndex: 2147483000,
|
|
295
|
+
display: "flex",
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
justifyContent: "center",
|
|
298
|
+
background: "rgba(0,0,0,.82)",
|
|
299
|
+
padding: 24,
|
|
300
|
+
boxSizing: "border-box",
|
|
301
|
+
animation: "convai-lightbox-in .16s ease-out",
|
|
302
|
+
},
|
|
303
|
+
lightbox: {
|
|
304
|
+
position: "relative",
|
|
305
|
+
display: "flex",
|
|
306
|
+
flexDirection: "column",
|
|
307
|
+
alignItems: "center",
|
|
308
|
+
gap: 10,
|
|
309
|
+
maxWidth: "90vw",
|
|
310
|
+
maxHeight: "90vh",
|
|
311
|
+
color: "#fff",
|
|
312
|
+
},
|
|
313
|
+
lightboxImage: {
|
|
314
|
+
display: "block",
|
|
315
|
+
maxWidth: "90vw",
|
|
316
|
+
maxHeight: "calc(90vh - 72px)",
|
|
317
|
+
objectFit: "contain",
|
|
318
|
+
borderRadius: RADIUS,
|
|
319
|
+
background: "#000",
|
|
320
|
+
},
|
|
321
|
+
lightboxCaption: {
|
|
322
|
+
fontSize: 12,
|
|
323
|
+
opacity: 0.8,
|
|
324
|
+
maxWidth: "90vw",
|
|
325
|
+
whiteSpace: "nowrap",
|
|
326
|
+
overflow: "hidden",
|
|
327
|
+
textOverflow: "ellipsis",
|
|
328
|
+
},
|
|
329
|
+
lightboxControls: {
|
|
330
|
+
position: "absolute",
|
|
331
|
+
top: -4,
|
|
332
|
+
right: -4,
|
|
333
|
+
transform: "translateY(-100%)",
|
|
334
|
+
display: "flex",
|
|
335
|
+
gap: 6,
|
|
336
|
+
},
|
|
337
|
+
lightboxButton: {
|
|
338
|
+
display: "inline-flex",
|
|
339
|
+
alignItems: "center",
|
|
340
|
+
gap: 6,
|
|
341
|
+
padding: "6px 10px",
|
|
342
|
+
borderRadius: 999,
|
|
343
|
+
border: "1px solid rgba(255,255,255,.25)",
|
|
344
|
+
background: "rgba(0,0,0,.5)",
|
|
345
|
+
color: "#fff",
|
|
346
|
+
fontSize: 12,
|
|
347
|
+
cursor: "pointer",
|
|
348
|
+
textDecoration: "none",
|
|
349
|
+
},
|
|
350
|
+
lightboxFallback: {
|
|
351
|
+
padding: "32px 40px",
|
|
352
|
+
fontSize: 13,
|
|
353
|
+
opacity: 0.8,
|
|
354
|
+
border: "1px dashed rgba(255,255,255,.3)",
|
|
355
|
+
borderRadius: RADIUS,
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
//# sourceMappingURL=linkPresentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPresentation.js","sourceRoot":"","sources":["../../src/utils/linkPresentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9C,MAAM,SAAS,GAAG,+BAA+B,CAAC;AAClD,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAC3C,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,kEAAkE;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACxC,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,cAA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,MAAM;QAChB,UAAU,EAAE,QAAQ;QACpB,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,UAAU;KACV;IAChB,gBAAgB,EAAE;QAChB,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC,CAAC;QACP,KAAK,EAAE,CAAC,CAAC;QACT,SAAS,EAAE,mBAAmB;QAC9B,OAAO,EAAE,MAAM;QACf,GAAG,EAAE,CAAC;KACQ;IAChB,cAAc,EAAE;QACd,OAAO,EAAE,aAAa;QACtB,UAAU,EAAE,QAAQ;QACpB,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,UAAU;QACnB,YAAY,EAAE,GAAG;QACjB,MAAM,EAAE,iCAAiC;QACzC,UAAU,EAAE,gBAAgB;QAC5B,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,SAAS;QACjB,cAAc,EAAE,MAAM;KACR;IAChB,gBAAgB,EAAE;QAChB,OAAO,EAAE,WAAW;QACpB,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,GAAG;QACZ,MAAM,EAAE,iCAAiC;QACzC,YAAY,EAAE,MAAM;KACN;CACjB,CAAC","sourcesContent":["/**\n * How a link the character sent should look and behave — shared by the React\n * `MarkdownRenderer` and the vanilla widget so the two cannot drift.\n *\n * The tokenizer (`inlineMarkdown.ts`) decides what IS a link and keeps\n * unsafe schemes off anchors. This module decides how a safe link is\n * presented: which kind of card or chip, what the hover title says, and the\n * failure budget a preview gets before it collapses. Pure functions and\n * style objects only; no DOM, so it is testable without a renderer.\n */\nimport { compactUrl } from \"./inlineMarkdown\";\n\nexport type LinkKind =\n | \"web\"\n | \"image\"\n | \"video\"\n | \"document\"\n | \"email\"\n | \"phone\"\n | \"sms\"\n | \"ftp\";\n\nconst IMAGE_EXT = /\\.(png|jpe?g|gif|webp|avif)$/i;\nconst VIDEO_EXT = /\\.(mp4|webm|mov|ogg)$/i;\nconst DOCUMENT_EXT = /\\.(pdf|docx?|xlsx?|csv|pptx?|txt|md|zip)$/i;\n\n/** How long a card may shimmer before it is treated as failed. */\nexport const PREVIEW_TIMEOUT_MS = 12000;\n/** Cards beyond this in one message render as plain anchors. */\nexport const MAX_CARDS_PER_MESSAGE = 6;\n\n/**\n * The presentation class of a safe URL. Distinct from `mediaKindForUrl`,\n * which stays the embed hint (`image | video | null`) that custom renderers\n * already branch on; this adds the kinds that get a chip or a file card.\n */\nexport function linkKindForUrl(url: string): LinkKind {\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toLowerCase();\n if (scheme === \"mailto\") return \"email\";\n if (scheme === \"tel\") return \"phone\";\n if (scheme === \"sms\") return \"sms\";\n if (scheme === \"ftp\" || scheme === \"ftps\") return \"ftp\";\n let pathname: string;\n try {\n pathname = new URL(url).pathname;\n } catch {\n return \"web\";\n }\n if (IMAGE_EXT.test(pathname)) return \"image\";\n if (VIDEO_EXT.test(pathname)) return \"video\";\n if (DOCUMENT_EXT.test(pathname)) return \"document\";\n return \"web\";\n}\n\n/** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */\nexport function describeUrl(url: string): string {\n try {\n const { host, pathname } = new URL(url);\n const file = pathname.split(\"/\").filter(Boolean).pop();\n return file ? `${host} · ${file}` : host;\n } catch {\n return compactUrl(url);\n }\n}\n\n/** The last path segment, for captions and aria labels; the whole URL when unparseable. */\nexport function fileNameOf(url: string): string {\n try {\n return new URL(url).pathname.split(\"/\").filter(Boolean).pop() ?? url;\n } catch {\n return url;\n }\n}\n\n/** Upper-case extension for the file tile; `FILE` when there is none worth showing. */\nexport function documentBadge(url: string): string {\n const ext = /\\.([a-z0-9]{1,5})$/i.exec(fileNameOf(url))?.[1];\n return ext ? ext.toUpperCase() : \"FILE\";\n}\n\n/** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */\nexport function contactLabel(href: string): string {\n return href.replace(/^[a-z][a-z0-9+.-]*:/i, \"\").split(\"?\")[0];\n}\n\n/**\n * The `title` attribute for an anchor of this kind, or nothing when it would\n * only repeat the visible label. For a web link this is how a compacted or\n * labelled URL reveals its real target before anyone clicks.\n */\nexport function hoverTitle(kind: LinkKind, href: string, label: string): string | undefined {\n switch (kind) {\n case \"email\":\n return `Send an email to ${contactLabel(href)}`;\n case \"phone\":\n return `Call ${contactLabel(href)}`;\n case \"sms\":\n return `Send a text to ${contactLabel(href)}`;\n case \"ftp\":\n return \"FTP link — most browsers no longer open these\";\n default:\n return label === href ? undefined : href;\n }\n}\n\n/** An `http:` asset cannot load on an `https:` page; do not even try. */\nexport function isMixedContent(\n src: string,\n pageProtocol: string = typeof location === \"undefined\" ? \"https:\" : location.protocol,\n): boolean {\n return pageProtocol === \"https:\" && /^http:/i.test(src);\n}\n\nexport type GlyphName = \"document\" | \"email\" | \"phone\" | \"sms\" | \"ftp\" | \"zoom\" | \"close\" | \"external\";\n\nconst SVG_OPEN =\n '<svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">';\n\nconst GLYPH_PATHS: Record<GlyphName, string> = {\n document:\n '<path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\"/><path d=\"M14 3v5h5\"/>',\n email: '<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\"/><path d=\"m3 7 9 6 9-6\"/>',\n phone:\n '<path d=\"M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8.1 9.7a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.8 2z\"/>',\n sms: '<path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>',\n ftp: '<path d=\"M4 17V7l8 5 8-5v10\"/><path d=\"M4 7h16\"/>',\n zoom: '<circle cx=\"11\" cy=\"11\" r=\"7\"/><path d=\"m21 21-4.3-4.3M11 8v6M8 11h6\"/>',\n close: '<path d=\"M18 6 6 18M6 6l12 12\"/>',\n external:\n '<path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"/><path d=\"M15 3h6v6M10 14 21 3\"/>',\n};\n\n/** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */\nexport function glyph(name: GlyphName): string {\n return `${SVG_OPEN}${GLYPH_PATHS[name]}</svg>`;\n}\n\nexport type StyleObject = Record<string, string | number>;\n\nconst UNITLESS = new Set([\n \"opacity\",\n \"zIndex\",\n \"flex\",\n \"flexGrow\",\n \"flexShrink\",\n \"lineHeight\",\n \"fontWeight\",\n \"order\",\n]);\n\n/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */\nexport function toCssText(style: StyleObject): string {\n return Object.entries(style)\n .map(([k, v]) => {\n const prop = k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n const val = typeof v === \"number\" && !UNITLESS.has(k) ? `${v}px` : String(v);\n return `${prop}: ${val};`;\n })\n .join(\" \");\n}\n\nconst RADIUS = 8;\nconst ACCENT = \"#10b981\";\nconst chrome = (pct: number) => `color-mix(in srgb, currentColor ${pct}%, transparent)`;\n\n/**\n * Every visual the link layer draws, as one style object per element. React\n * spreads these; vanilla serialises them with `toCssText`. Chrome derives from\n * `currentColor` because the widget sits on a host page whose background it\n * cannot know.\n */\nexport const presentationStyles = {\n link: {\n color: ACCENT,\n textDecoration: \"underline\",\n wordBreak: \"break-all\",\n borderRadius: 2,\n } as StyleObject,\n /** Applied on focus-visible by the renderer; kept here so both agree. */\n linkFocus: { outline: `2px solid ${chrome(60)}`, outlineOffset: 2 } as StyleObject,\n blocked: { opacity: 0.75, textDecoration: \"underline dotted\", cursor: \"help\" } as StyleObject,\n\n card: {\n display: \"block\",\n position: \"relative\",\n marginTop: 6,\n maxWidth: 320,\n aspectRatio: \"16 / 10\",\n borderRadius: RADIUS,\n overflow: \"hidden\",\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n } as StyleObject,\n cardButton: { cursor: \"zoom-in\" } as StyleObject,\n zoom: {\n position: \"absolute\",\n right: 6,\n bottom: 6,\n width: 24,\n height: 24,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: 6,\n background: \"rgba(0,0,0,.55)\",\n color: \"#fff\",\n fontSize: 14,\n pointerEvents: \"none\",\n } as StyleObject,\n media: {\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n borderRadius: RADIUS,\n transition: \"opacity .18s ease\",\n } as StyleObject,\n videoMedia: { objectFit: \"contain\" } as StyleObject,\n skeleton: {\n position: \"absolute\",\n inset: 0,\n borderRadius: RADIUS,\n background: chrome(8),\n backgroundImage: `linear-gradient(90deg, transparent, ${chrome(12)}, transparent)`,\n backgroundSize: \"200% 100%\",\n animation: \"convai-preview-shimmer 1.4s ease-in-out infinite\",\n } as StyleObject,\n caption: {\n display: \"block\",\n marginTop: 4,\n fontSize: 11,\n opacity: 0.7,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n unavailable: {\n display: \"block\",\n marginTop: 6,\n fontSize: 11,\n opacity: 0.55,\n fontStyle: \"italic\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n\n fileCard: {\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n marginTop: 6,\n maxWidth: 320,\n padding: \"8px 10px\",\n borderRadius: RADIUS,\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n color: \"inherit\",\n textDecoration: \"none\",\n } as StyleObject,\n fileIcon: {\n position: \"relative\",\n flex: \"0 0 auto\",\n width: 36,\n height: 44,\n display: \"flex\",\n alignItems: \"flex-end\",\n justifyContent: \"center\",\n paddingBottom: 4,\n boxSizing: \"border-box\",\n borderRadius: 4,\n background: chrome(10),\n color: ACCENT,\n fontSize: 9,\n fontWeight: 700,\n letterSpacing: \".04em\",\n } as StyleObject,\n fileBody: { minWidth: 0, display: \"flex\", flexDirection: \"column\", gap: 2 } as StyleObject,\n fileName: {\n fontSize: 13,\n fontWeight: 600,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n fileMeta: {\n fontSize: 11,\n opacity: 0.7,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n\n contact: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 4,\n padding: \"1px 8px 1px 6px\",\n borderRadius: 999,\n background: chrome(8),\n color: ACCENT,\n textDecoration: \"none\",\n fontSize: \"0.95em\",\n lineHeight: 1.6,\n verticalAlign: \"baseline\",\n maxWidth: \"100%\",\n } as StyleObject,\n contactGlyph: { display: \"inline-flex\", fontSize: 13, opacity: 0.9 } as StyleObject,\n badge: {\n display: \"inline-block\",\n marginLeft: 4,\n padding: \"0 4px\",\n borderRadius: 3,\n fontSize: 9,\n fontWeight: 700,\n letterSpacing: \".04em\",\n verticalAlign: \"middle\",\n background: chrome(10),\n opacity: 0.8,\n } as StyleObject,\n\n lightboxBackdrop: {\n position: \"fixed\",\n inset: 0,\n zIndex: 2147483000,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(0,0,0,.82)\",\n padding: 24,\n boxSizing: \"border-box\",\n animation: \"convai-lightbox-in .16s ease-out\",\n } as StyleObject,\n lightbox: {\n position: \"relative\",\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n gap: 10,\n maxWidth: \"90vw\",\n maxHeight: \"90vh\",\n color: \"#fff\",\n } as StyleObject,\n lightboxImage: {\n display: \"block\",\n maxWidth: \"90vw\",\n maxHeight: \"calc(90vh - 72px)\",\n objectFit: \"contain\",\n borderRadius: RADIUS,\n background: \"#000\",\n } as StyleObject,\n lightboxCaption: {\n fontSize: 12,\n opacity: 0.8,\n maxWidth: \"90vw\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n lightboxControls: {\n position: \"absolute\",\n top: -4,\n right: -4,\n transform: \"translateY(-100%)\",\n display: \"flex\",\n gap: 6,\n } as StyleObject,\n lightboxButton: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"6px 10px\",\n borderRadius: 999,\n border: \"1px solid rgba(255,255,255,.25)\",\n background: \"rgba(0,0,0,.5)\",\n color: \"#fff\",\n fontSize: 12,\n cursor: \"pointer\",\n textDecoration: \"none\",\n } as StyleObject,\n lightboxFallback: {\n padding: \"32px 40px\",\n fontSize: 13,\n opacity: 0.8,\n border: \"1px dashed rgba(255,255,255,.3)\",\n borderRadius: RADIUS,\n } as StyleObject,\n};\n"]}
|
|
@@ -13,7 +13,9 @@ export declare class AudioRenderer {
|
|
|
13
13
|
private boundHandleTrackSubscribed;
|
|
14
14
|
private boundHandleTrackUnsubscribed;
|
|
15
15
|
private boundHandleParticipantDisconnected;
|
|
16
|
-
constructor(room: Room
|
|
16
|
+
constructor(room: Room, options?: {
|
|
17
|
+
container?: HTMLElement;
|
|
18
|
+
});
|
|
17
19
|
/**
|
|
18
20
|
* Setup event listeners for room events
|
|
19
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRenderer.d.ts","sourceRoot":"","sources":["../../src/vanilla/AudioRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAwD,MAAM,gBAAgB,CAAC;AAG5F;;;;GAIG;AACH,qBAAa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