@liquidcommercedev/rmn-sdk 1.5.0-beta.2 → 1.5.0-beta.4

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 CHANGED
@@ -3,6 +3,7 @@
3
3
  exports.RMN_SPOT_TYPE = void 0;
4
4
  (function (RMN_SPOT_TYPE) {
5
5
  // Reserve Bar Spot Types
6
+ RMN_SPOT_TYPE["RB_HOMEPAGE_HERO"] = "rbHomepageHero";
6
7
  RMN_SPOT_TYPE["RB_HOMEPAGE_HERO_THREE_TILE"] = "rbHomepageHeroThreeTile";
7
8
  RMN_SPOT_TYPE["RB_HOMEPAGE_HERO_TWO_TILE"] = "rbHomepageHeroTwoTile";
8
9
  RMN_SPOT_TYPE["RB_HOMEPAGE_HERO_FULL_IMAGE"] = "rbHomepageHeroFullImage";
@@ -15207,6 +15208,10 @@ class IntersectionObserverService {
15207
15208
 
15208
15209
  class LocalStorage {
15209
15210
  constructor() {
15211
+ if (typeof window.localStorage === 'undefined') {
15212
+ console.warn('Local storage is not supported in this environment');
15213
+ return;
15214
+ }
15210
15215
  this.spots = new Map();
15211
15216
  // Sync local storage with the current state
15212
15217
  this.syncLocalStorage();
@@ -15220,7 +15225,7 @@ class LocalStorage {
15220
15225
  return LocalStorage.instance;
15221
15226
  }
15222
15227
  syncLocalStorage() {
15223
- const localStorageData = localStorage.getItem(LocalStorage.localStorageKey);
15228
+ const localStorageData = window.localStorage.getItem(LocalStorage.localStorageKey);
15224
15229
  // TODO: Encrypt the data before storing it in the local storage
15225
15230
  if (localStorageData) {
15226
15231
  try {
@@ -15239,30 +15244,37 @@ class LocalStorage {
15239
15244
  }
15240
15245
  }
15241
15246
  setSpot(spotId, data) {
15247
+ if (!this.spots)
15248
+ return;
15242
15249
  data.createdAt = Date.now();
15243
15250
  this.spots.set(spotId, data);
15244
15251
  this.updateLocalStorage();
15245
15252
  }
15246
15253
  getSpot(spotId) {
15247
- return this.spots.get(spotId);
15254
+ var _a;
15255
+ return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
15248
15256
  }
15249
15257
  removeSpot(spotId) {
15250
- this.spots.delete(spotId);
15258
+ var _a;
15259
+ (_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
15251
15260
  this.updateLocalStorage();
15252
15261
  }
15253
15262
  updateLocalStorage() {
15263
+ if (!this.spots)
15264
+ return;
15254
15265
  const data = this.mapToObj(this.spots);
15255
15266
  localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
15256
15267
  }
15257
15268
  clearLocalStorage() {
15258
- localStorage.removeItem(LocalStorage.localStorageKey);
15269
+ window.localStorage.removeItem(LocalStorage.localStorageKey);
15259
15270
  }
15260
15271
  removeExpiredSpots() {
15272
+ var _a;
15261
15273
  const currentTime = Date.now();
15262
- this.spots.forEach((spot, spotId) => {
15263
- var _a;
15274
+ (_a = this.spots) === null || _a === void 0 ? void 0 : _a.forEach((spot, spotId) => {
15275
+ var _a, _b;
15264
15276
  if (currentTime - ((_a = spot.createdAt) !== null && _a !== void 0 ? _a : 0) > LocalStorage.spotExpirationTime) {
15265
- this.spots.delete(spotId);
15277
+ (_b = this.spots) === null || _b === void 0 ? void 0 : _b.delete(spotId);
15266
15278
  }
15267
15279
  });
15268
15280
  this.updateLocalStorage();
@@ -18555,7 +18567,7 @@ class LiquidCommerceRmnClient {
18555
18567
  placement.removeAttribute('class');
18556
18568
  Object.assign(placement.style, {
18557
18569
  width: '100%',
18558
- height: 'auto',
18570
+ height: '100%',
18559
18571
  display: 'flex',
18560
18572
  justifyContent: 'center',
18561
18573
  });
package/dist/index.esm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  var RMN_SPOT_TYPE;
2
2
  (function (RMN_SPOT_TYPE) {
3
3
  // Reserve Bar Spot Types
4
+ RMN_SPOT_TYPE["RB_HOMEPAGE_HERO"] = "rbHomepageHero";
4
5
  RMN_SPOT_TYPE["RB_HOMEPAGE_HERO_THREE_TILE"] = "rbHomepageHeroThreeTile";
5
6
  RMN_SPOT_TYPE["RB_HOMEPAGE_HERO_TWO_TILE"] = "rbHomepageHeroTwoTile";
6
7
  RMN_SPOT_TYPE["RB_HOMEPAGE_HERO_FULL_IMAGE"] = "rbHomepageHeroFullImage";
@@ -15205,6 +15206,10 @@ class IntersectionObserverService {
15205
15206
 
15206
15207
  class LocalStorage {
15207
15208
  constructor() {
15209
+ if (typeof window.localStorage === 'undefined') {
15210
+ console.warn('Local storage is not supported in this environment');
15211
+ return;
15212
+ }
15208
15213
  this.spots = new Map();
15209
15214
  // Sync local storage with the current state
15210
15215
  this.syncLocalStorage();
@@ -15218,7 +15223,7 @@ class LocalStorage {
15218
15223
  return LocalStorage.instance;
15219
15224
  }
15220
15225
  syncLocalStorage() {
15221
- const localStorageData = localStorage.getItem(LocalStorage.localStorageKey);
15226
+ const localStorageData = window.localStorage.getItem(LocalStorage.localStorageKey);
15222
15227
  // TODO: Encrypt the data before storing it in the local storage
15223
15228
  if (localStorageData) {
15224
15229
  try {
@@ -15237,30 +15242,37 @@ class LocalStorage {
15237
15242
  }
15238
15243
  }
15239
15244
  setSpot(spotId, data) {
15245
+ if (!this.spots)
15246
+ return;
15240
15247
  data.createdAt = Date.now();
15241
15248
  this.spots.set(spotId, data);
15242
15249
  this.updateLocalStorage();
15243
15250
  }
15244
15251
  getSpot(spotId) {
15245
- return this.spots.get(spotId);
15252
+ var _a;
15253
+ return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
15246
15254
  }
15247
15255
  removeSpot(spotId) {
15248
- this.spots.delete(spotId);
15256
+ var _a;
15257
+ (_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
15249
15258
  this.updateLocalStorage();
15250
15259
  }
15251
15260
  updateLocalStorage() {
15261
+ if (!this.spots)
15262
+ return;
15252
15263
  const data = this.mapToObj(this.spots);
15253
15264
  localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
15254
15265
  }
15255
15266
  clearLocalStorage() {
15256
- localStorage.removeItem(LocalStorage.localStorageKey);
15267
+ window.localStorage.removeItem(LocalStorage.localStorageKey);
15257
15268
  }
15258
15269
  removeExpiredSpots() {
15270
+ var _a;
15259
15271
  const currentTime = Date.now();
15260
- this.spots.forEach((spot, spotId) => {
15261
- var _a;
15272
+ (_a = this.spots) === null || _a === void 0 ? void 0 : _a.forEach((spot, spotId) => {
15273
+ var _a, _b;
15262
15274
  if (currentTime - ((_a = spot.createdAt) !== null && _a !== void 0 ? _a : 0) > LocalStorage.spotExpirationTime) {
15263
- this.spots.delete(spotId);
15275
+ (_b = this.spots) === null || _b === void 0 ? void 0 : _b.delete(spotId);
15264
15276
  }
15265
15277
  });
15266
15278
  this.updateLocalStorage();
@@ -18553,7 +18565,7 @@ class LiquidCommerceRmnClient {
18553
18565
  placement.removeAttribute('class');
18554
18566
  Object.assign(placement.style, {
18555
18567
  width: '100%',
18556
- height: 'auto',
18568
+ height: '100%',
18557
18569
  display: 'flex',
18558
18570
  justifyContent: 'center',
18559
18571
  });
@@ -1,4 +1,5 @@
1
1
  export declare enum RMN_SPOT_TYPE {
2
+ RB_HOMEPAGE_HERO = "rbHomepageHero",
2
3
  RB_HOMEPAGE_HERO_THREE_TILE = "rbHomepageHeroThreeTile",
3
4
  RB_HOMEPAGE_HERO_TWO_TILE = "rbHomepageHeroTwoTile",
4
5
  RB_HOMEPAGE_HERO_FULL_IMAGE = "rbHomepageHeroFullImage",
@@ -1,4 +1,4 @@
1
- import type { RMN_SPOT_TYPE } from 'enums';
1
+ import type { RMN_FILTER_PROPERTIES, RMN_SPOT_TYPE } from 'enums';
2
2
  import type { ICarouselOptions, ICreateCarouselElementParams } from 'modules/element/component/carousel';
3
3
  import type { ICreateSpotElementParams } from 'modules/element/component/spot';
4
4
  import type { RmnFilterType } from 'modules/selection';
@@ -21,12 +21,15 @@ export interface IInjectSpotElementConfig {
21
21
  overlay?: ISpotOverlay;
22
22
  carousel?: ICarouselOptions;
23
23
  }
24
+ export type IInjectSpotElementFilterType = Partial<Omit<RmnFilterType, RMN_FILTER_PROPERTIES.KEYWORDS> & {
25
+ exactMatch?: string;
26
+ }>;
24
27
  export interface IInjectSpotElement {
25
28
  placementId: string;
26
29
  spotType: RMN_SPOT_TYPE | string;
27
30
  count?: number;
28
31
  config?: Omit<IInjectSpotElementConfig, 'url'>;
29
- filter?: Partial<RmnFilterType>;
32
+ filter?: IInjectSpotElementFilterType;
30
33
  }
31
34
  export interface ICreateElementConfig {
32
35
  spot?: RMN_SPOT_TYPE;
@@ -56,7 +56,7 @@ export interface IBuyNowEvent {
56
56
  placementId: string;
57
57
  spotId: string;
58
58
  }
59
- export interface IEventMap {
59
+ export interface IRmnEventMap {
60
60
  [RMN_SPOT_EVENT.LIFECYCLE_STATE]: ILifecycleState;
61
61
  [RMN_SPOT_EVENT.CLICK]: IClickEvent;
62
62
  [RMN_SPOT_EVENT.IMPRESSION]: IImpressionEvent;
@@ -1,5 +1,5 @@
1
1
  import { RMN_SPOT_EVENT } from 'enums';
2
- import type { IEventMap, ILifecycleState, IRegisterSpotParams } from './event.interface';
2
+ import type { ILifecycleState, IRegisterSpotParams, IRmnEventMap } from './event.interface';
3
3
  export declare class EventService {
4
4
  private static instance;
5
5
  private pubSub;
@@ -9,8 +9,8 @@ export declare class EventService {
9
9
  private activeSpots;
10
10
  private constructor();
11
11
  static getInstance(): EventService;
12
- subscribe(eventType: RMN_SPOT_EVENT, callback: (data: IEventMap[RMN_SPOT_EVENT]) => void): () => void;
13
- publish(eventType: RMN_SPOT_EVENT, data: IEventMap[RMN_SPOT_EVENT]): void;
12
+ subscribe(eventType: RMN_SPOT_EVENT, callback: (data: IRmnEventMap[RMN_SPOT_EVENT]) => void): () => void;
13
+ publish(eventType: RMN_SPOT_EVENT, data: IRmnEventMap[RMN_SPOT_EVENT]): void;
14
14
  registerSpot(params: IRegisterSpotParams): void;
15
15
  unregisterSpot(placementId: string): void;
16
16
  /**
@@ -1,6 +1,6 @@
1
1
  export declare class IntersectionObserverService {
2
2
  private observers;
3
- private defaultOptions;
3
+ private readonly defaultOptions;
4
4
  constructor(defaultOptions?: IntersectionObserverInit);
5
5
  observe(element: HTMLElement, callback: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): void;
6
6
  unobserve(element: HTMLElement): void;
@@ -8,7 +8,7 @@ export interface ILocalStorageSpot {
8
8
  createdAt?: number;
9
9
  }
10
10
  export declare class LocalStorage {
11
- private spots;
11
+ private spots?;
12
12
  private static instance;
13
13
  private static readonly localStorageKey;
14
14
  private static readonly spotExpirationTime;
@@ -18,7 +18,7 @@ export interface ISizeChangedEvent extends CustomEvent {
18
18
  }
19
19
  export declare class ResizeObserverService {
20
20
  private element;
21
- private container;
21
+ private readonly container;
22
22
  private resizeObserver;
23
23
  private maxSize;
24
24
  private minSize;
@@ -1,10 +1,11 @@
1
- import type { IEventMap } from './modules/event';
2
1
  export type { IInjectSpotElement, IInjectSpotElementConfig, IInjectSpotElementParams, IRmnCreateSpotElementConfig, ISpotColors, ISpotOverlay, } from 'modules/element';
3
2
  export type { CarouselNavPositionType, ICarouselButtonOptions, ICarouselDotOptions, ICarouselOptions, } from 'modules/element/component/carousel';
3
+ export type { IAddToCartEvent, IAddToWishlistEvent, IBuyNowEvent, IClickEvent, IImpressionEvent, ILifecycleState, ILSDisplayConfig, ILSDom, ILSIdentifier, ILSState, IPurchaseEvent, IRmnEventMap, } from 'modules/event';
4
4
  export type { ISpots, RmnFilterType, RmnSpotType } from 'modules/selection';
5
5
  export { ISpot, ISpotEvent, ISpotSelectionParams } from 'modules/selection';
6
6
  import type { RMN_ENV, RMN_SPOT_EVENT } from 'enums';
7
7
  import type { IInjectSpotElementParams } from 'modules/element';
8
+ import type { IRmnEventMap } from 'modules/event';
8
9
  import type { ISpots, ISpotSelectionParams } from 'modules/selection';
9
10
  export interface IRmnClient {
10
11
  spotSelection(params: ISpotSelectionParams): Promise<ISpots | {
@@ -13,8 +14,8 @@ export interface IRmnClient {
13
14
  injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
14
15
  }
15
16
  export interface IRmnEventManager {
16
- subscribe: (eventType: RMN_SPOT_EVENT, callback: (data: IEventMap[RMN_SPOT_EVENT]) => void) => () => void;
17
- publish: (eventType: RMN_SPOT_EVENT, data: IEventMap[RMN_SPOT_EVENT]) => void;
17
+ subscribe: (eventType: RMN_SPOT_EVENT, callback: (data: IRmnEventMap[RMN_SPOT_EVENT]) => void) => () => void;
18
+ publish: (eventType: RMN_SPOT_EVENT, data: IRmnEventMap[RMN_SPOT_EVENT]) => void;
18
19
  destroySpot: (placementId: string) => void;
19
20
  }
20
21
  export interface IRmnConfig {
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.5.0-beta.2",
5
+ "version": "1.5.0-beta.4",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",