@zenera/chat-widget 0.1.5 → 0.1.6

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 (34) hide show
  1. package/README.md +45 -1
  2. package/dist/catalog-BYJPdVB0.js +358 -0
  3. package/dist/index-Dw5Lv6cs.js +3151 -0
  4. package/dist/index.js +22 -14
  5. package/dist/shadow-CEK6vAGQ.js +4 -0
  6. package/dist/styles.css +1 -1
  7. package/dist/types/packages/chat-widget/src/index.d.ts +4 -2
  8. package/dist/types/packages/chat-widget/src/interceptors.d.ts +50 -0
  9. package/dist/types/packages/chat-widget/src/reducer.d.ts +14 -0
  10. package/dist/types/packages/chat-widget/src/transport.d.ts +32 -2
  11. package/dist/types/packages/chat-widget/src/ui/ChatThreadView.d.ts +22 -2
  12. package/dist/types/packages/chat-widget/src/ui/ZeneraChat.d.ts +8 -2
  13. package/dist/types/packages/chat-widget/src/useAttachments.d.ts +32 -0
  14. package/dist/types/packages/chat-widget/src/useChatThread.d.ts +3 -2
  15. package/dist/types/packages/chat-widget/src/widget.d.ts +8 -2
  16. package/dist/types/shared/components/A2uiSurface.d.ts +3 -0
  17. package/dist/types/shared/components/a2ui/Chart.d.ts +2 -0
  18. package/dist/types/shared/components/a2ui/ChartView.d.ts +3 -0
  19. package/dist/types/shared/components/a2ui/DataTable.d.ts +2 -0
  20. package/dist/types/shared/components/a2ui/Notice.d.ts +6 -0
  21. package/dist/types/shared/components/a2ui/catalog.d.ts +2 -0
  22. package/dist/types/shared/components/a2ui/catalogApi.d.ts +16 -0
  23. package/dist/types/shared/components/a2ui/chartData.d.ts +8 -0
  24. package/dist/types/shared/components/a2ui/tableData.d.ts +21 -0
  25. package/dist/types/shared/components/a2ui/useChartPayload.d.ts +9 -0
  26. package/dist/types/shared/lib/a2ui.d.ts +22 -0
  27. package/dist/types/shared/lib/a2uiData.d.ts +2 -0
  28. package/dist/types/shared/lib/a2uiFeed.d.ts +40 -0
  29. package/dist/ui.js +15 -2822
  30. package/dist/useThreadList-BbWSgDw_.js +899 -0
  31. package/dist/widget/chat-widget.iife.js +6179 -88
  32. package/package.json +7 -9
  33. package/dist/shadow-BRAwePHz.js +0 -4
  34. package/dist/useThreadList-Pg29akQ4.js +0 -576
