@asgard-js/core 0.2.53 → 0.2.54

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.
@@ -7,6 +7,10 @@ export default class AsgardServiceClient implements IAsgardServiceClient {
7
7
  private botProviderEndpoint?;
8
8
  private debugMode?;
9
9
  private destroy$;
10
+ private closed;
11
+ private detached;
12
+ private detachTimer?;
13
+ private inFlight;
10
14
  private sseEmitter;
11
15
  private transformSsePayload?;
12
16
  private customHeaders?;
@@ -14,6 +18,24 @@ export default class AsgardServiceClient implements IAsgardServiceClient {
14
18
  on<K extends keyof SseEvents>(event: K, listener: SseEvents[K]): void;
15
19
  handleEvent(response: SseResponse<EventType>): void;
16
20
  fetchSse(payload: FetchSsePayload, options?: FetchSseOptions): void;
21
+ /**
22
+ * Detach the client from its owning component without aborting in-flight SSE
23
+ * runs. Used when a chatbot unmounts (e.g. the user navigates to another
24
+ * in-app page) but the current run should be allowed to finish on the
25
+ * backend instead of being cut off. After detaching, the stream is still
26
+ * drained to keep the connection open but consumer callbacks no longer fire.
27
+ *
28
+ * The connection cleans itself up in all cases:
29
+ * - No run in flight → close immediately (nothing to keep alive).
30
+ * - Runs in flight → close once they all settle (`onRunSettled`), so the
31
+ * client never lingers past the work it is keeping alive.
32
+ * - A run gets stuck (stream stays open, no `run.done`/error) → the safety
33
+ * timeout force-closes it so the orphaned connection cannot leak.
34
+ */
35
+ detach(options: {
36
+ timeoutMs: number;
37
+ }): void;
38
+ private onRunSettled;
17
39
  close(): void;
18
40
  /**
19
41
  * 上傳檔案到 Blob API
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,WAAW,EACX,SAAS,EACT,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,C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