@saasquatch/squatch-js 2.8.2-0 → 2.8.2-10
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/CHANGELOG.md +8 -1
- package/README.md +3 -11
- package/dist/squatch.cjs.js +485 -34
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.d.ts +1 -1
- package/dist/squatch.esm.js +485 -34
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +485 -34
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/dist/utils/utmUtils.d.ts +1 -10
- package/dist/widgets/SkeletonTemplate.d.ts +12 -0
- package/dist/widgets/Widget.d.ts +1 -0
- package/package.json +1 -1
- package/coverage/clover.xml +0 -708
- package/coverage/coverage-final.json +0 -16
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -1276
package/dist/squatch.js
CHANGED
|
@@ -704,6 +704,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
704
704
|
const raw = params;
|
|
705
705
|
const clean = validatePasswordlessConfig(raw);
|
|
706
706
|
const { widgetType, engagementMedium = "POPUP", jwt, user } = clean;
|
|
707
|
+
console.log({ params });
|
|
707
708
|
const tenantAlias = encodeURIComponent(this.tenantAlias);
|
|
708
709
|
const accountId = (user == null ? void 0 : user.accountId) ? encodeURIComponent(user.accountId) : null;
|
|
709
710
|
const userId = (user == null ? void 0 : user.id) ? encodeURIComponent(user.id) : null;
|
|
@@ -892,6 +893,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
892
893
|
if ((options == null ? void 0 : options.maxWidth) || (options == null ? void 0 : options.minWidth)) {
|
|
893
894
|
frame.style.width = "100%";
|
|
894
895
|
}
|
|
896
|
+
if (options == null ? void 0 : options.initialHeight) {
|
|
897
|
+
frame.height = options.initialHeight;
|
|
898
|
+
}
|
|
895
899
|
return frame;
|
|
896
900
|
}
|
|
897
901
|
_findFrame() {
|
|
@@ -1106,41 +1110,416 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1106
1110
|
setTimeout(resolve, duration);
|
|
1107
1111
|
});
|
|
1108
1112
|
}
|
|
1113
|
+
const getSkeleton = ({
|
|
1114
|
+
height = "500px",
|
|
1115
|
+
skeletonBackgroundColor = "#e0e0e0",
|
|
1116
|
+
skeletonShimmerColor = "#f5f5f5",
|
|
1117
|
+
borderColor = "#ccc"
|
|
1118
|
+
}) => {
|
|
1119
|
+
return `
|
|
1120
|
+
<style>
|
|
1121
|
+
* {
|
|
1122
|
+
box-sizing: border-box;
|
|
1123
|
+
padding: 0;
|
|
1124
|
+
margin: 0;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
.widget-container {
|
|
1128
|
+
background: white;
|
|
1129
|
+
width: 100%;
|
|
1130
|
+
max-width: 900px;
|
|
1131
|
+
padding: 40px;
|
|
1132
|
+
border-radius: 12px;
|
|
1133
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
|
1134
|
+
box-sizing: border-box;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
@keyframes shimmer {
|
|
1138
|
+
0% {
|
|
1139
|
+
background-position: -100% 0;
|
|
1140
|
+
}
|
|
1141
|
+
100% {
|
|
1142
|
+
background-position: 100% 0;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
.skeleton {
|
|
1147
|
+
background: ${skeletonBackgroundColor};
|
|
1148
|
+
background: linear-gradient(
|
|
1149
|
+
90deg,
|
|
1150
|
+
${skeletonBackgroundColor} 25%,
|
|
1151
|
+
${skeletonShimmerColor} 50%,
|
|
1152
|
+
${skeletonBackgroundColor} 75%
|
|
1153
|
+
);
|
|
1154
|
+
background-size: 200% 100%;
|
|
1155
|
+
animation: shimmer 1.5s infinite linear;
|
|
1156
|
+
border-radius: 6px;
|
|
1157
|
+
margin-bottom: 12px;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.sk-title-lg {
|
|
1161
|
+
height: 36px;
|
|
1162
|
+
width: 50%;
|
|
1163
|
+
margin-bottom: 16px;
|
|
1164
|
+
}
|
|
1165
|
+
.sk-title-md {
|
|
1166
|
+
height: 28px;
|
|
1167
|
+
width: 30%;
|
|
1168
|
+
margin-bottom: 20px;
|
|
1169
|
+
margin-top: 40px;
|
|
1170
|
+
}
|
|
1171
|
+
.sk-text {
|
|
1172
|
+
height: 16px;
|
|
1173
|
+
width: 80%;
|
|
1174
|
+
margin-bottom: 8px;
|
|
1175
|
+
}
|
|
1176
|
+
.sk-text-short {
|
|
1177
|
+
width: 40%;
|
|
1178
|
+
}
|
|
1179
|
+
.sk-label {
|
|
1180
|
+
height: 14px;
|
|
1181
|
+
width: 25%;
|
|
1182
|
+
margin-bottom: 10px;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
.hero-section {
|
|
1186
|
+
display: flex;
|
|
1187
|
+
gap: 40px;
|
|
1188
|
+
margin-bottom: 40px;
|
|
1189
|
+
border-bottom: 1px solid ${borderColor};
|
|
1190
|
+
padding-bottom: 40px;
|
|
1191
|
+
flex-direction: row;
|
|
1192
|
+
}
|
|
1193
|
+
.hero-content {
|
|
1194
|
+
flex: 1;
|
|
1195
|
+
display: flex;
|
|
1196
|
+
flex-direction: column;
|
|
1197
|
+
justify-content: center;
|
|
1198
|
+
}
|
|
1199
|
+
.hero-image {
|
|
1200
|
+
flex: 1;
|
|
1201
|
+
height: 300px;
|
|
1202
|
+
border-radius: 12px;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
.share-section {
|
|
1206
|
+
margin-bottom: 40px;
|
|
1207
|
+
}
|
|
1208
|
+
.sk-input {
|
|
1209
|
+
height: 50px;
|
|
1210
|
+
width: 100%;
|
|
1211
|
+
border-radius: 8px;
|
|
1212
|
+
margin-bottom: 16px;
|
|
1213
|
+
}
|
|
1214
|
+
.social-buttons {
|
|
1215
|
+
display: flex;
|
|
1216
|
+
gap: 12px;
|
|
1217
|
+
}
|
|
1218
|
+
.sk-btn-social {
|
|
1219
|
+
flex: 1;
|
|
1220
|
+
height: 50px;
|
|
1221
|
+
border-radius: 8px;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
.stats-section {
|
|
1225
|
+
display: flex;
|
|
1226
|
+
gap: 24px;
|
|
1227
|
+
margin-bottom: 40px;
|
|
1228
|
+
padding: 30px 0;
|
|
1229
|
+
border-top: 1px solid ${borderColor};
|
|
1230
|
+
border-bottom: 1px solid ${borderColor};
|
|
1231
|
+
}
|
|
1232
|
+
.stat-card {
|
|
1233
|
+
flex: 1;
|
|
1234
|
+
display: flex;
|
|
1235
|
+
flex-direction: column;
|
|
1236
|
+
align-items: center;
|
|
1237
|
+
}
|
|
1238
|
+
.stat-divider {
|
|
1239
|
+
padding-left: 24px;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
.sk-stat-num {
|
|
1243
|
+
height: 48px;
|
|
1244
|
+
width: 120px;
|
|
1245
|
+
margin-bottom: 8px;
|
|
1246
|
+
}
|
|
1247
|
+
.sk-stat-label {
|
|
1248
|
+
height: 18px;
|
|
1249
|
+
width: 80px;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
.table-header {
|
|
1253
|
+
display: flex;
|
|
1254
|
+
gap: 16px;
|
|
1255
|
+
margin-bottom: 16px;
|
|
1256
|
+
}
|
|
1257
|
+
.sk-th {
|
|
1258
|
+
height: 16px;
|
|
1259
|
+
}
|
|
1260
|
+
.table-row {
|
|
1261
|
+
display: flex;
|
|
1262
|
+
align-items: center;
|
|
1263
|
+
gap: 16px;
|
|
1264
|
+
padding: 16px 0;
|
|
1265
|
+
border-bottom: 1px solid ${borderColor};
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
.col-user {
|
|
1269
|
+
flex: 2;
|
|
1270
|
+
}
|
|
1271
|
+
.col-status {
|
|
1272
|
+
flex: 1;
|
|
1273
|
+
}
|
|
1274
|
+
.col-reward {
|
|
1275
|
+
flex: 2;
|
|
1276
|
+
}
|
|
1277
|
+
.col-date {
|
|
1278
|
+
flex: 1;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
.sk-badge {
|
|
1282
|
+
height: 28px;
|
|
1283
|
+
width: 90px;
|
|
1284
|
+
border-radius: 14px;
|
|
1285
|
+
}
|
|
1286
|
+
.sk-reward-block {
|
|
1287
|
+
height: 36px;
|
|
1288
|
+
width: 100%;
|
|
1289
|
+
border-radius: 6px;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.pagination {
|
|
1293
|
+
display: flex;
|
|
1294
|
+
justify-content: flex-end;
|
|
1295
|
+
gap: 8px;
|
|
1296
|
+
margin-top: 24px;
|
|
1297
|
+
}
|
|
1298
|
+
.sk-btn-page {
|
|
1299
|
+
height: 36px;
|
|
1300
|
+
width: 64px;
|
|
1301
|
+
border-radius: 6px;
|
|
1302
|
+
margin-bottom: 0;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
@media (max-width: 768px) {
|
|
1306
|
+
body {
|
|
1307
|
+
padding: 20px;
|
|
1308
|
+
}
|
|
1309
|
+
.widget-container {
|
|
1310
|
+
padding: 24px;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
.hero-section {
|
|
1314
|
+
flex-direction: column-reverse;
|
|
1315
|
+
gap: 24px;
|
|
1316
|
+
}
|
|
1317
|
+
.hero-image {
|
|
1318
|
+
height: 220px;
|
|
1319
|
+
width: 100%;
|
|
1320
|
+
}
|
|
1321
|
+
.sk-title-lg {
|
|
1322
|
+
width: 80%;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
.col-date {
|
|
1326
|
+
display: none;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
@media (max-width: 480px) {
|
|
1331
|
+
body {
|
|
1332
|
+
padding: 10px;
|
|
1333
|
+
}
|
|
1334
|
+
.widget-container {
|
|
1335
|
+
padding: 16px;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
.sk-stat-num {
|
|
1339
|
+
width: 80px;
|
|
1340
|
+
height: 40px;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
.col-reward {
|
|
1344
|
+
display: none;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
.col-user {
|
|
1348
|
+
flex: 3;
|
|
1349
|
+
}
|
|
1350
|
+
.col-status {
|
|
1351
|
+
flex: 2;
|
|
1352
|
+
display: flex;
|
|
1353
|
+
justify-content: flex-end;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
</style>
|
|
1357
|
+
|
|
1358
|
+
<div class="widget-container">
|
|
1359
|
+
<div class="hero-section">
|
|
1360
|
+
<div class="hero-content">
|
|
1361
|
+
<div class="skeleton sk-title-lg"></div>
|
|
1362
|
+
<div class="skeleton sk-text"></div>
|
|
1363
|
+
<div class="skeleton sk-text sk-text-short"></div>
|
|
1364
|
+
</div>
|
|
1365
|
+
<div class="skeleton hero-image"></div>
|
|
1366
|
+
</div>
|
|
1367
|
+
|
|
1368
|
+
<div class="share-section">
|
|
1369
|
+
<div class="skeleton sk-label"></div>
|
|
1370
|
+
<div class="skeleton sk-input"></div>
|
|
1371
|
+
<div class="social-buttons">
|
|
1372
|
+
<div class="skeleton sk-btn-social"></div>
|
|
1373
|
+
<div class="skeleton sk-btn-social"></div>
|
|
1374
|
+
<div class="skeleton sk-btn-social"></div>
|
|
1375
|
+
<div class="skeleton sk-btn-social"></div>
|
|
1376
|
+
</div>
|
|
1377
|
+
</div>
|
|
1378
|
+
|
|
1379
|
+
<div
|
|
1380
|
+
class="skeleton sk-title-md"
|
|
1381
|
+
style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"
|
|
1382
|
+
></div>
|
|
1383
|
+
<div
|
|
1384
|
+
class="skeleton sk-text"
|
|
1385
|
+
style="width: 60%; margin-left: auto; margin-right: auto"
|
|
1386
|
+
></div>
|
|
1387
|
+
|
|
1388
|
+
<div class="stats-section">
|
|
1389
|
+
<div class="stat-card">
|
|
1390
|
+
<div class="skeleton sk-stat-num"></div>
|
|
1391
|
+
<div class="skeleton sk-stat-label"></div>
|
|
1392
|
+
</div>
|
|
1393
|
+
<div class="stat-card stat-divider">
|
|
1394
|
+
<div class="skeleton sk-stat-num"></div>
|
|
1395
|
+
<div class="skeleton sk-stat-label"></div>
|
|
1396
|
+
</div>
|
|
1397
|
+
</div>
|
|
1398
|
+
|
|
1399
|
+
<div class="skeleton sk-title-md"></div>
|
|
1400
|
+
|
|
1401
|
+
<div class="table-header">
|
|
1402
|
+
<div class="skeleton sk-th col-user"></div>
|
|
1403
|
+
<div class="skeleton sk-th col-status"></div>
|
|
1404
|
+
<div class="skeleton sk-th col-reward"></div>
|
|
1405
|
+
<div class="skeleton sk-th col-date"></div>
|
|
1406
|
+
</div>
|
|
1407
|
+
|
|
1408
|
+
<div class="table-row">
|
|
1409
|
+
<div class="col-user">
|
|
1410
|
+
<div class="skeleton sk-text" style="width: 70%; margin: 0"></div>
|
|
1411
|
+
</div>
|
|
1412
|
+
<div class="col-status">
|
|
1413
|
+
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1414
|
+
</div>
|
|
1415
|
+
<div class="col-reward">
|
|
1416
|
+
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1417
|
+
</div>
|
|
1418
|
+
<div class="col-date">
|
|
1419
|
+
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1420
|
+
</div>
|
|
1421
|
+
</div>
|
|
1422
|
+
<div class="table-row">
|
|
1423
|
+
<div class="col-user">
|
|
1424
|
+
<div class="skeleton sk-text" style="width: 60%; margin: 0"></div>
|
|
1425
|
+
</div>
|
|
1426
|
+
<div class="col-status">
|
|
1427
|
+
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1428
|
+
</div>
|
|
1429
|
+
<div class="col-reward">
|
|
1430
|
+
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1431
|
+
</div>
|
|
1432
|
+
<div class="col-date">
|
|
1433
|
+
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1434
|
+
</div>
|
|
1435
|
+
</div>
|
|
1436
|
+
<div class="table-row">
|
|
1437
|
+
<div class="col-user">
|
|
1438
|
+
<div class="skeleton sk-text" style="width: 75%; margin: 0"></div>
|
|
1439
|
+
</div>
|
|
1440
|
+
<div class="col-status">
|
|
1441
|
+
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1442
|
+
</div>
|
|
1443
|
+
<div class="col-reward">
|
|
1444
|
+
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1445
|
+
</div>
|
|
1446
|
+
<div class="col-date">
|
|
1447
|
+
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1448
|
+
</div>
|
|
1449
|
+
</div>
|
|
1450
|
+
|
|
1451
|
+
<div class="pagination">
|
|
1452
|
+
<div class="skeleton sk-btn-page"></div>
|
|
1453
|
+
<div class="skeleton sk-btn-page"></div>
|
|
1454
|
+
</div>
|
|
1455
|
+
</div>
|
|
1456
|
+
`;
|
|
1457
|
+
};
|
|
1109
1458
|
const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
|
|
1110
1459
|
class EmbedWidget extends Widget {
|
|
1111
1460
|
constructor(params, container) {
|
|
1112
1461
|
super(params);
|
|
1113
1462
|
__publicField(this, "show", this.open);
|
|
1114
1463
|
__publicField(this, "hide", this.close);
|
|
1115
|
-
if (container)
|
|
1464
|
+
if (container) {
|
|
1465
|
+
this.container = container;
|
|
1466
|
+
}
|
|
1116
1467
|
}
|
|
1117
1468
|
async load() {
|
|
1118
|
-
var _a2, _b, _c, _d, _e;
|
|
1469
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1119
1470
|
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1120
|
-
const
|
|
1471
|
+
const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
|
|
1472
|
+
const skeletonBackgroundColor = (_d = (_c = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _c.loadingSkeleton) == null ? void 0 : _d.background;
|
|
1473
|
+
const skeletonShimmerColor = (_f = (_e = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _e.loadingSkeleton) == null ? void 0 : _f.animationBackground;
|
|
1474
|
+
const borderColor = (_g = brandingConfig == null ? void 0 : brandingConfig.border) == null ? void 0 : _g.borderColor;
|
|
1475
|
+
const sizes = (_h = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _h.embeddedWidgets;
|
|
1121
1476
|
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
|
|
1122
1477
|
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
|
|
1123
|
-
|
|
1478
|
+
console.log({
|
|
1479
|
+
brandingConfig,
|
|
1480
|
+
initialHeight,
|
|
1481
|
+
widgetConfig: this.context.widgetConfig
|
|
1482
|
+
});
|
|
1483
|
+
const skeletonHTML = getSkeleton({
|
|
1484
|
+
height: initialHeight,
|
|
1485
|
+
skeletonBackgroundColor,
|
|
1486
|
+
skeletonShimmerColor,
|
|
1487
|
+
borderColor
|
|
1488
|
+
});
|
|
1489
|
+
const skeletonContainer = document.createElement("div");
|
|
1490
|
+
skeletonContainer.innerHTML = skeletonHTML;
|
|
1491
|
+
const frame = this._createFrame({
|
|
1492
|
+
minWidth,
|
|
1493
|
+
maxWidth,
|
|
1494
|
+
initialHeight
|
|
1495
|
+
});
|
|
1124
1496
|
const element = this._findElement();
|
|
1125
|
-
|
|
1497
|
+
element.innerHTML = skeletonHTML;
|
|
1498
|
+
frame.style.display = "none";
|
|
1499
|
+
const injectContents = (target) => {
|
|
1500
|
+
target.appendChild(skeletonContainer);
|
|
1501
|
+
target.appendChild(frame);
|
|
1502
|
+
};
|
|
1503
|
+
if ((_i = this.context) == null ? void 0 : _i.container) {
|
|
1126
1504
|
element.style.visibility = "hidden";
|
|
1127
1505
|
element.style.height = "0";
|
|
1128
1506
|
element.style["overflow-y"] = "hidden";
|
|
1129
1507
|
}
|
|
1130
1508
|
if (this.container) {
|
|
1131
1509
|
if (element.shadowRoot) {
|
|
1132
|
-
if (((
|
|
1510
|
+
if (((_j = element.shadowRoot.lastChild) == null ? void 0 : _j.nodeName) === "IFRAME") {
|
|
1133
1511
|
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1134
1512
|
} else {
|
|
1135
|
-
element.shadowRoot
|
|
1513
|
+
injectContents(element.shadowRoot);
|
|
1136
1514
|
}
|
|
1137
1515
|
} else if (element.firstChild) {
|
|
1138
|
-
element.
|
|
1516
|
+
element.innerHTML = "";
|
|
1517
|
+
injectContents(element);
|
|
1139
1518
|
} else {
|
|
1140
|
-
element
|
|
1519
|
+
injectContents(element);
|
|
1141
1520
|
}
|
|
1142
1521
|
} else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1143
|
-
element
|
|
1522
|
+
injectContents(element);
|
|
1144
1523
|
}
|
|
1145
1524
|
const { contentWindow } = frame;
|
|
1146
1525
|
if (!contentWindow) {
|
|
@@ -1148,19 +1527,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1148
1527
|
}
|
|
1149
1528
|
const frameDoc = contentWindow.document;
|
|
1150
1529
|
frameDoc.open();
|
|
1530
|
+
console.log({ content: this.content, context: this.context, this: this });
|
|
1531
|
+
const domain = this.widgetApi.domain;
|
|
1151
1532
|
frameDoc.write(`
|
|
1533
|
+
${((_k = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _k.brandFont) && `
|
|
1534
|
+
<link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
1535
|
+
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
1536
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1537
|
+
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1538
|
+
(_l = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _l.brandFont
|
|
1539
|
+
)}" as="style">`}
|
|
1152
1540
|
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1153
|
-
<style>
|
|
1154
|
-
|
|
1155
|
-
visibility: hidden;
|
|
1156
|
-
}
|
|
1541
|
+
<style data-styles>
|
|
1542
|
+
html { visibility:hidden;}
|
|
1157
1543
|
</style>
|
|
1158
1544
|
${this.content}
|
|
1545
|
+
|
|
1159
1546
|
`);
|
|
1160
1547
|
frameDoc.close();
|
|
1161
1548
|
domready(frameDoc, async () => {
|
|
1549
|
+
if (skeletonContainer && skeletonContainer.parentNode) {
|
|
1550
|
+
skeletonContainer.parentNode.removeChild(skeletonContainer);
|
|
1551
|
+
}
|
|
1552
|
+
frame.style.display = "block";
|
|
1162
1553
|
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1163
|
-
frame.height = frameDoc.body.scrollHeight;
|
|
1554
|
+
frame.height = initialHeight || frameDoc.body.scrollHeight;
|
|
1164
1555
|
console.log({ height: frameDoc.body.scrollHeight });
|
|
1165
1556
|
const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
1166
1557
|
for (const entry of entries) {
|
|
@@ -1797,7 +2188,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1797
2188
|
}
|
|
1798
2189
|
}
|
|
1799
2190
|
const _log$3 = browserExports.debug("squatch-js");
|
|
1800
|
-
function _getAutoConfig(
|
|
2191
|
+
function _getAutoConfig() {
|
|
2192
|
+
var _a2;
|
|
1801
2193
|
const queryString = window.location.search;
|
|
1802
2194
|
const urlParams = new URLSearchParams(queryString);
|
|
1803
2195
|
const refParam = urlParams.get("_saasquatchExtra") || "";
|
|
@@ -1805,6 +2197,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1805
2197
|
_log$3("No _saasquatchExtra param");
|
|
1806
2198
|
return;
|
|
1807
2199
|
}
|
|
2200
|
+
const config = validateConfig({
|
|
2201
|
+
tenantAlias: "UNKNOWN"
|
|
2202
|
+
});
|
|
2203
|
+
if (!config.domain) {
|
|
2204
|
+
_log$3("domain must be provided in config to use _saasquatchExtra");
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
1808
2207
|
let raw;
|
|
1809
2208
|
try {
|
|
1810
2209
|
raw = JSON.parse(b64decode(refParam));
|
|
@@ -1812,8 +2211,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1812
2211
|
_log$3("Unable to decode _saasquatchExtra config");
|
|
1813
2212
|
return;
|
|
1814
2213
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
2214
|
+
function normalizeDomain(domain) {
|
|
2215
|
+
return domain.replace(/^https?:\/\//, "");
|
|
2216
|
+
}
|
|
2217
|
+
const normalizedDomain = normalizeDomain(config.domain);
|
|
2218
|
+
const tenantAlias = Object.keys((raw == null ? void 0 : raw[normalizedDomain]) || {})[0];
|
|
2219
|
+
const widgetConfig = (_a2 = raw == null ? void 0 : raw[normalizedDomain]) == null ? void 0 : _a2[tenantAlias];
|
|
2220
|
+
if (!widgetConfig) {
|
|
1817
2221
|
_log$3("_saasquatchExtra did not have an expected structure");
|
|
1818
2222
|
return void 0;
|
|
1819
2223
|
}
|
|
@@ -1825,20 +2229,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1825
2229
|
...rest
|
|
1826
2230
|
},
|
|
1827
2231
|
squatchConfig: {
|
|
1828
|
-
...
|
|
1829
|
-
domain,
|
|
2232
|
+
...config,
|
|
1830
2233
|
tenantAlias
|
|
1831
2234
|
}
|
|
1832
2235
|
};
|
|
1833
2236
|
}
|
|
1834
|
-
function convertExtraToConfig(obj) {
|
|
1835
|
-
var _a2;
|
|
1836
|
-
const _domain = Object.keys(obj || {})[0];
|
|
1837
|
-
const tenantAlias = Object.keys((obj == null ? void 0 : obj[_domain]) || {})[0];
|
|
1838
|
-
const widgetConfig = (_a2 = obj == null ? void 0 : obj[_domain]) == null ? void 0 : _a2[tenantAlias];
|
|
1839
|
-
const domain = _domain ? `https://${_domain}` : void 0;
|
|
1840
|
-
return { domain, tenantAlias, widgetConfig };
|
|
1841
|
-
}
|
|
1842
2237
|
const _log$2 = browserExports.debug("squatch-js:decodeUserJwt");
|
|
1843
2238
|
function decodeUserJwt(tokenStr) {
|
|
1844
2239
|
var _a2;
|
|
@@ -2072,12 +2467,30 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2072
2467
|
}
|
|
2073
2468
|
}
|
|
2074
2469
|
async connectedCallback() {
|
|
2075
|
-
var _a2
|
|
2470
|
+
var _a2;
|
|
2076
2471
|
this.loaded = true;
|
|
2077
2472
|
this.container = this.getAttribute("container");
|
|
2473
|
+
const skeletonHTML = `
|
|
2474
|
+
<div>
|
|
2475
|
+
<h1>Dynamic Content</h1>
|
|
2476
|
+
<p>This content was dynamically added to the widget before it loaded.</p>
|
|
2477
|
+
<p>This content comes from the embeded widget class</p>
|
|
2478
|
+
</div>
|
|
2479
|
+
`;
|
|
2480
|
+
const skeletonContainer = document.createElement("div");
|
|
2481
|
+
skeletonContainer.id = "loading-skeleton";
|
|
2482
|
+
skeletonContainer.innerHTML = skeletonHTML;
|
|
2483
|
+
if (!this.shadowRoot) {
|
|
2484
|
+
this.attachShadow({ mode: "open" });
|
|
2485
|
+
}
|
|
2486
|
+
if (this.shadowRoot) {
|
|
2487
|
+
this.shadowRoot.innerHTML = skeletonHTML;
|
|
2488
|
+
}
|
|
2078
2489
|
await this.renderWidget();
|
|
2079
|
-
const
|
|
2080
|
-
if (
|
|
2490
|
+
const loadingElement = (_a2 = this.shadowRoot) == null ? void 0 : _a2.getElementById("loading-skeleton");
|
|
2491
|
+
if (loadingElement) {
|
|
2492
|
+
loadingElement.remove();
|
|
2493
|
+
}
|
|
2081
2494
|
if (this.getAttribute("open") !== null) this.open();
|
|
2082
2495
|
}
|
|
2083
2496
|
}
|
|
@@ -2106,7 +2519,45 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2106
2519
|
async connectedCallback() {
|
|
2107
2520
|
this.loaded = true;
|
|
2108
2521
|
this.container = this.getAttribute("container");
|
|
2109
|
-
|
|
2522
|
+
const skeletonHTML = `
|
|
2523
|
+
<div id="loading-skeleton-content">
|
|
2524
|
+
<h1>Dynamic Content</h1>
|
|
2525
|
+
<p>This content was dynamically added to the widget before it loaded.</p>
|
|
2526
|
+
<p>This content comes from the embedded widget class</p>
|
|
2527
|
+
</div>
|
|
2528
|
+
`;
|
|
2529
|
+
const skeletonContainer = document.createElement("div");
|
|
2530
|
+
skeletonContainer.id = "loading-skeleton";
|
|
2531
|
+
skeletonContainer.innerHTML = skeletonHTML;
|
|
2532
|
+
skeletonContainer.style.width = "100%";
|
|
2533
|
+
const root = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
2534
|
+
if (root.firstChild) {
|
|
2535
|
+
root.insertBefore(skeletonContainer, root.firstChild);
|
|
2536
|
+
} else {
|
|
2537
|
+
root.appendChild(skeletonContainer);
|
|
2538
|
+
}
|
|
2539
|
+
const removeSkeleton = () => {
|
|
2540
|
+
const el = root.getElementById("loading-skeleton");
|
|
2541
|
+
if (el) {
|
|
2542
|
+
el.remove();
|
|
2543
|
+
console.log("Skeleton removed successfully via event");
|
|
2544
|
+
}
|
|
2545
|
+
};
|
|
2546
|
+
this.addEventListener("sq:load", removeSkeleton);
|
|
2547
|
+
try {
|
|
2548
|
+
await this.renderWidget();
|
|
2549
|
+
console.log("Widget rendered (initialization complete)");
|
|
2550
|
+
setTimeout(() => {
|
|
2551
|
+
const el = root.getElementById("loading-skeleton");
|
|
2552
|
+
if (el) {
|
|
2553
|
+
console.warn("Removing skeleton via timeout (load event missing)");
|
|
2554
|
+
el.remove();
|
|
2555
|
+
}
|
|
2556
|
+
}, 5e3);
|
|
2557
|
+
} catch (err) {
|
|
2558
|
+
console.error("Critical Error in renderWidget:", err);
|
|
2559
|
+
removeSkeleton();
|
|
2560
|
+
}
|
|
2110
2561
|
if (this.getAttribute("open") !== null) this.open();
|
|
2111
2562
|
}
|
|
2112
2563
|
}
|
|
@@ -2151,9 +2602,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2151
2602
|
var _a2;
|
|
2152
2603
|
return (_a2 = widgets()) == null ? void 0 : _a2.render(widgetConfig);
|
|
2153
2604
|
}
|
|
2154
|
-
function _auto(
|
|
2605
|
+
function _auto() {
|
|
2155
2606
|
var _a2;
|
|
2156
|
-
const configs = _getAutoConfig(
|
|
2607
|
+
const configs = _getAutoConfig();
|
|
2157
2608
|
if (configs) {
|
|
2158
2609
|
const { squatchConfig, widgetConfig } = configs;
|
|
2159
2610
|
init(squatchConfig);
|