@liquidcommerce/elements-sdk 2.6.0-beta.42 → 2.6.0-beta.44

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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/index.checkout.esm.js +6706 -6696
  3. package/dist/index.esm.js +11264 -11155
  4. package/dist/ssr-stub.checkout.esm.js +18 -0
  5. package/dist/ssr-stub.esm.js +269 -0
  6. package/dist/types/auto-initialize/shared-utils.d.ts +3 -1
  7. package/dist/types/clients/base.d.ts +6 -3
  8. package/dist/types/clients/builder.d.ts +2 -1
  9. package/dist/types/clients/checkout.d.ts +2 -10
  10. package/dist/types/clients/main.d.ts +2 -1
  11. package/dist/types/core/client/client-action.service.d.ts +1 -1
  12. package/dist/types/core/client/client-config.service.d.ts +1 -1
  13. package/dist/types/core/pubsub/pubsub.service.d.ts +0 -2
  14. package/dist/types/core/singleton-manager.service.d.ts +1 -1
  15. package/dist/types/index.checkout.d.ts +3 -2
  16. package/dist/types/index.checkout.umd.d.ts +1 -1
  17. package/dist/types/index.d.ts +4 -1
  18. package/dist/types/interfaces/client.interface.d.ts +62 -0
  19. package/dist/types/interfaces/component.interface.d.ts +7 -0
  20. package/dist/types/interfaces/config.interface.d.ts +45 -0
  21. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  22. package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
  23. package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -1
  24. package/dist/types/interfaces/configs/global.interface.d.ts +1 -1
  25. package/dist/types/interfaces/configs/product-list.interface.d.ts +1 -1
  26. package/dist/types/interfaces/configs/product.interface.d.ts +1 -1
  27. package/dist/types/interfaces/injection.interface.d.ts +44 -0
  28. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +3 -0
  29. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +3 -0
  30. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +3 -1
  31. package/dist/types/modules/product-list/product-list.commands.d.ts +1 -1
  32. package/dist/types/modules/product-list/product-list.component.d.ts +1 -1
  33. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  34. package/dist/types/ssr/stub.d.ts +10 -0
  35. package/docs/v1/README.md +2 -2
  36. package/docs/v1/api/actions/address-actions.md +11 -11
  37. package/docs/v1/api/actions/cart-actions.md +13 -13
  38. package/docs/v1/api/actions/checkout-actions.md +23 -23
  39. package/docs/v1/api/actions/product-actions.md +6 -6
  40. package/docs/v1/api/client.md +11 -11
  41. package/docs/v1/api/ui-helpers.md +11 -11
  42. package/docs/v1/examples/advanced-patterns.md +1 -1
  43. package/docs/v1/examples/checkout-flow.md +1 -1
  44. package/docs/v1/getting-started/concepts.md +7 -7
  45. package/docs/v1/getting-started/installation.md +2 -2
  46. package/docs/v1/getting-started/quick-start.md +3 -3
  47. package/docs/v1/guides/address-component.md +11 -11
  48. package/docs/v1/guides/best-practices.md +14 -14
  49. package/docs/v1/guides/cart-component.md +23 -23
  50. package/docs/v1/guides/checkout-component.md +24 -24
  51. package/docs/v1/guides/product-component.md +5 -5
  52. package/docs/v1/integration/nextjs.md +11 -2
  53. package/docs/v1/integration/react.md +3 -3
  54. package/docs/v1/integration/vanilla-js.md +1 -1
  55. package/docs/v1/integration/vue.md +24 -0
  56. package/docs/v1/reference/error-handling.md +2 -2
  57. package/docs/v1/reference/troubleshooting.md +10 -2
  58. package/package.json +13 -9
  59. package/dist/types/interfaces/core.interface.d.ts +0 -140
  60. package/docs/gitbook/actions.md +0 -964
  61. package/docs/gitbook/address.md +0 -48
  62. package/docs/gitbook/cart.md +0 -65
  63. package/docs/gitbook/checkout.md +0 -131
  64. package/docs/gitbook/events.md +0 -1765
  65. package/docs/gitbook/overview.md +0 -166
  66. package/docs/gitbook/product.md +0 -64
  67. package/docs/gitbook/quick-start-guide.md +0 -393
