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