@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/dist/squatch.js
CHANGED
|
@@ -411,7 +411,6 @@ function _validateAnalyticsConfig(raw) {
|
|
|
411
411
|
return raw;
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
// @ts-check
|
|
415
414
|
/** @hidden */
|
|
416
415
|
|
|
417
416
|
var _log$8 = debug.debug("squatch-js:widget");
|
|
@@ -436,6 +435,7 @@ class Widget {
|
|
|
436
435
|
this.context = void 0;
|
|
437
436
|
this.npmCdn = void 0;
|
|
438
437
|
this.container = void 0;
|
|
438
|
+
this.loadEventListener = null;
|
|
439
439
|
|
|
440
440
|
_log$8("widget initializing ...");
|
|
441
441
|
|
|
@@ -496,6 +496,26 @@ class Widget {
|
|
|
496
496
|
return parent.querySelector("iframe#squatchFrame");
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
+
_detachLoadEventListener(frameDoc) {
|
|
500
|
+
if (this.loadEventListener) {
|
|
501
|
+
frameDoc.removeEventListener("sq:user-registration", this.loadEventListener);
|
|
502
|
+
this.loadEventListener = null;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
_attachLoadEventListener(frameDoc, sqh) {
|
|
507
|
+
if (this.loadEventListener === null) {
|
|
508
|
+
this.loadEventListener = e => {
|
|
509
|
+
this._loadEvent(_extends({}, sqh, {
|
|
510
|
+
userId: e.detail.userId,
|
|
511
|
+
accountId: e.detail.accountId
|
|
512
|
+
}));
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
frameDoc.addEventListener("sq:user-registration", this.loadEventListener);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
499
519
|
_loadEvent(sqh) {
|
|
500
520
|
var _this$analyticsApi$pu;
|
|
501
521
|
|
|
@@ -808,7 +828,6 @@ class EmbedWidget extends Widget {
|
|
|
808
828
|
} = entry.contentRect; // @ts-ignore -- number will be cast to string by browsers
|
|
809
829
|
|
|
810
830
|
frame.height = height;
|
|
811
|
-
console.log("RESIZE");
|
|
812
831
|
}
|
|
813
832
|
});
|
|
814
833
|
var container = await this._findInnerContainer(frame);
|
|
@@ -818,6 +837,8 @@ class EmbedWidget extends Widget {
|
|
|
818
837
|
this._loadEvent(_sqh);
|
|
819
838
|
|
|
820
839
|
_log$7("loaded");
|
|
840
|
+
} else {
|
|
841
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
821
842
|
}
|
|
822
843
|
});
|
|
823
844
|
}
|
|
@@ -845,6 +866,10 @@ class EmbedWidget extends Widget {
|
|
|
845
866
|
this._loadEvent(_sqh);
|
|
846
867
|
|
|
847
868
|
_log$7("loaded");
|
|
869
|
+
} else {
|
|
870
|
+
if (!frame.contentDocument) return;
|
|
871
|
+
|
|
872
|
+
this._attachLoadEventListener(frame.contentDocument, _sqh);
|
|
848
873
|
}
|
|
849
874
|
}
|
|
850
875
|
|
|
@@ -852,6 +877,7 @@ class EmbedWidget extends Widget {
|
|
|
852
877
|
var frame = this._findFrame();
|
|
853
878
|
|
|
854
879
|
if (!frame) return _log$7("no target element to close");
|
|
880
|
+
if (frame.contentDocument) this._detachLoadEventListener(frame.contentDocument);
|
|
855
881
|
|
|
856
882
|
var element = this._findElement();
|
|
857
883
|
|
|
@@ -1058,11 +1084,16 @@ class PopupWidget extends Widget {
|
|
|
1058
1084
|
this._loadEvent(_sqh);
|
|
1059
1085
|
|
|
1060
1086
|
_log$6("Popup opened");
|
|
1087
|
+
} else {
|
|
1088
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1061
1089
|
}
|
|
1062
1090
|
});
|
|
1063
1091
|
}
|
|
1064
1092
|
|
|
1065
1093
|
close() {
|
|
1094
|
+
var frame = this._findFrame();
|
|
1095
|
+
|
|
1096
|
+
if (frame != null && frame.contentDocument) this._detachLoadEventListener(frame.contentDocument);
|
|
1066
1097
|
var element = this.container ? this._findElement() : document.body;
|
|
1067
1098
|
var parent = element.shadowRoot || element;
|
|
1068
1099
|
var dialog = parent.querySelector("#" + this.id);
|
|
@@ -2084,7 +2115,7 @@ function help() {
|
|
|
2084
2115
|
console.log("Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes.");
|
|
2085
2116
|
}
|
|
2086
2117
|
|
|
2087
|
-
|
|
2118
|
+
var _window$squatch;
|
|
2088
2119
|
// debug.disable("squatch-js*");
|
|
2089
2120
|
|
|
2090
2121
|
/** @hidden */
|
|
@@ -2272,8 +2303,10 @@ function pushCookie() {
|
|
|
2272
2303
|
|
|
2273
2304
|
if (typeof document !== "undefined" && !window.SaaSquatchDoNotAutoDrop) {
|
|
2274
2305
|
pushCookie();
|
|
2275
|
-
}
|
|
2306
|
+
} // Show message if squatchjs has already been loaded on the page
|
|
2307
|
+
|
|
2276
2308
|
|
|
2309
|
+
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.");
|
|
2277
2310
|
if (typeof document !== "undefined") asyncLoad();
|
|
2278
2311
|
|
|
2279
2312
|
exports.DeclarativeEmbedWidget = DeclarativeEmbedWidget;
|