@liquidcommerce/elements-sdk 2.2.0-beta.34 → 2.2.0-beta.35
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/README.md +11 -6
- package/dist/index.esm.js +9800 -9652
- package/dist/types/core/singleton-manager.service.d.ts +3 -3
- package/dist/types/elements-base-client.d.ts +49 -0
- package/dist/types/elements-builder-client.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.umd.d.ts +2 -2
- package/dist/types/interfaces/core.interface.d.ts +23 -17
- package/dist/types/modules/cart/components/index.d.ts +1 -0
- package/docs/CONFIGURATION.md +134 -10
- package/package.json +4 -4
- package/umd/elements.js +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { IClientConfigs } from '@/core/client/client-config.service';
|
|
2
|
-
import type { LiquidCommerceElementsClientConstructor } from '@/interfaces/core.interface';
|
|
2
|
+
import type { LiquidCommerceElementsBuilderClientConstructor, LiquidCommerceElementsClientConstructor } from '@/interfaces/core.interface';
|
|
3
3
|
export declare class SingletonManager {
|
|
4
4
|
private static instances;
|
|
5
5
|
private static clientConstructor;
|
|
6
6
|
private static getInstances;
|
|
7
7
|
private constructor();
|
|
8
|
-
static setClientConstructor(lceConstructor: LiquidCommerceElementsClientConstructor): void;
|
|
9
|
-
static getClientConstructor(): LiquidCommerceElementsClientConstructor | null;
|
|
8
|
+
static setClientConstructor(lceConstructor: LiquidCommerceElementsClientConstructor | LiquidCommerceElementsBuilderClientConstructor): void;
|
|
9
|
+
static getClientConstructor(): LiquidCommerceElementsClientConstructor | LiquidCommerceElementsBuilderClientConstructor | null;
|
|
10
10
|
static getClassInstance<T>(className: string, instanceCreator: () => T): T;
|
|
11
11
|
static getClient<T>(clientConfigs: IClientConfigs): Promise<T>;
|
|
12
12
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AuthService } from '@/core/auth.service';
|
|
2
|
+
import { ClientActionService } from '@/core/client/client-action.service';
|
|
3
|
+
import { ClientConfigService, type IClientConfigs } from '@/core/client/client-config.service';
|
|
4
|
+
import { CommandService } from '@/core/command/command.service';
|
|
5
|
+
import { DebugPanelService } from '@/core/debug-panel/debug-panel.service';
|
|
6
|
+
import { FingerPrintService } from '@/core/fingerprint.service';
|
|
7
|
+
import { GoogleTagManagerService } from '@/core/google-tag-manager.service';
|
|
8
|
+
import { LoggerFactory } from '@/core/logger/logger-factory';
|
|
9
|
+
import { StoreService } from '@/core/store';
|
|
10
|
+
import { TelemetryService } from '@/core/telemetry/telemetry.service';
|
|
11
|
+
import { type ComponentType } from '@/enums';
|
|
12
|
+
import type { IInjectedComponent, ILiquidCommerceElementsActions, IProcessInjectElementParams } from '@/interfaces/core.interface';
|
|
13
|
+
import { ApiClientService } from '@/modules/api-client';
|
|
14
|
+
import { ThemeProviderService } from '@/modules/theme-provider';
|
|
15
|
+
export declare abstract class ElementsBaseClient {
|
|
16
|
+
protected readonly authService: AuthService;
|
|
17
|
+
protected readonly clientConfig: ClientConfigService;
|
|
18
|
+
protected readonly store: StoreService;
|
|
19
|
+
protected readonly commands: CommandService;
|
|
20
|
+
protected readonly apiClient: ApiClientService;
|
|
21
|
+
protected readonly themeProvider: ThemeProviderService;
|
|
22
|
+
protected readonly fingerPrintService: FingerPrintService;
|
|
23
|
+
protected readonly googleTagManager: GoogleTagManagerService;
|
|
24
|
+
protected readonly clientAction: ClientActionService;
|
|
25
|
+
protected readonly telemetry: TelemetryService;
|
|
26
|
+
protected readonly debugPanel: DebugPanelService;
|
|
27
|
+
protected readonly logger: ReturnType<typeof LoggerFactory.get>;
|
|
28
|
+
protected clientPrepared: boolean;
|
|
29
|
+
protected componentFactoryInitialized: boolean;
|
|
30
|
+
protected cartDrawerCreated: boolean;
|
|
31
|
+
protected gtmInitialized: boolean;
|
|
32
|
+
protected injectedComponents: Map<string, IInjectedComponent>;
|
|
33
|
+
constructor(clientConfigs: IClientConfigs);
|
|
34
|
+
prepare(): Promise<void>;
|
|
35
|
+
private prepareEssentialServices;
|
|
36
|
+
private deferHeavyInitialization;
|
|
37
|
+
private initializeHeavyServices;
|
|
38
|
+
get actions(): ILiquidCommerceElementsActions;
|
|
39
|
+
protected processInjectElement(params: IProcessInjectElementParams): Promise<IInjectedComponent | null>;
|
|
40
|
+
protected ensureCartDrawerExists(): void;
|
|
41
|
+
protected ensureAllComponentsRegistered(): void;
|
|
42
|
+
protected createInjectedComponentWrapper(containerId: string, type: ComponentType, element: HTMLElement): IInjectedComponent;
|
|
43
|
+
protected rerenderInjectedComponentsByType(type: ComponentType): void;
|
|
44
|
+
protected isElementsEnabled(): boolean;
|
|
45
|
+
protected injectDisabledElementsError(containerId: string, componentName: ComponentType): void;
|
|
46
|
+
private registerEssentialComponents;
|
|
47
|
+
protected registerComponents(): void;
|
|
48
|
+
protected registerAllComponents(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { ILiquidCommerceElementsBuilderClient, ILiquidCommerceElementsBuilderConfig } from '@/interfaces/core.interface';
|
|
2
|
+
export declare function ElementsBuilder(apiKey: string, config: ILiquidCommerceElementsBuilderConfig): Promise<ILiquidCommerceElementsBuilderClient | null>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Elements } from './index';
|
|
2
|
-
export { Elements };
|
|
1
|
+
import { Elements, ElementsBuilder } from './index';
|
|
2
|
+
export { Elements, ElementsBuilder };
|
|
@@ -17,12 +17,17 @@ export interface IClientCustomThemeConfig {
|
|
|
17
17
|
cart?: UpdateCartComponent;
|
|
18
18
|
checkout?: UpdateCheckoutComponent;
|
|
19
19
|
}
|
|
20
|
+
export interface ILiquidCommerceElementsBuilderConfig {
|
|
21
|
+
env?: ElementsEnv;
|
|
22
|
+
promoTicker?: IPromoTicker[];
|
|
23
|
+
customTheme?: IClientCustomThemeConfig;
|
|
24
|
+
debugMode?: DebugMode;
|
|
25
|
+
}
|
|
20
26
|
export interface ILiquidCommerceElementsConfig {
|
|
21
27
|
env?: ElementsEnv;
|
|
22
28
|
promoTicker?: IPromoTicker[];
|
|
23
29
|
customTheme?: IClientCustomThemeConfig;
|
|
24
30
|
proxy?: IElementsProxyConfig;
|
|
25
|
-
isBuilder?: boolean;
|
|
26
31
|
debugMode?: DebugMode;
|
|
27
32
|
}
|
|
28
33
|
export interface IInjectProductElement {
|
|
@@ -39,21 +44,6 @@ export interface IInjectedComponent {
|
|
|
39
44
|
getElement(): HTMLElement;
|
|
40
45
|
rerender(): void;
|
|
41
46
|
}
|
|
42
|
-
export interface ILiquidCommerceElementsBuilderMethod {
|
|
43
|
-
updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
|
|
44
|
-
updateProductComponent(configs: UpdateProductComponent): Promise<void>;
|
|
45
|
-
updateAddressComponent(configs: UpdateAddressComponent): void;
|
|
46
|
-
updateCartComponent(configs: UpdateCartComponent): void;
|
|
47
|
-
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
48
|
-
injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
|
|
49
|
-
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
50
|
-
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
51
|
-
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
52
|
-
injectCheckoutElement(containerId: string, options?: {
|
|
53
|
-
simulatePresale?: boolean;
|
|
54
|
-
presaleExpiresInMinutes?: number;
|
|
55
|
-
}): Promise<IInjectedComponent | null>;
|
|
56
|
-
}
|
|
57
47
|
export interface IProcessInjectElementParams {
|
|
58
48
|
type: ComponentType;
|
|
59
49
|
containerId: string;
|
|
@@ -72,8 +62,23 @@ export interface ILiquidCommerceElementsActions {
|
|
|
72
62
|
cart: ICartActions;
|
|
73
63
|
checkout: ICheckoutActions;
|
|
74
64
|
}
|
|
65
|
+
export interface ILiquidCommerceElementsBuilderClient {
|
|
66
|
+
updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
|
|
67
|
+
updateProductComponent(configs: UpdateProductComponent): Promise<void>;
|
|
68
|
+
updateAddressComponent(configs: UpdateAddressComponent): void;
|
|
69
|
+
updateCartComponent(configs: UpdateCartComponent): void;
|
|
70
|
+
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
71
|
+
injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
|
|
72
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
73
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
74
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
75
|
+
injectCheckoutElement(containerId: string, options?: {
|
|
76
|
+
simulatePresale?: boolean;
|
|
77
|
+
presaleExpiresInMinutes?: number;
|
|
78
|
+
}): Promise<IInjectedComponent | null>;
|
|
79
|
+
actions: ILiquidCommerceElementsActions;
|
|
80
|
+
}
|
|
75
81
|
export interface ILiquidCommerceElementsClient {
|
|
76
|
-
builder: ILiquidCommerceElementsBuilderMethod;
|
|
77
82
|
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
78
83
|
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
79
84
|
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
@@ -83,3 +88,4 @@ export interface ILiquidCommerceElementsClient {
|
|
|
83
88
|
getInjectedComponents(): Map<string, IInjectedComponent>;
|
|
84
89
|
}
|
|
85
90
|
export type LiquidCommerceElementsClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsClient;
|
|
91
|
+
export type LiquidCommerceElementsBuilderClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsBuilderClient;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './cart-body.component';
|
|
2
2
|
export * from './cart-footer.component';
|
|
3
3
|
export * from './cart-fulfillment.component';
|
|
4
|
+
export * from './cart-fulfillment.component';
|
|
4
5
|
export * from './cart-header.component';
|
|
5
6
|
export * from './cart-item.component';
|
|
6
7
|
export * from './cart-item-quantity-price.component';
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -308,34 +308,158 @@ data-env="production"
|
|
|
308
308
|
data-debug-mode="console"
|
|
309
309
|
```
|
|
310
310
|
|
|
311
|
-
#### `data-cart-
|
|
311
|
+
#### `data-cart-button`
|
|
312
312
|
|
|
313
313
|
**Type:** `string`
|
|
314
314
|
|
|
315
|
-
Container ID for cart button.
|
|
315
|
+
Container ID, CSS selector, or position-prefixed selector for simple cart button (no badge).
|
|
316
316
|
|
|
317
317
|
```html
|
|
318
|
-
|
|
318
|
+
<!-- Simple ID -->
|
|
319
|
+
data-cart-button="header-cart"
|
|
320
|
+
|
|
321
|
+
<!-- CSS Selector (from browser inspect tool) -->
|
|
322
|
+
data-cart-button=".header .nav-links"
|
|
323
|
+
data-cart-button="#main-navigation"
|
|
324
|
+
|
|
325
|
+
<!-- Position-prefixed selectors -->
|
|
326
|
+
data-cart-button="above:.header .logo" <!-- Place above the target -->
|
|
327
|
+
data-cart-button="below:#main-navigation" <!-- Place below the target -->
|
|
328
|
+
data-cart-button="replace:.old-cart" <!-- Replace the target -->
|
|
329
|
+
data-cart-button="inside:.header .nav" <!-- Place inside the target (default) -->
|
|
319
330
|
```
|
|
320
331
|
|
|
321
|
-
#### `data-
|
|
332
|
+
#### `data-cart-badge-button`
|
|
322
333
|
|
|
323
|
-
**Type:**
|
|
334
|
+
**Type:** `string`
|
|
324
335
|
|
|
325
|
-
|
|
336
|
+
Container ID, CSS selector, or position-prefixed selector for cart button with item count badge.
|
|
326
337
|
|
|
327
338
|
```html
|
|
328
|
-
|
|
339
|
+
<!-- Simple ID -->
|
|
340
|
+
data-cart-badge-button="header-cart"
|
|
341
|
+
|
|
342
|
+
<!-- CSS Selector (from browser inspect tool) -->
|
|
343
|
+
data-cart-badge-button=".header .nav-links"
|
|
344
|
+
data-cart-badge-button="#main-navigation"
|
|
345
|
+
|
|
346
|
+
<!-- Position-prefixed selectors -->
|
|
347
|
+
data-cart-badge-button="above:.header .logo" <!-- Place above the target -->
|
|
348
|
+
data-cart-badge-button="below:#main-navigation" <!-- Place below the target -->
|
|
349
|
+
data-cart-badge-button="replace:.old-cart" <!-- Replace the target -->
|
|
350
|
+
data-cart-badge-button="inside:.header .nav" <!-- Place inside the target (default) -->
|
|
329
351
|
```
|
|
330
352
|
|
|
331
|
-
|
|
353
|
+
**Position Prefixes:**
|
|
354
|
+
- `above:` - Place above the target element
|
|
355
|
+
- `below:` - Place below the target element
|
|
356
|
+
- `replace:` - Replace the target element
|
|
357
|
+
- `inside:` - Place inside the target element (default)
|
|
358
|
+
|
|
359
|
+
#### `data-cart-button-hidden`
|
|
332
360
|
|
|
333
361
|
**Type:** flag (no value)
|
|
334
362
|
|
|
335
|
-
Hide
|
|
363
|
+
Hide cart button completely.
|
|
336
364
|
|
|
337
365
|
```html
|
|
338
|
-
data-
|
|
366
|
+
data-cart-button-hidden
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Cart Button Examples
|
|
370
|
+
|
|
371
|
+
**Simple cart button (no badge):**
|
|
372
|
+
```html
|
|
373
|
+
<script
|
|
374
|
+
data-liquid-commerce-elements
|
|
375
|
+
data-token="your-api-key"
|
|
376
|
+
data-cart-button="header-cart"
|
|
377
|
+
src="elements.js">
|
|
378
|
+
</script>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Cart button with item count badge:**
|
|
382
|
+
```html
|
|
383
|
+
<script
|
|
384
|
+
data-liquid-commerce-elements
|
|
385
|
+
data-token="your-api-key"
|
|
386
|
+
data-cart-badge-button="header-cart"
|
|
387
|
+
src="elements.js">
|
|
388
|
+
</script>
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Using position-prefixed selectors:**
|
|
392
|
+
```html
|
|
393
|
+
<!-- Place inside the target element (default) -->
|
|
394
|
+
<script
|
|
395
|
+
data-liquid-commerce-elements
|
|
396
|
+
data-token="your-api-key"
|
|
397
|
+
data-cart-badge-button="inside:.header .nav-links"
|
|
398
|
+
src="elements.js">
|
|
399
|
+
</script>
|
|
400
|
+
|
|
401
|
+
<!-- Place above the target element -->
|
|
402
|
+
<script
|
|
403
|
+
data-liquid-commerce-elements
|
|
404
|
+
data-token="your-api-key"
|
|
405
|
+
data-cart-button="above:.header .logo"
|
|
406
|
+
src="elements.js">
|
|
407
|
+
</script>
|
|
408
|
+
|
|
409
|
+
<!-- Place below the target element -->
|
|
410
|
+
<script
|
|
411
|
+
data-liquid-commerce-elements
|
|
412
|
+
data-token="your-api-key"
|
|
413
|
+
data-cart-badge-button="below:#main-navigation"
|
|
414
|
+
src="elements.js">
|
|
415
|
+
</script>
|
|
416
|
+
|
|
417
|
+
<!-- Replace the target element -->
|
|
418
|
+
<script
|
|
419
|
+
data-liquid-commerce-elements
|
|
420
|
+
data-token="your-api-key"
|
|
421
|
+
data-cart-button="replace:.old-cart-button"
|
|
422
|
+
src="elements.js">
|
|
423
|
+
</script>
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
**No cart button:**
|
|
427
|
+
```html
|
|
428
|
+
<script
|
|
429
|
+
data-liquid-commerce-elements
|
|
430
|
+
data-token="your-api-key"
|
|
431
|
+
data-cart-button-hidden
|
|
432
|
+
src="elements.js">
|
|
433
|
+
</script>
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Default behavior (floating cart button with badge):**
|
|
437
|
+
```html
|
|
438
|
+
<script
|
|
439
|
+
data-liquid-commerce-elements
|
|
440
|
+
data-token="your-api-key"
|
|
441
|
+
src="elements.js">
|
|
442
|
+
</script>
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### Getting CSS Selectors from Browser
|
|
446
|
+
|
|
447
|
+
**Super Easy Method:**
|
|
448
|
+
1. **Right-click** on any element where you want the cart button
|
|
449
|
+
2. Select **"Inspect"** or **"Inspect Element"**
|
|
450
|
+
3. In developer tools, **right-click** on the highlighted element
|
|
451
|
+
4. Select **"Copy" → "Copy selector"**
|
|
452
|
+
5. Paste the selector into your `data-cart-button` or `data-cart-badge-button` attribute
|
|
453
|
+
|
|
454
|
+
**Example:**
|
|
455
|
+
```html
|
|
456
|
+
<!-- After copying selector from browser inspect tool -->
|
|
457
|
+
<script
|
|
458
|
+
data-liquid-commerce-elements
|
|
459
|
+
data-token="your-api-key"
|
|
460
|
+
data-cart-badge-button="body > div.container > header > nav > div.nav-links"
|
|
461
|
+
src="elements.js">
|
|
462
|
+
</script>
|
|
339
463
|
```
|
|
340
464
|
|
|
341
465
|
### Product Configuration
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "LiquidCommerce Elements SDK",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "LiquidCommerce Team",
|
|
6
|
-
"version": "2.2.0-beta.
|
|
6
|
+
"version": "2.2.0-beta.35",
|
|
7
7
|
"homepage": "https://docs.liquidcommerce.co/elements-sdk",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"embeddable commerce"
|
|
72
72
|
],
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@biomejs/biome": "2.2.
|
|
74
|
+
"@biomejs/biome": "2.2.7",
|
|
75
75
|
"@commitlint/cli": "^20.1.0",
|
|
76
76
|
"@commitlint/config-conventional": "^20.0.0",
|
|
77
77
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -87,14 +87,14 @@
|
|
|
87
87
|
"@semantic-release/npm": "^13.1.1",
|
|
88
88
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
89
89
|
"@types/core-js": "^2.5.8",
|
|
90
|
-
"@types/node": "^24.9.
|
|
90
|
+
"@types/node": "^24.9.1",
|
|
91
91
|
"conventional-changelog-cli": "^5.0.0",
|
|
92
92
|
"husky": "^9.1.7",
|
|
93
93
|
"process": "^0.11.10",
|
|
94
94
|
"rollup": "^4.52.5",
|
|
95
95
|
"rollup-obfuscator": "^4.1.1",
|
|
96
96
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
97
|
-
"semantic-release": "^
|
|
97
|
+
"semantic-release": "^25.0.1",
|
|
98
98
|
"ts-node": "^10.9.2",
|
|
99
99
|
"typescript": "^5.9.3"
|
|
100
100
|
},
|