@saasquatch/squatch-js 2.8.2-16 → 2.8.2-18
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/dist/squatch.cjs.js +102 -128
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +102 -128
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +102 -128
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/package.json +1 -1
package/dist/squatch.js
CHANGED
|
@@ -1121,104 +1121,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1121
1121
|
}
|
|
1122
1122
|
}
|
|
1123
1123
|
//Old code for testing
|
|
1124
|
-
async load() {
|
|
1125
|
-
var _a2, _b, _c, _d, _e;
|
|
1126
|
-
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1127
|
-
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
|
|
1128
|
-
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
|
|
1129
|
-
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
|
|
1130
|
-
const frame = this._createFrame({ minWidth, maxWidth });
|
|
1131
|
-
const element = this._findElement();
|
|
1132
|
-
if ((_d = this.context) == null ? void 0 : _d.container) {
|
|
1133
|
-
element.style.visibility = "hidden";
|
|
1134
|
-
element.style.height = "0";
|
|
1135
|
-
element.style["overflow-y"] = "hidden";
|
|
1136
|
-
}
|
|
1137
|
-
if (this.container) {
|
|
1138
|
-
if (element.shadowRoot) {
|
|
1139
|
-
if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
|
|
1140
|
-
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1141
|
-
} else {
|
|
1142
|
-
element.shadowRoot.appendChild(frame);
|
|
1143
|
-
}
|
|
1144
|
-
} else if (element.firstChild) {
|
|
1145
|
-
element.replaceChild(frame, element.firstChild);
|
|
1146
|
-
} else {
|
|
1147
|
-
element.appendChild(frame);
|
|
1148
|
-
}
|
|
1149
|
-
} else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1150
|
-
element.appendChild(frame);
|
|
1151
|
-
}
|
|
1152
|
-
const { contentWindow } = frame;
|
|
1153
|
-
if (!contentWindow) {
|
|
1154
|
-
throw new Error("Frame needs a content window");
|
|
1155
|
-
}
|
|
1156
|
-
const frameDoc = contentWindow.document;
|
|
1157
|
-
frameDoc.open();
|
|
1158
|
-
frameDoc.write(this.content);
|
|
1159
|
-
frameDoc.write(
|
|
1160
|
-
`<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
|
|
1161
|
-
);
|
|
1162
|
-
frameDoc.close();
|
|
1163
|
-
domready(frameDoc, async () => {
|
|
1164
|
-
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1165
|
-
frame.height = frameDoc.body.scrollHeight;
|
|
1166
|
-
const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
1167
|
-
for (const entry of entries) {
|
|
1168
|
-
const { height } = entry.contentRect;
|
|
1169
|
-
frame.height = height;
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
const container = await this._findInnerContainer(frame);
|
|
1173
|
-
ro.observe(container);
|
|
1174
|
-
if (this._shouldFireLoadEvent()) {
|
|
1175
|
-
this._loadEvent(_sqh);
|
|
1176
|
-
_log$7("loaded");
|
|
1177
|
-
} else if (frameDoc) {
|
|
1178
|
-
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
1124
|
// async load() {
|
|
1183
1125
|
// const brandingConfig = this.context.widgetConfig?.values?.brandingConfig;
|
|
1184
|
-
// // @ts-ignore
|
|
1185
|
-
// const initialHeight = brandingConfig?.loadingHeight;
|
|
1186
|
-
// const skeletonBackgroundColor =
|
|
1187
|
-
// brandingConfig?.color?.loadingSkeleton?.background;
|
|
1188
|
-
// const skeletonShimmerColor =
|
|
1189
|
-
// brandingConfig?.color?.loadingSkeleton?.animationBackground;
|
|
1190
|
-
// const borderColor = brandingConfig?.border?.borderColor;
|
|
1191
1126
|
// const sizes = brandingConfig?.widgetSize?.embeddedWidgets;
|
|
1192
1127
|
// const maxWidth = sizes?.maxWidth ? formatWidth(sizes.maxWidth) : "";
|
|
1193
1128
|
// const minWidth = sizes?.minWidth ? formatWidth(sizes.minWidth) : "";
|
|
1194
|
-
//
|
|
1195
|
-
// brandingConfig,
|
|
1196
|
-
// initialHeight,
|
|
1197
|
-
// widgetConfig: this.context.widgetConfig,
|
|
1198
|
-
// });
|
|
1199
|
-
// // const skeletonHTML = getSkeleton({
|
|
1200
|
-
// // height: initialHeight,
|
|
1201
|
-
// // skeletonBackgroundColor,
|
|
1202
|
-
// // skeletonShimmerColor,
|
|
1203
|
-
// // borderColor,
|
|
1204
|
-
// // });
|
|
1205
|
-
// // const skeletonContainer = document.createElement("div");
|
|
1206
|
-
// // skeletonContainer.innerHTML = skeletonHTML;
|
|
1207
|
-
// const frame = this._createFrame({
|
|
1208
|
-
// minWidth,
|
|
1209
|
-
// maxWidth,
|
|
1210
|
-
// initialHeight,
|
|
1211
|
-
// });
|
|
1129
|
+
// const frame = this._createFrame({ minWidth, maxWidth });
|
|
1212
1130
|
// const element = this._findElement();
|
|
1213
|
-
// // element.innerHTML = skeletonHTML;
|
|
1214
|
-
// // Hide frame initially
|
|
1215
|
-
// frame.style.display = "none";
|
|
1216
|
-
// const injectContents = (target: HTMLElement | ShadowRoot) => {
|
|
1217
|
-
// // Optional: Clear target to prevent duplicates if load() is called twice
|
|
1218
|
-
// // target.innerHTML = "";
|
|
1219
|
-
// // target.appendChild(skeletonContainer);
|
|
1220
|
-
// target.appendChild(frame);
|
|
1221
|
-
// };
|
|
1222
1131
|
// if (this.context?.container) {
|
|
1223
1132
|
// // Custom container is used
|
|
1224
1133
|
// element.style.visibility = "hidden";
|
|
@@ -1230,56 +1139,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1230
1139
|
// if (element.shadowRoot.lastChild?.nodeName === "IFRAME") {
|
|
1231
1140
|
// element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1232
1141
|
// } else {
|
|
1233
|
-
//
|
|
1142
|
+
// element.shadowRoot.appendChild(frame);
|
|
1234
1143
|
// }
|
|
1235
|
-
// }
|
|
1236
|
-
//
|
|
1237
|
-
//
|
|
1238
|
-
//
|
|
1144
|
+
// }
|
|
1145
|
+
// // Widget reloaded - replace existing element
|
|
1146
|
+
// else if (element.firstChild) {
|
|
1147
|
+
// element.replaceChild(frame, element.firstChild);
|
|
1148
|
+
// // Add iframe for the first time
|
|
1239
1149
|
// } else {
|
|
1240
|
-
//
|
|
1150
|
+
// element.appendChild(frame);
|
|
1241
1151
|
// }
|
|
1152
|
+
// } else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1153
|
+
// element.appendChild(frame);
|
|
1242
1154
|
// }
|
|
1243
|
-
// // else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1244
|
-
// // injectContents(element);
|
|
1245
|
-
// // }
|
|
1246
1155
|
// const { contentWindow } = frame;
|
|
1247
1156
|
// if (!contentWindow) {
|
|
1248
1157
|
// throw new Error("Frame needs a content window");
|
|
1249
1158
|
// }
|
|
1250
1159
|
// const frameDoc = contentWindow.document;
|
|
1251
1160
|
// frameDoc.open();
|
|
1252
|
-
//
|
|
1253
|
-
//
|
|
1254
|
-
//
|
|
1255
|
-
//
|
|
1256
|
-
// brandingConfig?.main?.brandFont &&
|
|
1257
|
-
// `
|
|
1258
|
-
// <link rel="preconnect" href="https://fast${
|
|
1259
|
-
// domain === "https://staging.referralsaasquatch.com" && "-staging"
|
|
1260
|
-
// }.ssqt.io">
|
|
1261
|
-
// <link rel="preconnect" href="https://fonts.gstatic.com">
|
|
1262
|
-
// <link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1263
|
-
// <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1264
|
-
// brandingConfig?.main?.brandFont
|
|
1265
|
-
// )}" as="style">`
|
|
1266
|
-
// }
|
|
1267
|
-
// <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1268
|
-
// <style data-styles>
|
|
1269
|
-
// html { visibility:hidden;}
|
|
1270
|
-
// </style>
|
|
1271
|
-
// ${this.content}
|
|
1272
|
-
// `);
|
|
1161
|
+
// frameDoc.write(this.content);
|
|
1162
|
+
// frameDoc.write(
|
|
1163
|
+
// `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
|
|
1164
|
+
// );
|
|
1273
1165
|
// frameDoc.close();
|
|
1274
1166
|
// domready(frameDoc, async () => {
|
|
1275
|
-
// // if (skeletonContainer && skeletonContainer.parentNode) {
|
|
1276
|
-
// // skeletonContainer.parentNode.removeChild(skeletonContainer);
|
|
1277
|
-
// // }
|
|
1278
|
-
// frame.style.display = "block";
|
|
1279
1167
|
// const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1280
1168
|
// // @ts-ignore -- number will be cast to string by browsers
|
|
1281
|
-
// frame.height =
|
|
1282
|
-
// console.log({ height: frameDoc.body.scrollHeight });
|
|
1169
|
+
// frame.height = frameDoc.body.scrollHeight;
|
|
1283
1170
|
// // Adjust frame height when size of body changes
|
|
1284
1171
|
// /* istanbul ignore next: hard to test */
|
|
1285
1172
|
// const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
@@ -1299,6 +1186,93 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1299
1186
|
// }
|
|
1300
1187
|
// });
|
|
1301
1188
|
// }
|
|
1189
|
+
async load() {
|
|
1190
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1191
|
+
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1192
|
+
const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
|
|
1193
|
+
(_d = (_c = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _c.loadingSkeleton) == null ? void 0 : _d.background;
|
|
1194
|
+
(_f = (_e = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _e.loadingSkeleton) == null ? void 0 : _f.animationBackground;
|
|
1195
|
+
(_g = brandingConfig == null ? void 0 : brandingConfig.border) == null ? void 0 : _g.borderColor;
|
|
1196
|
+
const sizes = (_h = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _h.embeddedWidgets;
|
|
1197
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
|
|
1198
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
|
|
1199
|
+
console.log({
|
|
1200
|
+
brandingConfig,
|
|
1201
|
+
initialHeight,
|
|
1202
|
+
widgetConfig: this.context.widgetConfig
|
|
1203
|
+
});
|
|
1204
|
+
const frame = this._createFrame({
|
|
1205
|
+
minWidth,
|
|
1206
|
+
maxWidth,
|
|
1207
|
+
initialHeight
|
|
1208
|
+
});
|
|
1209
|
+
const element = this._findElement();
|
|
1210
|
+
const injectContents = (target) => {
|
|
1211
|
+
target.appendChild(frame);
|
|
1212
|
+
};
|
|
1213
|
+
if ((_i = this.context) == null ? void 0 : _i.container) {
|
|
1214
|
+
element.style.visibility = "hidden";
|
|
1215
|
+
element.style.height = "0";
|
|
1216
|
+
element.style["overflow-y"] = "hidden";
|
|
1217
|
+
}
|
|
1218
|
+
if (this.container) {
|
|
1219
|
+
if (element.shadowRoot) {
|
|
1220
|
+
if (((_j = element.shadowRoot.lastChild) == null ? void 0 : _j.nodeName) === "IFRAME") {
|
|
1221
|
+
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1222
|
+
} else {
|
|
1223
|
+
injectContents(element.shadowRoot);
|
|
1224
|
+
}
|
|
1225
|
+
} else if (element.firstChild) {
|
|
1226
|
+
element.replaceChild(frame, element.firstChild);
|
|
1227
|
+
} else {
|
|
1228
|
+
injectContents(element);
|
|
1229
|
+
}
|
|
1230
|
+
} else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1231
|
+
injectContents(element);
|
|
1232
|
+
}
|
|
1233
|
+
const { contentWindow } = frame;
|
|
1234
|
+
if (!contentWindow) {
|
|
1235
|
+
throw new Error("Frame needs a content window");
|
|
1236
|
+
}
|
|
1237
|
+
const frameDoc = contentWindow.document;
|
|
1238
|
+
frameDoc.open();
|
|
1239
|
+
const domain = this.widgetApi.domain;
|
|
1240
|
+
frameDoc.write(`
|
|
1241
|
+
${((_k = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _k.brandFont) && `
|
|
1242
|
+
<link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
1243
|
+
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
1244
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1245
|
+
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1246
|
+
(_l = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _l.brandFont
|
|
1247
|
+
)}" as="style">`}
|
|
1248
|
+
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1249
|
+
<style data-styles>
|
|
1250
|
+
html { visibility:hidden;}
|
|
1251
|
+
</style>
|
|
1252
|
+
${this.content}
|
|
1253
|
+
|
|
1254
|
+
`);
|
|
1255
|
+
frameDoc.close();
|
|
1256
|
+
domready(frameDoc, async () => {
|
|
1257
|
+
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1258
|
+
frame.height = initialHeight || frameDoc.body.scrollHeight;
|
|
1259
|
+
console.log({ height: frameDoc.body.scrollHeight });
|
|
1260
|
+
const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
1261
|
+
for (const entry of entries) {
|
|
1262
|
+
const { height } = entry.contentRect;
|
|
1263
|
+
frame.height = height;
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
const container = await this._findInnerContainer(frame);
|
|
1267
|
+
ro.observe(container);
|
|
1268
|
+
if (this._shouldFireLoadEvent()) {
|
|
1269
|
+
this._loadEvent(_sqh);
|
|
1270
|
+
_log$7("loaded");
|
|
1271
|
+
} else if (frameDoc) {
|
|
1272
|
+
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1302
1276
|
/**
|
|
1303
1277
|
* Un-hide if element is available and refresh data
|
|
1304
1278
|
*/
|