@runtypelabs/persona 3.0.0 → 3.1.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 +33 -5
- package/dist/index.cjs +39 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.global.js +76 -76
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +39 -39
- package/dist/index.js.map +1 -1
- package/dist/widget.css +90 -83
- package/package.json +1 -3
- package/src/components/artifact-pane.ts +3 -3
- package/src/components/header-builder.ts +1 -1
- package/src/runtime/host-layout.test.ts +137 -0
- package/src/runtime/host-layout.ts +81 -0
- package/src/runtime/init.test.ts +36 -1
- package/src/runtime/init.ts +1 -1
- package/src/styles/widget.css +90 -83
- package/src/types.ts +32 -2
- package/src/ui.ts +24 -6
- package/src/utils/artifact-gate.ts +1 -1
- package/src/styles/tailwind.css +0 -20
package/src/ui.ts
CHANGED
|
@@ -385,12 +385,14 @@ export const createAgentExperience = (
|
|
|
385
385
|
initialConfig?: AgentWidgetConfig,
|
|
386
386
|
runtimeOptions?: { debugTools?: boolean }
|
|
387
387
|
): Controller => {
|
|
388
|
-
// Preserve original mount id as data attribute for window event instance scoping
|
|
389
|
-
|
|
390
|
-
if (mount.id && mount.id !== "persona-root" && !mount.getAttribute("data-persona-instance")) {
|
|
388
|
+
// Preserve original mount id as data attribute for window event instance scoping
|
|
389
|
+
if (mount.id && !mount.getAttribute("data-persona-instance")) {
|
|
391
390
|
mount.setAttribute("data-persona-instance", mount.id);
|
|
392
391
|
}
|
|
393
|
-
|
|
392
|
+
// Ensure root marker is present for Tailwind scoping and DOM traversal
|
|
393
|
+
if (!mount.hasAttribute("data-persona-root")) {
|
|
394
|
+
mount.setAttribute("data-persona-root", "true");
|
|
395
|
+
}
|
|
394
396
|
|
|
395
397
|
let config = mergeWithDefaults(initialConfig) as AgentWidgetConfig;
|
|
396
398
|
// Note: applyThemeVariables is called after applyFullHeightStyles() below
|
|
@@ -410,11 +412,20 @@ export const createAgentExperience = (
|
|
|
410
412
|
let persistentMetadata: Record<string, unknown> = {};
|
|
411
413
|
let pendingStoredState: Promise<AgentWidgetStoredState | null> | null = null;
|
|
412
414
|
|
|
413
|
-
|
|
415
|
+
let shouldOpenAfterStateLoaded = false;
|
|
416
|
+
|
|
417
|
+
// Helper to apply onStateLoaded hook and extract state.
|
|
418
|
+
// Supports both the legacy plain-state return and the new { state, open? } return.
|
|
414
419
|
const applyStateLoadedHook = (state: AgentWidgetStoredState): AgentWidgetStoredState => {
|
|
415
420
|
if (config.onStateLoaded) {
|
|
416
421
|
try {
|
|
417
|
-
|
|
422
|
+
const result = config.onStateLoaded(state);
|
|
423
|
+
if (result && typeof result === 'object' && 'state' in result) {
|
|
424
|
+
const { state: processedState, open } = result as { state: AgentWidgetStoredState; open?: boolean };
|
|
425
|
+
if (open) shouldOpenAfterStateLoaded = true;
|
|
426
|
+
return processedState;
|
|
427
|
+
}
|
|
428
|
+
return result as AgentWidgetStoredState;
|
|
418
429
|
} catch (error) {
|
|
419
430
|
if (typeof console !== "undefined") {
|
|
420
431
|
// eslint-disable-next-line no-console
|
|
@@ -5377,6 +5388,13 @@ export const createAgentExperience = (
|
|
|
5377
5388
|
}
|
|
5378
5389
|
}
|
|
5379
5390
|
|
|
5391
|
+
// If onStateLoaded signalled open: true, open the panel after init.
|
|
5392
|
+
// Mirrors the same setTimeout(0) pattern used by persistState restore so both
|
|
5393
|
+
// can fire independently without interfering with each other.
|
|
5394
|
+
if (shouldOpenAfterStateLoaded && launcherEnabled) {
|
|
5395
|
+
setTimeout(() => { controller.open(); }, 0);
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5380
5398
|
return controller;
|
|
5381
5399
|
};
|
|
5382
5400
|
|
|
@@ -32,7 +32,7 @@ export function applyArtifactPaneBorderTheme(mount: HTMLElement, config: AgentWi
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/** Set CSS variables on
|
|
35
|
+
/** Set CSS variables on the widget root for artifact split/pane sizing. Clears when artifacts disabled. */
|
|
36
36
|
function clearDocumentToolbarLayoutVars(mount: HTMLElement): void {
|
|
37
37
|
mount.style.removeProperty("--persona-artifact-doc-toolbar-icon-color");
|
|
38
38
|
mount.style.removeProperty("--persona-artifact-doc-toggle-active-bg");
|
package/src/styles/tailwind.css
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
@tailwind base;
|
|
2
|
-
@tailwind components;
|
|
3
|
-
@tailwind utilities;
|
|
4
|
-
|
|
5
|
-
@layer base {
|
|
6
|
-
/* Widget CSS Variables - scoped to widget root to avoid polluting global namespace */
|
|
7
|
-
#persona-root {
|
|
8
|
-
--runtype-primary: #111827;
|
|
9
|
-
--runtype-secondary: #4338ca;
|
|
10
|
-
--runtype-surface: #ffffff;
|
|
11
|
-
--runtype-muted: #6b7280;
|
|
12
|
-
--runtype-accent: #1d4ed8;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@layer components {
|
|
17
|
-
.persona-widget-shadow {
|
|
18
|
-
box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
|
|
19
|
-
}
|
|
20
|
-
}
|