@joryio/web-sdk 1.4.0-beta.5 → 1.4.0-beta.6

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/joryio-sw.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Joryio Web SDK v1.4.0-beta.5
2
+ * Joryio Web SDK v1.4.0-beta.6
3
3
  * (c) 2026 Joryio. All rights reserved.
4
4
  * @license Commercial - see https://github.com/joryio/joryio-web-sdk/blob/main/LICENSE
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Joryio Web SDK v1.4.0-beta.5
2
+ * Joryio Web SDK v1.4.0-beta.6
3
3
  * (c) 2026 Joryio. All rights reserved.
4
4
  * @license Commercial - see https://github.com/joryio/joryio-web-sdk/blob/main/LICENSE
5
5
  */
@@ -29,7 +29,7 @@ function bucketHash(input) {
29
29
  return fmix32(hash >>> 0);
30
30
  }
31
31
 
32
- const SDK_VERSION = '1.4.0';
32
+ const SDK_VERSION = '1.4.0-beta.6';
33
33
  const SDK_PLATFORM_HEADER = 'X-Joryio-SDK';
34
34
  const SDK_VERSION_HEADER = 'X-Joryio-SDK-Version';
35
35
  const SDK_PLATFORM = 'web';
@@ -550,7 +550,7 @@ function pageTriggerMet(trigger, signal, progress) {
550
550
  }
551
551
  }
552
552
 
553
- const PAGE_EDIT_POSITIONS = ['before', 'after', 'prepend', 'append'];
553
+ const PAGE_EDIT_POSITIONS = ['before', 'after', 'prepend', 'append', 'replace'];
554
554
  const PAGE_EDITS_CAPABILITY = 'page_edits';
555
555
  const PAGE_EDIT_ANTI_FLICKER_MS = 300;
556
556
  const MAX_SELECTOR_LENGTH = 500;
@@ -606,6 +606,27 @@ function safeRestoredUrl(v) {
606
606
  }
607
607
  const safeRestoredSrcset = (v) => typeof v === 'string' && v.split(',').every((c) => !c.trim() || safeRestoredUrl(c.trim().split(/\s+/)[0]) !== null) ? v : null;
608
608
  const HIDE_DECLARATION = 'display:none !important';
609
+ function hideElement(h) {
610
+ const display = h.style.getPropertyValue('display');
611
+ const priority = h.style.getPropertyPriority('display');
612
+ h.style.setProperty('display', 'none', 'important');
613
+ return () => (display ? h.style.setProperty('display', display, priority) : h.style.removeProperty('display'));
614
+ }
615
+ function undoServerHide(el, orig) {
616
+ var _a;
617
+ const current = el.getAttribute('style') || '';
618
+ const before = typeof orig.style === 'string' ? orig.style : null;
619
+ const base = before === null ? '' : before.trim().replace(/;+$/, '');
620
+ if (current === (base ? base + ';' : '') + HIDE_DECLARATION) {
621
+ if (before === null)
622
+ el.removeAttribute('style');
623
+ else
624
+ el.setAttribute('style', before);
625
+ }
626
+ else if (((_a = el.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue('display')) === 'none') {
627
+ el.style.removeProperty('display');
628
+ }
629
+ }
609
630
  const RESTORE_ELEMENTS = new Set(['A', 'ABBR', 'B', 'BDI', 'BDO', 'BR', 'CITE', 'CODE', 'DATA', 'DEL', 'DFN', 'EM', 'I', 'IMG', 'INS', 'KBD', 'MARK', 'Q', 'S', 'SAMP', 'SMALL', 'SPAN', 'STRONG', 'SUB', 'SUP', 'TIME', 'U', 'VAR', 'WBR']);
610
631
  const RESTORE_ATTRIBUTES = new Set(['class', 'id', 'title', 'lang', 'dir', 'alt', 'width', 'height', 'datetime', 'href', 'src', 'srcset', 'rel', 'target']);
611
632
  const MAX_RESTORE_NODES = 500;
@@ -1067,19 +1088,21 @@ class PageEditManager {
1067
1088
  el.setAttribute('href', edit.value);
1068
1089
  return () => (href === null ? el.removeAttribute('href') : el.setAttribute('href', href));
1069
1090
  }
1070
- case 'hide': {
1071
- const display = h.style.getPropertyValue('display');
1072
- const priority = h.style.getPropertyPriority('display');
1073
- h.style.setProperty('display', 'none', 'important');
1074
- return () => (display ? h.style.setProperty('display', display, priority) : h.style.removeProperty('display'));
1075
- }
1091
+ case 'hide':
1092
+ return hideElement(h);
1076
1093
  case 'insert_placement': {
1077
1094
  const spot = document.createElement('div');
1078
1095
  spot.setAttribute('data-joryio-placement', edit.placementKey);
1079
1096
  spot.setAttribute('data-joryio-edit', edit.id);
1080
1097
  const where = edit.position === 'before' ? 'beforebegin' : edit.position === 'prepend' ? 'afterbegin' : edit.position === 'append' ? 'beforeend' : 'afterend';
1081
1098
  el.insertAdjacentElement(where, spot);
1082
- return () => spot.remove();
1099
+ if (edit.position !== 'replace')
1100
+ return () => spot.remove();
1101
+ const show = hideElement(h);
1102
+ return () => {
1103
+ spot.remove();
1104
+ show();
1105
+ };
1083
1106
  }
1084
1107
  default:
1085
1108
  return null;
@@ -1260,7 +1283,6 @@ class PageEditManager {
1260
1283
  }
1261
1284
  }
