@liquidcommercedev/rmn-sdk 1.4.4 → 1.4.5-beta.2
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/index.cjs +136 -143
- package/dist/index.esm.js +136 -143
- package/dist/types/modules/spot/html/constants/html.constant.d.ts +8 -0
- package/dist/types/modules/spot/html/constants/index.d.ts +1 -0
- package/dist/types/modules/spot/html/spot.element.service.d.ts +1 -1
- package/dist/types/modules/spot/spot.constant.d.ts +1 -0
- package/dist/types/modules/spot/spot.html.service.d.ts +1 -1
- package/dist/types/modules/spot/spot.interface.d.ts +1 -3
- package/dist/types/modules/spot/spot.selection.service.d.ts +0 -1
- package/dist/types/rmn-client.d.ts +2 -2
- package/package.json +1 -1
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
- package/dist/types/modules/spot/html/spot.element.shadow-root.d.ts +0 -4
- package/dist/types/modules/spot/html/templates/iab/constants/fonts.constant.d.ts +0 -3
package/dist/index.cjs
CHANGED
@@ -15152,60 +15152,56 @@ class AuthService extends BaseApi {
|
|
15152
15152
|
}
|
15153
15153
|
|
15154
15154
|
const SPOT_ELEMENT_TAG = 'spot-element';
|
15155
|
+
const SPOT_ELEMENT_SLOT_NAME = `${SPOT_ELEMENT_TAG}-custom-content`;
|
15155
15156
|
const SPOTS_SELECTION_API_PATH = '/spots/selection';
|
15156
|
-
const SPOT_EVENT_API_PATH = '/spots/event';
|
15157
15157
|
|
15158
|
-
const
|
15158
|
+
const GFONT_PRECONNECT = `
|
15159
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
15160
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
15161
|
+
`;
|
15162
|
+
const GFONT_SOURCE_SANS_3 = `
|
15163
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap">
|
15164
|
+
`;
|
15165
|
+
const GFONT_CORMORANT = `
|
15166
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap">
|
15167
|
+
`;
|
15168
|
+
const SPOT_ELEMENT_TEMPLATE = (width, height, hasCustomContent) => {
|
15159
15169
|
const style = document.createElement('style');
|
15170
|
+
style.textContent = `
|
15171
|
+
:host {
|
15172
|
+
display: block;
|
15173
|
+
position: relative;
|
15174
|
+
container-type: inline-size;
|
15175
|
+
overflow: hidden;
|
15176
|
+
}
|
15177
|
+
:host([fluid="true"]) {
|
15178
|
+
width: 100%;
|
15179
|
+
height: 100%;
|
15180
|
+
}
|
15181
|
+
:host([fluid="false"]) {
|
15182
|
+
width: ${width}px;
|
15183
|
+
height: ${height}px;
|
15184
|
+
}
|
15185
|
+
`;
|
15160
15186
|
const wrapper = document.createElement('div');
|
15161
15187
|
wrapper.className = 'wrapper';
|
15162
|
-
|
15163
|
-
|
15164
|
-
|
15165
|
-
|
15166
|
-
|
15167
|
-
|
15168
|
-
|
15169
|
-
:
|
15170
|
-
|
15171
|
-
|
15172
|
-
|
15173
|
-
|
15174
|
-
width: ${width}px;
|
15175
|
-
height: ${height}px;
|
15176
|
-
}
|
15188
|
+
const slot = document.createElement('slot');
|
15189
|
+
slot.name = SPOT_ELEMENT_SLOT_NAME;
|
15190
|
+
if (!hasCustomContent) {
|
15191
|
+
style.textContent += `
|
15192
|
+
:host .wrapper {
|
15193
|
+
position: absolute;
|
15194
|
+
top: 0;
|
15195
|
+
left: 0;
|
15196
|
+
width: 100%;
|
15197
|
+
height: 100%;
|
15198
|
+
overflow: hidden;
|
15199
|
+
}
|
15177
15200
|
`;
|
15178
|
-
if (hasCustomHtmlElement) {
|
15179
|
-
return { style, wrapper };
|
15180
15201
|
}
|
15181
|
-
style
|
15182
|
-
.wrapper {
|
15183
|
-
position: absolute;
|
15184
|
-
top: 0;
|
15185
|
-
left: 0;
|
15186
|
-
width: 100%;
|
15187
|
-
height: 100%;
|
15188
|
-
overflow: hidden;
|
15189
|
-
}
|
15190
|
-
`;
|
15191
|
-
return { style, wrapper };
|
15202
|
+
return { style, wrapper, slot };
|
15192
15203
|
};
|
15193
15204
|
|
15194
|
-
const GFONT_PRECONNECT = () => `
|
15195
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
15196
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
15197
|
-
`;
|
15198
|
-
const GFONT_SOURCE_SANS_3 = () => `
|
15199
|
-
<link rel="stylesheet"
|
15200
|
-
href="https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
|
15201
|
-
>
|
15202
|
-
`;
|
15203
|
-
const GFONT_CORMORANT = () => `
|
15204
|
-
<link rel="stylesheet"
|
15205
|
-
href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
|
15206
|
-
>
|
15207
|
-
`;
|
15208
|
-
|
15209
15205
|
const STYLES$i = ({ primaryImage, secondaryImage }) => `
|
15210
15206
|
<style>
|
15211
15207
|
.content {
|
@@ -15301,9 +15297,9 @@ const STYLES$i = ({ primaryImage, secondaryImage }) => `
|
|
15301
15297
|
`;
|
15302
15298
|
function billboardV1Template(spot) {
|
15303
15299
|
return `
|
15304
|
-
${GFONT_PRECONNECT
|
15305
|
-
${GFONT_SOURCE_SANS_3
|
15306
|
-
${GFONT_CORMORANT
|
15300
|
+
${GFONT_PRECONNECT}
|
15301
|
+
${GFONT_SOURCE_SANS_3}
|
15302
|
+
${GFONT_CORMORANT}
|
15307
15303
|
${STYLES$i(spot)}
|
15308
15304
|
<div class="content">
|
15309
15305
|
<div class="big-image"></div>
|
@@ -15390,9 +15386,9 @@ const STYLES$h = ({ primaryImage }) => `
|
|
15390
15386
|
`;
|
15391
15387
|
function billboardV2Template(spot) {
|
15392
15388
|
return `
|
15393
|
-
${GFONT_PRECONNECT
|
15394
|
-
${GFONT_SOURCE_SANS_3
|
15395
|
-
${GFONT_CORMORANT
|
15389
|
+
${GFONT_PRECONNECT}
|
15390
|
+
${GFONT_SOURCE_SANS_3}
|
15391
|
+
${GFONT_CORMORANT}
|
15396
15392
|
${STYLES$h(spot)}
|
15397
15393
|
<div class="content">
|
15398
15394
|
<div class="text-container">
|
@@ -15491,9 +15487,9 @@ const STYLES$g = ({ primaryImage }) => `
|
|
15491
15487
|
`;
|
15492
15488
|
function billboardV3Template(spot) {
|
15493
15489
|
return `
|
15494
|
-
${GFONT_PRECONNECT
|
15495
|
-
${GFONT_SOURCE_SANS_3
|
15496
|
-
${GFONT_CORMORANT
|
15490
|
+
${GFONT_PRECONNECT}
|
15491
|
+
${GFONT_SOURCE_SANS_3}
|
15492
|
+
${GFONT_CORMORANT}
|
15497
15493
|
${STYLES$g(spot)}
|
15498
15494
|
<div class="content">
|
15499
15495
|
<div class="text">
|
@@ -15535,9 +15531,9 @@ const STYLES$f = () => `
|
|
15535
15531
|
`;
|
15536
15532
|
function inTextV1Template(spot) {
|
15537
15533
|
return `
|
15538
|
-
${GFONT_PRECONNECT
|
15539
|
-
${GFONT_SOURCE_SANS_3
|
15540
|
-
${GFONT_CORMORANT
|
15534
|
+
${GFONT_PRECONNECT}
|
15535
|
+
${GFONT_SOURCE_SANS_3}
|
15536
|
+
${GFONT_CORMORANT}
|
15541
15537
|
${STYLES$f()}
|
15542
15538
|
<div class="content">
|
15543
15539
|
<span class="header">${spot.header}</span>
|
@@ -15625,9 +15621,9 @@ const STYLES$e = ({ primaryImage }) => `
|
|
15625
15621
|
`;
|
15626
15622
|
function largeLeaderboardV1Template(spot) {
|
15627
15623
|
return `
|
15628
|
-
${GFONT_PRECONNECT
|
15629
|
-
${GFONT_SOURCE_SANS_3
|
15630
|
-
${GFONT_CORMORANT
|
15624
|
+
${GFONT_PRECONNECT}
|
15625
|
+
${GFONT_SOURCE_SANS_3}
|
15626
|
+
${GFONT_CORMORANT}
|
15631
15627
|
${STYLES$e(spot)}
|
15632
15628
|
<div class="content">
|
15633
15629
|
<div class="text">
|
@@ -15712,9 +15708,9 @@ const STYLES$d = ({ primaryImage }) => `
|
|
15712
15708
|
`;
|
15713
15709
|
function largeLeaderboardV2Template(spot) {
|
15714
15710
|
return `
|
15715
|
-
${GFONT_PRECONNECT
|
15716
|
-
${GFONT_SOURCE_SANS_3
|
15717
|
-
${GFONT_CORMORANT
|
15711
|
+
${GFONT_PRECONNECT}
|
15712
|
+
${GFONT_SOURCE_SANS_3}
|
15713
|
+
${GFONT_CORMORANT}
|
15718
15714
|
${STYLES$d(spot)}
|
15719
15715
|
<div class="content">
|
15720
15716
|
<div class="text">
|
@@ -15771,9 +15767,9 @@ const STYLES$c = ({ primaryImage }) => `
|
|
15771
15767
|
`;
|
15772
15768
|
function largeRectangleV1Template(spot) {
|
15773
15769
|
return `
|
15774
|
-
${GFONT_PRECONNECT
|
15775
|
-
${GFONT_SOURCE_SANS_3
|
15776
|
-
${GFONT_CORMORANT
|
15770
|
+
${GFONT_PRECONNECT}
|
15771
|
+
${GFONT_SOURCE_SANS_3}
|
15772
|
+
${GFONT_CORMORANT}
|
15777
15773
|
${STYLES$c(spot)}
|
15778
15774
|
<div class="content">
|
15779
15775
|
<div class="image"></div>
|
@@ -15869,9 +15865,9 @@ const STYLES$b = ({ primaryImage }) => `
|
|
15869
15865
|
`;
|
15870
15866
|
function squareV1Template(spot) {
|
15871
15867
|
return `
|
15872
|
-
${GFONT_PRECONNECT
|
15873
|
-
${GFONT_SOURCE_SANS_3
|
15874
|
-
${GFONT_CORMORANT
|
15868
|
+
${GFONT_PRECONNECT}
|
15869
|
+
${GFONT_SOURCE_SANS_3}
|
15870
|
+
${GFONT_CORMORANT}
|
15875
15871
|
${STYLES$b(spot)}
|
15876
15872
|
<div class="content">
|
15877
15873
|
<div class="text">
|
@@ -15924,9 +15920,9 @@ const STYLES$a = ({ primaryImage }) => `
|
|
15924
15920
|
`;
|
15925
15921
|
function squareV2Template(spot) {
|
15926
15922
|
return `
|
15927
|
-
${GFONT_PRECONNECT
|
15928
|
-
${GFONT_SOURCE_SANS_3
|
15929
|
-
${GFONT_CORMORANT
|
15923
|
+
${GFONT_PRECONNECT}
|
15924
|
+
${GFONT_SOURCE_SANS_3}
|
15925
|
+
${GFONT_CORMORANT}
|
15930
15926
|
${STYLES$a(spot)}
|
15931
15927
|
<div class="content">
|
15932
15928
|
<span class="header">${spot.header}</span>
|
@@ -15989,9 +15985,9 @@ const STYLES$9 = ({ primaryImage }) => `
|
|
15989
15985
|
`;
|
15990
15986
|
function verticalRectangleV1Template(spot) {
|
15991
15987
|
return `
|
15992
|
-
${GFONT_PRECONNECT
|
15993
|
-
${GFONT_SOURCE_SANS_3
|
15994
|
-
${GFONT_CORMORANT
|
15988
|
+
${GFONT_PRECONNECT}
|
15989
|
+
${GFONT_SOURCE_SANS_3}
|
15990
|
+
${GFONT_CORMORANT}
|
15995
15991
|
${STYLES$9(spot)}
|
15996
15992
|
<div class="content">
|
15997
15993
|
<div class="text">
|
@@ -16053,7 +16049,7 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot) {
|
|
16053
16049
|
`;
|
16054
16050
|
}
|
16055
16051
|
|
16056
|
-
const STYLES$6 = ({ textColor = '#
|
16052
|
+
const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
|
16057
16053
|
<style>
|
16058
16054
|
:host {
|
16059
16055
|
min-width: 320px;
|
@@ -16171,9 +16167,9 @@ const STYLES$6 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor
|
|
16171
16167
|
`;
|
16172
16168
|
function rbHomepageHeroFullImageTemplate(spot) {
|
16173
16169
|
return `
|
16174
|
-
${GFONT_PRECONNECT
|
16175
|
-
${GFONT_SOURCE_SANS_3
|
16176
|
-
${GFONT_CORMORANT
|
16170
|
+
${GFONT_PRECONNECT}
|
16171
|
+
${GFONT_SOURCE_SANS_3}
|
16172
|
+
${GFONT_CORMORANT}
|
16177
16173
|
${STYLES$6(spot)}
|
16178
16174
|
<div class="content">
|
16179
16175
|
<div class="text">
|
@@ -16338,9 +16334,9 @@ const STYLES$5 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
16338
16334
|
`;
|
16339
16335
|
function rbHomepageHeroThreeTileTemplate(spot) {
|
16340
16336
|
return `
|
16341
|
-
${GFONT_PRECONNECT
|
16342
|
-
${GFONT_SOURCE_SANS_3
|
16343
|
-
${GFONT_CORMORANT
|
16337
|
+
${GFONT_PRECONNECT}
|
16338
|
+
${GFONT_SOURCE_SANS_3}
|
16339
|
+
${GFONT_CORMORANT}
|
16344
16340
|
${STYLES$5(spot)}
|
16345
16341
|
<div class="content">
|
16346
16342
|
<div class="primary-image"></div>
|
@@ -16481,9 +16477,9 @@ const STYLES$4 = ({ textColor = '#212121', backgroundColor = '#e8e6de', ctaTextC
|
|
16481
16477
|
`;
|
16482
16478
|
function rbHomepageHeroTwoTileTemplate(spot) {
|
16483
16479
|
return `
|
16484
|
-
${GFONT_PRECONNECT
|
16485
|
-
${GFONT_SOURCE_SANS_3
|
16486
|
-
${GFONT_CORMORANT
|
16480
|
+
${GFONT_PRECONNECT}
|
16481
|
+
${GFONT_SOURCE_SANS_3}
|
16482
|
+
${GFONT_CORMORANT}
|
16487
16483
|
${STYLES$4(spot)}
|
16488
16484
|
<div class="content">
|
16489
16485
|
<div class="text">
|
@@ -16496,7 +16492,7 @@ function rbHomepageHeroTwoTileTemplate(spot) {
|
|
16496
16492
|
`;
|
16497
16493
|
}
|
16498
16494
|
|
16499
|
-
const STYLES$3 = ({ textColor = '#
|
16495
|
+
const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
|
16500
16496
|
<style>
|
16501
16497
|
:host {
|
16502
16498
|
min-width: 320px;
|
@@ -16603,9 +16599,9 @@ const STYLES$3 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor
|
|
16603
16599
|
`;
|
16604
16600
|
function rbLargeCategoryImageToutTemplate(spot) {
|
16605
16601
|
return `
|
16606
|
-
${GFONT_PRECONNECT
|
16607
|
-
${GFONT_SOURCE_SANS_3
|
16608
|
-
${GFONT_CORMORANT
|
16602
|
+
${GFONT_PRECONNECT}
|
16603
|
+
${GFONT_SOURCE_SANS_3}
|
16604
|
+
${GFONT_CORMORANT}
|
16609
16605
|
${STYLES$3(spot)}
|
16610
16606
|
<div class="content">
|
16611
16607
|
<div class="text">
|
@@ -16617,7 +16613,7 @@ function rbLargeCategoryImageToutTemplate(spot) {
|
|
16617
16613
|
`;
|
16618
16614
|
}
|
16619
16615
|
|
16620
|
-
const STYLES$2 = ({ textColor = '#
|
16616
|
+
const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
|
16621
16617
|
<style>
|
16622
16618
|
:host {
|
16623
16619
|
min-width: 320px;
|
@@ -16675,8 +16671,8 @@ const STYLES$2 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = prima
|
|
16675
16671
|
`;
|
16676
16672
|
function rbNavigationBannerTemplate(spot) {
|
16677
16673
|
return `
|
16678
|
-
${GFONT_PRECONNECT
|
16679
|
-
${GFONT_SOURCE_SANS_3
|
16674
|
+
${GFONT_PRECONNECT}
|
16675
|
+
${GFONT_SOURCE_SANS_3}
|
16680
16676
|
${STYLES$2(spot)}
|
16681
16677
|
<div class="content">
|
16682
16678
|
<div class="text">
|
@@ -16686,7 +16682,7 @@ function rbNavigationBannerTemplate(spot) {
|
|
16686
16682
|
`;
|
16687
16683
|
}
|
16688
16684
|
|
16689
|
-
const STYLES$1 = ({ textColor = '#
|
16685
|
+
const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
|
16690
16686
|
<style>
|
16691
16687
|
:host {
|
16692
16688
|
min-width: 165px;
|
@@ -16718,6 +16714,7 @@ const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = prima
|
|
16718
16714
|
font-style: normal;
|
16719
16715
|
font-weight: 400;
|
16720
16716
|
line-height: normal;
|
16717
|
+
margin: 0;
|
16721
16718
|
}
|
16722
16719
|
@media (min-width: 640px) {
|
16723
16720
|
.content {
|
@@ -16728,8 +16725,8 @@ const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = prima
|
|
16728
16725
|
`;
|
16729
16726
|
function rbSmallCategoryImageToutTemplate(spot) {
|
16730
16727
|
return `
|
16731
|
-
${GFONT_PRECONNECT
|
16732
|
-
${GFONT_CORMORANT
|
16728
|
+
${GFONT_PRECONNECT}
|
16729
|
+
${GFONT_CORMORANT}
|
16733
16730
|
${STYLES$1(spot)}
|
16734
16731
|
<div class="content">
|
16735
16732
|
<div class="text">
|
@@ -16739,7 +16736,7 @@ function rbSmallCategoryImageToutTemplate(spot) {
|
|
16739
16736
|
`;
|
16740
16737
|
}
|
16741
16738
|
|
16742
|
-
const STYLES = ({ textColor = '#
|
16739
|
+
const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
|
16743
16740
|
<style>
|
16744
16741
|
:host {
|
16745
16742
|
min-width: 165px;
|
@@ -16782,6 +16779,7 @@ const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryIm
|
|
16782
16779
|
font-style: normal;
|
16783
16780
|
font-weight: 400;
|
16784
16781
|
line-height: normal;
|
16782
|
+
margin: 0;
|
16785
16783
|
}
|
16786
16784
|
@media (min-width: 640px) {
|
16787
16785
|
.image {
|
@@ -16792,8 +16790,8 @@ const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryIm
|
|
16792
16790
|
`;
|
16793
16791
|
function rbSmallDiscoverToutTemplate(spot) {
|
16794
16792
|
return `
|
16795
|
-
${GFONT_PRECONNECT
|
16796
|
-
${GFONT_CORMORANT
|
16793
|
+
${GFONT_PRECONNECT}
|
16794
|
+
${GFONT_CORMORANT}
|
16797
16795
|
${STYLES(spot)}
|
16798
16796
|
<div class="content">
|
16799
16797
|
<div class="image"></div>
|
@@ -16889,16 +16887,20 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
16889
16887
|
class CustomSpotElement extends HTMLElement {
|
16890
16888
|
constructor() {
|
16891
16889
|
super();
|
16890
|
+
this.hasCustomContent = false;
|
16891
|
+
this.handleClick = this.handleClick.bind(this);
|
16892
16892
|
this.attachShadow({ mode: 'open' });
|
16893
16893
|
}
|
16894
16894
|
connectedCallback() {
|
16895
|
-
this.
|
16895
|
+
this.hasCustomContent = Boolean(this.customContent);
|
16896
|
+
this.addEventListener('click', this.handleClick);
|
16896
16897
|
this.setupIntersectionObserver();
|
16897
16898
|
this.render();
|
16898
16899
|
}
|
16899
16900
|
disconnectedCallback() {
|
16900
16901
|
var _a;
|
16901
16902
|
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
16903
|
+
this.removeEventListener('click', this.handleClick);
|
16902
16904
|
}
|
16903
16905
|
attributeChangedCallback(_name, oldValue, newValue) {
|
16904
16906
|
if (oldValue !== newValue) {
|
@@ -16908,14 +16910,26 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
16908
16910
|
render() {
|
16909
16911
|
if (!this.shadowRoot || !this.data)
|
16910
16912
|
return;
|
16911
|
-
const { style, wrapper } =
|
16912
|
-
|
16913
|
-
|
16913
|
+
const { style, wrapper, slot } = SPOT_ELEMENT_TEMPLATE(this.data.width, this.data.height, this.hasCustomContent);
|
16914
|
+
this.shadowRoot.replaceChildren(style, slot);
|
16915
|
+
if (this.hasCustomContent) {
|
16916
|
+
this.setCustomContent();
|
16914
16917
|
}
|
16915
|
-
|
16918
|
+
if (!this.hasCustomContent) {
|
16916
16919
|
wrapper.innerHTML = GET_SPOT_TEMPLATE_HTML_STRING(this.data);
|
16920
|
+
this.shadowRoot.appendChild(wrapper);
|
16917
16921
|
}
|
16918
|
-
|
16922
|
+
}
|
16923
|
+
setCustomContent() {
|
16924
|
+
const wrapper = document.createElement('div');
|
16925
|
+
wrapper.setAttribute('slot', SPOT_ELEMENT_SLOT_NAME);
|
16926
|
+
if (typeof this.customContent === 'string') {
|
16927
|
+
wrapper.innerHTML = this.customContent;
|
16928
|
+
}
|
16929
|
+
if (this.customContent instanceof HTMLElement) {
|
16930
|
+
wrapper.appendChild(this.customContent);
|
16931
|
+
}
|
16932
|
+
this.appendChild(wrapper);
|
16919
16933
|
}
|
16920
16934
|
setupIntersectionObserver() {
|
16921
16935
|
const options = {
|
@@ -16932,47 +16946,37 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
|
|
16932
16946
|
}, options);
|
16933
16947
|
this.observer.observe(this);
|
16934
16948
|
}
|
16949
|
+
handleClick() {
|
16950
|
+
this.registerEvent(exports.RMN_SPOT_EVENT.CLICK);
|
16951
|
+
}
|
16935
16952
|
async registerEvent(event) {
|
16936
16953
|
var _a, _b;
|
16937
16954
|
if (!this.data)
|
16938
16955
|
return;
|
16939
16956
|
const shouldRedirectOnClick = this.getAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK) === 'true';
|
16940
|
-
const
|
16957
|
+
const eventUrl = (_b = (_a = this.data.events.find((e) => e.event === event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';
|
16941
16958
|
try {
|
16942
16959
|
const options = {
|
16943
16960
|
method: 'POST',
|
16944
|
-
redirect: 'manual',
|
16961
|
+
redirect: event === exports.RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick ? 'follow' : 'manual',
|
16945
16962
|
};
|
16946
|
-
|
16947
|
-
options.redirect = 'follow';
|
16948
|
-
}
|
16949
|
-
const normalizedUrl = this.normalizeUrl(url);
|
16950
|
-
const response = await fetch(normalizedUrl, options);
|
16963
|
+
const response = await fetch(eventUrl, options);
|
16951
16964
|
if (response.ok && event === exports.RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
|
16952
|
-
window.location.href = this.getRedirectUrlFromPayload(
|
16965
|
+
window.location.href = this.getRedirectUrlFromPayload(eventUrl);
|
16953
16966
|
}
|
16954
16967
|
}
|
16955
16968
|
catch (error) {
|
16956
16969
|
console.error(`Rmn error sending ${event} event:`, error);
|
16957
16970
|
}
|
16958
16971
|
}
|
16959
|
-
normalizeUrl(url) {
|
16960
|
-
if (!this.data)
|
16961
|
-
return url;
|
16962
|
-
const rmnUrl = `${SDK_CONFIG.url[this.data.env]}/api${SPOT_EVENT_API_PATH}`;
|
16963
|
-
return url.replace(/https?:\/\/[^/]+\/[^?]+/, `${rmnUrl}`);
|
16964
|
-
}
|
16965
16972
|
getRedirectUrlFromPayload(url) {
|
16966
|
-
var _a;
|
16973
|
+
var _a, _b;
|
16967
16974
|
const base64String = (_a = new URL(url).searchParams.get('e')) !== null && _a !== void 0 ? _a : '';
|
16968
16975
|
try {
|
16969
|
-
const
|
16970
|
-
|
16971
|
-
return obj.ur;
|
16972
|
-
}
|
16973
|
-
return '';
|
16976
|
+
const data = JSON.parse(atob(base64String));
|
16977
|
+
return (_b = data.ur) !== null && _b !== void 0 ? _b : '';
|
16974
16978
|
}
|
16975
|
-
catch (
|
16979
|
+
catch (_c) {
|
16976
16980
|
return '';
|
16977
16981
|
}
|
16978
16982
|
}
|
@@ -16993,7 +16997,7 @@ class SpotHtmlService {
|
|
16993
16997
|
* @param {ISpot} spot - The spot data.
|
16994
16998
|
* @param {ICreateSpotElementConfig} config - The configuration object.
|
16995
16999
|
* @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
|
16996
|
-
* @param {ICreateSpotElementConfig.
|
17000
|
+
* @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
|
16997
17001
|
* @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
|
16998
17002
|
*
|
16999
17003
|
* @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
|
@@ -17012,8 +17016,9 @@ class SpotHtmlService {
|
|
17012
17016
|
element.setAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK, shouldRedirectOnClick.toString());
|
17013
17017
|
// Share the spot data with the element
|
17014
17018
|
element.data = spot;
|
17015
|
-
|
17016
|
-
|
17019
|
+
// Set custom content
|
17020
|
+
if (config === null || config === void 0 ? void 0 : config.customContent) {
|
17021
|
+
element.customContent = config.customContent;
|
17017
17022
|
}
|
17018
17023
|
return element;
|
17019
17024
|
}
|
@@ -17054,22 +17059,10 @@ class SpotSelectionService extends BaseApi {
|
|
17054
17059
|
if (isOk && val && val.data && (val === null || val === void 0 ? void 0 : val.refresh.token)) {
|
17055
17060
|
this.authInfo.authenticated = true;
|
17056
17061
|
this.authInfo.token = val.refresh.token;
|
17057
|
-
|
17058
|
-
spots = this.addEnvToSpotData(spots, this.authInfo.env);
|
17059
|
-
return spots;
|
17062
|
+
return val.data.spots;
|
17060
17063
|
}
|
17061
17064
|
throw new Error('Spot selection response was not successful');
|
17062
17065
|
}
|
17063
|
-
addEnvToSpotData(spots, env) {
|
17064
|
-
for (const key in spots) {
|
17065
|
-
if (spots[key]) {
|
17066
|
-
spots[key].forEach((spot) => {
|
17067
|
-
spot.env = env;
|
17068
|
-
});
|
17069
|
-
}
|
17070
|
-
}
|
17071
|
-
return spots;
|
17072
|
-
}
|
17073
17066
|
}
|
17074
17067
|
|
17075
17068
|
class LiquidCommerceRmnClient {
|
@@ -17097,7 +17090,7 @@ class LiquidCommerceRmnClient {
|
|
17097
17090
|
* @param {ISpot} spot - The spot data.
|
17098
17091
|
* @param {ICreateSpotElementConfig} config - The configuration object.
|
17099
17092
|
* @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
|
17100
|
-
* @param {ICreateSpotElementConfig.
|
17093
|
+
* @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
|
17101
17094
|
* @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
|
17102
17095
|
*
|
17103
17096
|
* @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
|
@@ -17129,7 +17122,7 @@ async function RmnClient(apiKey, config) {
|
|
17129
17122
|
* @param {ISpot} spot - The spot data.
|
17130
17123
|
* @param {ICreateSpotElementConfig} config - The configuration object.
|
17131
17124
|
* @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
|
17132
|
-
* @param {ICreateSpotElementConfig.
|
17125
|
+
* @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
|
17133
17126
|
* @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
|
17134
17127
|
*
|
17135
17128
|
* @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
|