@runtypelabs/persona 3.17.0 → 3.18.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 +142 -0
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-HPZY7oAI.d.cts → types-cwY5HaFD.d.cts} +25 -0
- package/dist/animations/{types-HPZY7oAI.d.ts → types-cwY5HaFD.d.ts} +25 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/index.cjs +47 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +300 -1
- package/dist/index.d.ts +300 -1
- package/dist/index.global.js +75 -75
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/theme-editor.cjs +1432 -159
- package/dist/theme-editor.d.cts +218 -0
- package/dist/theme-editor.d.ts +218 -0
- package/dist/theme-editor.js +1432 -159
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +14 -0
- package/dist/theme-reference.d.ts +14 -0
- package/dist/widget.css +432 -0
- package/package.json +1 -1
- package/src/client.test.ts +134 -0
- package/src/client.ts +71 -0
- package/src/components/ask-user-question-bubble.test.ts +583 -0
- package/src/components/ask-user-question-bubble.ts +924 -0
- package/src/components/messages.ts +33 -1
- package/src/components/panel.ts +41 -4
- package/src/defaults.ts +21 -0
- package/src/index.ts +16 -1
- package/src/plugins/types.ts +57 -0
- package/src/session.test.ts +183 -0
- package/src/session.ts +242 -3
- package/src/styles/widget.css +432 -0
- package/src/types/theme.ts +15 -0
- package/src/types.ts +150 -0
- package/src/ui.ask-user-question-plugin.test.ts +649 -0
- package/src/ui.ts +631 -5
- package/src/utils/storage.ts +10 -2
- package/src/utils/theme.test.ts +36 -0
- package/src/utils/tokens.ts +23 -0
package/src/utils/storage.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AgentWidgetMessage,
|
|
3
3
|
AgentWidgetStorageAdapter,
|
|
4
|
-
AgentWidgetStoredState
|
|
4
|
+
AgentWidgetStoredState,
|
|
5
|
+
PersonaArtifactRecord
|
|
5
6
|
} from "../types";
|
|
6
7
|
|
|
7
8
|
const safeJsonParse = (value: string | null) => {
|
|
@@ -23,6 +24,12 @@ const sanitizeMessages = (messages: AgentWidgetMessage[]) =>
|
|
|
23
24
|
streaming: false
|
|
24
25
|
}));
|
|
25
26
|
|
|
27
|
+
const sanitizeArtifacts = (artifacts: PersonaArtifactRecord[]) =>
|
|
28
|
+
artifacts.map((artifact) => ({
|
|
29
|
+
...artifact,
|
|
30
|
+
status: "complete" as const
|
|
31
|
+
}));
|
|
32
|
+
|
|
26
33
|
export const createLocalStorageAdapter = (
|
|
27
34
|
key = "persona-state"
|
|
28
35
|
): AgentWidgetStorageAdapter => {
|
|
@@ -45,7 +52,8 @@ export const createLocalStorageAdapter = (
|
|
|
45
52
|
try {
|
|
46
53
|
const payload: AgentWidgetStoredState = {
|
|
47
54
|
...state,
|
|
48
|
-
messages: state.messages ? sanitizeMessages(state.messages) : undefined
|
|
55
|
+
messages: state.messages ? sanitizeMessages(state.messages) : undefined,
|
|
56
|
+
artifacts: state.artifacts ? sanitizeArtifacts(state.artifacts) : undefined
|
|
49
57
|
};
|
|
50
58
|
storage.setItem(key, JSON.stringify(payload));
|
|
51
59
|
} catch (error) {
|
package/src/utils/theme.test.ts
CHANGED
|
@@ -252,6 +252,42 @@ describe('theme utils', () => {
|
|
|
252
252
|
expect(cssVars['--persona-scroll-to-bottom-icon-size']).toBe('14px');
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
+
it('maps introCard component tokens to dedicated CSS variables', () => {
|
|
256
|
+
const theme = createTheme({
|
|
257
|
+
components: {
|
|
258
|
+
introCard: {
|
|
259
|
+
background: 'palette.colors.accent.50',
|
|
260
|
+
borderRadius: 'palette.radius.xl',
|
|
261
|
+
padding: 'semantic.spacing.lg',
|
|
262
|
+
shadow: '0 10px 30px rgba(53, 44, 131, 0.15)',
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
} as any);
|
|
266
|
+
|
|
267
|
+
const cssVars = themeToCssVariables(theme);
|
|
268
|
+
|
|
269
|
+
expect(cssVars['--persona-components-introCard-background']).toBe('#ecfeff');
|
|
270
|
+
expect(cssVars['--persona-components-introCard-borderRadius']).toBe('0.75rem');
|
|
271
|
+
expect(cssVars['--persona-components-introCard-padding']).toBe('1.5rem');
|
|
272
|
+
expect(cssVars['--persona-components-introCard-shadow']).toBe(
|
|
273
|
+
'0 10px 30px rgba(53, 44, 131, 0.15)'
|
|
274
|
+
);
|
|
275
|
+
expect(cssVars['--persona-intro-card-bg']).toBe('#ecfeff');
|
|
276
|
+
expect(cssVars['--persona-intro-card-radius']).toBe('0.75rem');
|
|
277
|
+
expect(cssVars['--persona-intro-card-padding']).toBe('1.5rem');
|
|
278
|
+
expect(cssVars['--persona-intro-card-shadow']).toBe(
|
|
279
|
+
'0 10px 30px rgba(53, 44, 131, 0.15)'
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('falls back to the legacy intro-card shadow when no token is set', () => {
|
|
284
|
+
const theme = createTheme({});
|
|
285
|
+
const cssVars = themeToCssVariables(theme);
|
|
286
|
+
expect(cssVars['--persona-intro-card-shadow']).toBe(
|
|
287
|
+
'0 5px 15px rgba(15, 23, 42, 0.08)'
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
|
|
255
291
|
it('lets config.toolCall.shadow override theme tool bubble shadow on the root element', () => {
|
|
256
292
|
const el = document.createElement('div');
|
|
257
293
|
applyThemeVariables(el, {
|
package/src/utils/tokens.ts
CHANGED
|
@@ -318,6 +318,14 @@ export const DEFAULT_COMPONENTS: ComponentTokens = {
|
|
|
318
318
|
},
|
|
319
319
|
border: 'semantic.colors.border',
|
|
320
320
|
},
|
|
321
|
+
introCard: {
|
|
322
|
+
// Defaults preserve the legacy `persona-shadow-sm` look exactly so existing
|
|
323
|
+
// pages render unchanged when no token is set.
|
|
324
|
+
background: 'semantic.colors.surface',
|
|
325
|
+
borderRadius: 'palette.radius.2xl',
|
|
326
|
+
padding: 'semantic.spacing.lg',
|
|
327
|
+
shadow: '0 5px 15px rgba(15, 23, 42, 0.08)',
|
|
328
|
+
},
|
|
321
329
|
toolBubble: {
|
|
322
330
|
shadow: 'palette.shadows.sm',
|
|
323
331
|
},
|
|
@@ -763,6 +771,21 @@ export function themeToCssVariables(theme: PersonaTheme): Record<string, string>
|
|
|
763
771
|
if (headerTokens?.shadow) cssVars['--persona-header-shadow'] = headerTokens.shadow;
|
|
764
772
|
if (headerTokens?.borderBottom) cssVars['--persona-header-border-bottom'] = headerTokens.borderBottom;
|
|
765
773
|
|
|
774
|
+
// Intro card aliases — short names the panel inline-styles read directly.
|
|
775
|
+
// The full-path `--persona-components-introCard-*` variables auto-emit above;
|
|
776
|
+
// these mirror them with sensible fallbacks so existing pages keep their look.
|
|
777
|
+
const introCardTokens = theme.components?.introCard;
|
|
778
|
+
cssVars['--persona-intro-card-bg'] =
|
|
779
|
+
cssVars['--persona-components-introCard-background'] ?? cssVars['--persona-surface'];
|
|
780
|
+
cssVars['--persona-intro-card-radius'] =
|
|
781
|
+
cssVars['--persona-components-introCard-borderRadius'] ?? '1rem';
|
|
782
|
+
cssVars['--persona-intro-card-padding'] =
|
|
783
|
+
cssVars['--persona-components-introCard-padding'] ?? '1.5rem';
|
|
784
|
+
cssVars['--persona-intro-card-shadow'] =
|
|
785
|
+
introCardTokens?.shadow
|
|
786
|
+
?? cssVars['--persona-components-introCard-shadow']
|
|
787
|
+
?? '0 5px 15px rgba(15, 23, 42, 0.08)';
|
|
788
|
+
|
|
766
789
|
cssVars['--persona-input-background'] =
|
|
767
790
|
cssVars['--persona-components-input-background'] ?? cssVars['--persona-surface'];
|
|
768
791
|
cssVars['--persona-input-placeholder'] =
|