@everymatrix/user-transaction-history 1.87.25 → 1.87.27
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.
|
@@ -2360,6 +2360,8 @@ const TableComponent = ({ source, language, dateformat }) => {
|
|
|
2360
2360
|
index.h("span", { class: transaction.status.toLowerCase() }, transaction.status)))))));
|
|
2361
2361
|
};
|
|
2362
2362
|
|
|
2363
|
+
const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
|
|
2364
|
+
|
|
2363
2365
|
/**
|
|
2364
2366
|
* @name setClientStyling
|
|
2365
2367
|
* @description Method used to create and append to the passed element of the widget a style element with the content received
|
|
@@ -2405,18 +2407,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
|
|
|
2405
2407
|
* @param {HTMLElement} stylingContainer The highest element of the widget
|
|
2406
2408
|
* @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
|
|
2407
2409
|
* @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
|
|
2410
|
+
* @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
|
|
2408
2411
|
*/
|
|
2409
|
-
function setStreamStyling(stylingContainer, domain, subscription) {
|
|
2410
|
-
if (window.emMessageBus)
|
|
2411
|
-
const sheet = document.createElement('style');
|
|
2412
|
+
function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
|
|
2413
|
+
if (!window.emMessageBus) return;
|
|
2412
2414
|
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2415
|
+
const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
|
|
2416
|
+
|
|
2417
|
+
if (!supportAdoptStyle || !useAdoptedStyleSheets) {
|
|
2418
|
+
subscription = getStyleTagSubscription(stylingContainer, domain);
|
|
2419
|
+
|
|
2420
|
+
return subscription;
|
|
2419
2421
|
}
|
|
2422
|
+
|
|
2423
|
+
if (!window[StyleCacheKey]) {
|
|
2424
|
+
window[StyleCacheKey] = {};
|
|
2425
|
+
}
|
|
2426
|
+
subscription = getAdoptStyleSubscription(stylingContainer, domain);
|
|
2427
|
+
|
|
2428
|
+
const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
|
|
2429
|
+
const wrappedUnsubscribe = () => {
|
|
2430
|
+
if (window[StyleCacheKey][domain]) {
|
|
2431
|
+
const cachedObject = window[StyleCacheKey][domain];
|
|
2432
|
+
cachedObject.refCount > 1
|
|
2433
|
+
? (cachedObject.refCount = cachedObject.refCount - 1)
|
|
2434
|
+
: delete window[StyleCacheKey][domain];
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
originalUnsubscribe();
|
|
2438
|
+
};
|
|
2439
|
+
subscription.unsubscribe = wrappedUnsubscribe;
|
|
2440
|
+
|
|
2441
|
+
return subscription;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
function getStyleTagSubscription(stylingContainer, domain) {
|
|
2445
|
+
const sheet = document.createElement('style');
|
|
2446
|
+
|
|
2447
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
2448
|
+
if (stylingContainer) {
|
|
2449
|
+
sheet.innerHTML = data;
|
|
2450
|
+
stylingContainer.appendChild(sheet);
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
function getAdoptStyleSubscription(stylingContainer, domain) {
|
|
2456
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
2457
|
+
if (!stylingContainer) return;
|
|
2458
|
+
|
|
2459
|
+
const shadowRoot = stylingContainer.getRootNode();
|
|
2460
|
+
const cacheStyleObject = window[StyleCacheKey];
|
|
2461
|
+
let cachedStyle = cacheStyleObject[domain]?.sheet;
|
|
2462
|
+
|
|
2463
|
+
if (!cachedStyle) {
|
|
2464
|
+
cachedStyle = new CSSStyleSheet();
|
|
2465
|
+
cachedStyle.replaceSync(data);
|
|
2466
|
+
cacheStyleObject[domain] = {
|
|
2467
|
+
sheet: cachedStyle,
|
|
2468
|
+
refCount: 1
|
|
2469
|
+
};
|
|
2470
|
+
} else {
|
|
2471
|
+
cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
const currentSheets = shadowRoot.adoptedStyleSheets || [];
|
|
2475
|
+
if (!currentSheets.includes(cachedStyle)) {
|
|
2476
|
+
shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
|
|
2477
|
+
}
|
|
2478
|
+
});
|
|
2420
2479
|
}
|
|
2421
2480
|
|
|
2422
2481
|
function _arrayLikeToArray(r, a) {
|
|
@@ -5380,7 +5439,7 @@ const UserTransactionHistory = class {
|
|
|
5380
5439
|
componentDidLoad() {
|
|
5381
5440
|
if (this.stylingContainer) {
|
|
5382
5441
|
if (window.emMessageBus != undefined) {
|
|
5383
|
-
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style
|
|
5442
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
5384
5443
|
}
|
|
5385
5444
|
else {
|
|
5386
5445
|
if (this.clientStyling)
|
|
@@ -2356,6 +2356,8 @@ const TableComponent = ({ source, language, dateformat }) => {
|
|
|
2356
2356
|
h("span", { class: transaction.status.toLowerCase() }, transaction.status)))))));
|
|
2357
2357
|
};
|
|
2358
2358
|
|
|
2359
|
+
const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
|
|
2360
|
+
|
|
2359
2361
|
/**
|
|
2360
2362
|
* @name setClientStyling
|
|
2361
2363
|
* @description Method used to create and append to the passed element of the widget a style element with the content received
|
|
@@ -2401,18 +2403,75 @@ function setClientStylingURL(stylingContainer, clientStylingUrl) {
|
|
|
2401
2403
|
* @param {HTMLElement} stylingContainer The highest element of the widget
|
|
2402
2404
|
* @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
|
|
2403
2405
|
* @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
|
|
2406
|
+
* @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
|
|
2404
2407
|
*/
|
|
2405
|
-
function setStreamStyling(stylingContainer, domain, subscription) {
|
|
2406
|
-
if (window.emMessageBus)
|
|
2407
|
-
const sheet = document.createElement('style');
|
|
2408
|
+
function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
|
|
2409
|
+
if (!window.emMessageBus) return;
|
|
2408
2410
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2411
|
+
const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
|
|
2412
|
+
|
|
2413
|
+
if (!supportAdoptStyle || !useAdoptedStyleSheets) {
|
|
2414
|
+
subscription = getStyleTagSubscription(stylingContainer, domain);
|
|
2415
|
+
|
|
2416
|
+
return subscription;
|
|
2415
2417
|
}
|
|
2418
|
+
|
|
2419
|
+
if (!window[StyleCacheKey]) {
|
|
2420
|
+
window[StyleCacheKey] = {};
|
|
2421
|
+
}
|
|
2422
|
+
subscription = getAdoptStyleSubscription(stylingContainer, domain);
|
|
2423
|
+
|
|
2424
|
+
const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
|
|
2425
|
+
const wrappedUnsubscribe = () => {
|
|
2426
|
+
if (window[StyleCacheKey][domain]) {
|
|
2427
|
+
const cachedObject = window[StyleCacheKey][domain];
|
|
2428
|
+
cachedObject.refCount > 1
|
|
2429
|
+
? (cachedObject.refCount = cachedObject.refCount - 1)
|
|
2430
|
+
: delete window[StyleCacheKey][domain];
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
originalUnsubscribe();
|
|
2434
|
+
};
|
|
2435
|
+
subscription.unsubscribe = wrappedUnsubscribe;
|
|
2436
|
+
|
|
2437
|
+
return subscription;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
function getStyleTagSubscription(stylingContainer, domain) {
|
|
2441
|
+
const sheet = document.createElement('style');
|
|
2442
|
+
|
|
2443
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
2444
|
+
if (stylingContainer) {
|
|
2445
|
+
sheet.innerHTML = data;
|
|
2446
|
+
stylingContainer.appendChild(sheet);
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
function getAdoptStyleSubscription(stylingContainer, domain) {
|
|
2452
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
2453
|
+
if (!stylingContainer) return;
|
|
2454
|
+
|
|
2455
|
+
const shadowRoot = stylingContainer.getRootNode();
|
|
2456
|
+
const cacheStyleObject = window[StyleCacheKey];
|
|
2457
|
+
let cachedStyle = cacheStyleObject[domain]?.sheet;
|
|
2458
|
+
|
|
2459
|
+
if (!cachedStyle) {
|
|
2460
|
+
cachedStyle = new CSSStyleSheet();
|
|
2461
|
+
cachedStyle.replaceSync(data);
|
|
2462
|
+
cacheStyleObject[domain] = {
|
|
2463
|
+
sheet: cachedStyle,
|
|
2464
|
+
refCount: 1
|
|
2465
|
+
};
|
|
2466
|
+
} else {
|
|
2467
|
+
cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
const currentSheets = shadowRoot.adoptedStyleSheets || [];
|
|
2471
|
+
if (!currentSheets.includes(cachedStyle)) {
|
|
2472
|
+
shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2416
2475
|
}
|
|
2417
2476
|
|
|
2418
2477
|
function _arrayLikeToArray(r, a) {
|
|
@@ -5376,7 +5435,7 @@ const UserTransactionHistory = class {
|
|
|
5376
5435
|
componentDidLoad() {
|
|
5377
5436
|
if (this.stylingContainer) {
|
|
5378
5437
|
if (window.emMessageBus != undefined) {
|
|
5379
|
-
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style
|
|
5438
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
5380
5439
|
}
|
|
5381
5440
|
else {
|
|
5382
5441
|
if (this.clientStyling)
|