@mochabug/adapt-web 1.0.0-rc47 → 1.0.0-rc48
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.
|
@@ -230,8 +230,10 @@ export class AdaptCapWidget {
|
|
|
230
230
|
const token = e.detail?.token;
|
|
231
231
|
const expiresStr = e.detail?.expires;
|
|
232
232
|
const expires = expiresStr ? new Date(expiresStr) : new Date();
|
|
233
|
-
//
|
|
234
|
-
|
|
233
|
+
// Defer destroy to next microtask so Cap.js solve() can finish
|
|
234
|
+
// without its internal state being nulled mid-execution by
|
|
235
|
+
// disconnectedCallback → cleanup when we remove the element.
|
|
236
|
+
queueMicrotask(() => this.destroy());
|
|
235
237
|
if (token) {
|
|
236
238
|
this.options.onSolve(token, expires);
|
|
237
239
|
}
|
|
@@ -244,7 +246,7 @@ export class AdaptCapWidget {
|
|
|
244
246
|
if (this.destroyed)
|
|
245
247
|
return;
|
|
246
248
|
console.error("[AdaptCapWidget] Cap.js error:", e.detail);
|
|
247
|
-
this.destroy();
|
|
249
|
+
queueMicrotask(() => this.destroy());
|
|
248
250
|
this.options.onError?.(new Error(e.detail?.message || "Cap.js error"));
|
|
249
251
|
}));
|
|
250
252
|
// Mount to DOM
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdaptCapWidget.js","sourceRoot":"","sources":["../../src/AdaptCapWidget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGtE,+DAA+D;AAC/D,OAAO,gBAAgB,CAAC;AAgDxB;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAOzB,YAAY,OAA8B;QALlC,oBAAe,GAA0B,IAAI,CAAC;QAC9C,kBAAa,GAAuB,IAAI,CAAC;QACzC,cAAS,GAAG,KAAK,CAAC;QAIxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;Q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AG,CAAC,oBAAoB,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,sBAAsB;QACtB,iBAAiB,EAAE,CAAC;QAEpB,kBAAkB;QAClB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YAC5D,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/umd/adapt-web.js
CHANGED
|
@@ -7136,7 +7136,7 @@ var MbAdapt = (() => {
|
|
|
7136
7136
|
const token = e.detail?.token;
|
|
7137
7137
|
const expiresStr = e.detail?.expires;
|
|
7138
7138
|
const expires = expiresStr ? new Date(expiresStr) : /* @__PURE__ */ new Date();
|
|
7139
|
-
this.destroy();
|
|
7139
|
+
queueMicrotask(() => this.destroy());
|
|
7140
7140
|
if (token) {
|
|
7141
7141
|
this.options.onSolve(token, expires);
|
|
7142
7142
|
} else {
|
|
@@ -7146,7 +7146,7 @@ var MbAdapt = (() => {
|
|
|
7146
7146
|
this.widgetElement.addEventListener("error", ((e) => {
|
|
7147
7147
|
if (this.destroyed) return;
|
|
7148
7148
|
console.error("[AdaptCapWidget] Cap.js error:", e.detail);
|
|
7149
|
-
this.destroy();
|
|
7149
|
+
queueMicrotask(() => this.destroy());
|
|
7150
7150
|
this.options.onError?.(new Error(e.detail?.message || "Cap.js error"));
|
|
7151
7151
|
}));
|
|
7152
7152
|
innerContainer.appendChild(this.widgetElement);
|
|
@@ -7485,7 +7485,7 @@ var MbAdapt = (() => {
|
|
|
7485
7485
|
// src/index.ts
|
|
7486
7486
|
if (typeof window !== "undefined" && true && !window.CAP_CUSTOM_WASM_URL) {
|
|
7487
7487
|
window.CAP_CUSTOM_WASM_URL = new URL(
|
|
7488
|
-
"https://cdn.mochabug.com/adapt/web/1.0.0-
|
|
7488
|
+
"https://cdn.mochabug.com/adapt/web/1.0.0-rc48/cap_wasm.js",
|
|
7489
7489
|
window.location.href
|
|
7490
7490
|
).href;
|
|
7491
7491
|
}
|
|
@@ -136,7 +136,7 @@ to prevent this, set window.CAP_DONT_SKIP_REDEFINE to true`):customElements.defi
|
|
|
136
136
|
--mb-cap-font-size: 14px;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
`,document.head.appendChild(t)}mountWidget(){this.widgetContainer=document.createElement("div"),this.widgetContainer.className="mb-adapt-cap";let t=document.createElement("div");if(t.className="mb-adapt-cap__container",this.widgetElement=document.createElement("cap-widget"),this.widgetElement.setAttribute("data-cap-api-endpoint",`/adapt-cap-${this.options.automationId}/`),this.options.workerCount&&this.widgetElement.setAttribute("data-cap-worker-count",String(this.options.workerCount)),this.options.i18n){let{i18n:n}=this.options;n.verifyingLabel&&this.widgetElement.setAttribute("data-cap-i18n-verifying-label",n.verifyingLabel),n.initialState&&this.widgetElement.setAttribute("data-cap-i18n-initial-state",n.initialState),n.solvedLabel&&this.widgetElement.setAttribute("data-cap-i18n-solved-label",n.solvedLabel),n.errorLabel&&this.widgetElement.setAttribute("data-cap-i18n-error-label",n.errorLabel)}this.widgetElement.addEventListener("solve",(n=>{if(this.destroyed)return;let r=n.detail?.token,o=n.detail?.expires,a=o?new Date(o):new Date;this.destroy(),r?this.options.onSolve(r,a):this.options.onError?.(new Error("No token received from Cap.js"))})),this.widgetElement.addEventListener("error",(n=>{this.destroyed||(console.error("[AdaptCapWidget] Cap.js error:",n.detail),this.destroy(),this.options.onError?.(new Error(n.detail?.message||"Cap.js error")))})),t.appendChild(this.widgetElement),this.widgetContainer.appendChild(t),this.containerElement.appendChild(this.widgetContainer)}setDarkMode(t){this.widgetContainer&&(t?this.widgetContainer.classList.add("mb-adapt-cap--dark"):this.widgetContainer.classList.remove("mb-adapt-cap--dark"))}destroy(){this.destroyed||(this.destroyed=!0,Za(),this.widgetContainer&&this.widgetContainer.parentNode&&this.widgetContainer.parentNode.removeChild(this.widgetContainer),this.widgetContainer=null,this.widgetElement=null)}};function Qn(e,t){return`${e}${t?`#mb_token=${encodeURIComponent(t)}`:""}`}var Vs=["automation-id","session-token","auth-token","transmitter","challenge-token","requires-challenge","inherit-token","fork-display-mode","side-by-side-split","dialog-backdrop-close","dark-mode","auto-resizing"],xs=typeof HTMLElement<"u"?HTMLElement:class{},Qe=class extends xs{constructor(){super();this._client=null}static get observedAttributes(){return Vs}get automationId(){return this.getAttribute("automation-id")}set automationId(n){n===null?this.removeAttribute("automation-id"):this.setAttribute("automation-id",n)}get darkMode(){return this.hasAttribute("dark-mode")}set darkMode(n){n?this.setAttribute("dark-mode",""):this.removeAttribute("dark-mode")}get autoResizing(){return this.hasAttribute("auto-resizing")}set autoResizing(n){n?this.setAttribute("auto-resizing",""):this.removeAttribute("auto-resizing")}get forkDisplayMode(){return this.getAttribute("fork-display-mode")==="dialog"?"dialog":"side-by-side"}set forkDisplayMode(n){this.setAttribute("fork-display-mode",n)}get dialogBackdropClose(){return this.hasAttribute("dialog-backdrop-close")}set dialogBackdropClose(n){n?this.setAttribute("dialog-backdrop-close",""):this.removeAttribute("dialog-backdrop-close")}connectedCallback(){queueMicrotask(()=>this._tryInit())}disconnectedCallback(){this._destroyClient()}attributeChangedCallback(n,r,o){if(r!==o){if(n==="automation-id"){this._destroyClient(),queueMicrotask(()=>this._tryInit());return}if(this._client)switch(n){case"fork-display-mode":this._client.setForkDisplayMode(this.forkDisplayMode);break;case"dialog-backdrop-close":this._client.setDialogBackdropClose(this.dialogBackdropClose);break;case"dark-mode":this._client.setDarkMode(this.darkMode);break;case"auto-resizing":this._client.setAutoResizing(this.autoResizing);break}}}_tryInit(){if(this._client||!this.isConnected)return;let n=this.automationId;if(!n)return;let r=this.getAttribute("session-token"),o=this.getAttribute("auth-token"),a=this.getAttribute("transmitter"),i=this.getAttribute("challenge-token"),s=this.hasAttribute("requires-challenge"),u=this.getAttribute("inherit-token"),m=this.getAttribute("side-by-side-split"),f={container:this,id:n,forkDisplayMode:this.forkDisplayMode,dialogBackdropClose:this.dialogBackdropClose,darkMode:this.darkMode,autoResizing:this.autoResizing,onSession:(I,d)=>{this.onSessionCallback?.(I,d),this.dispatchEvent(new CustomEvent("adapt-session",{detail:{status:I,fork:d},bubbles:!0}))},onOutput:I=>{this.onOutputCallback?.(I),this.dispatchEvent(new CustomEvent("adapt-output",{detail:{output:I},bubbles:!0}))}};r&&(f.sessionToken=r),o&&(f.authToken=o),a&&(f.transmitter=a),i&&(f.challengeToken=i),s&&(f.requiresChallenge=!0),u&&(f.inheritToken=u),m!==null&&(f.sideBySideSplit=Number(m)),this.signals!==void 0&&(f.signals=this.signals),this.capWidgetOptions!==void 0&&(f.capWidgetOptions=this.capWidgetOptions),this.inheritFrom!==void 0&&(f.inheritFrom=this.inheritFrom),this.classNames!==void 0&&(f.classNames=this.classNames),this.styles!==void 0&&(f.styles=this.styles),this._client=new _e(f)}_destroyClient(){this._client&&(this._client.destroy(),this._client=null)}};if(typeof customElements<"u"&&!customElements.get("adapt-automation")){customElements.define("adapt-automation",Qe);let e="adapt-element-display";if(!document.getElementById(e)){let t=document.createElement("style");t.id=e,t.textContent="adapt-automation, adapt-cap { display: block; }",document.head.appendChild(t)}}var Xs=["automation-id","dark-mode","worker-count"],Ss=typeof HTMLElement<"u"?HTMLElement:class{},Oe=class extends Ss{constructor(){super();this._widget=null}static get observedAttributes(){return Xs}get client(){return this._client}set client(n){this._client=n,this._destroyWidget(),this._tryInit()}get automationId(){return this.getAttribute("automation-id")}set automationId(n){n===null?this.removeAttribute("automation-id"):this.setAttribute("automation-id",n)}get darkMode(){return this.hasAttribute("dark-mode")}set darkMode(n){n?this.setAttribute("dark-mode",""):this.removeAttribute("dark-mode")}connectedCallback(){this._tryInit()}disconnectedCallback(){this._destroyWidget()}attributeChangedCallback(n,r,o){if(r!==o){if(n==="automation-id"){this._destroyWidget(),this._tryInit();return}if(n==="dark-mode"){this._widget?.setDarkMode(this.darkMode);return}}}_tryInit(){if(this._widget||!this.isConnected)return;let n=this.automationId;if(!n||!this._client)return;let r=this.getAttribute("worker-count");this._widget=new ie({container:this,automationId:n,client:this._client,onSolve:(o,a)=>{this.onSolveCallback?.(o,a),this.dispatchEvent(new CustomEvent("adapt-cap-solve",{detail:{token:o,expires:a},bubbles:!0}))},onError:o=>{this.onErrorCallback?.(o),this.dispatchEvent(new CustomEvent("adapt-cap-error",{detail:{error:o},bubbles:!0}))},...r!==null&&{workerCount:Number(r)},...this.i18n!==void 0&&{i18n:this.i18n}}),this.darkMode&&this._widget.setDarkMode(!0)}_destroyWidget(){this._widget&&(this._widget.destroy(),this._widget=null)}};if(typeof customElements<"u"&&!customElements.get("adapt-cap")){customElements.define("adapt-cap",Oe);let e="adapt-element-display";if(!document.getElementById(e)){let t=document.createElement("style");t.id=e,t.textContent="adapt-automation, adapt-cap { display: block; }",document.head.appendChild(t)}}typeof window<"u"&&!window.CAP_CUSTOM_WASM_URL&&(window.CAP_CUSTOM_WASM_URL=new URL("https://cdn.mochabug.com/adapt/web/1.0.0-
|
|
139
|
+
`,document.head.appendChild(t)}mountWidget(){this.widgetContainer=document.createElement("div"),this.widgetContainer.className="mb-adapt-cap";let t=document.createElement("div");if(t.className="mb-adapt-cap__container",this.widgetElement=document.createElement("cap-widget"),this.widgetElement.setAttribute("data-cap-api-endpoint",`/adapt-cap-${this.options.automationId}/`),this.options.workerCount&&this.widgetElement.setAttribute("data-cap-worker-count",String(this.options.workerCount)),this.options.i18n){let{i18n:n}=this.options;n.verifyingLabel&&this.widgetElement.setAttribute("data-cap-i18n-verifying-label",n.verifyingLabel),n.initialState&&this.widgetElement.setAttribute("data-cap-i18n-initial-state",n.initialState),n.solvedLabel&&this.widgetElement.setAttribute("data-cap-i18n-solved-label",n.solvedLabel),n.errorLabel&&this.widgetElement.setAttribute("data-cap-i18n-error-label",n.errorLabel)}this.widgetElement.addEventListener("solve",(n=>{if(this.destroyed)return;let r=n.detail?.token,o=n.detail?.expires,a=o?new Date(o):new Date;queueMicrotask(()=>this.destroy()),r?this.options.onSolve(r,a):this.options.onError?.(new Error("No token received from Cap.js"))})),this.widgetElement.addEventListener("error",(n=>{this.destroyed||(console.error("[AdaptCapWidget] Cap.js error:",n.detail),queueMicrotask(()=>this.destroy()),this.options.onError?.(new Error(n.detail?.message||"Cap.js error")))})),t.appendChild(this.widgetElement),this.widgetContainer.appendChild(t),this.containerElement.appendChild(this.widgetContainer)}setDarkMode(t){this.widgetContainer&&(t?this.widgetContainer.classList.add("mb-adapt-cap--dark"):this.widgetContainer.classList.remove("mb-adapt-cap--dark"))}destroy(){this.destroyed||(this.destroyed=!0,Za(),this.widgetContainer&&this.widgetContainer.parentNode&&this.widgetContainer.parentNode.removeChild(this.widgetContainer),this.widgetContainer=null,this.widgetElement=null)}};function Qn(e,t){return`${e}${t?`#mb_token=${encodeURIComponent(t)}`:""}`}var Vs=["automation-id","session-token","auth-token","transmitter","challenge-token","requires-challenge","inherit-token","fork-display-mode","side-by-side-split","dialog-backdrop-close","dark-mode","auto-resizing"],xs=typeof HTMLElement<"u"?HTMLElement:class{},Qe=class extends xs{constructor(){super();this._client=null}static get observedAttributes(){return Vs}get automationId(){return this.getAttribute("automation-id")}set automationId(n){n===null?this.removeAttribute("automation-id"):this.setAttribute("automation-id",n)}get darkMode(){return this.hasAttribute("dark-mode")}set darkMode(n){n?this.setAttribute("dark-mode",""):this.removeAttribute("dark-mode")}get autoResizing(){return this.hasAttribute("auto-resizing")}set autoResizing(n){n?this.setAttribute("auto-resizing",""):this.removeAttribute("auto-resizing")}get forkDisplayMode(){return this.getAttribute("fork-display-mode")==="dialog"?"dialog":"side-by-side"}set forkDisplayMode(n){this.setAttribute("fork-display-mode",n)}get dialogBackdropClose(){return this.hasAttribute("dialog-backdrop-close")}set dialogBackdropClose(n){n?this.setAttribute("dialog-backdrop-close",""):this.removeAttribute("dialog-backdrop-close")}connectedCallback(){queueMicrotask(()=>this._tryInit())}disconnectedCallback(){this._destroyClient()}attributeChangedCallback(n,r,o){if(r!==o){if(n==="automation-id"){this._destroyClient(),queueMicrotask(()=>this._tryInit());return}if(this._client)switch(n){case"fork-display-mode":this._client.setForkDisplayMode(this.forkDisplayMode);break;case"dialog-backdrop-close":this._client.setDialogBackdropClose(this.dialogBackdropClose);break;case"dark-mode":this._client.setDarkMode(this.darkMode);break;case"auto-resizing":this._client.setAutoResizing(this.autoResizing);break}}}_tryInit(){if(this._client||!this.isConnected)return;let n=this.automationId;if(!n)return;let r=this.getAttribute("session-token"),o=this.getAttribute("auth-token"),a=this.getAttribute("transmitter"),i=this.getAttribute("challenge-token"),s=this.hasAttribute("requires-challenge"),u=this.getAttribute("inherit-token"),m=this.getAttribute("side-by-side-split"),f={container:this,id:n,forkDisplayMode:this.forkDisplayMode,dialogBackdropClose:this.dialogBackdropClose,darkMode:this.darkMode,autoResizing:this.autoResizing,onSession:(I,d)=>{this.onSessionCallback?.(I,d),this.dispatchEvent(new CustomEvent("adapt-session",{detail:{status:I,fork:d},bubbles:!0}))},onOutput:I=>{this.onOutputCallback?.(I),this.dispatchEvent(new CustomEvent("adapt-output",{detail:{output:I},bubbles:!0}))}};r&&(f.sessionToken=r),o&&(f.authToken=o),a&&(f.transmitter=a),i&&(f.challengeToken=i),s&&(f.requiresChallenge=!0),u&&(f.inheritToken=u),m!==null&&(f.sideBySideSplit=Number(m)),this.signals!==void 0&&(f.signals=this.signals),this.capWidgetOptions!==void 0&&(f.capWidgetOptions=this.capWidgetOptions),this.inheritFrom!==void 0&&(f.inheritFrom=this.inheritFrom),this.classNames!==void 0&&(f.classNames=this.classNames),this.styles!==void 0&&(f.styles=this.styles),this._client=new _e(f)}_destroyClient(){this._client&&(this._client.destroy(),this._client=null)}};if(typeof customElements<"u"&&!customElements.get("adapt-automation")){customElements.define("adapt-automation",Qe);let e="adapt-element-display";if(!document.getElementById(e)){let t=document.createElement("style");t.id=e,t.textContent="adapt-automation, adapt-cap { display: block; }",document.head.appendChild(t)}}var Xs=["automation-id","dark-mode","worker-count"],Ss=typeof HTMLElement<"u"?HTMLElement:class{},Oe=class extends Ss{constructor(){super();this._widget=null}static get observedAttributes(){return Xs}get client(){return this._client}set client(n){this._client=n,this._destroyWidget(),this._tryInit()}get automationId(){return this.getAttribute("automation-id")}set automationId(n){n===null?this.removeAttribute("automation-id"):this.setAttribute("automation-id",n)}get darkMode(){return this.hasAttribute("dark-mode")}set darkMode(n){n?this.setAttribute("dark-mode",""):this.removeAttribute("dark-mode")}connectedCallback(){this._tryInit()}disconnectedCallback(){this._destroyWidget()}attributeChangedCallback(n,r,o){if(r!==o){if(n==="automation-id"){this._destroyWidget(),this._tryInit();return}if(n==="dark-mode"){this._widget?.setDarkMode(this.darkMode);return}}}_tryInit(){if(this._widget||!this.isConnected)return;let n=this.automationId;if(!n||!this._client)return;let r=this.getAttribute("worker-count");this._widget=new ie({container:this,automationId:n,client:this._client,onSolve:(o,a)=>{this.onSolveCallback?.(o,a),this.dispatchEvent(new CustomEvent("adapt-cap-solve",{detail:{token:o,expires:a},bubbles:!0}))},onError:o=>{this.onErrorCallback?.(o),this.dispatchEvent(new CustomEvent("adapt-cap-error",{detail:{error:o},bubbles:!0}))},...r!==null&&{workerCount:Number(r)},...this.i18n!==void 0&&{i18n:this.i18n}}),this.darkMode&&this._widget.setDarkMode(!0)}_destroyWidget(){this._widget&&(this._widget.destroy(),this._widget=null)}};if(typeof customElements<"u"&&!customElements.get("adapt-cap")){customElements.define("adapt-cap",Oe);let e="adapt-element-display";if(!document.getElementById(e)){let t=document.createElement("style");t.id=e,t.textContent="adapt-automation, adapt-cap { display: block; }",document.head.appendChild(t)}}typeof window<"u"&&!window.CAP_CUSTOM_WASM_URL&&(window.CAP_CUSTOM_WASM_URL=new URL("https://cdn.mochabug.com/adapt/web/1.0.0-rc48/cap_wasm.js",window.location.href).href);var Bs=`
|
|
140
140
|
.mb-adapt {
|
|
141
141
|
width: 100%;
|
|
142
142
|
min-height: inherit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mochabug/adapt-web",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc48",
|
|
4
4
|
"description": "Browser client library for Adapt automation platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@cap.js/widget": "^0.1.41",
|
|
51
|
-
"@mochabug/adapt-core": "^1.0.0-
|
|
51
|
+
"@mochabug/adapt-core": "^1.0.0-rc44"
|
|
52
52
|
}
|
|
53
53
|
}
|