1262
1285
  undoServerEdit(token, edit) {
1263
- var _a;
1264
1286
  for (const el of Array.from(document.querySelectorAll(`[${SERVER_APPLIED_ATTR}]`))) {
1265
1287
  const tokens = tokensOf(el);
1266
1288
  if (!tokens.includes(token))
@@ -1269,7 +1291,7 @@ class PageEditManager {
1269
1291
  try {
1270
1292
  all = JSON.parse(el.getAttribute(SERVER_ORIG_ATTR) || '{}') || {};
1271
1293
  }
1272
- catch (_b) {
1294
+ catch (_a) {
1273
1295
  all = {};
1274
1296
  }
1275
1297
  const orig = all[token] || {};
@@ -1305,26 +1327,18 @@ class PageEditManager {
1305
1327
  el.setAttribute('href', href);
1306
1328
  }
1307
1329
  break;
1308
- case 'hide': {
1309
- const current = el.getAttribute('style') || '';
1310
- const before = typeof orig.style === 'string' ? orig.style : null;
1311
- const base = before === null ? '' : before.trim().replace(/;+$/, '');
1312
- if (current === (base ? base + ';' : '') + HIDE_DECLARATION) {
1313
- if (before === null)
1314
- el.removeAttribute('style');
1315
- else
1316
- el.setAttribute('style', before);
1317
- }
1318
- else if (((_a = el.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue('display')) === 'none') {
1319
- el.style.removeProperty('display');
1320
- }
1330
+ case 'hide':
1331
+ undoServerHide(el, orig);
1332
+ break;
1333
+ case 'insert_placement':
1334
+ if (edit.position === 'replace')
1335
+ undoServerHide(el, orig);
1321
1336
  break;
1322
- }
1323
1337
  default:
1324
1338
  break;
1325
1339
  }
1326
1340
  }
1327
- catch (_c) {
1341
+ catch (_b) {
1328
1342
  }
1329
1343
  const left = tokens.filter((t) => t !== token);
1330
1344
  if (left.length)
@@ -1417,13 +1431,16 @@ function readOwnFolder() {
1417
1431
  return null;
1418
1432
  }
1419
1433
  const OWN_FOLDER = readOwnFolder();
1420
- function sdkHostFileUrls(file, override, ownFolder = OWN_FOLDER) {
1434
+ function sdkHostFileUrls(file, override, ownFolder = OWN_FOLDER, version = SDK_VERSION) {
1421
1435
  if (override)
1422
1436
  return [override];
1423
- const major = SDK_VERSION.split('.')[0];
1424
- const exact = `${SDK_HOST}/web/${SDK_VERSION}/${file}`;
1437
+ const major = version.split('.')[0];
1438
+ const exact = `${SDK_HOST}/web/${version}/${file}`;
1425
1439
  const channel = `${SDK_HOST}/web/${major}/${file}`;
1426
- const urls = ownFolder && ownFolder !== `${SDK_HOST}/web/${major}/` ? [`${ownFolder}${file}`, exact, channel] : [exact, channel];
1440
+ const prerelease = version.includes('-');
1441
+ let urls = ownFolder && ownFolder !== `${SDK_HOST}/web/${major}/` ? [`${ownFolder}${file}`, exact, channel] : [exact, channel];
1442
+ if (prerelease)
1443
+ urls = urls.filter((u) => u !== channel);
1427
1444
  return urls.filter((u, i) => urls.indexOf(u) === i);
1428
1445
  }
1429
1446
  function loadSdkScript(src, marker) {