@deepdesk/deepdesk-sdk 11.6.1-beta.3 → 11.6.1-beta.4

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.mts CHANGED
@@ -214,7 +214,7 @@ type SelectionRange = {
214
214
  /**
215
215
  * A selection range representation for textarea's and contenteditables only using offsets.
216
216
  */
217
- type Caret = {
217
+ type CaretPosition = {
218
218
  top: number;
219
219
  left: number;
220
220
  };
@@ -224,19 +224,18 @@ interface InputEventMap {
224
224
  */
225
225
  change: (event: {
226
226
  plainText: string;
227
+ rawHTML: string | null;
227
228
  }) => void;
228
229
  /**
229
- * Updated value after User, platform and plugin changes
230
+ * Emits selection changes.
230
231
  */
231
- updated: (event: {
232
- plainText: string;
233
- }) => void;
232
+ selection: (event: SelectionRange | null) => void;
234
233
  /**
235
- * Emits when only the caret/selection changes. (No other state changes).
234
+ * Emits when the position of the caret on the screen changed
236
235
  */
237
- selection: (event: SelectionRange | null) => void;
238
- caret: (event: Caret | null) => void;
236
+ caretposition: (event: CaretPosition | null) => void;
239
237
  keydown: (event: KeyboardEvent) => void;
238
+ keyup: (event: KeyboardEvent) => void;
240
239
  paste: (event: {
241
240
  pastedText: string;
242
241
  selectionText: string;
@@ -255,40 +254,34 @@ type InputHandler<K extends keyof InputEventMap> = InputEventMap[K];
255
254
  type InputEventListeners<K extends keyof InputEventMap> = Record<K, InputHandler<K>[]>;
256
255
  declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
257
256
  protected element: HTMLElementType;
257
+ isFocused: boolean;
258
+ isActive: boolean;
259
+ isDisposed: boolean;
258
260
  protected eventListeners: Partial<InputEventListeners<keyof InputEventMap>>;
259
261
  protected disposeHandlers: (() => void)[];
260
- protected currentText: string;
261
- protected currentCaret: Caret | null;
262
- protected currentSelection: SelectionRange;
263
- protected currentHTML: string | null;
264
- protected isFocused: boolean;
265
- protected isActive: boolean;
266
- protected isSettingValue: boolean;
262
+ protected cachedText: string;
263
+ protected cachedCaretPosition: CaretPosition | null;
264
+ protected cachedSelection: SelectionRange;
265
+ protected cachedHTML: string | null;
267
266
  protected isSubmitting: boolean;
268
267
  protected isPossibleClearInputAction: boolean;
269
- protected isDisposed: boolean;
270
268
  constructor(element: HTMLElementType);
271
269
  protected addEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
272
270
  protected removeEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
273
- protected triggerChange(): void;
274
- protected triggerSelection(): void;
275
- protected triggerCaretPosition(): void;
271
+ protected handleInteraction(): void;
276
272
  abstract getSelectedText(): string;
277
- protected handleKeyUp(event: KeyboardEvent): void;
278
273
  protected handleClick(): void;
279
274
  protected handleFocus(): void;
280
275
  protected handleBlur(): void;
281
276
  protected handleKeyDown(event: KeyboardEvent): void;
277
+ protected handleKeyUp(event: KeyboardEvent): void;
282
278
  protected handleCut(): void;
283
279
  protected handlePaste(event: ClipboardEvent): void;
284
- protected listen(options?: {
285
- shouldObserve?: boolean;
286
- }): void;
280
+ protected listen(): void;
287
281
  abstract getText(): string;
288
282
  abstract getHTML(): string | null;
289
283
  abstract getSelection(): SelectionRange;
290
- abstract getCaretPosition(): Caret | null;
291
- abstract applyChanges(callback: (element: HTMLElementType) => void | Promise<void>): void | Promise<void>;
284
+ abstract getCaretPosition(): CaretPosition | null;
292
285
  focus(): void;
293
286
  emit<K extends keyof InputEventMap>(type: K, ...args: Parameters<InputHandler<K>>): void;
294
287
  on<K extends keyof InputEventMap>(type: K, handler: InputHandler<K>): void;
@@ -1526,7 +1519,6 @@ declare enum FetchState {
1526
1519
  ERROR = "error"
1527
1520
  }
1528
1521
 
1529
- type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
1530
1522
  type StageSuggestion = {
1531
1523
  text: string;
1532
1524
  suggestion: TextSuggestion;
@@ -1556,14 +1548,12 @@ type State$6 = {
1556
1548
  text: string;
1557
1549
  html: string | null;
1558
1550
  selection: SelectionRange;
1559
- stagedSuggestion: StageSuggestion | null;
1560
- userCommitted: {
1551
+ beforeKeyUp: {
1561
1552
  text: string;
1562
1553
  selection: SelectionRange;
1563
- };
1564
- tabCompletionSuggestion?: TextSuggestion;
1554
+ } | null;
1555
+ mixedSuggestion: TextSuggestion | null;
1565
1556
  metrics: MetricState;
1566
- previousKeyDownEvent: KeyboardMetric | null;
1567
1557
  textSuggestions: TextSuggestion[];
1568
1558
  selectedSuggestionIndex: number;
1569
1559
  };
@@ -2224,19 +2214,8 @@ declare class DeepdeskSDK {
2224
2214
  * Only refresh text suggestions when the agent is not typing.
2225
2215
  */
2226
2216
  refresh(): Promise<void>;
2227
- /**
2228
- * Method to call when the agent input has changed
2229
- */
2230
- private notifyInputChanged;
2231
- /**
2232
- * Method to call for the agent input keydown event
2233
- */
2234
- private notifyKeyDown;
2235
- private notifyPaste;
2236
- private notifyCut;
2237
2217
  notifyExternalSuggestion(suggestion: StageSuggestion): void;
2238
2218
  evaluateRule(label: string, params?: Record<string, any>, options?: EvaluateRuleOptions): Promise<Cue[]>;
2239
- private handleInputChanged;
2240
2219
  private handleKeyDown;
2241
2220
  private handleAfterSendMessage;
2242
2221
  handlingTimeStart(): void;
@@ -2250,10 +2229,7 @@ declare class DeepdeskSDK {
2250
2229
  notifySubmit(options?: {
2251
2230
  text?: string;
2252
2231
  }): void;
2253
- stageSelectedSuggestion(eventMetrics: SuggestionEventMetrics): void;
2254
- emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K], options?: {
2255
- mayApplyChanges?: boolean;
2256
- }): void;
2232
+ emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K]): void;
2257
2233
  /**
2258
2234
  * Attach listener to SDK event
2259
2235
  * Returns removeListener
@@ -2319,11 +2295,7 @@ declare class ContentEditableInput extends InputMediator<HTMLDivElement> {
2319
2295
  } | null;
2320
2296
  getSelection(): SelectionRange;
2321
2297
  getSelectedText(): string;
2322
- applyChanges(callback: (element: HTMLDivElement) => void | Promise<void>): void | Promise<void>;
2323
- listen(options?: {
2324
- shouldObserve?: boolean;
2325
- }): void;
2326
- dispose(): void;
2298
+ listen(): void;
2327
2299
  }
2328
2300
 
2329
2301
  declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
@@ -2332,8 +2304,7 @@ declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
2332
2304
  getHTML(): string | null;
2333
2305
  getSelection(): SelectionRange;
2334
2306
  getSelectedText(): string;
2335
- getCaretPosition(): Caret | null;
2336
- applyChanges(callback: (element: HTMLTextAreaElement) => void | Promise<void>): void | Promise<void>;
2307
+ getCaretPosition(): CaretPosition | null;
2337
2308
  listen(): void;
2338
2309
  }
2339
2310
 
package/dist/index.d.ts CHANGED
@@ -214,7 +214,7 @@ type SelectionRange = {
214
214
  /**
215
215
  * A selection range representation for textarea's and contenteditables only using offsets.
216
216
  */
217
- type Caret = {
217
+ type CaretPosition = {
218
218
  top: number;
219
219
  left: number;
220
220
  };
@@ -224,19 +224,18 @@ interface InputEventMap {
224
224
  */
225
225
  change: (event: {
226
226
  plainText: string;
227
+ rawHTML: string | null;
227
228
  }) => void;
228
229
  /**
229
- * Updated value after User, platform and plugin changes
230
+ * Emits selection changes.
230
231
  */
231
- updated: (event: {
232
- plainText: string;
233
- }) => void;
232
+ selection: (event: SelectionRange | null) => void;
234
233
  /**
235
- * Emits when only the caret/selection changes. (No other state changes).
234
+ * Emits when the position of the caret on the screen changed
236
235
  */
237
- selection: (event: SelectionRange | null) => void;
238
- caret: (event: Caret | null) => void;
236
+ caretposition: (event: CaretPosition | null) => void;
239
237
  keydown: (event: KeyboardEvent) => void;
238
+ keyup: (event: KeyboardEvent) => void;
240
239
  paste: (event: {
241
240
  pastedText: string;
242
241
  selectionText: string;
@@ -255,40 +254,34 @@ type InputHandler<K extends keyof InputEventMap> = InputEventMap[K];
255
254
  type InputEventListeners<K extends keyof InputEventMap> = Record<K, InputHandler<K>[]>;
256
255
  declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
257
256
  protected element: HTMLElementType;
257
+ isFocused: boolean;
258
+ isActive: boolean;
259
+ isDisposed: boolean;
258
260
  protected eventListeners: Partial<InputEventListeners<keyof InputEventMap>>;
259
261
  protected disposeHandlers: (() => void)[];
260
- protected currentText: string;
261
- protected currentCaret: Caret | null;
262
- protected currentSelection: SelectionRange;
263
- protected currentHTML: string | null;
264
- protected isFocused: boolean;
265
- protected isActive: boolean;
266
- protected isSettingValue: boolean;
262
+ protected cachedText: string;
263
+ protected cachedCaretPosition: CaretPosition | null;
264
+ protected cachedSelection: SelectionRange;
265
+ protected cachedHTML: string | null;
267
266
  protected isSubmitting: boolean;
268
267
  protected isPossibleClearInputAction: boolean;
269
- protected isDisposed: boolean;
270
268
  constructor(element: HTMLElementType);
271
269
  protected addEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
272
270
  protected removeEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
273
- protected triggerChange(): void;
274
- protected triggerSelection(): void;
275
- protected triggerCaretPosition(): void;
271
+ protected handleInteraction(): void;
276
272
  abstract getSelectedText(): string;
277
- protected handleKeyUp(event: KeyboardEvent): void;
278
273
  protected handleClick(): void;
279
274
  protected handleFocus(): void;
280
275
  protected handleBlur(): void;
281
276
  protected handleKeyDown(event: KeyboardEvent): void;
277
+ protected handleKeyUp(event: KeyboardEvent): void;
282
278
  protected handleCut(): void;
283
279
  protected handlePaste(event: ClipboardEvent): void;
284
- protected listen(options?: {
285
- shouldObserve?: boolean;
286
- }): void;
280
+ protected listen(): void;
287
281
  abstract getText(): string;
288
282
  abstract getHTML(): string | null;
289
283
  abstract getSelection(): SelectionRange;
290
- abstract getCaretPosition(): Caret | null;
291
- abstract applyChanges(callback: (element: HTMLElementType) => void | Promise<void>): void | Promise<void>;
284
+ abstract getCaretPosition(): CaretPosition | null;
292
285
  focus(): void;
293
286
  emit<K extends keyof InputEventMap>(type: K, ...args: Parameters<InputHandler<K>>): void;
294
287
  on<K extends keyof InputEventMap>(type: K, handler: InputHandler<K>): void;
@@ -1526,7 +1519,6 @@ declare enum FetchState {
1526
1519
  ERROR = "error"
1527
1520
  }
1528
1521
 
1529
- type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
1530
1522
  type StageSuggestion = {
1531
1523
  text: string;
1532
1524
  suggestion: TextSuggestion;
@@ -1556,14 +1548,12 @@ type State$6 = {
1556
1548
  text: string;
1557
1549
  html: string | null;
1558
1550
  selection: SelectionRange;
1559
- stagedSuggestion: StageSuggestion | null;
1560
- userCommitted: {
1551
+ beforeKeyUp: {
1561
1552
  text: string;
1562
1553
  selection: SelectionRange;
1563
- };
1564
- tabCompletionSuggestion?: TextSuggestion;
1554
+ } | null;
1555
+ mixedSuggestion: TextSuggestion | null;
1565
1556
  metrics: MetricState;
1566
- previousKeyDownEvent: KeyboardMetric | null;
1567
1557
  textSuggestions: TextSuggestion[];
1568
1558
  selectedSuggestionIndex: number;
1569
1559
  };
@@ -2224,19 +2214,8 @@ declare class DeepdeskSDK {
2224
2214
  * Only refresh text suggestions when the agent is not typing.
2225
2215
  */
2226
2216
  refresh(): Promise<void>;
2227
- /**
2228
- * Method to call when the agent input has changed
2229
- */
2230
- private notifyInputChanged;
2231
- /**
2232
- * Method to call for the agent input keydown event
2233
- */
2234
- private notifyKeyDown;
2235
- private notifyPaste;
2236
- private notifyCut;
2237
2217
  notifyExternalSuggestion(suggestion: StageSuggestion): void;
2238
2218
  evaluateRule(label: string, params?: Record<string, any>, options?: EvaluateRuleOptions): Promise<Cue[]>;
2239
- private handleInputChanged;
2240
2219
  private handleKeyDown;
2241
2220
  private handleAfterSendMessage;
2242
2221
  handlingTimeStart(): void;
@@ -2250,10 +2229,7 @@ declare class DeepdeskSDK {
2250
2229
  notifySubmit(options?: {
2251
2230
  text?: string;
2252
2231
  }): void;
2253
- stageSelectedSuggestion(eventMetrics: SuggestionEventMetrics): void;
2254
- emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K], options?: {
2255
- mayApplyChanges?: boolean;
2256
- }): void;
2232
+ emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K]): void;
2257
2233
  /**
2258
2234
  * Attach listener to SDK event
2259
2235
  * Returns removeListener
@@ -2319,11 +2295,7 @@ declare class ContentEditableInput extends InputMediator<HTMLDivElement> {
2319
2295
  } | null;
2320
2296
  getSelection(): SelectionRange;
2321
2297
  getSelectedText(): string;
2322
- applyChanges(callback: (element: HTMLDivElement) => void | Promise<void>): void | Promise<void>;
2323
- listen(options?: {
2324
- shouldObserve?: boolean;
2325
- }): void;
2326
- dispose(): void;
2298
+ listen(): void;
2327
2299
  }
2328
2300
 
2329
2301
  declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
@@ -2332,8 +2304,7 @@ declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
2332
2304
  getHTML(): string | null;
2333
2305
  getSelection(): SelectionRange;
2334
2306
  getSelectedText(): string;
2335
- getCaretPosition(): Caret | null;
2336
- applyChanges(callback: (element: HTMLTextAreaElement) => void | Promise<void>): void | Promise<void>;
2307
+ getCaretPosition(): CaretPosition | null;
2337
2308
  listen(): void;
2338
2309
  }
2339
2310