@liquidcommercedev/rmn-sdk 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs CHANGED
@@ -15152,43 +15152,45 @@ 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
15157
  const SPOT_EVENT_API_PATH = '/spots/event';
15157
15158
 
15158
- const SPOT_ELEMENT_SHADOW_ROOT = (width, height, hasCustomHtmlElement) => {
15159
+ const SPOT_ELEMENT_SHADOW_ROOT = (width, height, hasCustomContent) => {
15159
15160
  const style = document.createElement('style');
15161
+ style.textContent = `
15162
+ :host {
15163
+ display: block;
15164
+ position: relative;
15165
+ container-type: inline-size;
15166
+ overflow: hidden;
15167
+ }
15168
+ :host([fluid="true"]) {
15169
+ width: 100%;
15170
+ height: 100%;
15171
+ }
15172
+ :host([fluid="false"]) {
15173
+ width: ${width}px;
15174
+ height: ${height}px;
15175
+ }
15176
+ `;
15160
15177
  const wrapper = document.createElement('div');
15161
15178
  wrapper.className = 'wrapper';
15162
- style.textContent = `
15163
- :host {
15164
- display: block;
15165
- position: relative;
15166
- container-type: inline-size;
15167
- overflow: hidden;
15168
- }
15169
- :host([fluid="true"]) {
15170
- width: 100%;
15171
- height: 100%;
15172
- }
15173
- :host([fluid="false"]) {
15174
- width: ${width}px;
15175
- height: ${height}px;
15176
- }
15179
+ const slot = document.createElement('slot');
15180
+ slot.name = SPOT_ELEMENT_SLOT_NAME;
15181
+ if (!hasCustomContent) {
15182
+ style.textContent += `
15183
+ :host .wrapper {
15184
+ position: absolute;
15185
+ top: 0;
15186
+ left: 0;
15187
+ width: 100%;
15188
+ height: 100%;
15189
+ overflow: hidden;
15190
+ }
15177
15191
  `;
15178
- if (hasCustomHtmlElement) {
15179
- return { style, wrapper };
15180
15192
  }
15181
- style.textContent += `
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 };
15193
+ return { style, wrapper, slot };
15192
15194
  };
15193
15195
 
15194
15196
  const GFONT_PRECONNECT = () => `
@@ -16053,7 +16055,7 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot) {
16053
16055
  `;
16054
16056
  }
16055
16057
 
16056
- const STYLES$6 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16058
+ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16057
16059
  <style>
