@liquidcommerce/elements-sdk 2.6.0-beta.7 → 2.6.0-beta.71

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 (224) hide show
  1. package/README.md +83 -2519
  2. package/dist/index.checkout.esm.js +16607 -0
  3. package/dist/index.esm.js +23556 -20638
  4. package/dist/ssr-stub.checkout.esm.js +18 -0
  5. package/dist/ssr-stub.esm.js +270 -0
  6. package/dist/types/auto-initialize/checkout.d.ts +2 -0
  7. package/dist/types/auto-initialize/shared-utils.d.ts +46 -0
  8. package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +15 -2
  9. package/dist/types/clients/builder.d.ts +3 -0
  10. package/dist/types/clients/checkout.d.ts +6 -0
  11. package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +3 -1
  12. package/dist/types/clients/main.d.ts +3 -0
  13. package/dist/types/constants/core.constant.d.ts +2 -6
  14. package/dist/types/core/api/api-client.service.d.ts +20 -18
  15. package/dist/types/core/api/api-result.d.ts +19 -0
  16. package/dist/types/core/api/auth-client.service.d.ts +40 -13
  17. package/dist/types/core/api/http-client.service.d.ts +0 -1
  18. package/dist/types/core/base-component.service.d.ts +2 -1
  19. package/dist/types/core/client/actions/base-action.service.d.ts +15 -0
  20. package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
  21. package/dist/types/core/client/actions/client-cart-action.service.d.ts +37 -0
  22. package/dist/types/core/client/actions/client-checkout-action.service.d.ts +56 -0
  23. package/dist/types/core/client/actions/client-product-action.service.d.ts +15 -0
  24. package/dist/types/core/client/client-action.service.d.ts +6 -70
  25. package/dist/types/core/client/client-config.service.d.ts +8 -2
  26. package/dist/types/core/command/common-command.service.d.ts +1 -0
  27. package/dist/types/core/google-tag-manager.service.d.ts +2 -1
  28. package/dist/types/core/logger/logger.service.d.ts +1 -1
  29. package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +27 -52
  30. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +45 -51
  31. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +9 -4
  32. package/dist/types/core/pubsub/interfaces/product.interface.d.ts +16 -74
  33. package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
  34. package/dist/types/core/singleton-manager.service.d.ts +12 -8
  35. package/dist/types/core/store/interfaces/cart.interface.d.ts +3 -4
  36. package/dist/types/core/store/interfaces/checkout.interface.d.ts +17 -108
  37. package/dist/types/core/store/interfaces/core.interface.d.ts +12 -2
  38. package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
  39. package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
  40. package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
  41. package/dist/types/core/store/store.constant.d.ts +5 -0
  42. package/dist/types/core/store/store.service.d.ts +1 -0
  43. package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
  44. package/dist/types/enums/core.enum.d.ts +39 -1
  45. package/dist/types/enums/index.d.ts +0 -1
  46. package/dist/types/index.checkout.d.ts +8 -0
  47. package/dist/types/index.checkout.umd.d.ts +4 -0
  48. package/dist/types/index.d.ts +8 -3
  49. package/dist/types/interfaces/api/cart.interface.d.ts +13 -8
  50. package/dist/types/interfaces/api/checkout.interface.d.ts +239 -0
  51. package/dist/types/interfaces/api/index.d.ts +5 -0
  52. package/dist/types/interfaces/api/product-list.interface.d.ts +39 -0
  53. package/dist/types/interfaces/api/product.interface.d.ts +10 -4
  54. package/dist/types/interfaces/client.interface.d.ts +72 -0
  55. package/dist/types/interfaces/component.interface.d.ts +7 -0
  56. package/dist/types/interfaces/config.interface.d.ts +41 -0
  57. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  58. package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
  59. package/dist/types/interfaces/configs/checkout.interface.d.ts +2 -1
  60. package/dist/types/interfaces/configs/global.interface.d.ts +5 -3
  61. package/dist/types/interfaces/configs/index.d.ts +1 -0
  62. package/dist/types/interfaces/configs/product-list.interface.d.ts +47 -0
  63. package/dist/types/interfaces/configs/product.interface.d.ts +4 -1
  64. package/dist/types/interfaces/injection.interface.d.ts +47 -0
  65. package/dist/types/modules/address/address.command.d.ts +2 -1
  66. package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
  67. package/dist/types/modules/cart/cart.commands.d.ts +4 -4
  68. package/dist/types/modules/cart/components/cart-body.component.d.ts +2 -1
  69. package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
  70. package/dist/types/modules/checkout/checkout.commands.d.ts +23 -9
  71. package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
  72. package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +2 -2
  73. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +3 -0
  74. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
  75. package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
  76. package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +14 -1
  77. package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
  78. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  79. package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +2 -2
  80. package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
  81. package/dist/types/modules/checkout/constant.d.ts +3 -0
  82. package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
  83. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +1 -0
  84. package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
  85. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +3 -0
  86. package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
  87. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +3 -0
  88. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +5 -2
  89. package/dist/types/modules/product/product.commands.d.ts +2 -3
  90. package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
  91. package/dist/types/modules/product-list/components/card-components/index.d.ts +5 -0
  92. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
  93. package/dist/types/modules/product-list/components/card-components/product-button.d.ts +9 -0
  94. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
  95. package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +9 -0
  96. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +13 -0
  97. package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
  98. package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
  99. package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
  100. package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
  101. package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +14 -0
  102. package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-price-filter.components.d.ts → filter-components/product-list-price-filter.d.ts} +1 -1
  103. package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
  104. package/dist/types/modules/product-list/components/index.d.ts +6 -2
  105. package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +2 -1
  106. package/dist/types/modules/product-list/components/product-list-card.component.d.ts +27 -30
  107. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
  108. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +55 -36
  109. package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
  110. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +49 -0
  111. package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-search.component.d.ts → product-list-search.component.d.ts} +11 -4
  112. package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
  113. package/dist/types/modules/product-list/product-list.commands.d.ts +23 -8
  114. package/dist/types/modules/product-list/product-list.component.d.ts +10 -45
  115. package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
  116. package/dist/types/modules/product-list/product-list.interface.d.ts +20 -35
  117. package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
  118. package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
  119. package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
  120. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
  121. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
  122. package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
  123. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
  124. package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
  125. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
  126. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +1 -0
  127. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +6 -1
  128. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +6 -1
  129. package/dist/types/modules/ui-components/input/index.d.ts +0 -1
  130. package/dist/types/modules/ui-components/input/input.component.d.ts +8 -1
  131. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  132. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
  133. package/dist/types/modules/ui-components/ui.commands.d.ts +5 -1
  134. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  135. package/dist/types/ssr/stub.d.ts +10 -0
  136. package/dist/types/static/icon/check.icon.d.ts +2 -0
  137. package/dist/types/static/icon/index.d.ts +1 -0
  138. package/dist/types/utils/dom-compat.d.ts +2 -0
  139. package/dist/types/utils/format.d.ts +0 -14
  140. package/dist/types/utils/product-selection.d.ts +16 -0
  141. package/dist/types/utils/product.d.ts +10 -0
  142. package/docs/v1/README.md +210 -0
  143. package/docs/v1/api/actions/address-actions.md +281 -0
  144. package/docs/v1/api/actions/cart-actions.md +337 -0
  145. package/docs/v1/api/actions/checkout-actions.md +427 -0
  146. package/docs/v1/api/actions/product-actions.md +158 -0
  147. package/docs/v1/api/client.md +495 -0
  148. package/docs/v1/api/configuration.md +528 -0
  149. package/docs/v1/api/injection-methods.md +261 -0
  150. package/docs/v1/api/typescript-types.md +398 -0
  151. package/docs/v1/api/ui-helpers.md +200 -0
  152. package/docs/v1/examples/advanced-patterns.md +198 -0
  153. package/docs/v1/examples/checkout-flow.md +91 -0
  154. package/docs/v1/examples/custom-theming.md +63 -0
  155. package/docs/v1/examples/multi-product-page.md +90 -0
  156. package/docs/v1/examples/simple-product-page.md +89 -0
  157. package/docs/v1/getting-started/concepts.md +507 -0
  158. package/docs/v1/getting-started/installation.md +328 -0
  159. package/docs/v1/getting-started/quick-start.md +405 -0
  160. package/docs/v1/guides/address-component.md +431 -0
  161. package/docs/v1/guides/best-practices.md +353 -0
  162. package/docs/v1/guides/cart-component.md +737 -0
  163. package/docs/v1/guides/checkout-component.md +672 -0
  164. package/docs/v1/guides/events.md +926 -0
  165. package/docs/v1/guides/product-component.md +686 -0
  166. package/docs/v1/guides/product-list-component.md +507 -0
  167. package/docs/v1/guides/theming.md +216 -0
  168. package/docs/v1/integration/angular.md +39 -0
  169. package/docs/v1/integration/laravel.md +41 -0
  170. package/docs/v1/integration/nextjs.md +69 -0
  171. package/docs/v1/integration/proxy-setup.md +89 -0
  172. package/docs/v1/integration/react.md +64 -0
  173. package/docs/v1/integration/vanilla-js.md +84 -0
  174. package/docs/v1/integration/vue.md +58 -0
  175. package/docs/v1/reference/browser-support.md +44 -0
  176. package/docs/v1/reference/error-handling.md +70 -0
  177. package/docs/v1/reference/performance.md +54 -0
  178. package/docs/v1/reference/troubleshooting.md +136 -0
  179. package/package.json +31 -27
  180. package/dist/types/elements-builder-client.d.ts +0 -2
  181. package/dist/types/elements-client.d.ts +0 -2
  182. package/dist/types/enums/cloud.enum.d.ts +0 -106
  183. package/dist/types/interfaces/cloud/catalog.interface.d.ts +0 -42
  184. package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
  185. package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
  186. package/dist/types/interfaces/cloud/index.d.ts +0 -4
  187. package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
  188. package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
  189. package/dist/types/interfaces/core.interface.d.ts +0 -111
  190. package/dist/types/modules/cart/cart.commands.helper.d.ts +0 -4
  191. package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
  192. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
  193. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
  194. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
  195. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
  196. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  197. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  198. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  199. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  200. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  201. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  202. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  203. package/dist/types/utils/helper.d.ts +0 -28
  204. package/docs/ACTIONS.md +0 -1300
  205. package/docs/BROWSER_SUPPORT.md +0 -279
  206. package/docs/CONFIGURATION.md +0 -853
  207. package/docs/DOCUMENTATION_INDEX.md +0 -311
  208. package/docs/EVENTS.md +0 -798
  209. package/docs/PROXY.md +0 -228
  210. package/docs/THEMING.md +0 -592
  211. package/docs/TROUBLESHOOTING.md +0 -793
  212. package/umd/elements.js +0 -1
  213. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  214. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  215. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  216. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  217. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  218. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  219. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  220. /package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-checkbox-filter.components.d.ts → filter-components/product-list-checkbox-filter.d.ts} +0 -0
  221. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  222. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  223. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  224. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -0,0 +1,39 @@
