@corti/embedded-web 0.2.0 → 1.0.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/bundle.js CHANGED
@@ -1026,12 +1026,40 @@ var __decorate = function(decorators, target, key, desc) {
1026
1026
  return c4 > 3 && r5 && Object.defineProperty(target, key, r5), r5;
1027
1027
  };
1028
1028
  var IFRAME_SANDBOX_POLICY = "allow-forms allow-modals allow-scripts allow-same-origin";
1029
- var CortiEmbedded = class extends i4 {
1029
+ var DEPRECATION_TIMELINE_URL = "https://docs.corti.ai/assistant/deprecation-timeline";
1030
+ var CONFIGURATION_MIGRATION_URL = "https://docs.corti.ai/assistant/configuration-migration";
1031
+ var DEPRECATED_EVENT_SUBSCRIPTIONS = /* @__PURE__ */ new Set([
1032
+ "ready",
1033
+ "loaded",
1034
+ "recordingStarted",
1035
+ "recordingStopped",
1036
+ "documentGenerated",
1037
+ "documentUpdated",
1038
+ "documentSynced",
1039
+ "authChanged",
1040
+ "interactionCreated",
1041
+ "navigationChanged",
1042
+ "usage",
1043
+ "embedded-event"
1044
+ ]);
1045
+ var CortiEmbedded = class _CortiEmbedded extends i4 {
1030
1046
  constructor() {
1031
1047
  super(...arguments);
1032
1048
  this.visibility = "hidden";
1033
1049
  this.postMessageHandler = null;
1034
1050
  this.normalizedBaseURL = null;
1051
+ this.warnedDeprecatedEventSubscriptions = /* @__PURE__ */ new Set();
1052
+ }
1053
+ addEventListener(type, callback, options) {
1054
+ this.warnDeprecatedEventSubscription(type);
1055
+ super.addEventListener(type, callback, options);
1056
+ }
1057
+ warnDeprecatedEventSubscription(eventName) {
1058
+ if (!DEPRECATED_EVENT_SUBSCRIPTIONS.has(eventName) || this.warnedDeprecatedEventSubscriptions.has(eventName)) {
1059
+ return;
1060
+ }
1061
+ this.warnedDeprecatedEventSubscriptions.add(eventName);
1062
+ console.warn(`[Corti Embedded] The '${eventName}' event subscription is deprecated and will be removed in a future release. Subscribe to the canonical 'event' stream instead. See ${DEPRECATION_TIMELINE_URL}.`);
1035
1063
  }
1036
1064
  // eslint-disable-next-line class-methods-use-this
1037
1065
  getIframeAllowPolicy(normalizedBaseURL) {
@@ -1107,6 +1135,9 @@ var CortiEmbedded = class extends i4 {
1107
1135
  dispatchErrorEvent(error) {
1108
1136
  this.dispatchPublicEvent("error", error);
1109
1137
  }
1138
+ static warnDeprecatedAPI(methodName, replacement) {
1139
+ console.warn(`[Corti Embedded] ${methodName} is deprecated and will be removed in a future release. Use ${replacement} instead. See ${CONFIGURATION_MIGRATION_URL} and ${DEPRECATION_TIMELINE_URL}.`);
1140
+ }
1110
1141
  isRealIframeLoad(iframe) {
1111
1142
  const src = iframe.getAttribute("src") || "";
1112
1143
  if (!this.normalizedBaseURL)
@@ -1240,6 +1271,7 @@ var CortiEmbedded = class extends i4 {
1240
1271
  throw new Error("Component not ready");
1241
1272
  }
1242
1273
  try {
1274
+ _CortiEmbedded.warnDeprecatedAPI("configureSession()", "setInteractionOptions()");
1243
1275
  const payload = {
1244
1276
  defaultLanguage: config.defaultLanguage,
1245
1277
  defaultOutputLanguage: config.defaultOutputLanguage,
@@ -1281,20 +1313,20 @@ var CortiEmbedded = class extends i4 {
1281
1313
  }
1282
1314
  /**
1283
1315
  * Navigate to a specific path within the embedded UI
1284
- * @param path Path to navigate to
1316
+ * @param payload Navigation request payload or legacy path string
1285
1317
  * @returns Promise that resolves when navigation is complete
1286
1318
  */
1287
- async navigate(path) {
1319
+ async navigate(payload) {
1288
1320
  if (!this.postMessageHandler) {
1289
1321
  throw new Error("Component not ready");
1290
1322
  }
1291
1323
  try {
1292
- const payload = { path };
1324
+ const normalizedPayload = typeof payload === "string" ? { path: payload } : payload;
1293
1325
  await this.postMessageHandler.postMessage({
1294
1326
  type: "CORTI_EMBEDDED",
1295
1327
  version: "v1",
1296
1328
  action: "navigate",
1297
- payload
1329
+ payload: normalizedPayload
1298
1330
  });
1299
1331
  } catch (error) {
1300
1332
  const formattedError = formatError(error, "Failed to navigate");
@@ -1372,6 +1404,31 @@ var CortiEmbedded = class extends i4 {
1372
1404
  throw new Error(JSON.stringify(formattedError));
1373
1405
  }
1374
1406
  }
1407
+ /**
1408
+ * Configure the component
1409
+ * @param config Component configuration
1410
+ * @returns Promise that resolves when configuration is applied
1411
+ */
1412
+ async configureApp(config) {
1413
+ if (!this.postMessageHandler) {
1414
+ throw new Error("Component not ready");
1415
+ }
1416
+ try {
1417
+ const response = await this.postMessageHandler.postMessage({
1418
+ type: "CORTI_EMBEDDED",
1419
+ version: "v1",
1420
+ action: "configureApp",
1421
+ payload: config
1422
+ });
1423
+ if (response.success && response.payload) {
1424
+ return response.payload;
1425
+ }
1426
+ throw new Error(response.error);
1427
+ } catch (error) {
1428
+ const formattedError = formatError(error, "Failed to configure app");
1429
+ throw new Error(JSON.stringify(formattedError));
1430
+ }
1431
+ }
1375
1432
  /**
1376
1433
  * Configure the component
1377
1434
  * @param config Component configuration
@@ -1382,6 +1439,7 @@ var CortiEmbedded = class extends i4 {
1382
1439
  throw new Error("Component not ready");
1383
1440
  }
1384
1441
  try {
1442
+ _CortiEmbedded.warnDeprecatedAPI("configure()", "configureApp()");
1385
1443
  const response = await this.postMessageHandler.postMessage({
1386
1444
  type: "CORTI_EMBEDDED",
1387
1445
  version: "v1",
@@ -1397,6 +1455,30 @@ var CortiEmbedded = class extends i4 {
1397
1455
  throw new Error(JSON.stringify(formattedError));
1398
1456
  }
1399
1457
  }
1458
+ /**
1459
+ * Set one-shot interaction options for the embedded instance.
1460
+ * @param config Interaction/session-level options
1461
+ * @returns Promise that resolves when options are applied
1462
+ */
1463
+ async setInteractionOptions(config) {
1464
+ if (!this.postMessageHandler) {
1465
+ throw new Error("Component not ready");
1466
+ }
1467
+ try {
1468
+ const response = await this.postMessageHandler.postMessage({
1469
+ type: "CORTI_EMBEDDED",
1470
+ version: "v1",
1471
+ action: "setInteractionOptions",
1472
+ payload: config
1473
+ });
1474
+ if (response.success === false || response.error) {
1475
+ throw new Error(response.error);
1476
+ }
1477
+ } catch (error) {
1478
+ const formattedError = formatError(error, "Failed to set interaction options");
1479
+ throw new Error(JSON.stringify(formattedError));
1480
+ }
1481
+ }
1400
1482
  /**
1401
1483
  * Set authentication credentials without triggering auth flow
1402
1484
  * @param credentials Authentication credentials to store
@@ -1455,6 +1537,31 @@ var CortiEmbedded = class extends i4 {
1455
1537
  throw new Error(JSON.stringify(formattedError));
1456
1538
  }
1457
1539
  }
1540
+ /**
1541
+ * Show the device-link QR code in the embedded UI
1542
+ * @param payload Device-link token response to render as a QR code
1543
+ * @returns Promise resolving to the rendered QR code state
1544
+ */
1545
+ async showDeviceLinkQR(payload) {
1546
+ if (!this.postMessageHandler) {
1547
+ throw new Error("Component not ready");
1548
+ }
1549
+ try {
1550
+ const response = await this.postMessageHandler.postMessage({
1551
+ type: "CORTI_EMBEDDED",
1552
+ version: "v1",
1553
+ action: "showDeviceLinkQR",
1554
+ payload
1555
+ });
1556
+ if (response.success && response.payload) {
1557
+ return response.payload;
1558
+ }
1559
+ throw new Error(response.error);
1560
+ } catch (error) {
1561
+ const formattedError = formatError(error, "Failed to show device link QR");
1562
+ throw new Error(JSON.stringify(formattedError));
1563
+ }
1564
+ }
1458
1565
  /**
1459
1566
  * Check the current status of the iframe and PostMessageHandler
1460
1567
  * Useful for debugging
@@ -1635,9 +1742,12 @@ function useCortiEmbeddedApi(ref) {
1635
1742
  startRecording: (...args) => getInstance().startRecording(...args),
1636
1743
  stopRecording: (...args) => getInstance().stopRecording(...args),
1637
1744
  getStatus: (...args) => getInstance().getStatus(...args),
1745
+ configureApp: (...args) => getInstance().configureApp(...args),
1638
1746
  configure: (...args) => getInstance().configure(...args),
1747
+ setInteractionOptions: (...args) => getInstance().setInteractionOptions(...args),
1639
1748
  getTemplates: (...args) => getInstance().getTemplates(...args),
1640
1749
  setCredentials: (...args) => getInstance().setCredentials(...args),
1750
+ showDeviceLinkQR: (...args) => getInstance().showDeviceLinkQR(...args),
1641
1751
  show: (...args) => getInstance().show(...args),
1642
1752
  hide: (...args) => getInstance().hide(...args)
1643
1753
  }), [getInstance]);
@@ -1,4 +1,4 @@
1
- import type { CortiEmbeddedAPI, CortiEmbeddedWindowAPI } from "./types/api.js";
1
+ import type { CortiEmbeddedAPI, CortiEmbeddedWindowAPI } from "./public-types.js";
2
2
  /**
3
3
  * Type representing the corti-embedded custom element in the DOM.
4
4
  * When this package is installed, tag-name based APIs like
@@ -1 +1 @@
1
- {"version":3,"file":"corti-embedded.js","sourceRoot":"","sources":["../src/corti-embedded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,8BAA8B;AAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;IAC1C,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import { CortiEmbedded } from \"./CortiEmbedded.js\";\nimport type { CortiEmbeddedAPI, CortiEmbeddedWindowAPI } from \"./types/api.js\";\n\n// Register the main component\nif (!customElements.get(\"corti-embedded\")) {\n customElements.define(\"corti-embedded\", CortiEmbedded);\n}\n\n/**\n * Type representing the corti-embedded custom element in the DOM.\n * When this package is installed, tag-name based APIs like\n * document.querySelector('corti-embedded') and document.createElement('corti-embedded')\n * are automatically typed via HTMLElementTagNameMap. Other lookups such as getElementById\n * still return HTMLElement | null and require a cast or narrowing to CortiEmbeddedElement.\n */\nexport type CortiEmbeddedElement = HTMLElement & CortiEmbeddedAPI;\n\n// Extend Window interface\ndeclare global {\n interface Window {\n CortiEmbedded?: CortiEmbeddedWindowAPI;\n }\n interface HTMLElementTagNameMap {\n \"corti-embedded\": CortiEmbeddedElement;\n }\n}\n"]}
1
+ {"version":3,"file":"corti-embedded.js","sourceRoot":"","sources":["../src/corti-embedded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,8BAA8B;AAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;IAC1C,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import { CortiEmbedded } from \"./CortiEmbedded.js\";\nimport type {\n CortiEmbeddedAPI,\n CortiEmbeddedWindowAPI,\n} from \"./public-types.js\";\n\n// Register the main component\nif (!customElements.get(\"corti-embedded\")) {\n customElements.define(\"corti-embedded\", CortiEmbedded);\n}\n\n/**\n * Type representing the corti-embedded custom element in the DOM.\n * When this package is installed, tag-name based APIs like\n * document.querySelector('corti-embedded') and document.createElement('corti-embedded')\n * are automatically typed via HTMLElementTagNameMap. Other lookups such as getElementById\n * still return HTMLElement | null and require a cast or narrowing to CortiEmbeddedElement.\n */\nexport type CortiEmbeddedElement = HTMLElement & CortiEmbeddedAPI;\n\n// Extend Window interface\ndeclare global {\n interface Window {\n CortiEmbedded?: CortiEmbeddedWindowAPI;\n }\n interface HTMLElementTagNameMap {\n \"corti-embedded\": CortiEmbeddedElement;\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./corti-embedded.js";
2
2
  export { CortiEmbedded } from "./CortiEmbedded.js";
3
3
  export * from "./react/index.js";
4
- export * from "./types/index.js";
4
+ export * from "./public-types.js";
5
5
  export type { PostMessageHandlerCallbacks } from "./utils/PostMessageHandler.js";
package/dist/index.js CHANGED
@@ -2,6 +2,6 @@ import "./corti-embedded.js";
2
2
  export { CortiEmbedded } from "./CortiEmbedded.js";
3
3
  // Export React components
4
4
  export * from "./react/index.js";
5
- // Export clean public types only
6
- export * from "./types/index.js";
5
+ // Export hand-owned public types only. The src/types folder is generated.
6
+ export * from "./public-types.js";
7
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,0BAA0B;AAC1B,cAAc,kBAAkB,CAAC;AAEjC,iCAAiC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["import \"./corti-embedded.js\";\n\nexport { CortiEmbedded } from \"./CortiEmbedded.js\";\n\n// Export React components\nexport * from \"./react/index.js\";\n\n// Export clean public types only\nexport * from \"./types/index.js\";\n\n// Export PostMessageHandler types for advanced usage\nexport type { PostMessageHandlerCallbacks } from \"./utils/PostMessageHandler.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,0BAA0B;AAC1B,cAAc,kBAAkB,CAAC;AAEjC,0EAA0E;AAC1E,cAAc,mBAAmB,CAAC","sourcesContent":["import \"./corti-embedded.js\";\n\nexport { CortiEmbedded } from \"./CortiEmbedded.js\";\n\n// Export React components\nexport * from \"./react/index.js\";\n\n// Export hand-owned public types only. The src/types folder is generated.\nexport * from \"./public-types.js\";\n\n// Export PostMessageHandler types for advanced usage\nexport type { PostMessageHandlerCallbacks } from \"./utils/PostMessageHandler.js\";\n"]}
@@ -0,0 +1,192 @@
1
+ import type { ConfigureAppPayload as GeneratedConfigureApplicationPayload, ConfigureFeaturesConfig, ConfigurePayload } from "./types/config.js";
2
+ import type { AuthChangedEventPayload, DocumentEventPayload, ErrorEventPayload, InteractionCreatedEventPayload, NavigationChangedEventPayload, UsageEventPayload } from "./types/events.js";
3
+ import type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, DeviceLinkTokenResponse, Fact, KeycloakTokenResponse, NavigatePayload, SetCredentialsPayload, SetInteractionOptionsPayload } from "./types/payloads.js";
4
+ import type { DefaultMode } from "./types/protocol.js";
5
+ import type { AuthResponse, ConfigureAppResponse as GeneratedConfigureApplicationResponse, ConfigureResponse, CreateInteractionResponse, GetStatusResponse, GetTemplatesResponse, ShowDeviceLinkQRResponse } from "./types/responses.js";
6
+ export type { AppearanceConfig, ConfigureFeaturesConfig, ConfigurePayload, LocaleConfig, NetworkConfig, UIConfig, } from "./types/config.js";
7
+ export type { AuthChangedEventPayload, DocumentEventPayload, ErrorEventPayload, InteractionCreatedEventPayload, NavigationChangedEventPayload, UsageEventPayload, } from "./types/events.js";
8
+ export type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, DeviceLinkTokenResponse, Fact, KeycloakTokenResponse, NavigatePayload, SetCredentialsPayload, SetInteractionOptionsPayload, } from "./types/payloads.js";
9
+ export type { AnyDeprecatedEmbeddedEvent, AnyEmbeddedMessage, AnyEmbeddedRequest, AnyEmbeddedResponse, AnyEvent, APIVersion, BaseMessage, DeprecatedEmbeddedEvent, EmbeddedAction, EmbeddedEventMessage, EmbeddedRequest, EmbeddedResponse, MessageType, } from "./types/protocol.js";
10
+ export type { AuthResponse, ConfigureResponse, CreateInteractionResponse, EmbeddedTemplate, GetStatusResponse, GetTemplatesResponse, ShowDeviceLinkQRResponse, UserInfo, } from "./types/responses.js";
11
+ /**
12
+ * @deprecated Use ConfigureFeaturesConfig instead.
13
+ */
14
+ export type FeaturesConfig = ConfigureFeaturesConfig;
15
+ /**
16
+ * @deprecated Use ConfigurePayload for configure() or ConfigureApplicationPayload for configureApp().
17
+ */
18
+ export type ConfigureAppPayload = ConfigurePayload;
19
+ export type ConfigureApplicationPayload = GeneratedConfigureApplicationPayload;
20
+ /**
21
+ * @deprecated Use ConfigureResponse for configure() or ConfigureApplicationResponse for configureApp().
22
+ */
23
+ export type ConfigureAppResponse = ConfigureResponse;
24
+ export type ConfigureApplicationResponse = GeneratedConfigureApplicationResponse;
25
+ /**
26
+ * User information returned from authentication
27
+ */
28
+ export interface User {
29
+ id: string;
30
+ email: string;
31
+ }
32
+ /**
33
+ * Details of a created interaction
34
+ */
35
+ export interface InteractionDetails {
36
+ id: string;
37
+ createdAt: string;
38
+ }
39
+ /**
40
+ * Session configuration options
41
+ */
42
+ export interface SessionConfig {
43
+ defaultLanguage?: string;
44
+ defaultOutputLanguage?: string;
45
+ defaultTemplateKey?: string;
46
+ defaultMode?: DefaultMode;
47
+ }
48
+ /**
49
+ * Event data types for component events
50
+ */
51
+ export interface EmbeddedEventData {
52
+ ready: undefined;
53
+ "auth-changed": AuthChangedEventPayload;
54
+ "interaction-created": InteractionCreatedEventPayload;
55
+ "recording-started": undefined;
56
+ "recording-stopped": undefined;
57
+ "document-generated": DocumentEventPayload;
58
+ "document-updated": DocumentEventPayload;
59
+ "document-synced": DocumentEventPayload;
60
+ "navigation-changed": NavigationChangedEventPayload;
61
+ usage: UsageEventPayload;
62
+ error: ErrorEventPayload;
63
+ }
64
+ export interface CortiEmbeddedV1API {
65
+ auth(payload: KeycloakTokenResponse): Promise<AuthResponse>;
66
+ createInteraction(payload: CreateInteractionPayload): Promise<CreateInteractionResponse>;
67
+ addFacts(payload: AddFactsPayload): Promise<void>;
68
+ configureApp(payload: ConfigureApplicationPayload): Promise<ConfigureApplicationResponse>;
69
+ configureSession(payload: ConfigureSessionPayload): Promise<void>;
70
+ setInteractionOptions(payload: SetInteractionOptionsPayload): Promise<void>;
71
+ configure(payload: ConfigurePayload): Promise<ConfigureResponse>;
72
+ navigate(payload: NavigatePayload): Promise<void>;
73
+ startRecording(): Promise<void>;
74
+ stopRecording(): Promise<void>;
75
+ setCredentials(payload: SetCredentialsPayload): Promise<void>;
76
+ getStatus(): Promise<GetStatusResponse>;
77
+ getTemplates(): Promise<GetTemplatesResponse>;
78
+ showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
79
+ }
80
+ export interface CortiEmbeddedWindowAPI {
81
+ v1: CortiEmbeddedV1API;
82
+ }
83
+ declare global {
84
+ interface Window {
85
+ CortiEmbedded?: CortiEmbeddedWindowAPI;
86
+ }
87
+ }
88
+ /**
89
+ * Event listener function type
90
+ */
91
+ export type EventListener<T = unknown> = (data: T) => void;
92
+ /**
93
+ * Public API interface for the Corti Embedded component
94
+ */
95
+ export interface CortiEmbeddedAPI {
96
+ /**
97
+ * Authenticate with the Corti system
98
+ * @param credentials Authentication credentials
99
+ * @returns Promise resolving to user information
100
+ */
101
+ auth(credentials: KeycloakTokenResponse): Promise<User>;
102
+ /**
103
+ * Create a new interaction
104
+ * @param encounter Encounter request data
105
+ * @returns Promise resolving to interaction details
106
+ */
107
+ createInteraction(encounter: CreateInteractionPayload): Promise<InteractionDetails>;
108
+ /**
109
+ * Configure the current session
110
+ * @param config Session configuration
111
+ * @returns Promise that resolves when configuration is complete
112
+ * @deprecated Use setInteractionOptions() instead. See https://docs.corti.ai/assistant/deprecation-timeline.
113
+ */
114
+ configureSession(config: SessionConfig): Promise<void>;
115
+ /**
116
+ * Add facts to the current session
117
+ * @param facts Array of facts to add
118
+ * @returns Promise that resolves when facts are added
119
+ */
120
+ addFacts(facts: Fact[]): Promise<void>;
121
+ /**
122
+ * Navigate to a specific path within the embedded UI
123
+ * @param payload Navigation request payload or legacy path string
124
+ * @returns Promise that resolves when navigation is complete
125
+ */
126
+ navigate(payload: NavigatePayload | string): Promise<void>;
127
+ /**
128
+ * Start recording
129
+ * @returns Promise that resolves when recording starts
130
+ */
131
+ startRecording(): Promise<void>;
132
+ /**
133
+ * Stop recording
134
+ * @returns Promise that resolves when recording stops
135
+ */
136
+ stopRecording(): Promise<void>;
137
+ /**
138
+ * Get current component status
139
+ * @returns Promise resolving to current status
140
+ */
141
+ getStatus(): Promise<GetStatusResponse>;
142
+ /**
143
+ * Get all templates available to the current user
144
+ * @returns Promise resolving to list of templates
145
+ */
146
+ getTemplates(): Promise<GetTemplatesResponse>;
147
+ /**
148
+ * Configure the embedded application
149
+ * @param config Application-level configuration
150
+ * @returns Promise that resolves when configuration is applied
151
+ */
152
+ configureApp(config: ConfigureApplicationPayload): Promise<ConfigureApplicationResponse>;
153
+ /**
154
+ * Configure the application
155
+ * @param config Application configuration
156
+ * @returns Promise that resolves when configuration is applied
157
+ * @deprecated Use configureApp() and setInteractionOptions() instead. See https://docs.corti.ai/assistant/deprecation-timeline.
158
+ */
159
+ configure(config: ConfigurePayload): Promise<ConfigureResponse>;
160
+ /**
161
+ * Set one-shot interaction options for the embedded instance.
162
+ *
163
+ * Each call applies the provided interaction-options branches to the current
164
+ * snapshot for the embedded instance. Omitted branches preserve their existing
165
+ * values from previous calls.
166
+ * @param config Interaction/session-level options
167
+ * @returns Promise that resolves when options are applied
168
+ */
169
+ setInteractionOptions(config: SetInteractionOptionsPayload): Promise<void>;
170
+ /**
171
+ * Set authentication credentials without triggering auth flow
172
+ * @param credentials Authentication credentials to store
173
+ * @returns Promise that resolves when credentials are set
174
+ */
175
+ setCredentials(credentials: {
176
+ password: string;
177
+ }): Promise<void>;
178
+ /**
179
+ * Show the embedded UI
180
+ */
181
+ show(): void;
182
+ /**
183
+ * Hide the embedded UI
184
+ */
185
+ hide(): void;
186
+ /**
187
+ * Show the device-link QR code in the embedded UI
188
+ * @param payload Device-link token response to render as a QR code
189
+ * @returns Promise resolving to the rendered QR code state
190
+ */
191
+ showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
192
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=public-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-types.js","sourceRoot":"","sources":["../src/public-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ConfigureAppPayload as GeneratedConfigureApplicationPayload,\n ConfigureFeaturesConfig,\n ConfigurePayload,\n} from \"./types/config.js\";\nimport type {\n AuthChangedEventPayload,\n DocumentEventPayload,\n ErrorEventPayload,\n InteractionCreatedEventPayload,\n NavigationChangedEventPayload,\n UsageEventPayload,\n} from \"./types/events.js\";\nimport type {\n AddFactsPayload,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n DeviceLinkTokenResponse,\n Fact,\n KeycloakTokenResponse,\n NavigatePayload,\n SetCredentialsPayload,\n SetInteractionOptionsPayload,\n} from \"./types/payloads.js\";\nimport type { DefaultMode } from \"./types/protocol.js\";\nimport type {\n AuthResponse,\n ConfigureAppResponse as GeneratedConfigureApplicationResponse,\n ConfigureResponse,\n CreateInteractionResponse,\n GetStatusResponse,\n GetTemplatesResponse,\n ShowDeviceLinkQRResponse,\n} from \"./types/responses.js\";\n\nexport type {\n AppearanceConfig,\n ConfigureFeaturesConfig,\n ConfigurePayload,\n LocaleConfig,\n NetworkConfig,\n UIConfig,\n} from \"./types/config.js\";\nexport type {\n AuthChangedEventPayload,\n DocumentEventPayload,\n ErrorEventPayload,\n InteractionCreatedEventPayload,\n NavigationChangedEventPayload,\n UsageEventPayload,\n} from \"./types/events.js\";\nexport type {\n AddFactsPayload,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n DeviceLinkTokenResponse,\n Fact,\n KeycloakTokenResponse,\n NavigatePayload,\n SetCredentialsPayload,\n SetInteractionOptionsPayload,\n} from \"./types/payloads.js\";\nexport type {\n AnyDeprecatedEmbeddedEvent,\n AnyEmbeddedMessage,\n AnyEmbeddedRequest,\n AnyEmbeddedResponse,\n AnyEvent,\n APIVersion,\n BaseMessage,\n DeprecatedEmbeddedEvent,\n EmbeddedAction,\n EmbeddedEventMessage,\n EmbeddedRequest,\n EmbeddedResponse,\n MessageType,\n} from \"./types/protocol.js\";\nexport type {\n AuthResponse,\n ConfigureResponse,\n CreateInteractionResponse,\n EmbeddedTemplate,\n GetStatusResponse,\n GetTemplatesResponse,\n ShowDeviceLinkQRResponse,\n UserInfo,\n} from \"./types/responses.js\";\n\n/**\n * @deprecated Use ConfigureFeaturesConfig instead.\n */\nexport type FeaturesConfig = ConfigureFeaturesConfig;\n\n/**\n * @deprecated Use ConfigurePayload for configure() or ConfigureApplicationPayload for configureApp().\n */\nexport type ConfigureAppPayload = ConfigurePayload;\n\nexport type ConfigureApplicationPayload = GeneratedConfigureApplicationPayload;\n\n/**\n * @deprecated Use ConfigureResponse for configure() or ConfigureApplicationResponse for configureApp().\n */\nexport type ConfigureAppResponse = ConfigureResponse;\n\nexport type ConfigureApplicationResponse =\n GeneratedConfigureApplicationResponse;\n\n/**\n * User information returned from authentication\n */\nexport interface User {\n id: string;\n email: string;\n}\n\n/**\n * Details of a created interaction\n */\nexport interface InteractionDetails {\n id: string;\n createdAt: string;\n}\n\n/**\n * Session configuration options\n */\nexport interface SessionConfig {\n defaultLanguage?: string;\n defaultOutputLanguage?: string;\n defaultTemplateKey?: string;\n defaultMode?: DefaultMode;\n}\n\n/**\n * Event data types for component events\n */\nexport interface EmbeddedEventData {\n ready: undefined;\n \"auth-changed\": AuthChangedEventPayload;\n \"interaction-created\": InteractionCreatedEventPayload;\n \"recording-started\": undefined;\n \"recording-stopped\": undefined;\n \"document-generated\": DocumentEventPayload;\n \"document-updated\": DocumentEventPayload;\n \"document-synced\": DocumentEventPayload;\n \"navigation-changed\": NavigationChangedEventPayload;\n usage: UsageEventPayload;\n error: ErrorEventPayload;\n}\n\n// Window API Types\nexport interface CortiEmbeddedV1API {\n auth(payload: KeycloakTokenResponse): Promise<AuthResponse>;\n createInteraction(\n payload: CreateInteractionPayload,\n ): Promise<CreateInteractionResponse>;\n addFacts(payload: AddFactsPayload): Promise<void>;\n configureApp(\n payload: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse>;\n configureSession(payload: ConfigureSessionPayload): Promise<void>;\n setInteractionOptions(payload: SetInteractionOptionsPayload): Promise<void>;\n configure(payload: ConfigurePayload): Promise<ConfigureResponse>;\n navigate(payload: NavigatePayload): Promise<void>;\n startRecording(): Promise<void>;\n stopRecording(): Promise<void>;\n setCredentials(payload: SetCredentialsPayload): Promise<void>;\n getStatus(): Promise<GetStatusResponse>;\n getTemplates(): Promise<GetTemplatesResponse>;\n showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse>;\n}\n\nexport interface CortiEmbeddedWindowAPI {\n v1: CortiEmbeddedV1API;\n}\n\ndeclare global {\n interface Window {\n CortiEmbedded?: CortiEmbeddedWindowAPI;\n }\n}\n\n/**\n * Event listener function type\n */\nexport type EventListener<T = unknown> = (data: T) => void;\n\n/**\n * Public API interface for the Corti Embedded component\n */\nexport interface CortiEmbeddedAPI {\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n auth(credentials: KeycloakTokenResponse): Promise<User>;\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails>;\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n * @deprecated Use setInteractionOptions() instead. See https://docs.corti.ai/assistant/deprecation-timeline.\n */\n configureSession(config: SessionConfig): Promise<void>;\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n addFacts(facts: Fact[]): Promise<void>;\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param payload Navigation request payload or legacy path string\n * @returns Promise that resolves when navigation is complete\n */\n navigate(payload: NavigatePayload | string): Promise<void>;\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n startRecording(): Promise<void>;\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n stopRecording(): Promise<void>;\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n getStatus(): Promise<GetStatusResponse>;\n\n /**\n * Get all templates available to the current user\n * @returns Promise resolving to list of templates\n */\n getTemplates(): Promise<GetTemplatesResponse>;\n\n /**\n * Configure the embedded application\n * @param config Application-level configuration\n * @returns Promise that resolves when configuration is applied\n */\n configureApp(\n config: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse>;\n\n /**\n * Configure the application\n * @param config Application configuration\n * @returns Promise that resolves when configuration is applied\n * @deprecated Use configureApp() and setInteractionOptions() instead. See https://docs.corti.ai/assistant/deprecation-timeline.\n */\n configure(config: ConfigurePayload): Promise<ConfigureResponse>;\n\n /**\n * Set one-shot interaction options for the embedded instance.\n *\n * Each call applies the provided interaction-options branches to the current\n * snapshot for the embedded instance. Omitted branches preserve their existing\n * values from previous calls.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n setInteractionOptions(config: SetInteractionOptionsPayload): Promise<void>;\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n setCredentials(credentials: { password: string }): Promise<void>;\n\n /**\n * Show the embedded UI\n */\n show(): void;\n\n /**\n * Hide the embedded UI\n */\n hide(): void;\n\n /**\n * Show the device-link QR code in the embedded UI\n * @param payload Device-link token response to render as a QR code\n * @returns Promise resolving to the rendered QR code state\n */\n showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse>;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import "../corti-embedded.js";
3
3
  import type { CortiEmbedded } from "../CortiEmbedded.js";
4
- import type { CortiEmbeddedAPI } from "../types";
4
+ import type { CortiEmbeddedAPI } from "../public-types.js";
5
5
  export interface CortiEmbeddedEventDetail {
6
6
  name: string;
7
7
  payload: unknown;
@@ -23,7 +23,7 @@ export interface CortiEmbeddedReactProps {
23
23
  style?: React.CSSProperties;
24
24
  }
25
25
  export type CortiEmbeddedReactRef = CortiEmbedded & CortiEmbeddedAPI;
26
- export * from "../types/index.js";
26
+ export * from "../public-types.js";
27
27
  export declare const CortiEmbeddedReact: React.ForwardRefExoticComponent<CortiEmbeddedReactProps & React.RefAttributes<CortiEmbeddedReactRef>>;
28
28
  export interface UseCortiEmbeddedStatusOptions {
29
29
  enabled?: boolean;
@@ -46,9 +46,12 @@ export interface UseCortiEmbeddedApiResult {
46
46
  startRecording: (...args: Parameters<CortiEmbeddedReactRef["startRecording"]>) => ReturnType<CortiEmbeddedReactRef["startRecording"]>;
47
47
  stopRecording: (...args: Parameters<CortiEmbeddedReactRef["stopRecording"]>) => ReturnType<CortiEmbeddedReactRef["stopRecording"]>;
48
48
  getStatus: (...args: Parameters<CortiEmbeddedReactRef["getStatus"]>) => ReturnType<CortiEmbeddedReactRef["getStatus"]>;
49
+ configureApp: (...args: Parameters<CortiEmbeddedReactRef["configureApp"]>) => ReturnType<CortiEmbeddedReactRef["configureApp"]>;
49
50
  configure: (...args: Parameters<CortiEmbeddedReactRef["configure"]>) => ReturnType<CortiEmbeddedReactRef["configure"]>;
51
+ setInteractionOptions: (...args: Parameters<CortiEmbeddedReactRef["setInteractionOptions"]>) => ReturnType<CortiEmbeddedReactRef["setInteractionOptions"]>;
50
52
  getTemplates: (...args: Parameters<CortiEmbeddedReactRef["getTemplates"]>) => ReturnType<CortiEmbeddedReactRef["getTemplates"]>;
51
53
  setCredentials: (...args: Parameters<CortiEmbeddedReactRef["setCredentials"]>) => ReturnType<CortiEmbeddedReactRef["setCredentials"]>;
54
+ showDeviceLinkQR: (...args: Parameters<CortiEmbeddedReactRef["showDeviceLinkQR"]>) => ReturnType<CortiEmbeddedReactRef["showDeviceLinkQR"]>;
52
55
  show: (...args: Parameters<CortiEmbeddedReactRef["show"]>) => ReturnType<CortiEmbeddedReactRef["show"]>;
53
56
  hide: (...args: Parameters<CortiEmbeddedReactRef["hide"]>) => ReturnType<CortiEmbeddedReactRef["hide"]>;
54
57
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import "../corti-embedded.js";
3
3
  // Export public types
4
- export * from "../types/index.js";
4
+ export * from "../public-types.js";
5
5
  // Renders the custom element directly so React sets the ref to the actual
6
6
  // CortiEmbedded DOM instance. This avoids the @lit/react wrapper chain that
7
7
  // was preventing the ref from reaching the DOM node in React 19.
@@ -144,9 +144,12 @@ export function useCortiEmbeddedApi(ref) {
144
144
  startRecording: (...args) => getInstance().startRecording(...args),
145
145
  stopRecording: (...args) => getInstance().stopRecording(...args),
146
146
  getStatus: (...args) => getInstance().getStatus(...args),
147
+ configureApp: (...args) => getInstance().configureApp(...args),
147
148
  configure: (...args) => getInstance().configure(...args),
149
+ setInteractionOptions: (...args) => getInstance().setInteractionOptions(...args),
148
150
  getTemplates: (...args) => getInstance().getTemplates(...args),
149
151
  setCredentials: (...args) => getInstance().setCredentials(...args),
152
+ showDeviceLinkQR: (...args) => getInstance().showDeviceLinkQR(...args),
150
153
  show: (...args) => getInstance().show(...args),
151
154
  hide: (...args) => getInstance().hide(...args),
152
155
  }), [getInstance]);
@@ -1 +1 @@
1
- {"version":3,"file":"CortiEmbeddedReact.js","sourceRoot":"","sources":["../../src/react/CortiEmbeddedReact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAmC9B,sBAAsB;AACtB,cAAc,mBAAmB,CAAC;AAElC,0EAA0E;AAC1E,4EAA4E;AAC5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAIhD,CACE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,EACpE,YAAY,EACZ,EAAE;IACF,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAA+B,IAAI,CAAC,CAAC;IACrE,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/C,sEAAsE;IACtE,gDAAgD;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAC7B,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAC7B,UAAU,C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,IAAI,CAAC;QACxD,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;QAC9D,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;QAClE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC9C,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC/C,CAAC,EACF,CAAC,WAAW,CAAC,CACd,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport \"../corti-embedded.js\";\nimport type { CortiEmbedded } from \"../CortiEmbedded.js\";\nimport type { CortiEmbeddedAPI } from \"../types\";\n\nexport interface CortiEmbeddedEventDetail {\n name: string;\n payload: unknown;\n}\n\nexport type CortiEmbeddedEvent = CustomEvent<CortiEmbeddedEventDetail>;\nexport type CortiEmbeddedReadyEvent = CustomEvent<Record<string, unknown>>;\n\nexport interface CortiEmbeddedErrorDetail {\n message: string;\n code?: string;\n details?: unknown;\n}\n\n// Props interface\nexport interface CortiEmbeddedReactProps {\n baseURL: string;\n visibility?: \"visible\" | \"hidden\";\n\n // Event handlers receive the raw CustomEvent emitted by the custom element.\n onEvent?: (event: CortiEmbeddedEvent) => void;\n onReady?: (event: CortiEmbeddedReadyEvent) => void;\n onError?: (event: CustomEvent<CortiEmbeddedErrorDetail>) => void;\n\n // Additional props\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport type CortiEmbeddedReactRef = CortiEmbedded & CortiEmbeddedAPI;\n\n// Export public types\nexport * from \"../types/index.js\";\n\n// Renders the custom element directly so React sets the ref to the actual\n// CortiEmbedded DOM instance. This avoids the @lit/react wrapper chain that\n// was preventing the ref from reaching the DOM node in React 19.\nexport const CortiEmbeddedReact = React.forwardRef<\n CortiEmbeddedReactRef,\n CortiEmbeddedReactProps\n>(\n (\n { onEvent, onReady, onError, baseURL, visibility, className, style },\n forwardedRef,\n ) => {\n const internalRef = React.useRef<CortiEmbeddedReactRef | null>(null);\n const hasEmittedReadyRef = React.useRef(false);\n\n // \"Latest ref\" pattern: update on every render so handlers are always\n // current without re-attaching event listeners.\n const onEventRef = React.useRef(onEvent);\n const onReadyRef = React.useRef(onReady);\n const onErrorRef = React.useRef(onError);\n onEventRef.current = onEvent;\n onReadyRef.current = onReady;\n onErrorRef.current = onError;\n\n // Expose the DOM element to the consumer's forwarded ref. Native element\n // refs are set during React's mutation phase, before layout effects run,\n // so internalRef.current is always populated when this executes.\n React.useImperativeHandle(forwardedRef, () => internalRef.current!, []);\n\n // Keep LitElement reactive properties in sync with React props.\n React.useLayoutEffect(() => {\n if (internalRef.current) internalRef.current.baseURL = baseURL;\n }, [baseURL]);\n\n React.useLayoutEffect(() => {\n if (internalRef.current == null || visibility === undefined) return;\n internalRef.current.visibility = visibility;\n }, [visibility]);\n\n // Attach DOM event listeners once on mount. The latest-ref pattern above\n // ensures handlers always call the current prop without re-attaching.\n React.useEffect(() => {\n const el = internalRef.current;\n if (!el) return undefined;\n\n const handleEvent = (e: Event) =>\n onEventRef.current?.(e as CortiEmbeddedEvent);\n const handleReady = (e: Event) => {\n if (hasEmittedReadyRef.current) return;\n hasEmittedReadyRef.current = true;\n onReadyRef.current?.(e as CortiEmbeddedReadyEvent);\n };\n const handleError = (e: Event) =>\n onErrorRef.current?.(e as CustomEvent<CortiEmbeddedErrorDetail>);\n\n el.addEventListener(\"event\", handleEvent);\n el.addEventListener(\"embedded.ready\", handleReady);\n el.addEventListener(\"error\", handleError);\n return () => {\n el.removeEventListener(\"event\", handleEvent);\n el.removeEventListener(\"embedded.ready\", handleReady);\n el.removeEventListener(\"error\", handleError);\n };\n }, []);\n\n return React.createElement(\"corti-embedded\", {\n ref: internalRef,\n baseurl: baseURL,\n ...(visibility !== undefined ? { visibility } : {}),\n ...(className !== undefined ? { className } : {}),\n style,\n });\n },\n);\n\nCortiEmbeddedReact.displayName = \"CortiEmbeddedReact\";\n\nexport interface UseCortiEmbeddedStatusOptions {\n enabled?: boolean;\n onError?: (error: unknown) => void;\n shouldRefreshOnEvent?: (event: CortiEmbeddedEventDetail) => boolean;\n}\n\nexport interface UseCortiEmbeddedStatusResult {\n status: Awaited<ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>> | null;\n isLoading: boolean;\n error: unknown;\n lastEvent: CortiEmbeddedEventDetail | null;\n}\n\nexport function useCortiEmbeddedStatus(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n options: UseCortiEmbeddedStatusOptions = {},\n): UseCortiEmbeddedStatusResult {\n const {\n enabled = true,\n onError,\n shouldRefreshOnEvent = event => {\n const normalized = event.name.toLowerCase();\n if (normalized.includes(\"getstatus\")) return false;\n if (normalized.includes(\"statusreturned\")) return false;\n return true;\n },\n } = options;\n const [status, setStatus] =\n React.useState<UseCortiEmbeddedStatusResult[\"status\"]>(null);\n const [isLoading, setIsLoading] = React.useState(false);\n const [error, setError] = React.useState<unknown>(null);\n const [lastEvent, setLastEvent] =\n React.useState<UseCortiEmbeddedStatusResult[\"lastEvent\"]>(null);\n const onErrorRef = React.useRef(onError);\n const shouldRefreshOnEventRef = React.useRef(shouldRefreshOnEvent);\n const isRefreshingRef = React.useRef(false);\n\n React.useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n React.useEffect(() => {\n shouldRefreshOnEventRef.current = shouldRefreshOnEvent;\n }, [shouldRefreshOnEvent]);\n\n const refresh = React.useCallback(async () => {\n if (!enabled || !ref.current || isRefreshingRef.current) return;\n isRefreshingRef.current = true;\n setIsLoading(true);\n try {\n const nextStatus = await ref.current.getStatus();\n setStatus(nextStatus);\n setError(null);\n } catch (refreshError) {\n setError(refreshError);\n onErrorRef.current?.(refreshError);\n } finally {\n setIsLoading(false);\n isRefreshingRef.current = false;\n }\n }, [enabled, ref]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return undefined;\n\n const target = ref.current;\n const handleEvent = (event: Event) => {\n const { detail } = event as CustomEvent<CortiEmbeddedEventDetail>;\n setLastEvent(detail);\n if (!shouldRefreshOnEventRef.current(detail)) return;\n if (isRefreshingRef.current) return;\n refresh();\n };\n\n target.addEventListener(\"event\", handleEvent);\n return () => target.removeEventListener(\"event\", handleEvent);\n }, [enabled, ref, refresh]);\n\n return {\n status,\n isLoading,\n error,\n lastEvent,\n };\n}\n\nexport interface UseCortiEmbeddedApiResult {\n auth: (\n ...args: Parameters<CortiEmbeddedReactRef[\"auth\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"auth\"]>;\n createInteraction: (\n ...args: Parameters<CortiEmbeddedReactRef[\"createInteraction\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"createInteraction\"]>;\n configureSession: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureSession\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureSession\"]>;\n addFacts: (\n ...args: Parameters<CortiEmbeddedReactRef[\"addFacts\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"addFacts\"]>;\n navigate: (\n ...args: Parameters<CortiEmbeddedReactRef[\"navigate\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"navigate\"]>;\n startRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"startRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"startRecording\"]>;\n stopRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"stopRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"stopRecording\"]>;\n getStatus: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getStatus\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>;\n configure: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configure\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configure\"]>;\n getTemplates: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getTemplates\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getTemplates\"]>;\n setCredentials: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setCredentials\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setCredentials\"]>;\n show: (\n ...args: Parameters<CortiEmbeddedReactRef[\"show\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"show\"]>;\n hide: (\n ...args: Parameters<CortiEmbeddedReactRef[\"hide\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"hide\"]>;\n}\n\nfunction getCortiEmbeddedInstanceFromRefOrThrow(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): CortiEmbeddedReactRef {\n const instance = ref.current;\n if (!instance) {\n throw new Error(\n \"No active corti-embedded instance found for this ref. Mount <CortiEmbeddedReact ref={...} /> first.\",\n );\n }\n return instance;\n}\n\nexport function useCortiEmbeddedApi(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): UseCortiEmbeddedApiResult {\n const getInstance = React.useCallback(\n () => getCortiEmbeddedInstanceFromRefOrThrow(ref),\n [ref],\n );\n\n return React.useMemo(\n () => ({\n auth: (...args) => getInstance().auth(...args),\n createInteraction: (...args) => getInstance().createInteraction(...args),\n configureSession: (...args) => getInstance().configureSession(...args),\n addFacts: (...args) => getInstance().addFacts(...args),\n navigate: (...args) => getInstance().navigate(...args),\n startRecording: (...args) => getInstance().startRecording(...args),\n stopRecording: (...args) => getInstance().stopRecording(...args),\n getStatus: (...args) => getInstance().getStatus(...args),\n configure: (...args) => getInstance().configure(...args),\n getTemplates: (...args) => getInstance().getTemplates(...args),\n setCredentials: (...args) => getInstance().setCredentials(...args),\n show: (...args) => getInstance().show(...args),\n hide: (...args) => getInstance().hide(...args),\n }),\n [getInstance],\n );\n}\n"]}
1
+ {"version":3,"file":"CortiEmbeddedReact.js","sourceRoot":"","sources":["../../src/react/CortiEmbeddedReact.ts"],"names":[],"mappings":"AAAA,O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ClE,gBAAgB,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QACtE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC9C,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC/C,CAAC,EACF,CAAC,WAAW,CAAC,CACd,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport \"../corti-embedded.js\";\nimport type { CortiEmbedded } from \"../CortiEmbedded.js\";\nimport type { CortiEmbeddedAPI } from \"../public-types.js\";\n\nexport interface CortiEmbeddedEventDetail {\n name: string;\n payload: unknown;\n}\n\nexport type CortiEmbeddedEvent = CustomEvent<CortiEmbeddedEventDetail>;\nexport type CortiEmbeddedReadyEvent = CustomEvent<Record<string, unknown>>;\n\nexport interface CortiEmbeddedErrorDetail {\n message: string;\n code?: string;\n details?: unknown;\n}\n\n// Props interface\nexport interface CortiEmbeddedReactProps {\n baseURL: string;\n visibility?: \"visible\" | \"hidden\";\n\n // Event handlers receive the raw CustomEvent emitted by the custom element.\n onEvent?: (event: CortiEmbeddedEvent) => void;\n onReady?: (event: CortiEmbeddedReadyEvent) => void;\n onError?: (event: CustomEvent<CortiEmbeddedErrorDetail>) => void;\n\n // Additional props\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport type CortiEmbeddedReactRef = CortiEmbedded & CortiEmbeddedAPI;\n\n// Export public types\nexport * from \"../public-types.js\";\n\n// Renders the custom element directly so React sets the ref to the actual\n// CortiEmbedded DOM instance. This avoids the @lit/react wrapper chain that\n// was preventing the ref from reaching the DOM node in React 19.\nexport const CortiEmbeddedReact = React.forwardRef<\n CortiEmbeddedReactRef,\n CortiEmbeddedReactProps\n>(\n (\n { onEvent, onReady, onError, baseURL, visibility, className, style },\n forwardedRef,\n ) => {\n const internalRef = React.useRef<CortiEmbeddedReactRef | null>(null);\n const hasEmittedReadyRef = React.useRef(false);\n\n // \"Latest ref\" pattern: update on every render so handlers are always\n // current without re-attaching event listeners.\n const onEventRef = React.useRef(onEvent);\n const onReadyRef = React.useRef(onReady);\n const onErrorRef = React.useRef(onError);\n onEventRef.current = onEvent;\n onReadyRef.current = onReady;\n onErrorRef.current = onError;\n\n // Expose the DOM element to the consumer's forwarded ref. Native element\n // refs are set during React's mutation phase, before layout effects run,\n // so internalRef.current is always populated when this executes.\n React.useImperativeHandle(forwardedRef, () => internalRef.current!, []);\n\n // Keep LitElement reactive properties in sync with React props.\n React.useLayoutEffect(() => {\n if (internalRef.current) internalRef.current.baseURL = baseURL;\n }, [baseURL]);\n\n React.useLayoutEffect(() => {\n if (internalRef.current == null || visibility === undefined) return;\n internalRef.current.visibility = visibility;\n }, [visibility]);\n\n // Attach DOM event listeners once on mount. The latest-ref pattern above\n // ensures handlers always call the current prop without re-attaching.\n React.useEffect(() => {\n const el = internalRef.current;\n if (!el) return undefined;\n\n const handleEvent = (e: Event) =>\n onEventRef.current?.(e as CortiEmbeddedEvent);\n const handleReady = (e: Event) => {\n if (hasEmittedReadyRef.current) return;\n hasEmittedReadyRef.current = true;\n onReadyRef.current?.(e as CortiEmbeddedReadyEvent);\n };\n const handleError = (e: Event) =>\n onErrorRef.current?.(e as CustomEvent<CortiEmbeddedErrorDetail>);\n\n el.addEventListener(\"event\", handleEvent);\n el.addEventListener(\"embedded.ready\", handleReady);\n el.addEventListener(\"error\", handleError);\n return () => {\n el.removeEventListener(\"event\", handleEvent);\n el.removeEventListener(\"embedded.ready\", handleReady);\n el.removeEventListener(\"error\", handleError);\n };\n }, []);\n\n return React.createElement(\"corti-embedded\", {\n ref: internalRef,\n baseurl: baseURL,\n ...(visibility !== undefined ? { visibility } : {}),\n ...(className !== undefined ? { className } : {}),\n style,\n });\n },\n);\n\nCortiEmbeddedReact.displayName = \"CortiEmbeddedReact\";\n\nexport interface UseCortiEmbeddedStatusOptions {\n enabled?: boolean;\n onError?: (error: unknown) => void;\n shouldRefreshOnEvent?: (event: CortiEmbeddedEventDetail) => boolean;\n}\n\nexport interface UseCortiEmbeddedStatusResult {\n status: Awaited<ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>> | null;\n isLoading: boolean;\n error: unknown;\n lastEvent: CortiEmbeddedEventDetail | null;\n}\n\nexport function useCortiEmbeddedStatus(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n options: UseCortiEmbeddedStatusOptions = {},\n): UseCortiEmbeddedStatusResult {\n const {\n enabled = true,\n onError,\n shouldRefreshOnEvent = event => {\n const normalized = event.name.toLowerCase();\n if (normalized.includes(\"getstatus\")) return false;\n if (normalized.includes(\"statusreturned\")) return false;\n return true;\n },\n } = options;\n const [status, setStatus] =\n React.useState<UseCortiEmbeddedStatusResult[\"status\"]>(null);\n const [isLoading, setIsLoading] = React.useState(false);\n const [error, setError] = React.useState<unknown>(null);\n const [lastEvent, setLastEvent] =\n React.useState<UseCortiEmbeddedStatusResult[\"lastEvent\"]>(null);\n const onErrorRef = React.useRef(onError);\n const shouldRefreshOnEventRef = React.useRef(shouldRefreshOnEvent);\n const isRefreshingRef = React.useRef(false);\n\n React.useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n React.useEffect(() => {\n shouldRefreshOnEventRef.current = shouldRefreshOnEvent;\n }, [shouldRefreshOnEvent]);\n\n const refresh = React.useCallback(async () => {\n if (!enabled || !ref.current || isRefreshingRef.current) return;\n isRefreshingRef.current = true;\n setIsLoading(true);\n try {\n const nextStatus = await ref.current.getStatus();\n setStatus(nextStatus);\n setError(null);\n } catch (refreshError) {\n setError(refreshError);\n onErrorRef.current?.(refreshError);\n } finally {\n setIsLoading(false);\n isRefreshingRef.current = false;\n }\n }, [enabled, ref]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return undefined;\n\n const target = ref.current;\n const handleEvent = (event: Event) => {\n const { detail } = event as CustomEvent<CortiEmbeddedEventDetail>;\n setLastEvent(detail);\n if (!shouldRefreshOnEventRef.current(detail)) return;\n if (isRefreshingRef.current) return;\n refresh();\n };\n\n target.addEventListener(\"event\", handleEvent);\n return () => target.removeEventListener(\"event\", handleEvent);\n }, [enabled, ref, refresh]);\n\n return {\n status,\n isLoading,\n error,\n lastEvent,\n };\n}\n\nexport interface UseCortiEmbeddedApiResult {\n auth: (\n ...args: Parameters<CortiEmbeddedReactRef[\"auth\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"auth\"]>;\n createInteraction: (\n ...args: Parameters<CortiEmbeddedReactRef[\"createInteraction\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"createInteraction\"]>;\n configureSession: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureSession\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureSession\"]>;\n addFacts: (\n ...args: Parameters<CortiEmbeddedReactRef[\"addFacts\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"addFacts\"]>;\n navigate: (\n ...args: Parameters<CortiEmbeddedReactRef[\"navigate\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"navigate\"]>;\n startRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"startRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"startRecording\"]>;\n stopRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"stopRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"stopRecording\"]>;\n getStatus: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getStatus\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>;\n configureApp: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureApp\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureApp\"]>;\n configure: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configure\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configure\"]>;\n setInteractionOptions: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setInteractionOptions\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setInteractionOptions\"]>;\n getTemplates: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getTemplates\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getTemplates\"]>;\n setCredentials: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setCredentials\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setCredentials\"]>;\n showDeviceLinkQR: (\n ...args: Parameters<CortiEmbeddedReactRef[\"showDeviceLinkQR\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"showDeviceLinkQR\"]>;\n show: (\n ...args: Parameters<CortiEmbeddedReactRef[\"show\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"show\"]>;\n hide: (\n ...args: Parameters<CortiEmbeddedReactRef[\"hide\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"hide\"]>;\n}\n\nfunction getCortiEmbeddedInstanceFromRefOrThrow(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): CortiEmbeddedReactRef {\n const instance = ref.current;\n if (!instance) {\n throw new Error(\n \"No active corti-embedded instance found for this ref. Mount <CortiEmbeddedReact ref={...} /> first.\",\n );\n }\n return instance;\n}\n\nexport function useCortiEmbeddedApi(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): UseCortiEmbeddedApiResult {\n const getInstance = React.useCallback(\n () => getCortiEmbeddedInstanceFromRefOrThrow(ref),\n [ref],\n );\n\n return React.useMemo(\n () => ({\n auth: (...args) => getInstance().auth(...args),\n createInteraction: (...args) => getInstance().createInteraction(...args),\n configureSession: (...args) => getInstance().configureSession(...args),\n addFacts: (...args) => getInstance().addFacts(...args),\n navigate: (...args) => getInstance().navigate(...args),\n startRecording: (...args) => getInstance().startRecording(...args),\n stopRecording: (...args) => getInstance().stopRecording(...args),\n getStatus: (...args) => getInstance().getStatus(...args),\n configureApp: (...args) => getInstance().configureApp(...args),\n configure: (...args) => getInstance().configure(...args),\n setInteractionOptions: (...args) =>\n getInstance().setInteractionOptions(...args),\n getTemplates: (...args) => getInstance().getTemplates(...args),\n setCredentials: (...args) => getInstance().setCredentials(...args),\n showDeviceLinkQR: (...args) => getInstance().showDeviceLinkQR(...args),\n show: (...args) => getInstance().show(...args),\n hide: (...args) => getInstance().hide(...args),\n }),\n [getInstance],\n );\n}\n"]}