@epam/ai-dial-visualizer-connector 0.50.0-dev.10 → 0.50.0-dev.12

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.
Files changed (2) hide show
  1. package/README.md +69 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  DIAL Visualizer Connector is a library for connecting DIAL CHAT with custom visualizers - applications which could visualize some special type data (for example **plot data** for the **Plotly**).
4
4
 
5
+ This is the **chat side** of the integration: it creates the iframe, shows a loader until the embedded page is ready, and exchanges post messages with it. The embedded page uses [DIAL Chat Visualizer Connector](../chat-visualizer-connector/README.md).
6
+
5
7
  ## Public classes to use
6
8
 
7
9
  `VisualizerConnector` - class which creates iframe with provided **VisualizerConnector**, allows to interact with **Visualizer** rendered in the iframe (send data). Types for configuration options is `VisualizerConnectorOptions`.
@@ -10,4 +12,70 @@ DIAL Visualizer Connector is a library for connecting DIAL CHAT with custom visu
10
12
 
11
13
  How to configure your DIAL CHAT to use **Custom Visualizers** you could find [here](../chat-visualizer-connector/README.md).
12
14
 
13
- At **Visualizer** side should be used [DIAL Chat VIsualizer Connector](../chat-visualizer-connector/README.md)
15
+ At **Visualizer** side should be used [DIAL Chat VIsualizer Connector](../chat-visualizer-connector/README.md).
16
+
17
+ For **Custom Viewers** (a viewer replacing the whole chat UI for an application) see [Custom Viewers](../../docs/CUSTOM-VIEWERS.md).
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { VisualizerConnectorRequests } from '@epam/ai-dial-shared';
23
+ import { VisualizerConnector } from '@epam/ai-dial-visualizer-connector';
24
+
25
+ const visualizer = new VisualizerConnector(containerElement, {
26
+ domain: 'http://localhost:8000',
27
+ hostDomain: window.location.origin,
28
+ visualizerName: 'CUSTOM_VISUALIZER',
29
+ loaderClass: 'bg-layer-1',
30
+ });
31
+
32
+ await visualizer.ready();
33
+
34
+ await visualizer.send(VisualizerConnectorRequests.sendVisualizeData, {
35
+ mimeType: 'application/json',
36
+ visualizerData: { layout: { width: 0, height: 0 } },
37
+ });
38
+
39
+ visualizer.destroy();
40
+ ```
41
+
42
+ The in-repo consumer is `apps/chat/src/components/IframeRenderer` — use it as a reference.
43
+
44
+ ## Options
45
+
46
+ ```typescript
47
+ interface VisualizerConnectorOptions {
48
+ domain: string; // origin of the embedded visualizer/viewer - also the postMessage target origin
49
+ hostDomain: string; // origin of the DIAL Chat host
50
+ visualizerName: string; // message namespace, must match the visualizer's appName
51
+ loaderStyles?: Styles; // overrides for the built-in loader styles
52
+ loaderClass?: string; // className applied to the loader element
53
+ loaderInnerHTML?: string; // custom loader markup (defaults to a built-in spinner SVG)
54
+ requestTimeout?: number; // per-request timeout in ms
55
+ }
56
+ ```
57
+
58
+ ## Message naming
59
+
60
+ Every message is namespaced with the visualizer name: `<visualizerName>/<TYPE>`. Responses are `<visualizerName>/<TYPE>/RESPONSE` and carry the originating `requestId`. Message types come from the `VisualizerConnectorRequests` and `VisualizerConnectorEvents` enums exported by `@epam/ai-dial-shared` — see the [event reference](../chat-visualizer-connector/README.md#event-and-request-types).
61
+
62
+ Messages are accepted only from the connector's own iframe, so multiple connectors can coexist on one page.
63
+
64
+ ## API
65
+
66
+ | Method | Description |
67
+ | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
68
+ | `constructor(root, options)` | Creates the iframe and loader inside `root` (an element or a selector; throws if the selector matches nothing) |
69
+ | `ready(): Promise<boolean>` | Resolves once the embedded page has sent `READY_TO_INTERACT` |
70
+ | `send(type, payload?, waitForReady = true)` | Sends a request and resolves with the response payload. Awaits `ready()` first unless `waitForReady` is `false`. Resolves `undefined` if destroyed or detached |
71
+ | `subscribe(eventType, callback)` | Subscribes to events sent without a `requestId`. Returns an unsubscribe function |
72
+ | `setVisualizerConnectorOptions(options)` | Replaces the current options |
73
+ | `destroy()` | Removes the listener, rejects pending work and removes the iframe and loader |
74
+
75
+ ## Loader
76
+
77
+ A loader element is shown over the iframe from construction until the embedded page sends `READY` or `READY_TO_INTERACT`. By default it is an absolutely positioned, centred spinner SVG on a white background (`z-index: 2`); override it with `loaderClass`, `loaderStyles` or `loaderInnerHTML`.
78
+
79
+ ## Iframe sandbox
80
+
81
+ The created iframe is sandboxed with `allow-same-origin`, `allow-scripts`, `allow-modals`, `allow-forms`, `allow-downloads`, `allow-popups` and `allow-presentation`, and permits `clipboard-write`, `fullscreen`, `accelerometer`, `gyroscope`, `autoplay`, `web-share` and `encrypted-media`. It loads lazily and fills its container.
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@epam/ai-dial-visualizer-connector",
3
3
  "description": "Package for connecting custom visualizer into DIAL Chat",
4
4
  "homepage": "https://dialx.ai",
5
- "version": "0.50.0-dev.10",
5
+ "version": "0.50.0-dev.12",
6
6
  "dependencies": {
7
- "@epam/ai-dial-shared": "0.50.0-dev.10"
7
+ "@epam/ai-dial-shared": "0.50.0-dev.12"
8
8
  },
9
9
  "type": "module",
10
10
  "bugs": {