1
+ # Angular Integration
2
+
3
+ Initialize Elements in a browser-only lifecycle hook and inject the component after the view mounts.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @liquidcommerce/elements-sdk
9
+ ```
10
+
11
+ ## Standalone Component Example
12
+
13
+ ```ts
14
+ import { AfterViewInit, Component } from '@angular/core';
15
+ import { Elements } from '@liquidcommerce/elements-sdk';
16
+
17
+ @Component({
18
+ selector: 'app-product-page',
19
+ standalone: true,
20
+ template: '<div id="product"></div>'
21
+ })
22
+ export class ProductPageComponent implements AfterViewInit {
23
+ async ngAfterViewInit() {
24
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
25
+ await client.injectProductElement([
26
+ { containerId: 'product', identifier: '00619947000020' }
27
+ ]);
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## Notes
33
+
34
+ - Initialize only in the browser (not during server rendering).
35
+
36
+ ## Related Docs
37
+
38
+ - [Product Component](../guides/product-component.md)
39
+ - [Client API](../api/client.md)
@@ -0,0 +1,41 @@
1
+ # Laravel Integration
2
+
3
+ Use the CDN build in a Blade view for a quick server-rendered setup.
4
+
5
+ ## Blade Template (CDN)
6
+
7
+ ```blade
8
+ <!-- resources/views/product.blade.php -->
9
+ <!DOCTYPE html>
10
+ <html lang="en">
11
+ <head>
12
+ <meta charset="UTF-8">
13
+ <meta name="viewport" content="width=device-width, initial-scale=1">
14
+ <title>Product</title>
15
+
16
+ <script
17
+ defer
18
+ data-liquid-commerce-elements
19
+ data-token="{{ env('LCE_API_KEY') }}"
20
+ data-env="production"
21
+ data-container-1="product"
22
+ data-product-1="00619947000020"
23
+ type="text/javascript"
24
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
25
+ ></script>
26
+ </head>
27
+ <body>
28
+ <div id="product"></div>
29
+ </body>
30
+ </html>
31
+ ```
32
+
33
+ ## Notes
34
+
35
+ - Keep your API key in `.env` and reference it in Blade.
36
+ - You can add a cart button with `data-cart-badge-button` on the script tag.
37
+
38
+ ## Related Docs
39
+
40
+ - [Product Component](../guides/product-component.md)
41
+ - [Cart Component](../guides/cart-component.md)
@@ -0,0 +1,69 @@
1
+ # Next.js Integration
2
+
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
+
5
+ ## App Router (Client Component)
6
+
7
+ ```jsx
8
+ 'use client';
9
+
10
+ import { useEffect } from 'react';
11
+ import { Elements } from '@liquidcommerce/elements-sdk';
12
+
13
+ export default function ProductPage() {
14
+ useEffect(() => {
15
+ (async () => {
16
+ const client = await Elements('YOUR_API_KEY', {
17
+ env: 'production',
18
+ proxy: { baseUrl: '/api/elements-proxy' }
19
+ });
20
+
21
+ await client.injectProductElement([
22
+ { containerId: 'product', identifier: '00619947000020' }
23
+ ]);
24
+ })();
25
+ }, []);
26
+
27
+ return <div id="product"></div>;
28
+ }
29
+ ```
30
+
31
+ ## Pages Router
32
+
33
+ ```jsx
34
+ import { useEffect } from 'react';
35
+ import { Elements } from '@liquidcommerce/elements-sdk';
36
+
37
+ export default function ProductPage() {
38
+ useEffect(() => {
39
+ (async () => {
40
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
41
+ await client.injectProductElement([
42
+ { containerId: 'product', identifier: '00619947000020' }
43
+ ]);
44
+ })();
45
+ }, []);
46
+
47
+ return <div id="product"></div>;
48
+ }
49
+ ```
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
+
61
+ ## Notes
62
+
63
+ - For ad blocker mitigation, configure the proxy (see [Proxy Setup](./proxy-setup.md)).
64
+
65
+ ## Related Docs
66
+
67
+ - [Proxy Setup](./proxy-setup.md)
68
+ - [Product Component](../guides/product-component.md)
69
+ - [Client API](../api/client.md)
@@ -0,0 +1,89 @@
1
+ # Proxy Setup
2
+
3
+ If ad blockers or network policies block the SDK assets, use a proxy on your domain. The SDK supports a `proxy.baseUrl` that routes API calls through your server.
4
+
5
+ ## 1) Configure the SDK
6
+
7
+ ### NPM
8
+
9
+ ```javascript
10
+ import { Elements } from '@liquidcommerce/elements-sdk';
11
+
12
+ const client = await Elements('YOUR_API_KEY', {
13
+ env: 'production',
14
+ proxy: {
15
+ baseUrl: 'https://yoursite.com/api/elements-proxy'
16
+ }
17
+ });
18
+ ```
19
+
20
+ ### CDN (Next.js example)
21
+
22
+ ```jsx
23
+ 'use client';
24
+
25
+ import { useEffect } from 'react';
26
+ import { Elements } from '@liquidcommerce/elements-sdk';
27
+
28
+ export default function ProductPage() {
29
+ useEffect(() => {
30
+ (async () => {
31
+ const client = await Elements('YOUR_API_KEY', {
32
+ env: 'production',
33
+ proxy: { baseUrl: '/api/elements-proxy' }
34
+ });
35
+
36
+ await client.injectProductElement([
37
+ { containerId: 'product', identifier: '00619947000020' }
38
+ ]);
39
+ })();
40
+ }, []);
41
+
42
+ return <div id="product"></div>;
43
+ }
44
+ ```
45
+
46
+ ## 2) Create the Proxy Endpoint
47
+
48
+ Your endpoint should forward requests to the LiquidCommerce Elements API, preserving method, headers, and body.
49
+
50
+ ### Minimal Express Example
51
+
52
+ ```javascript
53
+ import express from 'express';
54
+ import fetch from 'node-fetch';
55
+
56
+ const app = express();
57
+ app.use(express.json());
58
+
59
+ app.all('/api/elements-proxy/*', async (req, res) => {
60
+ const targetPath = req.params[0];
61
+ const targetUrl = `https://api.liquidcommerce.us/${targetPath}`;
62
+
63
+ const response = await fetch(targetUrl, {
64
+ method: req.method,
65
+ headers: {
66
+ ...req.headers,
67
+ host: 'api.liquidcommerce.us'
68
+ },
69
+ body: ['GET', 'HEAD'].includes(req.method) ? undefined : JSON.stringify(req.body)
70
+ });
71
+
72
+ const data = await response.text();
73
+ res.status(response.status).send(data);
74
+ });
75
+
76
+ app.listen(3000, () => {
77
+ console.log('Proxy listening on port 3000');
78
+ });
79
+ ```
80
+
81
+ ## Notes
82
+
83
+ - Keep your API key server-side whenever possible.
84
+ - Ensure CORS allows your storefront domain to call the proxy.
85
+
86
+ ## Related Docs
87
+
88
+ - [Installation](../getting-started/installation.md)
89
+ - [Client API](../api/client.md)
@@ -0,0 +1,64 @@
1
+ # React Integration
2
+
3
+ Use the NPM package and initialize the SDK client on the client side. Then inject components after mount.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @liquidcommerce/elements-sdk
9
+ ```
10
+
11
+ ## Basic Product Page
12
+
13
+ ```jsx
14
+ import { useEffect, useState } from 'react';
15
+ import { Elements } from '@liquidcommerce/elements-sdk';
16
+
17
+ export default function ProductPage() {
18
+ const [client, setClient] = useState(null);
19
+
20
+ useEffect(() => {
21
+ let mounted = true;
22
+ (async () => {
23
+ const instance = await Elements('YOUR_API_KEY', { env: 'production' });
24
+ if (mounted) setClient(instance);
25
+ })();
26
+ return () => { mounted = false; };
27
+ }, []);
28
+
29
+ useEffect(() => {
30
+ if (!client) return;
31
+ client.injectProductElement([
32
+ { containerId: 'product', identifier: '00619947000020' }
33
+ ]);
34
+ }, [client]);
35
+
36
+ return <div id="product"></div>;
37
+ }
38
+ ```
39
+
40
+ ## Cart Button
41
+
42
+ ```jsx
43
+ import { useEffect } from 'react';
44
+
45
+ export default function CartButton() {
46
+ useEffect(() => {
47
+ if (!window.LiquidCommerce.elements) return;
48
+ window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
49
+ }, []);
50
+
51
+ return <div id="header-cart"></div>;
52
+ }
53
+ ```
54
+
55
+ ## Notes
56
+
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
+ - For multiple products, call `injectProductElement` with multiple entries.
59
+
60
+ ## Related Docs
61
+
62
+ - [Product Component](../guides/product-component.md)
63
+ - [Cart Component](../guides/cart-component.md)
64
+ - [Client API](../api/client.md)
@@ -0,0 +1,84 @@
1
+ # Vanilla JavaScript Integration
2
+
3
+ Use the CDN build for the fastest setup, or use NPM if you have a build step.
4
+
5
+ ## Option A: CDN (Declarative)
6
+
7
+ ```html
8
+ <!DOCTYPE html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="UTF-8" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
13
+ <title>Vanilla JS Product Page</title>
14
+
15
+ <script
16
+ defer
17
+ data-liquid-commerce-elements
18
+ data-token="YOUR_API_KEY"
19
+ data-env="production"
20
+ data-container-1="product"
21
+ data-product-1="00619947000020"
22
+ data-cart-badge-button="header-cart"
23
+ type="text/javascript"
24
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
25
+ ></script>
26
+ </head>
27
+ <body>
28
+ <header>
29
+ <h1>Premium Spirits</h1>
30
+ <div id="header-cart"></div>
31
+ </header>
32
+
33
+ <main>
34
+ <div id="product"></div>
35
+ </main>
36
+ </body>
37
+ </html>
38
+ ```
39
+
40
+ ## Option B: CDN (Programmatic)
41
+
42
+ ```html
43
+ <script
44
+ defer
45
+ data-liquid-commerce-elements
46
+ data-token="YOUR_API_KEY"
47
+ data-env="production"
48
+ type="text/javascript"
49
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
50
+ ></script>
51
+
52
+ <script>
53
+ window.addEventListener('lce:actions.client_ready', async () => {
54
+ const client = window.LiquidCommerce.elements;
55
+ await client.injectProductElement([
56
+ { containerId: 'product', identifier: '00619947000020' }
57
+ ]);
58
+ });
59
+ </script>
60
+
61
+ <div id="product"></div>
62
+ ```
63
+
64
+ ## Option C: NPM
65
+
66
+ ```bash
67
+ npm install @liquidcommerce/elements-sdk
68
+ ```
69
+
70
+ ```javascript
71
+ import { Elements } from '@liquidcommerce/elements-sdk';
72
+
73
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
74
+
75
+ await client.injectProductElement([
76
+ { containerId: 'product', identifier: '00619947000020' }
77
+ ]);
78
+ ```
79
+
80
+ ## Related Docs
81
+
82
+ - [Product Component](../guides/product-component.md)
83
+ - [Cart Component](../guides/cart-component.md)
84
+ - [Client API](../api/client.md)
@@ -0,0 +1,58 @@
1
+ # Vue Integration
2
+
3
+ Use the NPM package and initialize Elements in `onMounted`.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @liquidcommerce/elements-sdk
9
+ ```
10
+
11
+ ## Vue 3 (Single File Component)
12
+
13
+ ```vue
14
+ <template>
15
+ <div id="product"></div>
16
+ </template>
17
+
18
+ <script setup>
19
+ import { onMounted } from 'vue';
20
+ import { Elements } from '@liquidcommerce/elements-sdk';
21
+
22
+ onMounted(async () => {
23
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
24
+ await client.injectProductElement([
25
+ { containerId: 'product', identifier: '00619947000020' }
26
+ ]);
27
+ });
28
+ </script>
29
+ ```
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
+
55
+ ## Related Docs
56
+
57
+ - [Product Component](../guides/product-component.md)
58
+ - [Client API](../api/client.md)
@@ -0,0 +1,44 @@
1
+ # Browser Support
2
+
3
+ The Elements SDK requires modern browser features (Web Components + Shadow DOM). If you need to support older browsers, include polyfills.
4
+
5
+ ## Minimum Versions
6
+
7
+ - Chrome 66+
8
+ - Firefox 60+
9
+ - Safari 12+
10
+ - Edge 79+
11
+
12
+ ## Required Features
13
+
14
+ - Custom Elements (Web Components)
15
+ - Shadow DOM
16
+ - ES2018 JavaScript
17
+ - Fetch API
18
+ - LocalStorage
19
+
20
+ ## Server-Side Rendering (SSR)
21
+
22
+ The SDK is browser-only, but it is safe to import in SSR frameworks (Next.js, Remix, Nuxt).
23
+ In non-browser environments, initialization is skipped. If you call the SDK on the server,
24
+ it returns `null` and logs a warning instead of throwing.
25
+
26
+ Call `Elements`, `ElementsCheckout`, or `ElementsBuilder` from client-only code (e.g., after mount)
27
+ to render components.
28
+
29
+ ## Polyfills (Legacy Browsers)
30
+
31
+ ```html
32
+ <script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-bundle.js"></script>
33
+ <script defer data-liquid-commerce-elements ...></script>
34
+ ```
35
+
36
+ ## Notes
37
+
38
+ - Always load the SDK script with `defer` to avoid blocking page render.
39
+ - If you see Web Components errors in the console, add the polyfill before the SDK.
40
+
41
+ ## Related Docs
42
+
43
+ - [Installation](../getting-started/installation.md)
44
+ - [Troubleshooting](./troubleshooting.md)
@@ -0,0 +1,70 @@
1
+ # Error Handling
2
+
3
+ The SDK emits errors as events and (when applicable) throws a custom `SDKError`. Your app should handle both.
4
+
5
+ ## SDKError
6
+
7
+ All SDK errors use a custom error class:
8
+
9
+ ```typescript
10
+ class SDKError extends Error {
11
+ constructor(message: string, reThrow?: boolean);
12
+ name: 'SDKError';
13
+ isSdk: boolean;
14
+ reThrow: boolean;
15
+ }
16
+ ```
17
+
18
+ ## Catching Errors
19
+
20
+ ```javascript
21
+ try {
22
+ await window.LiquidCommerce.elements.injectProductElement([
23
+ { containerId: 'product', identifier: 'invalid_id' }
24
+ ]);
25
+ } catch (error) {
26
+ if (error.name === 'SDKError') {
27
+ console.error('SDK Error:', error);
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## Error Isolation
33
+
34
+ The SDK catches and contains its own errors so your app keeps running:
35
+
36
+ ```javascript
37
+ window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
38
+ console.log('App still working');
39
+ ```
40
+
41
+ ## Error Events
42
+
43
+ Listen for failure events to show user-friendly messages or trigger retries:
44
+
45
+ ```javascript
46
+ // Cart add failed
47
+ window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
48
+ console.error('Failed to add:', event.detail.data.error);
49
+ });
50
+
51
+ // Address failed
52
+ window.addEventListener('lce:actions.address_failed', (event) => {
53
+ console.error('Address error:', event.detail.data.error);
54
+ });
55
+
56
+ // Checkout submit failed
57
+ window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
58
+ console.error('Checkout failed:', event.detail.data.error);
59
+ });
60
+ ```
61
+
62
+ ## UI Errors
63
+
64
+ When a component fails to load, the SDK renders an error view inside the container and logs details to the console.
65
+
66
+ ## Related Docs
67
+
68
+ - [Events Guide](../guides/events.md)
69
+ - [Client API](../api/client.md)
70
+ - [Troubleshooting](./troubleshooting.md)
@@ -0,0 +1,54 @@
1
+ # Performance Guide
2
+
3
+ The SDK is optimized out of the box. These tweaks help reduce load time and layout shift.
4
+
5
+ ## 1) Load Non-Blocking
6
+
7
+ ```html
8
+ <script defer data-liquid-commerce-elements ...></script>
9
+ ```
10
+
11
+ ## 2) Use the Checkout-Only Build When Appropriate
12
+
13
+ If you only need checkout, use the tree-shaken build:
14
+
15
+ ```javascript
16
+ import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
17
+ ```
18
+
19
+ ## 3) Inject Components When Needed
20
+
21
+ Inject above-the-fold products first, then load the rest:
22
+
23
+ ```javascript
24
+ await client.injectProductElement([
25
+ { containerId: 'hero-product', identifier: '001' }
26
+ ]);
27
+
28
+ setTimeout(async () => {
29
+ await client.injectProductElement([
30
+ { containerId: 'related-1', identifier: '002' },
31
+ { containerId: 'related-2', identifier: '003' }
32
+ ]);
33
+ }, 1000);
34
+ ```
35
+
36
+ ## 4) Reserve Space to Prevent Layout Shift
37
+
38
+ ```css
39
+ #product {
40
+ min-height: 600px;
41
+ }
42
+ ```
43
+
44
+ ## 5) Let the SDK Handle Media Optimization
45
+
46
+ The SDK automatically:
47
+ - Lazy loads images
48
+ - Uses responsive image sizes
49
+ - Virtualizes carousel images
50
+
51
+ ## Related Docs
52
+
53
+ - [Best Practices](../guides/best-practices.md)
54
+ - [Product Component](../guides/product-component.md)