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