16058
16060
  :host {
16059
16061
  min-width: 320px;
@@ -16496,7 +16498,7 @@ function rbHomepageHeroTwoTileTemplate(spot) {
16496
16498
  `;
16497
16499
  }
16498
16500
 
16499
- const STYLES$3 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16501
+ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16500
16502
  <style>
16501
16503
  :host {
16502
16504
  min-width: 320px;
@@ -16617,7 +16619,7 @@ function rbLargeCategoryImageToutTemplate(spot) {
16617
16619
  `;
16618
16620
  }
16619
16621
 
16620
- const STYLES$2 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16622
+ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16621
16623
  <style>
16622
16624
  :host {
16623
16625
  min-width: 320px;
@@ -16686,7 +16688,7 @@ function rbNavigationBannerTemplate(spot) {
16686
16688
  `;
16687
16689
  }
16688
16690
 
16689
- const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16691
+ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16690
16692
  <style>
16691
16693
  :host {
16692
16694
  min-width: 165px;
@@ -16739,7 +16741,7 @@ function rbSmallCategoryImageToutTemplate(spot) {
16739
16741
  `;
16740
16742
  }
16741
16743
 
16742
- const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16744
+ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16743
16745
  <style>
16744
16746
  :host {
16745
16747
  min-width: 165px;
@@ -16889,16 +16891,20 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16889
16891
  class CustomSpotElement extends HTMLElement {
16890
16892
  constructor() {
16891
16893
  super();
16894
+ this.hasCustomContent = false;
16895
+ this.handleClick = this.handleClick.bind(this);
16892
16896
  this.attachShadow({ mode: 'open' });
16893
16897
  }
16894
16898
  connectedCallback() {
16895
- this.addEventListener('click', () => this.registerEvent(exports.RMN_SPOT_EVENT.CLICK));
16899
+ this.hasCustomContent = Boolean(this.customContent);
16900
+ this.addEventListener('click', this.handleClick);
16896
16901
  this.setupIntersectionObserver();
16897
16902
  this.render();
16898
16903
  }
16899
16904
  disconnectedCallback() {
16900
16905
  var _a;
16901
16906
  (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
16907
+ this.removeEventListener('click', this.handleClick);
16902
16908
  }
16903
16909
  attributeChangedCallback(_name, oldValue, newValue) {
16904
16910
  if (oldValue !== newValue) {
@@ -16908,14 +16914,26 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16908
16914
  render() {
16909
16915
  if (!this.shadowRoot || !this.data)
16910
16916
  return;
16911
- const { style, wrapper } = SPOT_ELEMENT_SHADOW_ROOT(this.data.width, this.data.height, Boolean(this.customHtmlElement));
16912
- if (this.customHtmlElement) {
16913
- wrapper.innerHTML = this.customHtmlElement.outerHTML;
16917
+ const { style, wrapper, slot } = SPOT_ELEMENT_SHADOW_ROOT(this.data.width, this.data.height, this.hasCustomContent);
16918
+ this.shadowRoot.replaceChildren(style, slot);
16919
+ if (this.hasCustomContent) {
16920
+ this.setCustomContent();
16914
16921
  }
16915
- else {
16922
+ if (!this.hasCustomContent) {
16916
16923
  wrapper.innerHTML = GET_SPOT_TEMPLATE_HTML_STRING(this.data);
16924
+ this.shadowRoot.appendChild(wrapper);
16917
16925
  }
16918
- this.shadowRoot.replaceChildren(style, wrapper);
16926
+ }
16927
+ setCustomContent() {
16928
+ const wrapper = document.createElement('div');
16929
+ wrapper.setAttribute('slot', SPOT_ELEMENT_SLOT_NAME);
16930
+ if (typeof this.customContent === 'string') {
16931
+ wrapper.innerHTML = this.customContent;
16932
+ }
16933
+ if (this.customContent instanceof HTMLElement) {
16934
+ wrapper.appendChild(this.customContent);
16935
+ }
16936
+ this.appendChild(wrapper);
16919
16937
  }
16920
16938
  setupIntersectionObserver() {
16921
16939
  const options = {
@@ -16932,21 +16950,21 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16932
16950
  }, options);
16933
16951
  this.observer.observe(this);
16934
16952
  }
16953
+ handleClick() {
16954
+ this.registerEvent(exports.RMN_SPOT_EVENT.CLICK);
16955
+ }
16935
16956
  async registerEvent(event) {
16936
16957
  var _a, _b;
16937
16958
  if (!this.data)
16938
16959
  return;
16939
16960
  const shouldRedirectOnClick = this.getAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK) === 'true';
16940
- const url = (_b = (_a = this.data.events.find((e) => e.event === event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';
16961
+ 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
16962
  try {
16942
16963
  const options = {
16943
16964
  method: 'POST',
16944
- redirect: 'manual',
16965
+ redirect: event === exports.RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick ? 'follow' : 'manual',
16945
16966
  };
16946
- if (event === exports.RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
16947
- options.redirect = 'follow';
16948
- }
16949
- const normalizedUrl = this.normalizeUrl(url);
16967
+ const normalizedUrl = this.normalizeUrl(eventUrl);
16950
16968
  const response = await fetch(normalizedUrl, options);
16951
16969
  if (response.ok && event === exports.RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
16952
16970
  window.location.href = this.getRedirectUrlFromPayload(normalizedUrl);
@@ -16963,16 +16981,13 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16963
16981
  return url.replace(/https?:\/\/[^/]+\/[^?]+/, `${rmnUrl}`);
16964
16982
  }
16965
16983
  getRedirectUrlFromPayload(url) {
16966
- var _a;
16984
+ var _a, _b;
16967
16985
  const base64String = (_a = new URL(url).searchParams.get('e')) !== null && _a !== void 0 ? _a : '';
16968
16986
  try {
16969
- const obj = JSON.parse(atob(base64String));
16970
- if (obj.ur) {
16971
- return obj.ur;
16972
- }
16973
- return '';
16987
+ const data = JSON.parse(atob(base64String));
16988
+ return (_b = data.ur) !== null && _b !== void 0 ? _b : '';
16974
16989
  }
16975
- catch (_b) {
16990
+ catch (_c) {
16976
16991
  return '';
16977
16992
  }
16978
16993
  }
@@ -16993,7 +17008,7 @@ class SpotHtmlService {
16993
17008
  * @param {ISpot} spot - The spot data.
16994
17009
  * @param {ICreateSpotElementConfig} config - The configuration object.
16995
17010
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
16996
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17011
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
16997
17012
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
16998
17013
  *
16999
17014
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -17012,8 +17027,9 @@ class SpotHtmlService {
17012
17027
  element.setAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK, shouldRedirectOnClick.toString());
17013
17028
  // Share the spot data with the element
17014
17029
  element.data = spot;
17015
- if (config === null || config === void 0 ? void 0 : config.customHtmlElement) {
17016
- element.customHtmlElement = config.customHtmlElement;
17030
+ // Set custom content
17031
+ if (config === null || config === void 0 ? void 0 : config.customContent) {
17032
+ element.customContent = config.customContent;
17017
17033
  }
17018
17034
  return element;
17019
17035
  }
@@ -17097,7 +17113,7 @@ class LiquidCommerceRmnClient {
17097
17113
  * @param {ISpot} spot - The spot data.
17098
17114
  * @param {ICreateSpotElementConfig} config - The configuration object.
17099
17115
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
17100
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17116
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
17101
17117
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
17102
17118
  *
17103
17119
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -17129,7 +17145,7 @@ async function RmnClient(apiKey, config) {
17129
17145
  * @param {ISpot} spot - The spot data.
17130
17146
  * @param {ICreateSpotElementConfig} config - The configuration object.
17131
17147
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
17132
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17148
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
17133
17149
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
17134
17150
  *
17135
17151
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
package/dist/index.esm.js CHANGED
@@ -15150,43 +15150,45 @@ class AuthService extends BaseApi {
15150
15150
  }
15151
15151
 
15152
15152
  const SPOT_ELEMENT_TAG = 'spot-element';
15153
+ const SPOT_ELEMENT_SLOT_NAME = `${SPOT_ELEMENT_TAG}-custom-content`;
15153
15154
  const SPOTS_SELECTION_API_PATH = '/spots/selection';
15154
15155
  const SPOT_EVENT_API_PATH = '/spots/event';
15155
15156
 
15156
- const SPOT_ELEMENT_SHADOW_ROOT = (width, height, hasCustomHtmlElement) => {
15157
+ const SPOT_ELEMENT_SHADOW_ROOT = (width, height, hasCustomContent) => {
15157
15158
  const style = document.createElement('style');
15159
+ style.textContent = `
15160
+ :host {
15161
+ display: block;
15162
+ position: relative;
15163
+ container-type: inline-size;
15164
+ overflow: hidden;
15165
+ }
15166
+ :host([fluid="true"]) {
15167
+ width: 100%;
15168
+ height: 100%;
15169
+ }
15170
+ :host([fluid="false"]) {
15171
+ width: ${width}px;
15172
+ height: ${height}px;
15173
+ }
15174
+ `;
15158
15175
  const wrapper = document.createElement('div');
15159
15176
  wrapper.className = 'wrapper';
15160
- style.textContent = `
15161
- :host {
15162
- display: block;
15163
- position: relative;
15164
- container-type: inline-size;
15165
- overflow: hidden;
15166
- }
15167
- :host([fluid="true"]) {
15168
- width: 100%;
15169
- height: 100%;
15170
- }
15171
- :host([fluid="false"]) {
15172
- width: ${width}px;
15173
- height: ${height}px;
15174
- }
15177
+ const slot = document.createElement('slot');
15178
+ slot.name = SPOT_ELEMENT_SLOT_NAME;
15179
+ if (!hasCustomContent) {
15180
+ style.textContent += `
15181
+ :host .wrapper {
15182
+ position: absolute;
15183
+ top: 0;
15184
+ left: 0;
15185
+ width: 100%;
15186
+ height: 100%;
15187
+ overflow: hidden;
15188
+ }
15175
15189
  `;
15176
- if (hasCustomHtmlElement) {
15177
- return { style, wrapper };
15178
15190
  }
15179
- style.textContent += `
15180
- .wrapper {
15181
- position: absolute;
15182
- top: 0;
15183
- left: 0;
15184
- width: 100%;
15185
- height: 100%;
15186
- overflow: hidden;
15187
- }
15188
- `;
15189
- return { style, wrapper };
15191
+ return { style, wrapper, slot };
15190
15192
  };
15191
15193
 
15192
15194
  const GFONT_PRECONNECT = () => `
@@ -16051,7 +16053,7 @@ function rbCollectionBannerWithoutTextBlockTemplate(spot) {
16051
16053
  `;
16052
16054
  }
16053
16055
 
16054
- const STYLES$6 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16056
+ const STYLES$6 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16055
16057
  <style>
16056
16058
  :host {
16057
16059
  min-width: 320px;
@@ -16494,7 +16496,7 @@ function rbHomepageHeroTwoTileTemplate(spot) {
16494
16496
  `;
16495
16497
  }
16496
16498
 
16497
- const STYLES$3 = ({ textColor = '#fff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16499
+ const STYLES$3 = ({ textColor = '#ffffff', ctaTextColor = textColor, ctaBorderColor = ctaTextColor, primaryImage, mobilePrimaryImage = primaryImage, }) => `
16498
16500
  <style>
16499
16501
  :host {
16500
16502
  min-width: 320px;
@@ -16615,7 +16617,7 @@ function rbLargeCategoryImageToutTemplate(spot) {
16615
16617
  `;
16616
16618
  }
16617
16619
 
16618
- const STYLES$2 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16620
+ const STYLES$2 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16619
16621
  <style>
16620
16622
  :host {
16621
16623
  min-width: 320px;
@@ -16684,7 +16686,7 @@ function rbNavigationBannerTemplate(spot) {
16684
16686
  `;
16685
16687
  }
16686
16688
 
16687
- const STYLES$1 = ({ textColor = '#fff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16689
+ const STYLES$1 = ({ textColor = '#ffffff', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16688
16690
  <style>
16689
16691
  :host {
16690
16692
  min-width: 165px;
@@ -16737,7 +16739,7 @@ function rbSmallCategoryImageToutTemplate(spot) {
16737
16739
  `;
16738
16740
  }
16739
16741
 
16740
- const STYLES = ({ textColor = '#000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16742
+ const STYLES = ({ textColor = '#000000', backgroundColor = 'transparent', primaryImage, mobilePrimaryImage = primaryImage, }) => `
16741
16743
  <style>
16742
16744
  :host {
16743
16745
  min-width: 165px;
@@ -16887,16 +16889,20 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16887
16889
  class CustomSpotElement extends HTMLElement {
16888
16890
  constructor() {
16889
16891
  super();
16892
+ this.hasCustomContent = false;
16893
+ this.handleClick = this.handleClick.bind(this);
16890
16894
  this.attachShadow({ mode: 'open' });
16891
16895
  }
16892
16896
  connectedCallback() {
16893
- this.addEventListener('click', () => this.registerEvent(RMN_SPOT_EVENT.CLICK));
16897
+ this.hasCustomContent = Boolean(this.customContent);
16898
+ this.addEventListener('click', this.handleClick);
16894
16899
  this.setupIntersectionObserver();
16895
16900
  this.render();
16896
16901
  }
16897
16902
  disconnectedCallback() {
16898
16903
  var _a;
16899
16904
  (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
16905
+ this.removeEventListener('click', this.handleClick);
16900
16906
  }
16901
16907
  attributeChangedCallback(_name, oldValue, newValue) {
16902
16908
  if (oldValue !== newValue) {
@@ -16906,14 +16912,26 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16906
16912
  render() {
16907
16913
  if (!this.shadowRoot || !this.data)
16908
16914
  return;
16909
- const { style, wrapper } = SPOT_ELEMENT_SHADOW_ROOT(this.data.width, this.data.height, Boolean(this.customHtmlElement));
16910
- if (this.customHtmlElement) {
16911
- wrapper.innerHTML = this.customHtmlElement.outerHTML;
16915
+ const { style, wrapper, slot } = SPOT_ELEMENT_SHADOW_ROOT(this.data.width, this.data.height, this.hasCustomContent);
16916
+ this.shadowRoot.replaceChildren(style, slot);
16917
+ if (this.hasCustomContent) {
16918
+ this.setCustomContent();
16912
16919
  }
16913
- else {
16920
+ if (!this.hasCustomContent) {
16914
16921
  wrapper.innerHTML = GET_SPOT_TEMPLATE_HTML_STRING(this.data);
16922
+ this.shadowRoot.appendChild(wrapper);
16915
16923
  }
16916
- this.shadowRoot.replaceChildren(style, wrapper);
16924
+ }
16925
+ setCustomContent() {
16926
+ const wrapper = document.createElement('div');
16927
+ wrapper.setAttribute('slot', SPOT_ELEMENT_SLOT_NAME);
16928
+ if (typeof this.customContent === 'string') {
16929
+ wrapper.innerHTML = this.customContent;
16930
+ }
16931
+ if (this.customContent instanceof HTMLElement) {
16932
+ wrapper.appendChild(this.customContent);
16933
+ }
16934
+ this.appendChild(wrapper);
16917
16935
  }
16918
16936
  setupIntersectionObserver() {
16919
16937
  const options = {
@@ -16930,21 +16948,21 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16930
16948
  }, options);
16931
16949
  this.observer.observe(this);
16932
16950
  }
16951
+ handleClick() {
16952
+ this.registerEvent(RMN_SPOT_EVENT.CLICK);
16953
+ }
16933
16954
  async registerEvent(event) {
16934
16955
  var _a, _b;
16935
16956
  if (!this.data)
16936
16957
  return;
16937
16958
  const shouldRedirectOnClick = this.getAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK) === 'true';
16938
- const url = (_b = (_a = this.data.events.find((e) => e.event === event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';
16959
+ 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 : '';
16939
16960
  try {
16940
16961
  const options = {
16941
16962
  method: 'POST',
16942
- redirect: 'manual',
16963
+ redirect: event === RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick ? 'follow' : 'manual',
16943
16964
  };
16944
- if (event === RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
16945
- options.redirect = 'follow';
16946
- }
16947
- const normalizedUrl = this.normalizeUrl(url);
16965
+ const normalizedUrl = this.normalizeUrl(eventUrl);
16948
16966
  const response = await fetch(normalizedUrl, options);
16949
16967
  if (response.ok && event === RMN_SPOT_EVENT.CLICK && shouldRedirectOnClick) {
16950
16968
  window.location.href = this.getRedirectUrlFromPayload(normalizedUrl);
@@ -16961,16 +16979,13 @@ if (typeof window !== 'undefined' && typeof window.customElements !== 'undefined
16961
16979
  return url.replace(/https?:\/\/[^/]+\/[^?]+/, `${rmnUrl}`);
16962
16980
  }
16963
16981
  getRedirectUrlFromPayload(url) {
16964
- var _a;
16982
+ var _a, _b;
16965
16983
  const base64String = (_a = new URL(url).searchParams.get('e')) !== null && _a !== void 0 ? _a : '';
16966
16984
  try {
16967
- const obj = JSON.parse(atob(base64String));
16968
- if (obj.ur) {
16969
- return obj.ur;
16970
- }
16971
- return '';
16985
+ const data = JSON.parse(atob(base64String));
16986
+ return (_b = data.ur) !== null && _b !== void 0 ? _b : '';
16972
16987
  }
16973
- catch (_b) {
16988
+ catch (_c) {
16974
16989
  return '';
16975
16990
  }
16976
16991
  }
@@ -16991,7 +17006,7 @@ class SpotHtmlService {
16991
17006
  * @param {ISpot} spot - The spot data.
16992
17007
  * @param {ICreateSpotElementConfig} config - The configuration object.
16993
17008
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
16994
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17009
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
16995
17010
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
16996
17011
  *
16997
17012
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -17010,8 +17025,9 @@ class SpotHtmlService {
17010
17025
  element.setAttribute(ENUM_SPOT_ELEMENT_ATTRIBUTE.REDIRECT_ON_CLICK, shouldRedirectOnClick.toString());
17011
17026
  // Share the spot data with the element
17012
17027
  element.data = spot;
17013
- if (config === null || config === void 0 ? void 0 : config.customHtmlElement) {
17014
- element.customHtmlElement = config.customHtmlElement;
17028
+ // Set custom content
17029
+ if (config === null || config === void 0 ? void 0 : config.customContent) {
17030
+ element.customContent = config.customContent;
17015
17031
  }
17016
17032
  return element;
17017
17033
  }
@@ -17095,7 +17111,7 @@ class LiquidCommerceRmnClient {
17095
17111
  * @param {ISpot} spot - The spot data.
17096
17112
  * @param {ICreateSpotElementConfig} config - The configuration object.
17097
17113
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
17098
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17114
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
17099
17115
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
17100
17116
  *
17101
17117
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -17127,7 +17143,7 @@ async function RmnClient(apiKey, config) {
17127
17143
  * @param {ISpot} spot - The spot data.
17128
17144
  * @param {ICreateSpotElementConfig} config - The configuration object.
17129
17145
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
17130
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
17146
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
17131
17147
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
17132
17148
  *
17133
17149
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -1,7 +1,7 @@
1
1
  import type { ISpot } from 'types';
2
2
  export interface ICustomSpotElement extends HTMLElement {
3
3
  data?: ISpot;
4
- customHtmlElement?: HTMLElement;
4
+ customContent?: HTMLElement | string;
5
5
  }
6
6
  declare let SpotElement: new () => HTMLElement;
7
7
  export { SpotElement };
@@ -1,4 +1,5 @@
1
- export declare const SPOT_ELEMENT_SHADOW_ROOT: (width: number, height: number, hasCustomHtmlElement: boolean) => {
1
+ export declare const SPOT_ELEMENT_SHADOW_ROOT: (width: number, height: number, hasCustomContent: boolean) => {
2
2
  style: HTMLStyleElement;
3
3
  wrapper: HTMLDivElement;
4
+ slot: HTMLSlotElement;
4
5
  };
@@ -1,3 +1,4 @@
1
1
  export declare const SPOT_ELEMENT_TAG = "spot-element";
2
+ export declare const SPOT_ELEMENT_SLOT_NAME = "spot-element-custom-content";
2
3
  export declare const SPOTS_SELECTION_API_PATH = "/spots/selection";
3
4
  export declare const SPOT_EVENT_API_PATH = "/spots/event";
@@ -9,7 +9,7 @@ export declare class SpotHtmlService implements ISpotHtmlService {
9
9
  * @param {ISpot} spot - The spot data.
10
10
  * @param {ICreateSpotElementConfig} config - The configuration object.
11
11
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
12
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
12
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
13
13
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
14
14
  *
15
15
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -33,7 +33,7 @@ export interface ISpot {
33
33
  }
34
34
  export interface ICreateSpotElementConfig {
35
35
  fluid?: boolean;
36
- customHtmlElement?: HTMLElement;
36
+ customContent?: HTMLElement | string;
37
37
  redirectOnClick?: boolean;
38
38
  }
39
39
  export type ISpots = Record<SpotIdentifierType, ISpot[]>;
@@ -23,7 +23,7 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
23
23
  * @param {ISpot} spot - The spot data.
24
24
  * @param {ICreateSpotElementConfig} config - The configuration object.
25
25
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
26
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
26
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
27
27
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
28
28
  *
29
29
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
@@ -49,7 +49,7 @@ declare function RmnClient(apiKey: string, config: IRmnConfig): Promise<IRmnClie
49
49
  * @param {ISpot} spot - The spot data.
50
50
  * @param {ICreateSpotElementConfig} config - The configuration object.
51
51
  * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
52
- * @param {ICreateSpotElementConfig.customHtmlElement} config.customHtmlElement - Use a custom html element.
52
+ * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
53
53
  * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
54
54
  *
55
55
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@liquidcommercedev/rmn-sdk",
3
3
  "description": "LiquidCommerce RMN SDK",
4
4
  "author": "LiquidCommerce Tech",
5
- "version": "1.4.4",
5
+ "version": "1.4.5",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",