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