@mochabug/adapt-web 1.0.1-rc.21 → 1.0.1-rc.23

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.
Binary file
@@ -11488,8 +11488,21 @@ html.mb-dragging webview {
11488
11488
  }
11489
11489
  }
11490
11490
  // --- Lifecycle ---
11491
+ /**
11492
+ * Explicitly initialize the element after all properties are set.
11493
+ * Framework wrappers (React, Vue, Svelte, Angular, Astro) MUST call this
11494
+ * after setting non-serializable properties like `signals`, `inheritFrom`, etc.
11495
+ *
11496
+ * For plain HTML usage without a framework, the element auto-initializes
11497
+ * when `automation-id` is set (via `attributeChangedCallback`).
11498
+ *
11499
+ * Idempotent — safe to call multiple times. Only creates the client once.
11500
+ */
11501
+ initialize() {
11502
+ this._tryInit();
11503
+ }
11491
11504
  connectedCallback() {
11492
- queueMicrotask(() => this._tryInit());
11505
+ requestAnimationFrame(() => this._tryInit());
11493
11506
  }
11494
11507
  disconnectedCallback() {
11495
11508
  this._destroyClient();
@@ -11498,7 +11511,7 @@ html.mb-dragging webview {
11498
11511
  if (oldValue === newValue) return;
11499
11512
  if (name === "automation-id" || name === "persist" || name === "debug") {
11500
11513
  this._destroyClient();
11501
- queueMicrotask(() => this._tryInit());
11514
+ requestAnimationFrame(() => this._tryInit());
11502
11515
  return;
11503
11516
  }
11504
11517
  if (!this._client) return;
@@ -11621,21 +11634,37 @@ html.mb-dragging webview {
11621
11634
  if (challengeToken) options.challengeToken = challengeToken;
11622
11635
  if (requiresChallenge) options.requiresChallenge = true;
11623
11636
  if (inheritToken) options.inheritToken = inheritToken;
11624
- if (this.signals !== void 0) options.signals = this.signals;
11625
- if (this.capWidgetOptions !== void 0)
11626
- options.capWidgetOptions = this.capWidgetOptions;
11627
- if (this.inheritFrom !== void 0) options.inheritFrom = this.inheritFrom;
11628
- if (this.classNames !== void 0) options.classNames = this.classNames;
11637
+ const signals = this.signals ?? this._parseData("adaptSignals");
11638
+ const capWidgetOptions = this.capWidgetOptions ?? this._parseData("adaptCapWidgetOptions");
11639
+ const inheritFrom = this.inheritFrom ?? this._parseData("adaptInheritFrom");
11640
+ const classNames = this.classNames ?? this._parseData("adaptClassNames");
11641
+ const text = this.text ?? this._parseData("adaptText");
11642
+ const theme = this._theme ?? this._parseData("adaptTheme");
11643
+ const persistOptions = this.persistOptions ?? this._parseData("adaptPersistOptions");
11644
+ if (signals !== void 0) options.signals = signals;
11645
+ if (capWidgetOptions !== void 0)
11646
+ options.capWidgetOptions = capWidgetOptions;
11647
+ if (inheritFrom !== void 0) options.inheritFrom = inheritFrom;
11648
+ if (classNames !== void 0) options.classNames = classNames;
11629
11649
  if (this.styles !== void 0) options.styles = this.styles;
11630
- if (this.text !== void 0) options.text = this.text;
11631
- if (this._theme !== void 0) options.theme = this._theme;
11632
- if (this.persistOptions !== void 0) {
11633
- options.persist = this.persistOptions;
11650
+ if (text !== void 0) options.text = text;
11651
+ if (theme !== void 0) options.theme = theme;
11652
+ if (persistOptions !== void 0) {
11653
+ options.persist = persistOptions;
11634
11654
  } else if (this.persist) {
11635
11655
  options.persist = true;
11636
11656
  }
11637
11657
  this._client = new AdaptWebClient(options);
11638
11658
  }
11659
+ _parseData(key) {
11660
+ const raw = this.dataset[key];
11661
+ if (!raw) return void 0;
11662
+ try {
11663
+ return JSON.parse(raw);
11664
+ } catch {
11665
+ return void 0;
11666
+ }
11667
+ }
11639
11668
  _destroyClient() {
11640
11669
  if (this._client) {
11641
11670
  this._client.destroy();
@@ -13631,7 +13660,7 @@ html.mb-dragging webview {
13631
13660
  // src/cap-adapter.ts
13632
13661
  if (typeof window !== "undefined" && true && !window.CAP_CUSTOM_WASM_URL) {
13633
13662
  window.CAP_CUSTOM_WASM_URL = new URL(
13634
- "https://cdn.mochabug.com/adapt/web/1.0.1-rc.21/cap_wasm_bg.wasm",
13663
+ "https://cdn.mochabug.com/adapt/web/1.0.1-rc.23/cap_wasm_bg.wasm",
13635
13664
  window.location.href
13636
13665
  ).href;
13637
13666
  }
Binary file