@@ -90,19 +90,19 @@ The `{token}` placeholder is replaced with the checkout token.
90
90
  ### Open Checkout
91
91
 
92
92
  ```javascript
93
- window.elements.actions.checkout.openCheckout();
93
+ window.LiquidCommerce.elements.actions.checkout.openCheckout();
94
94
  ```
95
95
 
96
96
  ### Close Checkout
97
97
 
98
98
  ```javascript
99
- window.elements.actions.checkout.closeCheckout();
99
+ window.LiquidCommerce.elements.actions.checkout.closeCheckout();
100
100
  ```
101
101
 
102
102
  ### Toggle Checkout
103
103
 
104
104
  ```javascript
105
- window.elements.actions.checkout.toggleCheckout();
105
+ window.LiquidCommerce.elements.actions.checkout.toggleCheckout();
106
106
  ```
107
107
 
108
108
  ### Exit Checkout
@@ -110,7 +110,7 @@ window.elements.actions.checkout.toggleCheckout();
110
110
  Navigate away from checkout (requires `exitUrl` configuration):
111
111
 
112
112
  ```javascript
113
- window.elements.actions.checkout.exitCheckout();
113
+ window.LiquidCommerce.elements.actions.checkout.exitCheckout();
114
114
  ```
115
115
 
116
116
  Configure exit URL:
