@joryio/web-sdk 1.4.0-beta.4 → 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/CHANGELOG.md +11 -3
- package/dist/core/cards.d.ts +2 -1
- package/dist/core/cards.d.ts.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/flags.d.ts +2 -1
- package/dist/core/flags.d.ts.map +1 -1
- package/dist/core/page-edits.d.ts +1 -1
- package/dist/core/page-edits.d.ts.map +1 -1
- package/dist/core/placements.d.ts +2 -1
- package/dist/core/placements.d.ts.map +1 -1
- package/dist/core/sdk-host-files.d.ts +1 -1
- package/dist/core/sdk-host-files.d.ts.map +1 -1
- package/dist/core/sdk.d.ts +4 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +6 -0
- package/dist/core/subscription.d.ts.map +1 -0
- package/dist/editor/editor-model.d.ts +13 -0
- package/dist/editor/editor-model.d.ts.map +1 -0
- package/dist/editor/editor-strings.d.ts +79 -0
- package/dist/editor/editor-strings.d.ts.map +1 -0
- package/dist/editor/editor-ui.d.ts +25 -0
- package/dist/editor/editor-ui.d.ts.map +1 -0
- package/dist/editor/visual-editor.d.ts +59 -8
- package/dist/editor/visual-editor.d.ts.map +1 -1
- package/dist/index.d.mts +10 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/joryio-cards-ui.min.js +1 -1
- package/dist/joryio-cards-ui.min.js.map +1 -1
- package/dist/joryio-editor.min.js +2 -2
- package/dist/joryio-editor.min.js.map +1 -1
- package/dist/joryio-sw.js +1 -1
- package/dist/joryio.cjs.js +83 -46
- package/dist/joryio.min.js +2 -2
- package/dist/joryio.min.js.map +1 -1
- package/dist/joryio.mjs +83 -46
- package/dist/joryio.umd.js +83 -46
- package/package.json +1 -1
- package/src/core/cards.ts +10 -7
- package/src/core/config.ts +1 -1
- package/src/core/flags.ts +10 -4
- package/src/core/page-edits.ts +43 -22
- package/src/core/placements.ts +10 -7
- package/src/core/sdk-host-files.ts +15 -10
- package/src/core/sdk.ts +14 -9
- package/src/core/subscription.ts +27 -0
- package/src/editor/editor-model.ts +102 -0
- package/src/editor/editor-strings.ts +102 -0
- package/src/editor/editor-ui.ts +145 -0
- package/src/editor/visual-editor.ts +815 -105
- package/src/index.ts +2 -0
package/dist/joryio-sw.js
CHANGED
package/dist/joryio.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Joryio Web SDK v1.4.0-beta.
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
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 (
|
|
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 =
|
|
1424
|
-
const exact = `${SDK_HOST}/web/${
|
|
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
|
|
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) {
|
|
@@ -5567,6 +5584,19 @@ function inAppTriggerFilterMatches(trigger, properties) {
|
|
|
5567
5584
|
}
|
|
5568
5585
|
}
|
|
5569
5586
|
|
|
5587
|
+
function joryioSubscription(stop) {
|
|
5588
|
+
let done = false;
|
|
5589
|
+
const cancel = () => {
|
|
5590
|
+
if (done)
|
|
5591
|
+
return;
|
|
5592
|
+
done = true;
|
|
5593
|
+
stop();
|
|
5594
|
+
};
|
|
5595
|
+
const sub = (() => cancel());
|
|
5596
|
+
sub.cancel = cancel;
|
|
5597
|
+
return sub;
|
|
5598
|
+
}
|
|
5599
|
+
|
|
5570
5600
|
const PLACEMENT_VIEWABLE_FRACTION = 0.5;
|
|
5571
5601
|
const PLACEMENT_MIN_REFRESH_SECONDS = 30;
|
|
5572
5602
|
const PLACEMENT_BATCH_WINDOW_MS = 50;
|
|
@@ -5750,11 +5780,12 @@ class PlacementManager {
|
|
|
5750
5780
|
}
|
|
5751
5781
|
onPlacementsUpdated(callback) {
|
|
5752
5782
|
if (typeof callback !== 'function')
|
|
5753
|
-
return () => undefined;
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5783
|
+
return joryioSubscription(() => undefined);
|
|
5784
|
+
const entry = (placements) => callback(placements);
|
|
5785
|
+
this.listeners.add(entry);
|
|
5786
|
+
return joryioSubscription(() => {
|
|
5787
|
+
this.listeners.delete(entry);
|
|
5788
|
+
});
|
|
5758
5789
|
}
|
|
5759
5790
|
autoMount() {
|
|
5760
5791
|
if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function')
|
|
@@ -6719,11 +6750,12 @@ class CardManager {
|
|
|
6719
6750
|
}
|
|
6720
6751
|
onCardsUpdated(callback) {
|
|
6721
6752
|
if (typeof callback !== 'function')
|
|
6722
|
-
return () => undefined;
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6753
|
+
return joryioSubscription(() => undefined);
|
|
6754
|
+
const entry = (feed) => callback(feed);
|
|
6755
|
+
this.listeners.add(entry);
|
|
6756
|
+
return joryioSubscription(() => {
|
|
6757
|
+
this.listeners.delete(entry);
|
|
6758
|
+
});
|
|
6727
6759
|
}
|
|
6728
6760
|
markCardViewed(card) {
|
|
6729
6761
|
this.report(card, CARD_ACTIONS.VIEWED);
|
|
@@ -7374,9 +7406,14 @@ class FlagsManager {
|
|
|
7374
7406
|
await this.refresh(true);
|
|
7375
7407
|
}
|
|
7376
7408
|
onFlagsUpdated(callback) {
|
|
7377
|
-
|
|
7409
|
+
if (typeof callback !== 'function')
|
|
7410
|
+
return joryioSubscription(() => undefined);
|
|
7411
|
+
const entry = (keys) => callback(keys);
|
|
7412
|
+
this.listeners.add(entry);
|
|
7378
7413
|
this.use();
|
|
7379
|
-
return () =>
|
|
7414
|
+
return joryioSubscription(() => {
|
|
7415
|
+
this.listeners.delete(entry);
|
|
7416
|
+
});
|
|
7380
7417
|
}
|
|
7381
7418
|
read(key, type) {
|
|
7382
7419
|
if (!this.runtime.canSend())
|
|
@@ -11260,7 +11297,7 @@ class JoryioSDK {
|
|
|
11260
11297
|
onPlacementsUpdated(callback) {
|
|
11261
11298
|
if (!this.isInitialized) {
|
|
11262
11299
|
this.logger.error('SDK not initialized');
|
|
11263
|
-
return () => undefined;
|
|
11300
|
+
return joryioSubscription(() => undefined);
|
|
11264
11301
|
}
|
|
11265
11302
|
return this.placements.onPlacementsUpdated(callback);
|
|
11266
11303
|
}
|
|
@@ -11304,7 +11341,7 @@ class JoryioSDK {
|
|
|
11304
11341
|
onCardsUpdated(callback) {
|
|
11305
11342
|
if (!this.isInitialized) {
|
|
11306
11343
|
this.logger.error('SDK not initialized');
|
|
11307
|
-
return () => undefined;
|
|
11344
|
+
return joryioSubscription(() => undefined);
|
|
11308
11345
|
}
|
|
11309
11346
|
return this.cards.onCardsUpdated(callback);
|
|
11310
11347
|
}
|
|
@@ -11343,7 +11380,7 @@ class JoryioSDK {
|
|
|
11343
11380
|
onFlagsUpdated(callback) {
|
|
11344
11381
|
if (!this.isInitialized) {
|
|
11345
11382
|
this.logger.error('SDK not initialized');
|
|
11346
|
-
return () => undefined;
|
|
11383
|
+
return joryioSubscription(() => undefined);
|
|
11347
11384
|
}
|
|
11348
11385
|
return this.flags.onFlagsUpdated(callback);
|
|
11349
11386
|
}
|