@ai-gui/plugin-ui 0.4.4 → 0.6.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.d.cts CHANGED
@@ -27,9 +27,21 @@ interface ASTNode {
27
27
  /** Patch event produced by diffing. */
28
28
 
29
29
  /** Framework-neutral render descriptor returned by plugin node renderers. */
30
- type RenderOutput = {
30
+ type RenderOutput =
31
+ /**
32
+ * `trusted` marks markup the plugin built itself rather than markup taken from the model.
33
+ *
34
+ * A plugin that renders a diagram returns SVG, and sanitizing SVG escapes it — the reader gets
35
+ * the source text instead of the picture. Hosts worked around that by matching the plugin's
36
+ * internal id prefix with a regular expression, which breaks the moment the plugin renames its
37
+ * ids and lets any model output wearing that prefix through unsanitized. A plugin is code the
38
+ * host chose to install, so it can say so itself; a host that disagrees sets
39
+ * `sanitize: { trustPlugins: false }`.
40
+ */
41
+ {
31
42
  kind: "html";
32
43
  html: string;
44
+ trusted?: boolean;
33
45
  } | {
34
46
  kind: "element";
35
47
  tag: string;
@@ -54,7 +66,18 @@ interface MountedCardSlot {
54
66
  interface RenderMountContext {
55
67
  mountCard?: (host: HTMLElement, request: MountCardSlotRequest) => MountedCardSlot | undefined;
56
68
  }
57
- type NodeRenderer = (node: ASTNode) => RenderOutput | Promise<RenderOutput>;
69
+ /** What the host can tell a plugin about the surroundings it is rendering into. */
70
+ interface NodeRenderContext {
71
+ /**
72
+ * The host's colour scheme, "light" or "dark" by convention.
73
+ *
74
+ * A diagram or a chart picks its own palette, and a plugin has no way to read the palette of
75
+ * the page it is embedded in, so without this an answer rendered on a dark page comes back
76
+ * with white plot areas.
77
+ */
78
+ readonly theme?: string;
79
+ }
80
+ type NodeRenderer = (node: ASTNode, context?: NodeRenderContext) => RenderOutput | Promise<RenderOutput>;
58
81
  interface PluginCommitContext {
59
82
  readonly generation: number;
60
83
  emitDebug(type: string, data?: Record<string, unknown>): void;
package/dist/index.d.ts CHANGED
@@ -27,9 +27,21 @@ interface ASTNode {
27
27
  /** Patch event produced by diffing. */
28
28
 
29
29
  /** Framework-neutral render descriptor returned by plugin node renderers. */
30
- type RenderOutput = {
30
+ type RenderOutput =
31
+ /**
32
+ * `trusted` marks markup the plugin built itself rather than markup taken from the model.
33
+ *
34
+ * A plugin that renders a diagram returns SVG, and sanitizing SVG escapes it — the reader gets
35
+ * the source text instead of the picture. Hosts worked around that by matching the plugin's
36
+ * internal id prefix with a regular expression, which breaks the moment the plugin renames its
37
+ * ids and lets any model output wearing that prefix through unsanitized. A plugin is code the
38
+ * host chose to install, so it can say so itself; a host that disagrees sets
39
+ * `sanitize: { trustPlugins: false }`.
40
+ */
41
+ {
31
42
  kind: "html";
32
43
  html: string;
44
+ trusted?: boolean;
33
45
  } | {
34
46
  kind: "element";
35
47
  tag: string;
@@ -54,7 +66,18 @@ interface MountedCardSlot {
54
66
  interface RenderMountContext {
55
67
  mountCard?: (host: HTMLElement, request: MountCardSlotRequest) => MountedCardSlot | undefined;
56
68
  }
57
- type NodeRenderer = (node: ASTNode) => RenderOutput | Promise<RenderOutput>;
69
+ /** What the host can tell a plugin about the surroundings it is rendering into. */
70
+ interface NodeRenderContext {
71
+ /**
72
+ * The host's colour scheme, "light" or "dark" by convention.
73
+ *
74
+ * A diagram or a chart picks its own palette, and a plugin has no way to read the palette of
75
+ * the page it is embedded in, so without this an answer rendered on a dark page comes back
76
+ * with white plot areas.
77
+ */
78
+ readonly theme?: string;
79
+ }
80
+ type NodeRenderer = (node: ASTNode, context?: NodeRenderContext) => RenderOutput | Promise<RenderOutput>;
58
81
  interface PluginCommitContext {
59
82
  readonly generation: number;
60
83
  emitDebug(type: string, data?: Record<string, unknown>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-gui/plugin-ui",
3
- "version": "0.4.4",
3
+ "version": "0.6.0",
4
4
  "description": "Bounded declarative AI-generated interfaces for AIGUI.",
5
5
  "keywords": [
6
6
  "llm",
@@ -49,7 +49,7 @@
49
49
  "access": "public"
50
50
  },
51
51
  "dependencies": {
52
- "@ai-gui/core": "0.4.4"
52
+ "@ai-gui/core": "0.6.0"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsdown",