@saasquatch/squatch-js 2.7.0-4 → 2.8.0-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 +9 -1
- package/dist/squatch.cjs.js +63 -33
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +63 -33
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +63 -33
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/dist/types.d.ts +11 -0
- package/dist/utils/widgetUtils.d.ts +4 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.7.0] - 2025-05-14
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Updated package to use `vite` for the build instead of `webpack`
|
|
15
|
+
- Fixes issue where `define` in webpack's UMD build could have conflicts within certain environments
|
|
16
|
+
|
|
10
17
|
## [2.6.3] - 2024-06-10
|
|
11
18
|
|
|
12
19
|
### Fixed
|
|
@@ -363,7 +370,8 @@ No release notes.
|
|
|
363
370
|
|
|
364
371
|
No release notes.
|
|
365
372
|
|
|
366
|
-
[unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.
|
|
373
|
+
[unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.7.0...HEAD
|
|
374
|
+
[2.7.0]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.3...@saasquatch%2Fsquatch-js@2.7.0
|
|
367
375
|
[2.6.3]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.2...@saasquatch%2Fsquatch-js@2.6.3
|
|
368
376
|
[2.6.2]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.1...@saasquatch%2Fsquatch-js@2.6.2
|
|
369
377
|
[2.6.1]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.0...@saasquatch%2Fsquatch-js@2.6.1
|
package/dist/squatch.cjs.js
CHANGED
|
@@ -756,6 +756,41 @@ function _buildParams({
|
|
|
756
756
|
if (locale) queryParams.append("locale", locale);
|
|
757
757
|
return `?${queryParams.toString()}`;
|
|
758
758
|
}
|
|
759
|
+
/*!
|
|
760
|
+
* domready (c) Dustin Diaz 2014 - License MIT
|
|
761
|
+
*
|
|
762
|
+
*/
|
|
763
|
+
function domready(targetDoc, fn) {
|
|
764
|
+
let fns = [];
|
|
765
|
+
let listener;
|
|
766
|
+
let doc = targetDoc;
|
|
767
|
+
let hack = doc.documentElement.doScroll;
|
|
768
|
+
let domContentLoaded = "DOMContentLoaded";
|
|
769
|
+
let loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
|
|
770
|
+
if (!loaded)
|
|
771
|
+
doc.addEventListener(
|
|
772
|
+
domContentLoaded,
|
|
773
|
+
listener = () => {
|
|
774
|
+
doc.removeEventListener(domContentLoaded, listener);
|
|
775
|
+
loaded = true;
|
|
776
|
+
while (listener = fns.shift()) listener();
|
|
777
|
+
}
|
|
778
|
+
);
|
|
779
|
+
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
780
|
+
}
|
|
781
|
+
function formatWidth({
|
|
782
|
+
value,
|
|
783
|
+
unit
|
|
784
|
+
}) {
|
|
785
|
+
switch (unit) {
|
|
786
|
+
case "PX":
|
|
787
|
+
return `${value}px`;
|
|
788
|
+
case "%":
|
|
789
|
+
return `${value}%`;
|
|
790
|
+
default:
|
|
791
|
+
return `${value}px`;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
759
794
|
class AnalyticsApi {
|
|
760
795
|
/**
|
|
761
796
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
@@ -1064,28 +1099,6 @@ function delay(duration) {
|
|
|
1064
1099
|
setTimeout(resolve, duration);
|
|
1065
1100
|
});
|
|
1066
1101
|
}
|
|
1067
|
-
/*!
|
|
1068
|
-
* domready (c) Dustin Diaz 2014 - License MIT
|
|
1069
|
-
*
|
|
1070
|
-
*/
|
|
1071
|
-
function domready(targetDoc, fn) {
|
|
1072
|
-
let fns = [];
|
|
1073
|
-
let listener;
|
|
1074
|
-
let doc = targetDoc;
|
|
1075
|
-
let hack = doc.documentElement.doScroll;
|
|
1076
|
-
let domContentLoaded = "DOMContentLoaded";
|
|
1077
|
-
let loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
|
|
1078
|
-
if (!loaded)
|
|
1079
|
-
doc.addEventListener(
|
|
1080
|
-
domContentLoaded,
|
|
1081
|
-
listener = () => {
|
|
1082
|
-
doc.removeEventListener(domContentLoaded, listener);
|
|
1083
|
-
loaded = true;
|
|
1084
|
-
while (listener = fns.shift()) listener();
|
|
1085
|
-
}
|
|
1086
|
-
);
|
|
1087
|
-
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
1088
|
-
}
|
|
1089
1102
|
const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
|
|
1090
1103
|
class EmbedWidget extends Widget {
|
|
1091
1104
|
constructor(params, container) {
|
|
@@ -1095,7 +1108,7 @@ class EmbedWidget extends Widget {
|
|
|
1095
1108
|
if (container) this.container = container;
|
|
1096
1109
|
}
|
|
1097
1110
|
async load() {
|
|
1098
|
-
var _a2, _b;
|
|
1111
|
+
var _a2, _b, _c, _d, _e;
|
|
1099
1112
|
const frame = this._createFrame();
|
|
1100
1113
|
const element = this._findElement();
|
|
1101
1114
|
if ((_a2 = this.context) == null ? void 0 : _a2.container) {
|
|
@@ -1103,9 +1116,15 @@ class EmbedWidget extends Widget {
|
|
|
1103
1116
|
element.style.height = "0";
|
|
1104
1117
|
element.style["overflow-y"] = "hidden";
|
|
1105
1118
|
}
|
|
1119
|
+
const brandingConfig = (_c = (_b = this.context.widgetConfig) == null ? void 0 : _b.values) == null ? void 0 : _c.brandingConfig;
|
|
1120
|
+
const sizes = (_d = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _d.embedWidgets;
|
|
1121
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "100%";
|
|
1122
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
|
|
1123
|
+
element.style.maxWidth = maxWidth;
|
|
1124
|
+
element.style.minWidth = minWidth;
|
|
1106
1125
|
if (this.container) {
|
|
1107
1126
|
if (element.shadowRoot) {
|
|
1108
|
-
if (((
|
|
1127
|
+
if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
|
|
1109
1128
|
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1110
1129
|
} else {
|
|
1111
1130
|
element.shadowRoot.appendChild(frame);
|
|
@@ -1228,11 +1247,16 @@ class PopupWidget extends Widget {
|
|
|
1228
1247
|
}
|
|
1229
1248
|
}
|
|
1230
1249
|
_createPopupDialog() {
|
|
1250
|
+
var _a2, _b, _c;
|
|
1231
1251
|
const dialog = document.createElement("dialog");
|
|
1252
|
+
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1253
|
+
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
|
|
1254
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
|
|
1255
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
|
|
1232
1256
|
dialog.id = this.id;
|
|
1233
1257
|
dialog.setAttribute(
|
|
1234
1258
|
"style",
|
|
1235
|
-
|
|
1259
|
+
`width: 100%; min-width: ${minWidth}; max-width: ${maxWidth}; border: none; padding: 0;`
|
|
1236
1260
|
);
|
|
1237
1261
|
const onClick = (e) => {
|
|
1238
1262
|
e.stopPropagation();
|
|
@@ -1861,16 +1885,17 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1861
1885
|
* @hidden
|
|
1862
1886
|
*/
|
|
1863
1887
|
__publicField(this, "loaded");
|
|
1864
|
-
__publicField(this, "_setWidget", (
|
|
1888
|
+
__publicField(this, "_setWidget", (res, config) => {
|
|
1865
1889
|
var _a2;
|
|
1866
1890
|
const params = {
|
|
1867
1891
|
api: this.widgetApi,
|
|
1868
|
-
content: template,
|
|
1892
|
+
content: res.template,
|
|
1869
1893
|
context: {
|
|
1870
1894
|
type: config.type,
|
|
1871
1895
|
user: config.user,
|
|
1872
1896
|
container: this.container || void 0,
|
|
1873
|
-
engagementMedium: this.type
|
|
1897
|
+
engagementMedium: this.type,
|
|
1898
|
+
config: res.widgetConfig
|
|
1874
1899
|
},
|
|
1875
1900
|
type: this.widgetType,
|
|
1876
1901
|
domain: ((_a2 = this.config) == null ? void 0 : _a2.domain) || DEFAULT_DOMAIN,
|
|
@@ -1938,7 +1963,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1938
1963
|
engagementMedium: this.type,
|
|
1939
1964
|
widgetType: this.widgetType,
|
|
1940
1965
|
locale: this.locale
|
|
1941
|
-
}).then((res) => this._setWidget(res
|
|
1966
|
+
}).then((res) => this._setWidget(res, { type: "passwordless" })).catch(this.setErrorWidget);
|
|
1942
1967
|
}
|
|
1943
1968
|
async renderUserUpsertVariant() {
|
|
1944
1969
|
this._setupApis();
|
|
@@ -1947,15 +1972,20 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1947
1972
|
return this.setErrorWidget(Error("No user object in token."));
|
|
1948
1973
|
}
|
|
1949
1974
|
_log$1("Rendering as a Verified widget");
|
|
1950
|
-
|
|
1975
|
+
await this.widgetApi.upsertUser({
|
|
1951
1976
|
user: userObj,
|
|
1952
1977
|
locale: this.locale,
|
|
1953
1978
|
engagementMedium: this.type,
|
|
1954
1979
|
widgetType: this.widgetType,
|
|
1955
1980
|
jwt: this.token
|
|
1956
|
-
})
|
|
1957
|
-
|
|
1958
|
-
|
|
1981
|
+
});
|
|
1982
|
+
const widgetInstance = await this.widgetApi.render({
|
|
1983
|
+
locale: this.locale,
|
|
1984
|
+
engagementMedium: this.type,
|
|
1985
|
+
widgetType: this.widgetType
|
|
1986
|
+
}).then((res) => {
|
|
1987
|
+
return this._setWidget(res, { type: "upsert", user: userObj });
|
|
1988
|
+
}).catch(this.setErrorWidget);
|
|
1959
1989
|
return widgetInstance;
|
|
1960
1990
|
}
|
|
1961
1991
|
/**
|