@syntrologie/adapt-chatbot 2.8.0-canary.570 → 2.8.0-canary.571

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.
@@ -55,8 +55,8 @@ export declare const FORWARDED_BAR_FIELDS: readonly ["placeholder", "assistantNa
55
55
  * Mirrors `observer/index.ts` `_resetObserverForTests`.
56
56
  */
57
57
  export declare function _resetElementStoreForTests(): void;
58
- export declare function resolveTileWidget(templateId: string): string | undefined;
59
- export declare function refreshTemplateWidgetMap(uiTemplates: Record<string, unknown> | undefined): void;
58
+ export declare const resolveTileWidget: (templateId: string) => string | undefined;
59
+ export declare const refreshTemplateWidgetMap: (uiTemplates: Record<string, unknown> | undefined) => void;
60
60
  /**
61
61
  * Observation enrichment (exported for direct testing).
62
62
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AdaptiveChatBarMountable.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatBarMountable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,EAKL,KAAK,wBAAwB,EAI9B,MAAM,4BAA4B,CAAC;AAmBpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQvE,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0HxE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,gKAWvB,CAAC;AAsBX;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD;AA6BD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAExE;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAgB/F;AA+DD;;;;;;;;;;;;GAYG;AACH,wBAA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AAgB,mBAAmB,CAAC,UAAU,EAAE;IAC9C,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;CAC/C,GAAG,CAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,QAAQ,KAAK,gBAAgB,CAkC5D;AAOD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAkDxF;AAED,6EAA6E;AAC7E,wBAAgB,0BAA0B,IAAI,IAAI,CAMjD;AAsGD,0BAA0B;AAC1B,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AA0ED,wBAAgB,+BAA+B,IAAI,IAAI,CAUtD;AAyID,eAAO,MAAM,wBAAwB;qBAClB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;sBA6G9D,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAQ5E,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ChatAssistantLitMountable,
3
3
  renderFallbackHtml
4
- } from "./chunk-YY2EOPOU.js";
4
+ } from "./chunk-OIXUXUUQ.js";
5
5
  import "./chunk-EWPPVPJ4.js";
6
6
  import "./chunk-GN7Z5IVP.js";
7
7
  import "./chunk-3AHKDXIQ.js";
package/dist/cdn.d.ts CHANGED
@@ -34,6 +34,7 @@ export declare const manifest: {
34
34
  icon: string;
35
35
  };
36
36
  })[];
37
+ onActivate: typeof import("./hostAgentController").activateHostAgent;
37
38
  };
38
39
  editor: {
39
40
  component: typeof ChatbotEditorLit;
package/dist/cdn.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAC;AAaF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBpB,CAAC;AAaF,eAAe,QAAQ,CAAC"}
@@ -7795,6 +7795,7 @@ var ElementInstanceStore = class {
7795
7795
  this._instances = /* @__PURE__ */ new Map();
7796
7796
  /** Active TTL timeout — replaced on each call to `scheduleClientTtl`. */
7797
7797
  this._ttlTimer = null;
7798
+ this._disposed = false;
7798
7799
  /** Instance IDs the client has dismissed. Persists across canvas remounts
7799
7800
  * so a dismissed tile never silently reappears on replay/broadcast. */
7800
7801
  this._dismissedIds = /* @__PURE__ */ new Set();
@@ -7821,7 +7822,7 @@ var ElementInstanceStore = class {
7821
7822
  const subscribe = this._events?.subscribe;
7822
7823
  const publish = this._events?.publish;
7823
7824
  if (!subscribe || !publish) return;
7824
- subscribe(
7825
+ this._unsubscribeReplay = subscribe(
7825
7826
  {
7826
7827
  names: [
7827
7828
  COMPOSITIONAL_REPLAY_REQUEST_EVENT,
@@ -7830,6 +7831,7 @@ var ElementInstanceStore = class {
7830
7831
  ]
7831
7832
  },
7832
7833
  (event) => {
7834
+ if (this._disposed) return;
7833
7835
  if (event.name === TILE_UNMOUNTED_EVENT) {
7834
7836
  const id = String(event.props?.instance_id ?? "");
7835
7837
  if (id) this._dismissedIds.add(id);
@@ -7850,6 +7852,7 @@ var ElementInstanceStore = class {
7850
7852
  }
7851
7853
  _replayItems(tileId, publish) {
7852
7854
  for (const instance of this._instances.values()) {
7855
+ if (this._disposed) return;
7853
7856
  if (instance.element_type !== "item") continue;
7854
7857
  if (instance.placement.type !== "parent_tile") continue;
7855
7858
  if (instance.placement.tile_id !== tileId) continue;
@@ -7864,6 +7867,7 @@ var ElementInstanceStore = class {
7864
7867
  }
7865
7868
  _replayTiles(publish) {
7866
7869
  for (const instance of this._instances.values()) {
7870
+ if (this._disposed) return;
7867
7871
  if (instance.element_type !== "tile") continue;
7868
7872
  if (instance.placement.type !== "slot") continue;
7869
7873
  if (instance.state !== "active") continue;
@@ -7978,6 +7982,7 @@ var ElementInstanceStore = class {
7978
7982
  */
7979
7983
  async hydrate(snapshot) {
7980
7984
  for (const instance of snapshot) {
7985
+ if (this._disposed) return;
7981
7986
  const existing = this._instances.get(instance.instance_id);
7982
7987
  if (existing && existing.version >= instance.version) {
7983
7988
  continue;
@@ -8008,6 +8013,7 @@ var ElementInstanceStore = class {
8008
8013
  * (items via tile_id filter).
8009
8014
  */
8010
8015
  _broadcastActive() {
8016
+ if (this._disposed) return;
8011
8017
  const publish = this._events?.publish;
8012
8018
  if (!publish) return;
8013
8019
  this._replayTiles(publish);
@@ -8029,6 +8035,7 @@ var ElementInstanceStore = class {
8029
8035
  */
8030
8036
  async apply(mutations) {
8031
8037
  for (const mutation of mutations) {
8038
+ if (this._disposed) return;
8032
8039
  try {
8033
8040
  await this._applyOne(mutation);
8034
8041
  } catch (err) {
@@ -8043,6 +8050,48 @@ var ElementInstanceStore = class {
8043
8050
  getInstance(instance_id) {
8044
8051
  return this._instances.get(instance_id);
8045
8052
  }
8053
+ /** Replace a host-provided complete UI snapshot; never replay imperative actions. */
8054
+ async reconcileSnapshot(snapshot) {
8055
+ if (this._disposed) return;
8056
+ const active = snapshot.filter(
8057
+ (instance) => instance.state === "active" && instance.element_type !== "action"
8058
+ );
8059
+ const ids = new Set(active.map((instance) => instance.instance_id));
8060
+ for (const instance of this._instances.values()) {
8061
+ if (this._disposed) return;
8062
+ if (ids.has(instance.instance_id)) continue;
8063
+ if (instance.state === "active") {
8064
+ await this.apply([{ op: "unmount", instance_id: instance.instance_id }]);
8065
+ }
8066
+ this._instances.delete(instance.instance_id);
8067
+ this._dismissedIds.delete(instance.instance_id);
8068
+ }
8069
+ for (const instance of active) {
8070
+ if (this._disposed) return;
8071
+ const existing = this._instances.get(instance.instance_id);
8072
+ if (!existing || existing.state !== "active" || existing.version >= instance.version)
8073
+ continue;
8074
+ await this.apply([
8075
+ {
8076
+ op: "patch",
8077
+ instance_id: instance.instance_id,
8078
+ patches: [],
8079
+ expected_version: existing.version,
8080
+ resulting_version: instance.version,
8081
+ resulting_content: instance.content
8082
+ }
8083
+ ]);
8084
+ }
8085
+ await this.hydrate(active);
8086
+ }
8087
+ /** Release page-lifetime listeners and timers; queued work becomes inert. */
8088
+ dispose() {
8089
+ this._disposed = true;
8090
+ this._unsubscribeReplay?.();
8091
+ this._unsubscribeReplay = void 0;
8092
+ if (this._ttlTimer !== null) clearTimeout(this._ttlTimer);
8093
+ this._ttlTimer = null;
8094
+ }
8046
8095
  /**
8047
8096
  * Schedule a client-side TTL that unmounts every active stateful
8048
8097
  * instance when the server-side session expires. Replaces any
@@ -8057,6 +8106,7 @@ var ElementInstanceStore = class {
8057
8106
  * Pass a past timestamp to trigger cleanup immediately.
8058
8107
  */
8059
8108
  scheduleClientTtl(session_expires_at) {
8109
+ if (this._disposed) return;
8060
8110
  if (this._ttlTimer !== null) {
8061
8111
  clearTimeout(this._ttlTimer);
8062
8112
  this._ttlTimer = null;
@@ -8210,7 +8260,14 @@ var ElementInstanceStore = class {
8210
8260
  return true;
8211
8261
  }
8212
8262
  _ctx() {
8213
- return { actions: this._actions, events: this._events };
8263
+ return {
8264
+ actions: this._actions,
8265
+ events: this._events && {
8266
+ publish: (name, props) => {
8267
+ if (!this._disposed) this._events?.publish(name, props);
8268
+ }
8269
+ }
8270
+ };
8214
8271
  }
8215
8272
  };
8216
8273
 
@@ -9033,4 +9090,4 @@ fast-json-patch/module/duplex.mjs:
9033
9090
  * MIT license
9034
9091
  *)
9035
9092
  */
9036
- //# sourceMappingURL=chunk-YY2EOPOU.js.map
9093
+ //# sourceMappingURL=chunk-OIXUXUUQ.js.map