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

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.
@@ -10950,8 +10950,21 @@ html.mb-dragging webview {
10950
10950
  }
10951
10951
  }
10952
10952
  // --- Lifecycle ---
10953
+ /**
10954
+ * Explicitly initialize the element after all properties are set.
10955
+ * Framework wrappers (React, Vue, Svelte, Angular, Astro) MUST call this
10956
+ * after setting non-serializable properties like `signals`, `inheritFrom`, etc.
10957
+ *
10958
+ * For plain HTML usage without a framework, the element auto-initializes
10959
+ * when `automation-id` is set (via `attributeChangedCallback`).
10960
+ *
10961
+ * Idempotent — safe to call multiple times. Only creates the client once.
10962
+ */
10963
+ initialize() {
10964
+ this._tryInit();
10965
+ }
10953
10966
  connectedCallback() {
10954
- queueMicrotask(() => this._tryInit());
10967
+ requestAnimationFrame(() => this._tryInit());
10955
10968
  }
10956
10969
  disconnectedCallback() {
10957
10970
  this._destroyClient();
@@ -10960,7 +10973,7 @@ html.mb-dragging webview {
10960
10973
  if (oldValue === newValue) return;
10961
10974
  if (name === "automation-id" || name === "persist" || name === "debug") {
10962
10975
  this._destroyClient();
10963
- queueMicrotask(() => this._tryInit());
10976
+ requestAnimationFrame(() => this._tryInit());
10964
10977
  return;
10965
10978
  }
10966
10979
  if (!this._client) return;
@@ -11083,21 +11096,37 @@ html.mb-dragging webview {
11083
11096
  if (challengeToken) options.challengeToken = challengeToken;
11084
11097
  if (requiresChallenge) options.requiresChallenge = true;
11085
11098
  if (inheritToken) options.inheritToken = inheritToken;
11086
- if (this.signals !== void 0) options.signals = this.signals;
11087
- if (this.capWidgetOptions !== void 0)
11088
- options.capWidgetOptions = this.capWidgetOptions;
11089
- if (this.inheritFrom !== void 0) options.inheritFrom = this.inheritFrom;
11090
- if (this.classNames !== void 0) options.classNames = this.classNames;
11099
+ const signals = this.signals ?? this._parseData("adaptSignals");
11100
+ const capWidgetOptions = this.capWidgetOptions ?? this._parseData("adaptCapWidgetOptions");
11101
+ const inheritFrom = this.inheritFrom ?? this._parseData("adaptInheritFrom");
11102
+ const classNames = this.classNames ?? this._parseData("adaptClassNames");
11103
+ const text = this.text ?? this._parseData("adaptText");
11104
+ const theme = this._theme ?? this._parseData("adaptTheme");
11105
+ const persistOptions = this.persistOptions ?? this._parseData("adaptPersistOptions");
11106
+ if (signals !== void 0) options.signals = signals;
11107
+ if (capWidgetOptions !== void 0)
11108
+ options.capWidgetOptions = capWidgetOptions;
11109
+ if (inheritFrom !== void 0) options.inheritFrom = inheritFrom;
11110
+ if (classNames !== void 0) options.classNames = classNames;
11091
11111
  if (this.styles !== void 0) options.styles = this.styles;
11092
- if (this.text !== void 0) options.text = this.text;
11093
- if (this._theme !== void 0) options.theme = this._theme;
11094
- if (this.persistOptions !== void 0) {
11095
- options.persist = this.persistOptions;
11112
+ if (text !== void 0) options.text = text;
11113
+ if (theme !== void 0) options.theme = theme;
11114
+ if (persistOptions !== void 0) {
11115
+ options.persist = persistOptions;
11096
11116
  } else if (this.persist) {
11097
11117
  options.persist = true;
11098
11118
  }
11099
11119
  this._client = new AdaptWebClient(options);
11100
11120
  }
11121
+ _parseData(key) {
11122
+ const raw = this.dataset[key];
11123
+ if (!raw) return void 0;
11124
+ try {
11125
+ return JSON.parse(raw);
11126
+ } catch {
11127
+ return void 0;
11128
+ }
11129
+ }
11101
11130
  _destroyClient() {
11102
11131
  if (this._client) {
11103
11132
  this._client.destroy();
Binary file