@@ -0,0 +1,16 @@
1
+ import { basicCatalog } from '@a2ui/web_core/v0_9';
2
+ import type { ComponentApi } from '@a2ui/web_core/v0_9';
3
+ /** An identifier, never fetched. Changing it breaks the agents' validators. */
4
+ export declare const ZENERA_CATALOG_ID = "https://zenera.ai/a2ui/catalogs/zenera/v1/catalog.json";
5
+ /** What an EChart's properties are, once the renderer has checked them against ChartApi. */
6
+ export interface ChartProps {
7
+ apiUrl: string;
8
+ }
9
+ export declare const ChartApi: ComponentApi;
10
+ /** What a DataTable's properties are, once checked against TableApi. */
11
+ export interface TableProps {
12
+ apiUrl: string;
13
+ pageSize?: number;
14
+ }
15
+ export declare const TableApi: ComponentApi;
16
+ export declare const deriveZeneraCatalog: (zenera: ComponentApi[]) => typeof basicCatalog;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A copy of a parsed option without what must not reach echarts: object-internal keys, the keys
3
+ * of OPTION_KEYS, `image://` symbols, a `formatter` with markup (tooltips are HTML), and
4
+ * anything nested deeper than MAX_DEPTH.
5
+ */
6
+ export declare function clean(value: unknown, depth?: number): unknown;
7
+ /** The option an answer is, cleaned; null when the answer is not an object or has nothing in it. */
8
+ export declare function parseChart(payload: unknown): Record<string, unknown> | null;
@@ -0,0 +1,21 @@
1
+ export type ColumnType = 'string' | 'number' | 'date' | 'boolean';
2
+ export type Cell = string | number | boolean | null;
3
+ export type Row = Record<string, Cell>;
4
+ export interface Column {
5
+ key: string;
6
+ label: string;
7
+ type: ColumnType;
8
+ sortable: boolean;
9
+ align: 'left' | 'right' | 'center';
10
+ }
11
+ export interface TablePage {
12
+ columns: Column[];
13
+ rows: Row[];
14
+ /** Rows of the whole table, not of this page. */
15
+ total: number;
16
+ }
17
+ /** The page an answer is; null when it is not an object or has no rows and no columns. */
18
+ export declare function parseTable(payload: unknown): TablePage | null;
19
+ export declare function formatCell(value: Cell, type: ColumnType): string;
20
+ /** A copy of `rows` ordered by a column; empty cells come last either way, ties keep their order. */
21
+ export declare function sortRows(rows: Row[], column: Column, direction: 'asc' | 'desc'): Row[];
@@ -0,0 +1,9 @@
1
+ export type ChartPayload = {
2
+ status: 'loading';
3
+ } | {
4
+ status: 'failed';
5
+ } | {
6
+ status: 'ready';
7
+ payload: unknown;
8
+ };
9
+ export declare function useChartPayload(apiUrl: string): ChartPayload;
@@ -0,0 +1,22 @@
1
+ export interface ParsedA2ui {
2
+ messages: Record<string, unknown>[];
3
+ /**
4
+ * The updateComponents message still being written, cut down to the components already
5
+ * complete in it, so a form can appear component by component while its message streams.
6
+ */
7
+ partial?: Record<string, unknown> & {
8
+ updateComponents: {
9
+ surfaceId: string;
10
+ components: unknown[];
11
+ };
12
+ };
13
+ /** the text cannot be a stream of A2UI messages: the block is not (valid) A2UI */
14
+ broken: boolean;
15
+ }
16
+ export declare function parseA2ui(code: string): ParsedA2ui;
17
+ /**
18
+ * The ids of the components this one shows inside itself (children, a Card's child, Tabs,
19
+ * a Modal's trigger and content), or null for a leaf such as Text. A container with none
20
+ * of its children available has nothing to show.
21
+ */
22
+ export declare function childRefs(component: Record<string, unknown>): string[] | null;
@@ -0,0 +1,2 @@
1
+ /** `origin`: where relative URLs lead and whose requests carry cookies; the page's by default. */
2
+ export declare function fetchChart(apiUrl: string, signal?: AbortSignal, origin?: string): Promise<unknown>;
@@ -0,0 +1,40 @@
1
+ import type { ReactCatalogComponent } from '@a2ui/react/v0_9';
2
+ import type { SurfaceModel } from '@a2ui/web_core/v0_9';
3
+ import { type ParsedA2ui } from './a2ui.js';
4
+ export type A2uiLib = Awaited<ReturnType<typeof loadA2ui>>;
5
+ export declare const loadA2ui: () => Promise<{
6
+ core: typeof import("@a2ui/web_core/v0_9");
7
+ catalog: (typeof import("../components/a2ui/catalog.js"))["zeneraCatalog"];
8
+ Surface: (typeof import("@a2ui/react/v0_9"))["A2uiSurface"];
9
+ }>;
10
+ export interface FeedState {
11
+ /** the surfaces with something to show: their root component is there */
12
+ surfaces: SurfaceModel<ReactCatalogComponent>[];
13
+ /**
14
+ * ready: there is something to draw; building: nothing yet; rejected: the processor
15
+ * refused what came and there is nothing to draw; deleted: every surface was removed again
16
+ */
17
+ status: 'ready' | 'building' | 'rejected' | 'deleted';
18
+ }
19
+ export declare class A2uiFeed {
20
+ private lib;
21
+ private processor;
22
+ private code;
23
+ private fed;
24
+ private rejected;
25
+ /** per surface, the components waiting for one of their children */
26
+ private held;
27
+ constructor(lib: A2uiLib);
28
+ /** `parsed` is parseA2ui(code), which the caller already needs. */
29
+ update(code: string, { messages, partial }: ParsedA2ui): FeedState;
30
+ dispose(): void;
31
+ private reset;
32
+ /** Returns the errors the processor reported for the message. */
33
+ private send;
34
+ /**
35
+ * Cuts an updateComponents message down to the components that can be shown: leaves, and
36
+ * containers with a child that is already on the surface or comes with them. The rest wait
37
+ * and are tried again with every later message. Returns null when nothing can be shown yet.
38
+ */
39
+ private withoutEmptyContainers;
40
+ }