@liquidcommerce/elements-sdk 2.7.0 → 2.7.2
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 +83 -2750
- package/dist/index.checkout.esm.js +6898 -6837
- package/dist/index.esm.js +11463 -10993
- package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
- package/dist/types/constants/core.constant.d.ts +0 -4
- package/dist/types/core/base-component.service.d.ts +2 -1
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +11 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
- package/dist/types/interfaces/core.interface.d.ts +5 -4
- package/dist/types/modules/address/address-input.component.d.ts +11 -0
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
- package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -0
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
- package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +2 -0
- package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
- package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
- package/dist/types/modules/product-list/components/index.d.ts +1 -0
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
- package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +10 -2
- package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
- package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
- package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
- package/dist/types/utils/dom-compat.d.ts +2 -0
- package/docs/gitbook/actions.md +964 -0
- package/docs/gitbook/address.md +48 -0
- package/docs/gitbook/cart.md +65 -0
- package/docs/gitbook/checkout.md +131 -0
- package/docs/gitbook/events.md +1765 -0
- package/docs/gitbook/overview.md +166 -0
- package/docs/gitbook/product.md +64 -0
- package/docs/gitbook/quick-start-guide.md +393 -0
- package/docs/v1/README.md +210 -0
- package/docs/v1/api/actions/address-actions.md +281 -0
- package/docs/v1/api/actions/cart-actions.md +337 -0
- package/docs/v1/api/actions/checkout-actions.md +387 -0
- package/docs/v1/api/actions/product-actions.md +115 -0
- package/docs/v1/api/client.md +482 -0
- package/docs/v1/api/configuration.md +1 -0
- package/docs/v1/api/injection-methods.md +247 -0
- package/docs/v1/api/typescript-types.md +1 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +96 -0
- package/docs/v1/examples/checkout-flow.md +91 -0
- package/docs/v1/examples/custom-theming.md +63 -0
- package/docs/v1/examples/multi-product-page.md +90 -0
- package/docs/v1/examples/simple-product-page.md +89 -0
- package/docs/v1/getting-started/concepts.md +507 -0
- package/docs/v1/getting-started/installation.md +328 -0
- package/docs/v1/getting-started/quick-start.md +405 -0
- package/docs/v1/guides/address-component.md +431 -0
- package/docs/v1/guides/best-practices.md +324 -0
- package/docs/v1/guides/cart-component.md +737 -0
- package/docs/v1/guides/checkout-component.md +672 -0
- package/docs/v1/guides/events.md +926 -0
- package/docs/v1/guides/product-component.md +686 -0
- package/docs/v1/guides/product-list-component.md +598 -0
- package/docs/v1/guides/theming.md +216 -0
- package/docs/v1/integration/angular.md +39 -0
- package/docs/v1/integration/laravel.md +41 -0
- package/docs/v1/integration/nextjs.md +60 -0
- package/docs/v1/integration/proxy-setup.md +89 -0
- package/docs/v1/integration/react.md +64 -0
- package/docs/v1/integration/vanilla-js.md +84 -0
- package/docs/v1/integration/vue.md +34 -0
- package/docs/v1/reference/browser-support.md +44 -0
- package/docs/v1/reference/error-handling.md +70 -0
- package/docs/v1/reference/performance.md +54 -0
- package/docs/v1/reference/troubleshooting.md +64 -0
- package/package.json +1 -1
- package/docs/ACTIONS.md +0 -1301
- package/docs/BROWSER_SUPPORT.md +0 -279
- package/docs/CONFIGURATION.md +0 -997
- package/docs/DOCUMENTATION_INDEX.md +0 -319
- package/docs/EVENTS.md +0 -798
- package/docs/PROXY.md +0 -228
- package/docs/THEMING.md +0 -681
- package/docs/TROUBLESHOOTING.md +0 -793
|
@@ -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.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.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)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
Common setup issues and how to resolve them.
|
|
4
|
+
|
|
5
|
+
## SDK Script Not Loading
|
|
6
|
+
|
|
7
|
+
**Symptoms:** 404/CORS in Network tab, `window.elements` is undefined.
|
|
8
|
+
|
|
9
|
+
**Fixes:**
|
|
10
|
+
- Verify the script URL and that the tag includes `data-liquid-commerce-elements`.
|
|
11
|
+
- Check ad blockers; proxy the API if needed.
|
|
12
|
+
- Confirm `data-env` is set correctly.
|
|
13
|
+
|
|
14
|
+
## Web Components Error
|
|
15
|
+
|
|
16
|
+
**Symptoms:** Console logs about Custom Elements or Shadow DOM.
|
|
17
|
+
|
|
18
|
+
**Fix:** Add the Web Components polyfill before the SDK:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-bundle.js"></script>
|
|
22
|
+
<script defer data-liquid-commerce-elements ...></script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Product Not Showing
|
|
26
|
+
|
|
27
|
+
**Symptoms:** Empty container or error view.
|
|
28
|
+
|
|
29
|
+
**Fixes:**
|
|
30
|
+
- Confirm the container ID matches your HTML.
|
|
31
|
+
- Verify the product identifier exists.
|
|
32
|
+
- Check for errors in the console or network tab.
|
|
33
|
+
|
|
34
|
+
## Cart Drawer Not Opening
|
|
35
|
+
|
|
36
|
+
**Symptoms:** Add to cart works but cart stays closed.
|
|
37
|
+
|
|
38
|
+
**Fixes:**
|
|
39
|
+
- Ensure a cart button is configured or call `window.elements.actions.cart.openCart()`.
|
|
40
|
+
- Check for JavaScript errors in the console.
|
|
41
|
+
|
|
42
|
+
## Checkout Issues
|
|
43
|
+
|
|
44
|
+
**Symptoms:** Checkout fails to load or submit.
|
|
45
|
+
|
|
46
|
+
**Fixes:**
|
|
47
|
+
- Verify you are on a supported browser.
|
|
48
|
+
- Look for `checkout_*_failed` events in the console.
|
|
49
|
+
- Check for Stripe-related errors in the browser console.
|
|
50
|
+
|
|
51
|
+
## Address/Availability Problems
|
|
52
|
+
|
|
53
|
+
**Symptoms:** Products show unavailable or address prompts fail.
|
|
54
|
+
|
|
55
|
+
**Fixes:**
|
|
56
|
+
- Make sure the address is set and valid.
|
|
57
|
+
- Listen for `lce:actions.address_failed` to surface errors.
|
|
58
|
+
|
|
59
|
+
## Related Docs
|
|
60
|
+
|
|
61
|
+
- [Installation](../getting-started/installation.md)
|
|
62
|
+
- [Browser Support](./browser-support.md)
|
|
63
|
+
- [Error Handling](./error-handling.md)
|
|
64
|
+
- [Proxy Setup](../integration/proxy-setup.md)
|
package/package.json
CHANGED