@@ -130,7 +130,7 @@ customTheme: {
130
130
  Skip the cart and go directly to checkout:
131
131
 
132
132
  ```javascript
133
- await window.elements.actions.checkout.addProduct([
133
+ await window.LiquidCommerce.elements.actions.checkout.addProduct([
134
134
  {
135
135
  identifier: '00619947000020',
136
136
  fulfillmentType: 'shipping',
@@ -142,25 +142,25 @@ await window.elements.actions.checkout.addProduct([
142
142
  ### Apply Promo Code
143
143
 
144
144
  ```javascript
145
- await window.elements.actions.checkout.applyPromoCode('WELCOME10');
145
+ await window.LiquidCommerce.elements.actions.checkout.applyPromoCode('WELCOME10');
146
146
  ```
147
147
 
148
148
  ### Remove Promo Code
149
149
 
150
150
  ```javascript
151
- await window.elements.actions.checkout.removePromoCode();
151
+ await window.LiquidCommerce.elements.actions.checkout.removePromoCode();
152
152
  ```
153
153
 
154
154
  ### Apply Gift Card
155
155
 
156
156
  ```javascript
157
- await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
157
+ await window.LiquidCommerce.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
158
158
  ```
159
159
 
160
160
  ### Remove Gift Card
161
161
 
162
162
  ```javascript
163
- await window.elements.actions.checkout.removeGiftCard('GIFT-1234-5678');
163
+ await window.LiquidCommerce.elements.actions.checkout.removeGiftCard('GIFT-1234-5678');
164
164
  ```
165
165
 
166
166
  ### Toggle Gift Mode
@@ -169,33 +169,33 @@ Enable/disable "Send as Gift" mode:
169
169
 
170
170
  ```javascript
171
171
  // Enable gift mode
172
- await window.elements.actions.checkout.toggleIsGift(true);
172
+ await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(true);
173
173
 
174
174
  // Disable gift mode
175
- await window.elements.actions.checkout.toggleIsGift(false);
175
+ await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(false);
176
176
 
177
177
  // Toggle current state
178
- await window.elements.actions.checkout.toggleIsGift();
178
+ await window.LiquidCommerce.elements.actions.checkout.toggleIsGift();
179
179
  ```
180
180
 
181
181
  ### Toggle Billing Same As Shipping
182
182
 
183
183
  ```javascript
184
184
  // Use shipping address for billing
185
- await window.elements.actions.checkout.toggleBillingSameAsShipping(true);
185
+ await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(true);
186
186
 
187
187
  // Use different billing address
188
- await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
188
+ await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(false);
189
189
  ```
190
190
 
191
191
  ### Toggle Marketing Preferences
192
192
 
193
193
  ```javascript
194
194
  // Opt into email marketing
195
- await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
195
+ await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
196
196
 
197
197
  // Opt into SMS marketing
198
- await window.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
198
+ await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
199
199
  ```
200
200
 
201
201
  ### Update Customer Information
@@ -203,7 +203,7 @@ await window.elements.actions.checkout.toggleMarketingPreferences('canSms', true
203
203
  Pre-fill customer information:
204
204
 
205
205
  ```javascript
206
- window.elements.actions.checkout.updateCustomerInfo({
206
+ window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
207
207
  firstName: 'John',
208
208
  lastName: 'Doe',
209
209
  email: 'john@example.com',
@@ -225,7 +225,7 @@ window.elements.actions.checkout.updateCustomerInfo({
225
225
  Pre-fill gift recipient information:
226
226
 
227
227
  ```javascript
228
- window.elements.actions.checkout.updateGiftInfo({
228
+ window.LiquidCommerce.elements.actions.checkout.updateGiftInfo({
229
229
  firstName: 'Jane',
230
230
  lastName: 'Smith',
231
231
  email: 'jane@example.com',
@@ -246,7 +246,7 @@ window.elements.actions.checkout.updateGiftInfo({
246
246
  Pre-fill billing address:
247
247
 
248
248
  ```javascript
249
- window.elements.actions.checkout.updateBillingInfo({
249
+ window.LiquidCommerce.elements.actions.checkout.updateBillingInfo({
250
250
  firstName: 'John',
251
251
  lastName: 'Doe',
252
252
  email: 'john@example.com',
@@ -268,7 +268,7 @@ window.elements.actions.checkout.updateBillingInfo({
268
268
  ### Get Checkout Details
269
269
 
270
270
  ```javascript
271
- const checkoutData = window.elements.actions.checkout.getDetails();
271
+ const checkoutData = window.LiquidCommerce.elements.actions.checkout.getDetails();
272
272
 
273
273
  console.log(checkoutData);
274
274
  // {
@@ -532,7 +532,7 @@ If you have customer data, pre-fill it:
532
532
  // After user logs in
533
533
  if (userIsLoggedIn) {
534
534
  window.addEventListener('lce:actions.checkout_opened', () => {
535
- window.elements.actions.checkout.updateCustomerInfo({
535
+ window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
536
536
  firstName: currentUser.firstName,
537
537
  lastName: currentUser.lastName,
538
538
  email: currentUser.email,
@@ -637,10 +637,10 @@ checkout: {
637
637
 
638
638
  ### Checkout Not Opening
639
639
 
640
- 1. Verify cart has items: `window.elements.actions.cart.getDetails()`
640
+ 1. Verify cart has items: `window.LiquidCommerce.elements.actions.cart.getDetails()`
641
641
  2. Check for JavaScript errors in console
642
- 3. Ensure SDK is initialized: `window.elements`
643
- 4. Try manually: `window.elements.actions.checkout.openCheckout()`
642
+ 3. Ensure SDK is initialized: `window.LiquidCommerce.elements`
643
+ 4. Try manually: `window.LiquidCommerce.elements.actions.checkout.openCheckout()`
644
644
 
645
645
  ### Payment Form Not Loading
646
646
 
@@ -212,7 +212,7 @@ Programmatically interact with products:
212
212
  Retrieve product information:
213
213
 
214
214
  ```javascript
215
- const productData = window.elements.actions.product.getDetails('00619947000020');
215
+ const productData = window.LiquidCommerce.elements.actions.product.getDetails('00619947000020');
216
216
 
217
217
  console.log(productData);
218
218
  // {
@@ -388,10 +388,10 @@ Set address programmatically to skip prompting:
388
388
 
389
389
  ```javascript
390
390
  // Using Google Places ID
391
- await window.elements.actions.address.setAddressByPlacesId('ChIJ...');
391
+ await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJ...');
392
392
 
393
393
  // Or manually
394
- await window.elements.actions.address.setAddressManually(
394
+ await window.LiquidCommerce.elements.actions.address.setAddressManually(
395
395
  {
396
396
  one: '123 Main St',
397
397
  two: 'Apt 4',
@@ -423,7 +423,7 @@ Presale products are handled automatically; no special configuration needed.
423
423
  Force a product to reload and rerender:
424
424
 
425
425
  ```javascript
426
- const components = window.elements.getInjectedComponents();
426
+ const components = window.LiquidCommerce.elements.getInjectedComponents();
427
427
  const productComponent = components.get('product-1');
428
428
 
429
429
  if (productComponent) {
@@ -656,7 +656,7 @@ document.querySelectorAll('.product-placeholder').forEach(el => {
656
656
  1. Check browser console for errors
657
657
  2. Verify container ID exists in the DOM
658
658
  3. Confirm product identifier is valid
659
- 4. Check that SDK is initialized (`window.elements` exists)
659
+ 4. Check that SDK is initialized (`window.LiquidCommerce.elements` exists)
660
660
 
661
661
  ### Wrong Pricing
662
662
 
@@ -1,6 +1,6 @@
1
1
  # Next.js Integration
2
2
 
3
- Use a client component (App Router) or `useEffect` in a client-only page (Pages Router). Initialize the SDK on the client.
3
+ The SDK is SSR-safe out of the box. When imported on the server, a lightweight stub is resolved automatically via the `node` export condition no dynamic imports or special configuration required. The real SDK activates on the client.
4
4
 
5
5
  ## App Router (Client Component)
6
6
 
@@ -48,9 +48,18 @@ export default function ProductPage() {
48
48
  }
49
49
  ```
50
50
 
51
+ ## SSR Behavior
52
+
53
+ When the module is evaluated during SSR (server components, `getServerSideProps`, middleware, etc.):
54
+
55
+ - All **types and enums** are available — TypeScript works identically.
56
+ - `Elements()` and `ElementsBuilder()` return `null` and log a warning.
57
+ - No browser APIs (`window`, `document`, `navigator`) are accessed.
58
+
59
+ You do **not** need `next/dynamic`, conditional `import()`, or `typeof window` guards in your own code.
60
+
51
61
  ## Notes
52
62
 
53
- - Do not initialize server-side (Window/Document required).
54
63
  - For ad blocker mitigation, configure the proxy (see [Proxy Setup](./proxy-setup.md)).
55
64
 
56
65
  ## Related Docs
@@ -44,8 +44,8 @@ import { useEffect } from 'react';
44
44
 
45
45
  export default function CartButton() {
46
46
  useEffect(() => {
47
- if (!window.elements) return;
48
- window.elements.ui.cartButton('header-cart', true);
47
+ if (!window.LiquidCommerce.elements) return;
48
+ window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
49
49
  }, []);
50
50
 
51
51
  return <div id="header-cart"></div>;
@@ -54,7 +54,7 @@ export default function CartButton() {
54
54
 
55
55
  ## Notes
56
56
 
57
- - Initialize only on the client; the SDK uses browser APIs.
57
+ - The SDK is SSR-safe — importing it on the server resolves a no-op stub automatically. Initialize in `useEffect` to get the real client.
58
58
  - For multiple products, call `injectProductElement` with multiple entries.
59
59
 
60
60
  ## Related Docs
@@ -51,7 +51,7 @@ Use the CDN build for the fastest setup, or use NPM if you have a build step.
51
51
 
52
52
  <script>
53
53
  window.addEventListener('lce:actions.client_ready', async () => {
54
- const client = window.elements;
54
+ const client = window.LiquidCommerce.elements;
55
55
  await client.injectProductElement([
56
56
  { containerId: 'product', identifier: '00619947000020' }
57
57
  ]);
@@ -28,6 +28,30 @@ onMounted(async () => {
28
28
  </script>
29
29
  ```
30
30
 
31
+ ## Nuxt 3
32
+
33
+ The SDK is SSR-safe out of the box. When Nuxt evaluates the import on the server, a lightweight stub is resolved automatically — no `<ClientOnly>`, `process.client` checks, or dynamic imports required.
34
+
35
+ ```vue
36
+ <template>
37
+ <div id="product"></div>
38
+ </template>
39
+
40
+ <script setup>
41
+ import { onMounted } from 'vue';
42
+ import { Elements } from '@liquidcommerce/elements-sdk';
43
+
44
+ onMounted(async () => {
45
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
46
+ await client.injectProductElement([
47
+ { containerId: 'product', identifier: '00619947000020' }
48
+ ]);
49
+ });
50
+ </script>
51
+ ```
52
+
53
+ During SSR, `Elements()` returns `null` and logs a warning. All types and enums remain available for TypeScript.
54
+
31
55
  ## Related Docs
32
56
 
33
57
  - [Product Component](../guides/product-component.md)
@@ -19,7 +19,7 @@ class SDKError extends Error {
19
19
 
20
20
  ```javascript
21
21
  try {
22
- await window.elements.injectProductElement([
22
+ await window.LiquidCommerce.elements.injectProductElement([
23
23
  { containerId: 'product', identifier: 'invalid_id' }
24
24
  ]);
25
25
  } catch (error) {
@@ -34,7 +34,7 @@ try {
34
34
  The SDK catches and contains its own errors so your app keeps running:
35
35
 
36
36
  ```javascript
37
- window.elements.actions.cart.addProduct([/* invalid */]);
37
+ window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
38
38
  console.log('App still working');
39
39
  ```
40
40
 
@@ -4,7 +4,7 @@ Common setup issues and how to resolve them.
4
4
 
5
5
  ## SDK Script Not Loading
6
6
 
7
- **Symptoms:** 404/CORS in Network tab, `window.elements` is undefined.
7
+ **Symptoms:** 404/CORS in Network tab, `window.LiquidCommerce.elements` is undefined.
8
8
 
9
9
  **Fixes:**
10
10
  - Verify the script URL and that the tag includes `data-liquid-commerce-elements`.
@@ -36,7 +36,7 @@ Common setup issues and how to resolve them.
36
36
  **Symptoms:** Add to cart works but cart stays closed.
37
37
 
38
38
  **Fixes:**
39
- - Ensure a cart button is configured or call `window.elements.actions.cart.openCart()`.
39
+ - Ensure a cart button is configured or call `window.LiquidCommerce.elements.actions.cart.openCart()`.
40
40
  - Check for JavaScript errors in the console.
41
41
 
42
42
  ## Checkout Issues
@@ -56,6 +56,14 @@ Common setup issues and how to resolve them.
56
56
  - Make sure the address is set and valid.
57
57
  - Listen for `lce:actions.address_failed` to surface errors.
58
58
 
59
+ ## SSR / Server-Side Rendering
60
+
61
+ **Symptoms:** Console warning "This SDK is designed for the browser. Calls made during SSR return null."
62
+
63
+ This is expected behavior. The SDK ships an SSR stub that is automatically resolved when bundled for Node.js (via the `node` export condition in `package.json`). The stub exports all types and enums for TypeScript compatibility and returns `null` from factory functions (`Elements`, `ElementsBuilder`, `ElementsCheckout`).
64
+
65
+ **No action required** — initialize the SDK in a client-only lifecycle hook (`useEffect`, `onMounted`, etc.) and the real client will activate in the browser.
66
+
59
67
  ## Related Docs
60
68
 
61
69
  - [Installation](../getting-started/installation.md)
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.6.0-beta.42",
6
+ "version": "2.6.0-beta.44",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",
@@ -18,11 +18,15 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/types/index.d.ts",
21
+ "node": "./dist/ssr-stub.esm.js",
22
+ "browser": "./dist/index.esm.js",
21
23
  "import": "./dist/index.esm.js",
22
24
  "default": "./dist/index.esm.js"
23
25
  },
24
26
  "./checkout": {
25
27
  "types": "./dist/types/index.checkout.d.ts",
28
+ "node": "./dist/ssr-stub.checkout.esm.js",
29
+ "browser": "./dist/index.checkout.esm.js",
26
30
  "import": "./dist/index.checkout.esm.js",
27
31
  "default": "./dist/index.checkout.esm.js"
28
32
  },
@@ -30,7 +34,7 @@
30
34
  },
31
35
  "files": [
32
36
  "dist",
33
- "docs",
37
+ "docs/v1",
34
38
  "README.md",
35
39
  "LICENSE"
36
40
  ],
@@ -77,9 +81,9 @@
77
81
  "embeddable commerce"
78
82
  ],
79
83
  "devDependencies": {
80
- "@biomejs/biome": "2.3.12",
81
- "@commitlint/cli": "^20.3.1",
82
- "@commitlint/config-conventional": "^20.3.1",
84
+ "@biomejs/biome": "2.3.13",
85
+ "@commitlint/cli": "^20.4.1",
86
+ "@commitlint/config-conventional": "^20.4.1",
83
87
  "@rollup/plugin-alias": "^6.0.0",
84
88
  "@rollup/plugin-commonjs": "^29.0.0",
85
89
  "@rollup/plugin-json": "^6.1.0",
@@ -89,18 +93,18 @@
89
93
  "@semantic-release/changelog": "^6.0.3",
90
94
  "@semantic-release/commit-analyzer": "^13.0.1",
91
95
  "@semantic-release/git": "^10.0.1",
92
- "@semantic-release/github": "^12.0.2",
96
+ "@semantic-release/github": "^12.0.3",
93
97
  "@semantic-release/npm": "^13.1.3",
94
98
  "@semantic-release/release-notes-generator": "^14.1.0",
95
99
  "@types/core-js": "^2.5.8",
96
- "@types/node": "^25.0.10",
100
+ "@types/node": "^25.2.0",
97
101
  "conventional-changelog-cli": "^5.0.0",
98
102
  "husky": "^9.1.7",
99
103
  "process": "^0.11.10",
100
- "rollup": "^4.56.0",
104
+ "rollup": "^4.57.1",
101
105
  "rollup-obfuscator": "^4.1.1",
102
106
  "rollup-plugin-typescript2": "^0.36.0",
103
- "semantic-release": "^25.0.2",
107
+ "semantic-release": "^25.0.3",
104
108
  "ts-node": "^10.9.2",
105
109
  "typescript": "^5.9.3"
106
110
  },
@@ -1,140 +0,0 @@
1
- import type { PRODUCT_LIST_FILTER_TYPES } from '@/constants';
2
- import type { IAddressActions } from '@/core/client/actions/client-address-action.service';
3
- import type { ICartActions } from '@/core/client/actions/client-cart-action.service';
4
- import type { ICheckoutActions } from '@/core/client/actions/client-checkout-action.service';
5
- import type { IProductActions } from '@/core/client/actions/client-product-action.service';
6
- import type { IClientConfigs } from '@/core/client/client-config.service';
7
- import type { ComponentType, DebugMode, ElementsEnv } from '@/enums';
8
- import type { IAddressOptions } from '@/modules/address/address.interface';
9
- import type { IPromoTicker, UpdateAddressComponent, UpdateCartComponent, UpdateCheckoutComponent, UpdateComponentGlobalConfigs, UpdateProductComponent } from './configs';
10
- export type DeepPartial<T> = {
11
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
12
- };
13
- export interface IElementsProxyConfig {
14
- baseUrl: string;
15
- headers?: Record<string, string>;
16
- }
17
- export interface ILiquidCommerceElementsDevelopmentConfig {
18
- customApiUrl?: string;
19
- paymentMethodId?: string;
20
- openShadowDom?: boolean;
21
- }
22
- export interface IClientCustomThemeConfig {
23
- global?: UpdateComponentGlobalConfigs;
24
- product?: UpdateProductComponent;
25
- address?: UpdateAddressComponent;
26
- cart?: UpdateCartComponent;
27
- checkout?: UpdateCheckoutComponent;
28
- }
29
- export interface ILiquidCommerceElementsCheckoutConfig {
30
- pageUrl: string;
31
- }
32
- export interface ILiquidCommerceElementsBaseConfig {
33
- env?: ElementsEnv;
34
- promoTicker?: IPromoTicker[];
35
- customTheme?: IClientCustomThemeConfig;
36
- debugMode?: DebugMode;
37
- checkout?: ILiquidCommerceElementsCheckoutConfig;
38
- }
39
- export interface ILiquidCommerceElementsBuilderConfig extends ILiquidCommerceElementsBaseConfig {
40
- }
41
- export interface ILiquidCommerceElementsConfig extends ILiquidCommerceElementsBaseConfig {
42
- proxy?: IElementsProxyConfig;
43
- development?: ILiquidCommerceElementsDevelopmentConfig;
44
- }
45
- export interface ILiquidCommerceElementsCheckoutClientConfig {
46
- env?: ElementsEnv;
47
- customTheme?: IClientCustomThemeConfig;
48
- debugMode?: DebugMode;
49
- checkout?: ILiquidCommerceElementsCheckoutConfig;
50
- proxy?: IElementsProxyConfig;
51
- development?: ILiquidCommerceElementsDevelopmentConfig;
52
- }
53
- export interface IInjectProductElement {
54
- containerId: string;
55
- identifier: string;
56
- }
57
- export type ProductListFilterType = (typeof PRODUCT_LIST_FILTER_TYPES)[keyof typeof PRODUCT_LIST_FILTER_TYPES];
58
- export interface IInjectProductListParams {
59
- containerId: string;
60
- rows?: number;
61
- columns?: number;
62
- filters?: ProductListFilterType[];
63
- productUrl?: string;
64
- }
65
- export interface IInjectProductListSearchParams {
66
- containerId: string;
67
- }
68
- export interface IInjectProductListFiltersParams {
69
- containerId: string;
70
- filters: ProductListFilterType[];
71
- }
72
- export interface IBuilderInjectElementParams {
73
- type: ComponentType;
74
- containerId: string;
75
- [key: string]: any;
76
- }
77
- export interface IInjectedComponent {
78
- getType(): ComponentType;
79
- getElement(): HTMLElement;
80
- rerender(): void;
81
- }
82
- export interface IProcessInjectElementParams {
83
- type: ComponentType;
84
- containerId: string;
85
- identifier?: string;
86
- options?: IAddressOptions;
87
- checkoutId?: string;
88
- hideHeader?: boolean;
89
- }
90
- export interface IInjectCheckoutParams {
91
- containerId: string;
92
- checkoutId?: string;
93
- hideHeader?: boolean;
94
- }
95
- export interface IInjectCheckoutBuilderParams extends IInjectCheckoutParams {
96
- simulatePresale?: boolean;
97
- presaleExpiresInMinutes?: number;
98
- }
99
- export interface ILiquidCommerceElementsUIMethod {
100
- cartButton(containerId: string, showItemsCount?: boolean): void;
101
- floatingCartButton(showItemsCount?: boolean): void;
102
- cartSubtotal(elementId: string): void;
103
- cartItemsCount(elementId: string, options?: {
104
- hideZero: boolean;
105
- }): void;
106
- }
107
- export interface ILiquidCommerceElementsActions {
108
- product: IProductActions;
109
- address: IAddressActions;
110
- cart: ICartActions;
111
- checkout: ICheckoutActions;
112
- }
113
- export interface ILiquidCommerceElementsBuilderClient {
114
- updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
115
- updateProductComponent(configs: UpdateProductComponent): Promise<void>;
116
- updateAddressComponent(configs: UpdateAddressComponent): void;
117
- updateCartComponent(configs: UpdateCartComponent): void;
118
- updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
119
- injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
120
- injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
121
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
122
- injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
123
- injectCheckoutElement(params: IInjectCheckoutBuilderParams): Promise<IInjectedComponent | null>;
124
- injectProductList(params: IInjectProductListParams): Promise<void>;
125
- actions: ILiquidCommerceElementsActions;
126
- }
127
- export interface ILiquidCommerceElementsClient {
128
- injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
129
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
130
- injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
131
- injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
132
- injectProductList(params: IInjectProductListParams): Promise<void>;
133
- injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>;
134
- injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>;
135
- ui: ILiquidCommerceElementsUIMethod;
136
- actions: ILiquidCommerceElementsActions;
137
- getInjectedComponents(): Map<string, IInjectedComponent>;
138
- }
139
- export type LiquidCommerceElementsClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsClient;
140
- export type LiquidCommerceElementsBuilderClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsBuilderClient;