@saasquatch/squatch-js 2.8.2-34 → 2.8.2-36

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.js CHANGED
@@ -1168,6 +1168,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1168
1168
  <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1169
1169
  (_g = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _g.brandFont
1170
1170
  )}" as="style">` : ""}
1171
+ <link rel="dns-prefetch" href="https://res.cloudinary.com">
1172
+ <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1171
1173
  <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1172
1174
  <style data-styles>
1173
1175
  html { visibility:hidden;}
@@ -1275,11 +1277,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1275
1277
  };
1276
1278
  }
1277
1279
  }
1278
- _createPopupDialog() {
1279
- var _a2, _b, _c;
1280
+ _createPopupDialog(brandingConfig) {
1281
+ var _a2;
1280
1282
  const dialog = document.createElement("dialog");
1281
- const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1282
- const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
1283
+ const sizes = (_a2 = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _a2.popupWidgets;
1283
1284
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
1284
1285
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
1285
1286
  dialog.id = this.id;
@@ -1295,14 +1296,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1295
1296
  return dialog;
1296
1297
  }
1297
1298
  async load() {
1298
- var _a2;
1299
- const frame = this._createFrame();
1299
+ var _a2, _b, _c, _d, _e;
1300
+ console.log("TESTING!");
1301
+ const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1302
+ const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1303
+ console.log({ initialHeight, brandingConfig });
1304
+ const frame = this._createFrame({ initialHeight });
1300
1305
  this._initialiseCTA();
1301
1306
  const element = this.container ? this._findElement() : document.body;
1302
1307
  const dialogParent = element.shadowRoot || element;
1303
- const dialog = this._createPopupDialog();
1308
+ const dialog = this._createPopupDialog(brandingConfig);
1304
1309
  dialog.appendChild(frame);
1305
- if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
1310
+ if (((_c = dialogParent.lastChild) == null ? void 0 : _c.nodeName) === "DIALOG") {
1306
1311
  dialogParent.replaceChild(dialog, dialogParent.lastChild);
1307
1312
  } else {
1308
1313
  dialogParent.appendChild(dialog);
@@ -1313,27 +1318,29 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1313
1318
  }
1314
1319
  const frameDoc = contentWindow.document;
1315
1320
  frameDoc.open();
1316
- frameDoc.write(this.content);
1317
- frameDoc.write(
1318
- `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1319
- );
1321
+ const domain = this.widgetApi.domain;
1320
1322
  frameDoc.write(`
1321
- <style>
1322
- body {
1323
- height: 600px;
1324
- border: 2px solid #ccc;
1325
- background-color: red;
1326
- margin: 0;
1327
- padding: 0;
1328
- box-sizing: border-box;
1329
- }
1330
- </style>
1331
- `);
1323
+ ${((_d = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _d.brandFont) ? `
1324
+ <link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
1325
+ <link rel="preconnect" href="https://fonts.gstatic.com">
1326
+ <link rel="preconnect" href="https://fonts.googleapis.com">
1327
+ <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1328
+ (_e = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _e.brandFont
1329
+ )}" as="style">` : ""}
1330
+ <link rel="dns-prefetch" href="https://res.cloudinary.com">
1331
+ <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1332
+ <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1333
+ <style data-styles>
1334
+ html { visibility:hidden;}
1335
+ </style>
1336
+ ${this.content}
1337
+
1338
+ `);
1332
1339
  frameDoc.close();
1333
1340
  _log$6("Popup template loaded into iframe");
1334
- await this._setupResizeHandler(frame);
1341
+ await this._setupResizeHandler(frame, initialHeight);
1335
1342
  }
1336
- async _setupResizeHandler(frame) {
1343
+ async _setupResizeHandler(frame, initialHeight) {
1337
1344
  const { contentWindow } = frame;
1338
1345
  if (!contentWindow) {
1339
1346
  throw new Error("Frame needs a content window");
@@ -1341,7 +1348,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1341
1348
  const frameDoc = contentWindow.document;
1342
1349
  domready(frameDoc, async () => {
1343
1350
  frameDoc.body.style.overflowY = "hidden";
1344
- frame.height = `${frameDoc.body.offsetHeight}px`;
1351
+ frame.height = initialHeight || frameDoc.body.offsetHeight;
1345
1352
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1346
1353
  for (const entry of entries) {
1347
1354
  const { top, bottom } = entry.contentRect;
@@ -1507,11 +1514,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1507
1514
  engagementMedium: clean.engagementMedium,
1508
1515
  container: clean.container,
1509
1516
  trigger: clean.trigger,
1510
- widgetConfig: {
1511
- values: {
1512
- brandingConfig: response == null ? void 0 : response.brandingConfig
1513
- }
1514
- }
1517
+ widgetConfig: response == null ? void 0 : response.widgetConfig
1515
1518
  }),
1516
1519
  user: response.user
1517
1520
  };