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