@runtypelabs/persona 4.7.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/animations/glyph-cycle.cjs +2 -2
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/glyph-cycle.js +2 -2
- package/dist/animations/{types-CSmiKRVa.d.cts → types-4ROVJ1gA.d.cts} +85 -3
- package/dist/animations/{types-CSmiKRVa.d.ts → types-4ROVJ1gA.d.ts} +85 -3
- package/dist/animations/wipe.cjs +2 -2
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/chunk-5EIIHQLQ.js +1 -0
- package/dist/chunk-IO5VVUKP.js +3 -0
- package/dist/chunk-IPVK3KOM.js +1 -0
- package/dist/chunk-UPO4GUFC.js +1 -0
- package/dist/codegen.cjs +13 -13
- package/dist/codegen.js +14 -14
- package/dist/context-mentions-7S5KVUTG.js +169 -0
- package/dist/context-mentions-inline-TTCN7ZM2.js +4 -0
- package/dist/context-mentions-inline.cjs +4 -0
- package/dist/context-mentions-inline.d.cts +203 -0
- package/dist/context-mentions-inline.d.ts +203 -0
- package/dist/context-mentions-inline.js +4 -0
- package/dist/context-mentions.cjs +295 -0
- package/dist/context-mentions.d.cts +7025 -0
- package/dist/context-mentions.d.ts +7025 -0
- package/dist/context-mentions.js +295 -0
- package/dist/index.cjs +99 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1507 -182
- package/dist/index.d.ts +1507 -182
- package/dist/index.global.js +88 -56
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +99 -68
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +3 -2
- package/dist/launcher.global.js.map +1 -1
- package/dist/markdown-parsers.js +24 -24
- package/dist/plugin-kit.cjs +1 -1
- package/dist/plugin-kit.d.cts +17 -0
- package/dist/plugin-kit.d.ts +17 -0
- package/dist/plugin-kit.js +1 -1
- package/dist/runtype-tts-entry-UJAEF7NZ.js +1 -0
- package/dist/runtype-tts.js +1 -1
- package/dist/session-reconnect-JKIJBHS5.js +1 -0
- package/dist/smart-dom-reader.cjs +18 -17
- package/dist/smart-dom-reader.d.cts +1260 -16
- package/dist/smart-dom-reader.d.ts +1260 -16
- package/dist/smart-dom-reader.js +18 -17
- package/dist/testing.cjs +3 -3
- package/dist/testing.js +3 -3
- package/dist/theme-editor-preview.cjs +260 -58
- package/dist/theme-editor-preview.d.cts +1234 -15
- package/dist/theme-editor-preview.d.ts +1234 -15
- package/dist/theme-editor-preview.js +87 -58
- package/dist/theme-editor.cjs +10 -10
- package/dist/theme-editor.d.cts +1226 -15
- package/dist/theme-editor.d.ts +1226 -15
- package/dist/theme-editor.js +10 -10
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +76 -0
- package/dist/theme-reference.d.ts +76 -0
- package/dist/theme-reference.js +1 -1
- package/dist/voice-worklet-player.cjs +2 -2
- package/dist/voice-worklet-player.js +2 -2
- package/dist/webmcp-polyfill.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +16 -5
- package/src/artifacts-session.test.ts +178 -0
- package/src/client.test.ts +255 -1
- package/src/client.ts +157 -60
- package/src/components/artifact-card.test.ts +333 -0
- package/src/components/artifact-card.ts +75 -28
- package/src/components/artifact-inline.test.ts +1328 -0
- package/src/components/artifact-inline.ts +920 -0
- package/src/components/artifact-pane.test.ts +1042 -0
- package/src/components/artifact-pane.ts +440 -131
- package/src/components/artifact-preview.test.ts +1155 -0
- package/src/components/artifact-preview.ts +994 -0
- package/src/components/composer-parts.ts +3 -12
- package/src/components/context-mention-button.test.ts +70 -0
- package/src/components/context-mention-button.ts +82 -0
- package/src/components/context-mention-chip.ts +134 -0
- package/src/components/context-mention-menu.test.ts +508 -0
- package/src/components/context-mention-menu.ts +0 -0
- package/src/components/message-bubble.test.ts +175 -0
- package/src/components/message-bubble.ts +177 -19
- package/src/components/panel.ts +7 -10
- package/src/components/pill-composer-builder.test.ts +6 -2
- package/src/components/pill-composer-builder.ts +6 -6
- package/src/components/reasoning-bubble.ts +1 -13
- package/src/components/registry.ts +38 -3
- package/src/components/tool-bubble.ts +1 -13
- package/src/context-mentions-bundle.test.ts +163 -0
- package/src/context-mentions-entry.ts +185 -0
- package/src/context-mentions-inline-entry.test.ts +136 -0
- package/src/context-mentions-inline-entry.ts +226 -0
- package/src/context-mentions-inline-loader.test.ts +30 -0
- package/src/context-mentions-inline-loader.ts +36 -0
- package/src/context-mentions-inline.ts +15 -0
- package/src/context-mentions-loader.ts +32 -0
- package/src/context-mentions.ts +16 -0
- package/src/defaults.ts +1 -0
- package/src/generated/runtype-openapi-contract.ts +55 -3
- package/src/index-core.ts +46 -1
- package/src/index-global.ts +51 -0
- package/src/index.ts +8 -0
- package/src/markdown-parsers-loader.test.ts +158 -0
- package/src/markdown-parsers-loader.ts +83 -27
- package/src/plugin-kit.test.ts +40 -0
- package/src/plugin-kit.ts +39 -5
- package/src/runtime/host-layout.test.ts +163 -0
- package/src/runtime/host-layout.ts +110 -7
- package/src/runtime/init.ts +18 -61
- package/src/session.mentions.test.ts +175 -0
- package/src/session.test.ts +52 -4
- package/src/session.ts +197 -27
- package/src/smart-dom-reader.test.ts +129 -2
- package/src/smart-dom-reader.ts +127 -1
- package/src/styles/context-mention-menu-css.ts +176 -0
- package/src/styles/widget.css +1002 -152
- package/src/theme-editor/preview.ts +2 -0
- package/src/theme-editor/sections.test.ts +26 -1
- package/src/theme-editor/sections.ts +13 -5
- package/src/theme-reference.ts +2 -2
- package/src/tool-call-display-defaults.test.ts +1 -0
- package/src/types/theme.ts +79 -0
- package/src/types.ts +1041 -17
- package/src/ui.artifact-pane-gating.test.ts +636 -0
- package/src/ui.component-directive.test.ts +104 -0
- package/src/ui.composer-bar.test.ts +60 -2
- package/src/ui.detached-panel.test.ts +1049 -0
- package/src/ui.mention-submit.test.ts +235 -0
- package/src/ui.tool-display.test.ts +51 -0
- package/src/ui.ts +998 -159
- package/src/utils/artifact-custom-actions.ts +128 -0
- package/src/utils/artifact-display.test.ts +42 -0
- package/src/utils/artifact-display.ts +84 -0
- package/src/utils/artifact-file.test.ts +116 -0
- package/src/utils/artifact-file.ts +117 -0
- package/src/utils/artifact-gate.test.ts +112 -5
- package/src/utils/artifact-gate.ts +39 -14
- package/src/utils/artifact-loading-status.ts +55 -0
- package/src/utils/artifact-status-label.ts +190 -0
- package/src/utils/buttons.ts +7 -1
- package/src/utils/chunk-loader.test.ts +97 -0
- package/src/utils/chunk-loader.ts +88 -0
- package/src/utils/code-highlight.test.ts +186 -0
- package/src/utils/code-highlight.ts +400 -0
- package/src/utils/composer-contenteditable.test.ts +507 -0
- package/src/utils/composer-contenteditable.ts +626 -0
- package/src/utils/composer-document.test.ts +280 -0
- package/src/utils/composer-document.ts +293 -0
- package/src/utils/composer-history.test.ts +35 -7
- package/src/utils/composer-history.ts +30 -20
- package/src/utils/composer-input.ts +159 -0
- package/src/utils/context-mention-controller.test.ts +1215 -0
- package/src/utils/context-mention-controller.ts +1186 -0
- package/src/utils/context-mention-manager.test.ts +422 -0
- package/src/utils/context-mention-manager.ts +410 -0
- package/src/utils/context-mention-orchestrator.test.ts +538 -0
- package/src/utils/context-mention-orchestrator.ts +348 -0
- package/src/utils/icons.ts +2 -0
- package/src/utils/live-region.test.ts +108 -0
- package/src/utils/live-region.ts +94 -0
- package/src/utils/mention-channels.ts +63 -0
- package/src/utils/mention-llm-format.test.ts +91 -0
- package/src/utils/mention-llm-format.ts +79 -0
- package/src/utils/mention-matcher.test.ts +86 -0
- package/src/utils/mention-matcher.ts +221 -0
- package/src/utils/mention-token.ts +72 -0
- package/src/utils/mention-trigger.test.ts +155 -0
- package/src/utils/mention-trigger.ts +156 -0
- package/src/utils/roving-tablist.test.ts +152 -0
- package/src/utils/roving-tablist.ts +111 -0
- package/src/utils/spinner.ts +45 -0
- package/src/utils/theme.test.ts +76 -4
- package/src/utils/theme.ts +7 -0
- package/src/utils/tokens.ts +118 -11
- package/src/utils/tool-loading-animation.test.ts +32 -0
- package/src/utils/tool-loading-animation.ts +24 -0
- package/dist/chunk-DFBSCFYN.js +0 -1
- package/dist/runtype-tts-entry-HFUV2UF7.js +0 -1
- package/dist/session-reconnect-U77QFUR7.js +0 -1
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { ComponentContext, ComponentRenderer } from "./registry";
|
|
2
|
+
import type { PersonaArtifactFileMeta, PersonaArtifactRecord } from "../types";
|
|
3
|
+
import { fileTypeLabel, basenameOf } from "../utils/artifact-file";
|
|
4
|
+
import {
|
|
5
|
+
applyArtifactStatus,
|
|
6
|
+
clearArtifactStatusTracking,
|
|
7
|
+
resolveArtifactStatusLabel
|
|
8
|
+
} from "../utils/artifact-status-label";
|
|
9
|
+
import { createLabelButton } from "../utils/buttons";
|
|
10
|
+
import { buildArtifactActionButton } from "../utils/artifact-custom-actions";
|
|
11
|
+
import type { PersonaArtifactActionContext } from "../types";
|
|
2
12
|
|
|
3
13
|
/**
|
|
4
14
|
* Default artifact card renderer.
|
|
@@ -6,26 +16,32 @@ import type { ComponentContext, ComponentRenderer } from "./registry";
|
|
|
6
16
|
*/
|
|
7
17
|
function renderDefaultArtifactCard(
|
|
8
18
|
props: Record<string, unknown>,
|
|
9
|
-
|
|
19
|
+
context: ComponentContext
|
|
10
20
|
): HTMLElement {
|
|
11
|
-
const
|
|
21
|
+
const file =
|
|
22
|
+
props.file && typeof props.file === "object" && !Array.isArray(props.file)
|
|
23
|
+
? (props.file as PersonaArtifactFileMeta)
|
|
24
|
+
: undefined;
|
|
25
|
+
const rawTitle =
|
|
12
26
|
typeof props.title === "string" && props.title
|
|
13
27
|
? props.title
|
|
14
28
|
: "Untitled artifact";
|
|
29
|
+
// File artifacts show the basename (title stays the full path on the wire).
|
|
30
|
+
const title = file ? basenameOf(file.path) : rawTitle;
|
|
15
31
|
const artifactId =
|
|
16
32
|
typeof props.artifactId === "string" ? props.artifactId : "";
|
|
17
33
|
const status = props.status === "streaming" ? "streaming" : "complete";
|
|
18
34
|
const artifactType =
|
|
19
35
|
typeof props.artifactType === "string" ? props.artifactType : "markdown";
|
|
20
|
-
const subtitle =
|
|
21
|
-
|
|
36
|
+
const subtitle = file
|
|
37
|
+
? fileTypeLabel(file)
|
|
38
|
+
: artifactType === "component"
|
|
39
|
+
? "Component"
|
|
40
|
+
: "Document";
|
|
22
41
|
|
|
23
42
|
const root = document.createElement("div");
|
|
24
43
|
root.className =
|
|
25
|
-
"persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-
|
|
26
|
-
root.style.border = "1px solid var(--persona-border, #e5e7eb)";
|
|
27
|
-
root.style.backgroundColor = "var(--persona-surface, #ffffff)";
|
|
28
|
-
root.style.cursor = "pointer";
|
|
44
|
+
"persona-artifact-card persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-px-4 persona-py-3";
|
|
29
45
|
root.tabIndex = 0;
|
|
30
46
|
root.setAttribute("role", "button");
|
|
31
47
|
root.setAttribute("aria-label", `Open ${title} in artifact panel`);
|
|
@@ -56,35 +72,66 @@ function renderDefaultArtifactCard(
|
|
|
56
72
|
subtitleEl.style.color = "var(--persona-muted, #9ca3af)";
|
|
57
73
|
|
|
58
74
|
if (status === "streaming") {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
const artifactsCfg = context?.config?.features?.artifacts;
|
|
76
|
+
// The card re-renders only at streaming-start and completion (deltas flow to
|
|
77
|
+
// the pane / inline block, not here), so live counters don't tick on the
|
|
78
|
+
// card; the string / label form still applies. Build a minimal record from
|
|
79
|
+
// the card props so the shared resolver derives the same typeLabel + ctx.
|
|
80
|
+
const record: PersonaArtifactRecord = {
|
|
81
|
+
id: artifactId,
|
|
82
|
+
artifactType: artifactType === "component" ? "component" : "markdown",
|
|
83
|
+
title: rawTitle,
|
|
84
|
+
status: "streaming",
|
|
85
|
+
...(typeof props.markdown === "string" ? { markdown: props.markdown } : {}),
|
|
86
|
+
...(file ? { file } : {})
|
|
87
|
+
};
|
|
88
|
+
const resolved = resolveArtifactStatusLabel(record, artifactsCfg, "card");
|
|
89
|
+
applyArtifactStatus(subtitleEl, resolved, artifactsCfg);
|
|
69
90
|
} else {
|
|
91
|
+
if (artifactId) clearArtifactStatusTracking(artifactId);
|
|
70
92
|
subtitleEl.textContent = subtitle;
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
meta.append(titleEl, subtitleEl);
|
|
74
96
|
root.append(iconBox, meta);
|
|
75
97
|
|
|
76
|
-
// Download button
|
|
98
|
+
// Custom actions + Download button render only on complete artifacts, same
|
|
99
|
+
// as Download: content-dependent actions during streaming would act on
|
|
100
|
+
// partial content, so they wait until the artifact is fully materialized.
|
|
77
101
|
if (status === "complete") {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
// Custom card actions carry NO direct listeners (the card re-renders during
|
|
103
|
+
// streaming and is morphed by idiomorph). Clicks are handled by event
|
|
104
|
+
// delegation in ui.ts, keyed off data-artifact-custom-action, mirroring the
|
|
105
|
+
// Download button's data-download-artifact delegation.
|
|
106
|
+
const cardActions = context?.config?.features?.artifacts?.cardActions;
|
|
107
|
+
if (cardActions && cardActions.length > 0) {
|
|
108
|
+
const ctx: PersonaArtifactActionContext = {
|
|
109
|
+
artifactId: artifactId || null,
|
|
110
|
+
title,
|
|
111
|
+
artifactType,
|
|
112
|
+
markdown:
|
|
113
|
+
typeof props.markdown === "string" ? props.markdown : undefined,
|
|
114
|
+
file,
|
|
115
|
+
};
|
|
116
|
+
for (const action of cardActions) {
|
|
117
|
+
try {
|
|
118
|
+
if (action.visible === undefined || action.visible(ctx)) {
|
|
119
|
+
const btn = buildArtifactActionButton(action);
|
|
120
|
+
btn.setAttribute("data-artifact-custom-action", action.id);
|
|
121
|
+
btn.className = `${btn.className} persona-flex-shrink-0`;
|
|
122
|
+
root.append(btn);
|
|
123
|
+
}
|
|
124
|
+
} catch {
|
|
125
|
+
// A single bad action must not take down the whole card.
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const dl = createLabelButton({
|
|
131
|
+
label: "Download",
|
|
132
|
+
className: "persona-flex-shrink-0",
|
|
133
|
+
});
|
|
81
134
|
dl.title = `Download ${title}`;
|
|
82
|
-
dl.className =
|
|
83
|
-
"persona-flex-shrink-0 persona-rounded-md persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium";
|
|
84
|
-
dl.style.border = "1px solid var(--persona-border, #e5e7eb)";
|
|
85
|
-
dl.style.color = "var(--persona-text, #1f2937)";
|
|
86
|
-
dl.style.backgroundColor = "transparent";
|
|
87
|
-
dl.style.cursor = "pointer";
|
|
88
135
|
dl.setAttribute("data-download-artifact", artifactId);
|
|
89
136
|
root.append(dl);
|
|
90
137
|
}
|