@saasquatch/squatch-js 2.6.1-0 → 2.6.2-0
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.
- package/CHANGELOG.md +5 -3
- package/dist/squatch.esm.js +37 -4
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +37 -4
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/dist/widgets/Widget.d.ts +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,8 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
## [2.6.1] - 2023-09-01
|
|
11
|
+
|
|
12
|
+
- Fix customElementRegistry error that occurs when multiple instances of squatchjs are loaded on the same page.
|
|
12
13
|
|
|
13
14
|
## [2.6.0] - 2023-08-23
|
|
14
15
|
|
|
@@ -348,7 +349,8 @@ No release notes.
|
|
|
348
349
|
|
|
349
350
|
No release notes.
|
|
350
351
|
|
|
351
|
-
[unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.
|
|
352
|
+
[unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.1...HEAD
|
|
353
|
+
[2.6.1]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.5.0...@saasquatch%2Fsquatch-js@2.6.1
|
|
352
354
|
[2.6.0]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.5.0...@saasquatch%2Fsquatch-js@2.6.0
|
|
353
355
|
[2.5.0]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.4.1...@saasquatch%2Fsquatch-js@2.5.0
|
|
354
356
|
[2.4.3]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.4.2...@saasquatch%2Fsquatch-js@2.4.3
|
package/dist/squatch.esm.js
CHANGED
|
@@ -406,7 +406,6 @@ function _validateAnalyticsConfig(raw) {
|
|
|
406
406
|
return raw;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
// @ts-check
|
|
410
409
|
/** @hidden */
|
|
411
410
|
|
|
412
411
|
var _log$8 = debug("squatch-js:widget");
|
|
@@ -431,6 +430,7 @@ class Widget {
|
|
|
431
430
|
this.context = void 0;
|
|
432
431
|
this.npmCdn = void 0;
|
|
433
432
|
this.container = void 0;
|
|
433
|
+
this.loadEventListener = null;
|
|
434
434
|
|
|
435
435
|
_log$8("widget initializing ...");
|
|
436
436
|
|
|
@@ -491,6 +491,26 @@ class Widget {
|
|
|
491
491
|
return parent.querySelector("iframe#squatchFrame");
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
_detachLoadEventListener(frameDoc) {
|
|
495
|
+
if (this.loadEventListener) {
|
|
496
|
+
frameDoc.removeEventListener("sq:user-registration", this.loadEventListener);
|
|
497
|
+
this.loadEventListener = null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
_attachLoadEventListener(frameDoc, sqh) {
|
|
502
|
+
if (this.loadEventListener === null) {
|
|
503
|
+
this.loadEventListener = e => {
|
|
504
|
+
this._loadEvent(_extends({}, sqh, {
|
|
505
|
+
userId: e.detail.userId,
|
|
506
|
+
accountId: e.detail.accountId
|
|
507
|
+
}));
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
frameDoc.addEventListener("sq:user-registration", this.loadEventListener);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
494
514
|
_loadEvent(sqh) {
|
|
495
515
|
var _this$analyticsApi$pu;
|
|
496
516
|
|
|
@@ -803,7 +823,6 @@ class EmbedWidget extends Widget {
|
|
|
803
823
|
} = entry.contentRect; // @ts-ignore -- number will be cast to string by browsers
|
|
804
824
|
|
|
805
825
|
frame.height = height;
|
|
806
|
-
console.log("RESIZE");
|
|
807
826
|
}
|
|
808
827
|
});
|
|
809
828
|
var container = await this._findInnerContainer(frame);
|
|
@@ -813,6 +832,8 @@ class EmbedWidget extends Widget {
|
|
|
813
832
|
this._loadEvent(_sqh);
|
|
814
833
|
|
|
815
834
|
_log$7("loaded");
|
|
835
|
+
} else {
|
|
836
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
816
837
|
}
|
|
817
838
|
});
|
|
818
839
|
}
|
|
@@ -840,6 +861,10 @@ class EmbedWidget extends Widget {
|
|
|
840
861
|
this._loadEvent(_sqh);
|
|
841
862
|
|
|
842
863
|
_log$7("loaded");
|
|
864
|
+
} else {
|
|
865
|
+
if (!frame.contentDocument) return;
|
|
866
|
+
|
|
867
|
+
this._attachLoadEventListener(frame.contentDocument, _sqh);
|
|
843
868
|
}
|
|
844
869
|
}
|
|
845
870
|
|
|
@@ -847,6 +872,7 @@ class EmbedWidget extends Widget {
|
|
|
847
872
|
var frame = this._findFrame();
|
|
848
873
|
|
|
849
874
|
if (!frame) return _log$7("no target element to close");
|
|
875
|
+
if (frame.contentDocument) this._detachLoadEventListener(frame.contentDocument);
|
|
850
876
|
|
|
851
877
|
var element = this._findElement();
|
|
852
878
|
|
|
@@ -1053,11 +1079,16 @@ class PopupWidget extends Widget {
|
|
|
1053
1079
|
this._loadEvent(_sqh);
|
|
1054
1080
|
|
|
1055
1081
|
_log$6("Popup opened");
|
|
1082
|
+
} else {
|
|
1083
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1056
1084
|
}
|
|
1057
1085
|
});
|
|
1058
1086
|
}
|
|
1059
1087
|
|
|
1060
1088
|
close() {
|
|
1089
|
+
var frame = this._findFrame();
|
|
1090
|
+
|
|
1091
|
+
if (frame != null && frame.contentDocument) this._detachLoadEventListener(frame.contentDocument);
|
|
1061
1092
|
var element = this.container ? this._findElement() : document.body;
|
|
1062
1093
|
var parent = element.shadowRoot || element;
|
|
1063
1094
|
var dialog = parent.querySelector("#" + this.id);
|
|
@@ -2079,7 +2110,7 @@ function help() {
|
|
|
2079
2110
|
console.log("Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes.");
|
|
2080
2111
|
}
|
|
2081
2112
|
|
|
2082
|
-
|
|
2113
|
+
var _window$squatch;
|
|
2083
2114
|
// debug.disable("squatch-js*");
|
|
2084
2115
|
|
|
2085
2116
|
/** @hidden */
|
|
@@ -2267,8 +2298,10 @@ function pushCookie() {
|
|
|
2267
2298
|
|
|
2268
2299
|
if (typeof document !== "undefined" && !window.SaaSquatchDoNotAutoDrop) {
|
|
2269
2300
|
pushCookie();
|
|
2270
|
-
}
|
|
2301
|
+
} // Show message if squatchjs has already been loaded on the page
|
|
2302
|
+
|
|
2271
2303
|
|
|
2304
|
+
if ((_window$squatch = window["squatch"]) != null && _window$squatch.init) _log("Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics.");
|
|
2272
2305
|
if (typeof document !== "undefined") asyncLoad();
|
|
2273
2306
|
|
|
2274
2307
|
export { DeclarativeEmbedWidget, DeclarativePopupWidget, EmbedWidget, PopupWidget, WidgetApi, Widgets, _auto, api, autofill, events, help, init, pushCookie, ready, widget, widgets };
|