@runtypelabs/persona 3.2.2 → 3.4.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/index.cjs +281 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -1
- package/dist/index.d.ts +53 -1
- package/dist/index.global.js +321 -80
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +277 -36
- package/dist/index.js.map +1 -1
- package/dist/theme-reference.cjs +1 -0
- package/dist/theme-reference.d.cts +899 -0
- package/dist/theme-reference.d.ts +899 -0
- package/dist/theme-reference.js +1 -0
- package/dist/widget.css +62 -0
- package/package.json +8 -2
- package/src/components/composer-builder.ts +20 -4
- package/src/components/demo-carousel.ts +699 -0
- package/src/components/header-builder.ts +1 -1
- package/src/index.ts +8 -0
- package/src/styles/widget.css +62 -0
- package/src/theme-reference.ts +371 -0
- package/src/types.ts +4 -0
- package/src/ui.ts +31 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={colors:{primary:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"}},spacing:{0:"0px",1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem",20:"5rem",24:"6rem",32:"8rem",40:"10rem",48:"12rem",56:"14rem",64:"16rem"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.625"}},shadows:{none:"none",sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)"},borders:{none:"none",sm:"1px solid",md:"2px solid",lg:"4px solid"},radius:{none:"0px",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"}};var o={overview:"Persona uses a three-layer design token system: palette \u2192 semantic \u2192 components. Most themes only need palette.colors overrides \u2014 semantic and component layers auto-derive from palette values. Config also accepts non-theme appearance options (launcher, sendButton, toolCall, etc.).",layers:{palette:{description:"Primitive design tokens. Override specific shades to change the entire widget feel.",colors:{description:"7 color scales, each with shades 50 (lightest) to 950 (darkest). Override only the shades you need.",scales:{gray:"Neutrals \u2014 backgrounds, text, borders. Key shades: 50 (lightest bg), 100 (secondary bg), 200 (borders), 500 (muted text), 900 (primary text).",primary:"Brand color \u2014 buttons, links, interactive elements. Key shades: 500 (default), 600 (hover).",accent:"Secondary highlight. Key shades: 500 (default), 600 (hover).",secondary:"Tertiary color scale.",success:"Positive feedback (default: green).",warning:"Caution feedback (default: yellow).",error:"Error/danger feedback (default: red)."}},radius:{description:"Border radius scale. Add custom keys like launcher, button.",defaults:{none:"0px",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"}},typography:{fontFamily:"Three stacks: sans (system-ui), serif (Georgia), mono (ui-monospace). Override individual stack values.",fontSize:"Scale: xs (0.75rem), sm (0.875rem), base (1rem), lg (1.125rem), xl (1.25rem), 2xl (1.5rem), 3xl (1.875rem), 4xl (2.25rem).",fontWeight:"normal (400), medium (500), semibold (600), bold (700).",lineHeight:"tight (1.25), normal (1.5), relaxed (1.625)."},shadows:"Scale: none, sm, md, lg, xl, 2xl. Values are CSS box-shadow strings.",borders:"Scale: none, sm (1px solid), md (2px solid), lg (4px solid).",spacing:"Scale: 0 (0px), 1 (0.25rem), 2 (0.5rem), 3 (0.75rem), 4 (1rem), 5 (1.25rem), 6 (1.5rem), 8 (2rem), 10 (2.5rem), 12 (3rem), 16-64."},semantic:{description:'Design intent tokens. Auto-derived from palette by default. Override to redirect token resolution. Values are token reference strings like "palette.colors.primary.500".',colors:{primary:"palette.colors.primary.500 \u2014 Primary brand color.",secondary:"palette.colors.gray.500 \u2014 Secondary color.",accent:"palette.colors.primary.600 \u2014 Accent/interactive color.",surface:"palette.colors.gray.50 \u2014 Panel/card backgrounds.",background:"palette.colors.gray.50 \u2014 Page background.",container:"palette.colors.gray.100 \u2014 Container backgrounds.",text:"palette.colors.gray.900 \u2014 Primary text.",textMuted:"palette.colors.gray.500 \u2014 Muted/secondary text.",textInverse:"palette.colors.gray.50 \u2014 Text on dark backgrounds.",border:"palette.colors.gray.200 \u2014 Default border color.",divider:"palette.colors.gray.200 \u2014 Divider lines.",interactive:{default:"palette.colors.primary.500",hover:"palette.colors.primary.600",focus:"palette.colors.primary.700",active:"palette.colors.primary.800",disabled:"palette.colors.gray.300"},feedback:{success:"palette.colors.success.500",warning:"palette.colors.warning.500",error:"palette.colors.error.500",info:"palette.colors.primary.500"}},spacing:"xs (0.25rem), sm (0.5rem), md (1rem), lg (1.5rem), xl (2rem), 2xl (2.5rem).",typography:"fontFamily, fontSize, fontWeight, lineHeight \u2014 reference palette typography tokens."},components:{description:"UI element tokens. Rarely needed for basic theming. Override for fine-grained control. All values are token references or raw CSS strings.",button:{description:"Three variants: primary, secondary, ghost.",properties:"background, foreground, borderRadius, padding."},input:{description:"Message input field.",properties:"background, placeholder, borderRadius, padding, focus.border, focus.ring."},launcher:{description:"Floating launcher button.",properties:"size (60px), iconSize (28px), borderRadius, shadow."},panel:{description:"Chat panel container.",properties:"width, maxWidth (400px), height (600px), maxHeight, borderRadius, shadow."},header:{description:"Chat panel header.",properties:"background, border, borderRadius, padding, iconBackground, iconForeground, titleForeground, subtitleForeground, actionIconForeground, shadow, borderBottom."},message:{description:"Chat message bubbles.",user:"background, text, borderRadius, shadow.",assistant:"background, text, borderRadius, border (optional), shadow (optional)."},markdown:{description:"Markdown rendering in messages and artifact pane.",properties:"inlineCode (background, foreground), link.foreground, prose.fontFamily, heading.h1/h2 (fontSize, fontWeight)."},voice:"recording (indicator, background, border), processing (icon, background), speaking (icon).",approval:"requested (background, border, text), approve (background, foreground), deny (background, foreground).",attachment:"image (background, border).",toolBubble:"shadow \u2014 tool call row box-shadow.",reasoningBubble:"shadow \u2014 reasoning/thinking row box-shadow.",composer:"shadow \u2014 message input form box-shadow.",artifact:"toolbar (icon styling, copy menu), tab (background, active states), pane (background, toolbarBackground)."}},colorScheme:'"dark" merges darkTheme overrides on top of theme. "auto" detects system preference or <html class="dark">. "light" is default. colorScheme does NOT auto-invert colors \u2014 provide dark palette and semantic overrides yourself.',plugins:{description:"Plugins transform theme tokens before resolution. Use with createTheme().",available:{brandPlugin:'Auto-generates full color scales from a single brand hex: brandPlugin({ colors: { primary: "#7c3aed" } }).',accessibilityPlugin:"Enhanced focus indicators and disabled states.",highContrastPlugin:"Increased contrast for visual accessibility.",reducedMotionPlugin:"Disables all animations (sets transitions to 0ms).",animationsPlugin:"Adds transition and easing tokens."},usage:'createTheme(themeOverrides, { plugins: [brandPlugin({ colors: { primary: "#7c3aed" } })] })'},widgetConfig:{description:'Non-theme config options on the widget config object that affect appearance. These are siblings of "theme" in the config, not nested inside it.',launcher:{description:"Floating launcher button and panel positioning.",properties:{enabled:"Show/hide the launcher button.",title:"Header title text.",subtitle:"Header subtitle text.",position:'"bottom-right" | "bottom-left" | "top-right" | "top-left".',width:"Chat panel width (CSS value).",fullHeight:"Fill full height of container.",mountMode:'"floating" | "docked".',agentIconText:"Emoji/text for agent icon.",border:"Border style for launcher button.",shadow:"Box shadow for launcher button.",collapsedMaxWidth:"Max-width for launcher pill when panel closed."}},sendButton:{description:"Send button appearance.",properties:"backgroundColor, textColor, borderWidth, borderColor, paddingX, paddingY, iconText, iconName, size."},closeButton:{description:"Close button (on launcher config).",properties:"closeButtonSize, closeButtonColor, closeButtonBackgroundColor, closeButtonBorderWidth, closeButtonBorderColor, closeButtonBorderRadius."},clearChat:{description:"Clear chat button (on launcher.clearChat config).",properties:"enabled, iconColor, backgroundColor, borderWidth, borderColor, borderRadius, size."},toolCall:{description:"Tool call display styling.",properties:"backgroundColor, borderColor, borderWidth, borderRadius, headerBackgroundColor, headerTextColor, contentBackgroundColor, contentTextColor, codeBlockBackgroundColor, codeBlockBorderColor, codeBlockTextColor, toggleTextColor, labelTextColor."},copy:{description:"Widget text content.",properties:"welcomeTitle, welcomeSubtitle, inputPlaceholder, sendButtonLabel."},voiceRecognition:{description:"Voice input configuration.",properties:"enabled, pauseDuration, iconColor, backgroundColor."},suggestionChips:"string[] \u2014 Suggested prompts shown to the user.",layout:{description:"Layout configuration.",header:'"default" | "minimal". Options: showIcon, showTitle, showSubtitle, showCloseButton.',messages:'"bubble" | "flat" | "minimal". Avatar and timestamp options available.'},features:{description:"Feature flags.",properties:"showReasoning (AI thinking steps), showToolCalls (tool invocations), artifacts (sidebar config)."}}},r={darkIndigo:{description:"Dark mode with indigo accent \u2014 override grays for dark backgrounds and semantic tokens for inverted text/surface",theme:{palette:{colors:{primary:{500:"#6366f1",600:"#4f46e5"},gray:{50:"#f1f5f9",100:"#1e293b",200:"#334155",500:"#94a3b8",900:"#0f172a",950:"#020617"}}},semantic:{colors:{surface:"palette.colors.gray.900",background:"palette.colors.gray.900",container:"palette.colors.gray.100",text:"palette.colors.gray.50",textMuted:"palette.colors.gray.500",textInverse:"palette.colors.gray.900",border:"palette.colors.gray.200"}}}},warmVintage:{description:"Warm sepia tones with serif font and subtle radius",theme:{palette:{colors:{primary:{500:"#b45309",600:"#92400e"},gray:{50:"#fef3c7",100:"#fef9c3",200:"#d6d3d1",500:"#78716c",900:"#44403c"}},radius:{sm:"0.125rem",md:"0.25rem",lg:"0.375rem"},typography:{fontFamily:{sans:'Georgia, Cambria, "Times New Roman", Times, serif'}}}}},neonCyberpunk:{description:"Neon on dark with monospace font \u2014 full semantic override for dark background",theme:{palette:{colors:{primary:{500:"#f0abfc",600:"#e879f9"},accent:{500:"#22d3ee",600:"#06b6d4"},gray:{50:"#f0abfc",100:"#1e0a3c",200:"#3b0764",500:"#c084fc",900:"#0c0a1a",950:"#050412"}},radius:{sm:"0",md:"0.25rem",lg:"0.375rem"},typography:{fontFamily:{sans:"ui-monospace, SFMono-Regular, Menlo, monospace"}}},semantic:{colors:{surface:"palette.colors.gray.900",background:"palette.colors.gray.950",container:"palette.colors.gray.100",text:"palette.colors.gray.50",textMuted:"palette.colors.gray.500",border:"palette.colors.gray.200"}}}},cleanRounded:{description:"Clean light theme with large radius and panel styling",theme:{palette:{radius:{sm:"6px",md:"8px",lg:"12px",launcher:"50px",button:"8px"}},components:{panel:{borderRadius:"16px",shadow:"palette.shadows.2xl"}}}}};function n(){return{tokenDocs:o,defaultColorPalette:e.colors,defaultRadius:e.radius,examples:r,sdkPresets:["shop","minimal","fullscreen"]}}export{r as THEME_EXAMPLES,o as THEME_TOKEN_DOCS,n as getThemeReference};
|
package/dist/widget.css
CHANGED
|
@@ -1222,6 +1222,68 @@
|
|
|
1222
1222
|
font-size: 0.8125rem;
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
+
/* Code block copy button */
|
|
1226
|
+
.persona-code-block-wrapper {
|
|
1227
|
+
position: relative;
|
|
1228
|
+
margin: 0.5rem 0;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
.persona-code-block-wrapper pre {
|
|
1232
|
+
margin: 0 !important;
|
|
1233
|
+
border-top-left-radius: 0 !important;
|
|
1234
|
+
border-top-right-radius: 0 !important;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
.persona-code-block-header {
|
|
1238
|
+
display: flex;
|
|
1239
|
+
align-items: center;
|
|
1240
|
+
justify-content: space-between;
|
|
1241
|
+
background-color: var(--persona-md-code-block-bg, #f3f4f6);
|
|
1242
|
+
border: 1px solid var(--persona-md-code-block-border-color, #e5e7eb);
|
|
1243
|
+
border-bottom: none;
|
|
1244
|
+
border-top-left-radius: var(--persona-md-code-block-border-radius, 0.375rem);
|
|
1245
|
+
border-top-right-radius: var(--persona-md-code-block-border-radius, 0.375rem);
|
|
1246
|
+
padding: 0.25rem 0.5rem 0.25rem 0.75rem;
|
|
1247
|
+
font-size: 0.75rem;
|
|
1248
|
+
color: var(--persona-text-muted, #6b7280);
|
|
1249
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
.persona-code-copy-btn {
|
|
1253
|
+
display: inline-flex;
|
|
1254
|
+
align-items: center;
|
|
1255
|
+
gap: 0.25rem;
|
|
1256
|
+
background: none;
|
|
1257
|
+
border: 1px solid transparent;
|
|
1258
|
+
border-radius: 0.25rem;
|
|
1259
|
+
padding: 0.25rem 0.5rem;
|
|
1260
|
+
cursor: pointer;
|
|
1261
|
+
color: var(--persona-text-muted, #6b7280);
|
|
1262
|
+
font-size: 0.75rem;
|
|
1263
|
+
font-family: inherit;
|
|
1264
|
+
line-height: 1;
|
|
1265
|
+
transition: color 0.15s ease, border-color 0.15s ease;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
.persona-code-copy-btn:hover {
|
|
1269
|
+
color: var(--persona-text, #111827);
|
|
1270
|
+
border-color: var(--persona-md-code-block-border-color, #e5e7eb);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
.persona-code-copy-btn.persona-code-copied {
|
|
1274
|
+
color: #16a34a;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
.persona-code-copy-btn.persona-code-copy-generating {
|
|
1278
|
+
cursor: default;
|
|
1279
|
+
opacity: 0.5;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
.persona-code-copy-btn.persona-code-copy-generating:hover {
|
|
1283
|
+
color: var(--persona-text-muted, #6b7280);
|
|
1284
|
+
border-color: transparent;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1225
1287
|
/* Ensure all links in chat bubbles have underlines */
|
|
1226
1288
|
.vanilla-message-bubble a {
|
|
1227
1289
|
text-decoration: underline;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/persona",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Themeable, pluggable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
14
|
},
|
|
15
|
+
"./theme-reference": {
|
|
16
|
+
"types": "./dist/theme-reference.d.ts",
|
|
17
|
+
"import": "./dist/theme-reference.js",
|
|
18
|
+
"require": "./dist/theme-reference.cjs"
|
|
19
|
+
},
|
|
15
20
|
"./widget.css": {
|
|
16
21
|
"import": "./widget.css",
|
|
17
22
|
"default": "./dist/widget.css"
|
|
@@ -70,7 +75,8 @@
|
|
|
70
75
|
"access": "public"
|
|
71
76
|
},
|
|
72
77
|
"scripts": {
|
|
73
|
-
"build": "rimraf dist && pnpm run build:styles && pnpm run build:client && pnpm run build:installer",
|
|
78
|
+
"build": "rimraf dist && pnpm run build:styles && pnpm run build:client && pnpm run build:installer && pnpm run build:theme-ref",
|
|
79
|
+
"build:theme-ref": "tsup src/theme-reference.ts --format esm,cjs --minify --dts",
|
|
74
80
|
"build:styles": "node -e \"const fs=require('fs');fs.mkdirSync('dist',{recursive:true});fs.copyFileSync('src/styles/widget.css','dist/widget.css');\"",
|
|
75
81
|
"build:client": "tsup src/index.ts --format esm,cjs,iife --global-name AgentWidget --minify --sourcemap --splitting false --dts --loader \".css=text\"",
|
|
76
82
|
"build:installer": "tsup src/install.ts --format iife --global-name SiteAgentInstaller --out-dir dist --minify --sourcemap --no-splitting",
|
|
@@ -480,17 +480,33 @@ export const buildComposer = (context: ComposerBuildContext): ComposerElements =
|
|
|
480
480
|
actionsRow.append(leftActions, rightActions);
|
|
481
481
|
composerForm.append(actionsRow);
|
|
482
482
|
|
|
483
|
+
// Apply status indicator config
|
|
484
|
+
const statusConfig = config?.statusIndicator ?? {};
|
|
485
|
+
const alignClass =
|
|
486
|
+
statusConfig.align === "left" ? "persona-text-left"
|
|
487
|
+
: statusConfig.align === "center" ? "persona-text-center"
|
|
488
|
+
: "persona-text-right";
|
|
483
489
|
const statusText = createElement(
|
|
484
490
|
"div",
|
|
485
|
-
|
|
491
|
+
`persona-mt-2 ${alignClass} persona-text-xs persona-text-persona-muted`
|
|
486
492
|
);
|
|
487
493
|
statusText.setAttribute("data-persona-composer-status", "");
|
|
488
494
|
|
|
489
|
-
// Apply status indicator config
|
|
490
|
-
const statusConfig = config?.statusIndicator ?? {};
|
|
491
495
|
const isVisible = statusConfig.visible ?? true;
|
|
492
496
|
statusText.style.display = isVisible ? "" : "none";
|
|
493
|
-
|
|
497
|
+
const idleLabel = statusConfig.idleText ?? "Online";
|
|
498
|
+
if (statusConfig.idleLink) {
|
|
499
|
+
const link = createElement("a");
|
|
500
|
+
link.href = statusConfig.idleLink;
|
|
501
|
+
link.target = "_blank";
|
|
502
|
+
link.rel = "noopener noreferrer";
|
|
503
|
+
link.textContent = idleLabel;
|
|
504
|
+
link.style.color = "inherit";
|
|
505
|
+
link.style.textDecoration = "none";
|
|
506
|
+
statusText.appendChild(link);
|
|
507
|
+
} else {
|
|
508
|
+
statusText.textContent = idleLabel;
|
|
509
|
+
}
|
|
494
510
|
|
|
495
511
|
footer.append(suggestions, composerForm, statusText);
|
|
496
512
|
|