@liquidcommercedev/rmn-sdk 1.5.0-beta.3 → 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 +19 -8
- package/dist/index.esm.js +19 -8
- package/dist/types/modules/event/event.interface.d.ts +1 -1
- package/dist/types/modules/event/event.service.d.ts +3 -3
- package/dist/types/modules/event/helpers/intersection.service.d.ts +1 -1
- package/dist/types/modules/event/helpers/localstorage.service.d.ts +1 -1
- package/dist/types/modules/event/helpers/resize.service.d.ts +1 -1
- package/dist/types/types.d.ts +4 -3
- package/package.json +1 -1
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
package/dist/index.cjs
CHANGED
@@ -15208,6 +15208,10 @@ class IntersectionObserverService {
|
|
15208
15208
|
|
15209
15209
|
class LocalStorage {
|
15210
15210
|
constructor() {
|
15211
|
+
if (typeof window.localStorage === 'undefined') {
|
15212
|
+
console.warn('Local storage is not supported in this environment');
|
15213
|
+
return;
|
15214
|
+
}
|
15211
15215
|
this.spots = new Map();
|
15212
15216
|
// Sync local storage with the current state
|
15213
15217
|
this.syncLocalStorage();
|
@@ -15221,7 +15225,7 @@ class LocalStorage {
|
|
15221
15225
|
return LocalStorage.instance;
|
15222
15226
|
}
|
15223
15227
|
syncLocalStorage() {
|
15224
|
-
const localStorageData = localStorage.getItem(LocalStorage.localStorageKey);
|
15228
|
+
const localStorageData = window.localStorage.getItem(LocalStorage.localStorageKey);
|
15225
15229
|
// TODO: Encrypt the data before storing it in the local storage
|
15226
15230
|
if (localStorageData) {
|
15227
15231
|
try {
|
@@ -15240,30 +15244,37 @@ class LocalStorage {
|
|
15240
15244
|
}
|
15241
15245
|
}
|
15242
15246
|
setSpot(spotId, data) {
|
15247
|
+
if (!this.spots)
|
15248
|
+
return;
|
15243
15249
|
data.createdAt = Date.now();
|
15244
15250
|
this.spots.set(spotId, data);
|
15245
15251
|
this.updateLocalStorage();
|
15246
15252
|
}
|
15247
15253
|
getSpot(spotId) {
|
15248
|
-
|
15254
|
+
var _a;
|
15255
|
+
return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
|
15249
15256
|
}
|
15250
15257
|
removeSpot(spotId) {
|
15251
|
-
|
15258
|
+
var _a;
|
15259
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
|
15252
15260
|
this.updateLocalStorage();
|
15253
15261
|
}
|
15254
15262
|
updateLocalStorage() {
|
15263
|
+
if (!this.spots)
|
15264
|
+
return;
|
15255
15265
|
const data = this.mapToObj(this.spots);
|
15256
15266
|
localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
|
15257
15267
|
}
|
15258
15268
|
clearLocalStorage() {
|
15259
|
-
localStorage.removeItem(LocalStorage.localStorageKey);
|
15269
|
+
window.localStorage.removeItem(LocalStorage.localStorageKey);
|
15260
15270
|
}
|
15261
15271
|
removeExpiredSpots() {
|
15272
|
+
var _a;
|
15262
15273
|
const currentTime = Date.now();
|
15263
|
-
this.spots.forEach((spot, spotId) => {
|
15264
|
-
var _a;
|
15274
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.forEach((spot, spotId) => {
|
15275
|
+
var _a, _b;
|
15265
15276
|
if (currentTime - ((_a = spot.createdAt) !== null && _a !== void 0 ? _a : 0) > LocalStorage.spotExpirationTime) {
|
15266
|
-
this.spots.delete(spotId);
|
15277
|
+
(_b = this.spots) === null || _b === void 0 ? void 0 : _b.delete(spotId);
|
15267
15278
|
}
|
15268
15279
|
});
|
15269
15280
|
this.updateLocalStorage();
|
@@ -18556,7 +18567,7 @@ class LiquidCommerceRmnClient {
|
|
18556
18567
|
placement.removeAttribute('class');
|
18557
18568
|
Object.assign(placement.style, {
|
18558
18569
|
width: '100%',
|
18559
|
-
height: '
|
18570
|
+
height: '100%',
|
18560
18571
|
display: 'flex',
|
18561
18572
|
justifyContent: 'center',
|
18562
18573
|
});
|
package/dist/index.esm.js
CHANGED
@@ -15206,6 +15206,10 @@ class IntersectionObserverService {
|
|
15206
15206
|
|
15207
15207
|
class LocalStorage {
|
15208
15208
|
constructor() {
|
15209
|
+
if (typeof window.localStorage === 'undefined') {
|
15210
|
+
console.warn('Local storage is not supported in this environment');
|
15211
|
+
return;
|
15212
|
+
}
|
15209
15213
|
this.spots = new Map();
|
15210
15214
|
// Sync local storage with the current state
|
15211
15215
|
this.syncLocalStorage();
|
@@ -15219,7 +15223,7 @@ class LocalStorage {
|
|
15219
15223
|
return LocalStorage.instance;
|
15220
15224
|
}
|
15221
15225
|
syncLocalStorage() {
|
15222
|
-
const localStorageData = localStorage.getItem(LocalStorage.localStorageKey);
|
15226
|
+
const localStorageData = window.localStorage.getItem(LocalStorage.localStorageKey);
|
15223
15227
|
// TODO: Encrypt the data before storing it in the local storage
|
15224
15228
|
if (localStorageData) {
|
15225
15229
|
try {
|
@@ -15238,30 +15242,37 @@ class LocalStorage {
|
|
15238
15242
|
}
|
15239
15243
|
}
|
15240
15244
|
setSpot(spotId, data) {
|
15245
|
+
if (!this.spots)
|
15246
|
+
return;
|
15241
15247
|
data.createdAt = Date.now();
|
15242
15248
|
this.spots.set(spotId, data);
|
15243
15249
|
this.updateLocalStorage();
|
15244
15250
|
}
|
15245
15251
|
getSpot(spotId) {
|
15246
|
-
|
15252
|
+
var _a;
|
15253
|
+
return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
|
15247
15254
|
}
|
15248
15255
|
removeSpot(spotId) {
|
15249
|
-
|
15256
|
+
var _a;
|
15257
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
|
15250
15258
|
this.updateLocalStorage();
|
15251
15259
|
}
|
15252
15260
|
updateLocalStorage() {
|
15261
|
+
if (!this.spots)
|
15262
|
+
return;
|
15253
15263
|
const data = this.mapToObj(this.spots);
|
15254
15264
|
localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
|
15255
15265
|
}
|
15256
15266
|
clearLocalStorage() {
|
15257
|
-
localStorage.removeItem(LocalStorage.localStorageKey);
|
15267
|
+
window.localStorage.removeItem(LocalStorage.localStorageKey);
|
15258
15268
|
}
|
15259
15269
|
removeExpiredSpots() {
|
15270
|
+
var _a;
|
15260
15271
|
const currentTime = Date.now();
|
15261
|
-
this.spots.forEach((spot, spotId) => {
|
15262
|
-
var _a;
|
15272
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.forEach((spot, spotId) => {
|
15273
|
+
var _a, _b;
|
15263
15274
|
if (currentTime - ((_a = spot.createdAt) !== null && _a !== void 0 ? _a : 0) > LocalStorage.spotExpirationTime) {
|
15264
|
-
this.spots.delete(spotId);
|
15275
|
+
(_b = this.spots) === null || _b === void 0 ? void 0 : _b.delete(spotId);
|
15265
15276
|
}
|
15266
15277
|
});
|
15267
15278
|
this.updateLocalStorage();
|
@@ -18554,7 +18565,7 @@ class LiquidCommerceRmnClient {
|
|
18554
18565
|
placement.removeAttribute('class');
|
18555
18566
|
Object.assign(placement.style, {
|
18556
18567
|
width: '100%',
|
18557
|
-
height: '
|
18568
|
+
height: '100%',
|
18558
18569
|
display: 'flex',
|
18559
18570
|
justifyContent: 'center',
|
18560
18571
|
});
|
@@ -56,7 +56,7 @@ export interface IBuyNowEvent {
|
|
56
56
|
placementId: string;
|
57
57
|
spotId: string;
|
58
58
|
}
|
59
|
-
export interface
|
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 {
|
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:
|
13
|
-
publish(eventType: RMN_SPOT_EVENT, data:
|
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;
|
package/dist/types/types.d.ts
CHANGED
@@ -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:
|
17
|
-
publish: (eventType: RMN_SPOT_EVENT, data:
|
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.
|
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",
|