@moonbase.sh/storefront 2.0.2 → 2.2.1

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 CHANGED
@@ -29,7 +29,31 @@ Moonbase.on(MoonbaseEvent.CheckoutCompleted, ({ order }) => {
29
29
  })
30
30
  ```
31
31
 
32
- `setup` should be run once, client-side, after the DOM is available.
32
+ `setup` should be run once, client-side.
33
+
34
+ When you load the widget via the CDN script tag:
35
+
36
+ ```html
37
+ <script src="https://assets.moonbase.sh/storefront/moonbase.js"></script>
38
+ <script>
39
+ Moonbase.setup('https://demo.moonbase.sh')
40
+ Moonbase.on('checkout-completed', ({ order }) => console.log(order.id))
41
+ </script>
42
+ ```
43
+
44
+ …you can call `Moonbase.setup(...)`, `Moonbase.on(...)`, and any intent method from anywhere on the page — including inline `<script>` in `<head>` — without waiting for `DOMContentLoaded`. The CDN script is a tiny loader that queues calls and replays them once the real bundle and the DOM are both ready.
45
+
46
+ When you import from npm (`import Moonbase from '@moonbase.sh/storefront'`), `setup` still needs the DOM to be available before it runs, since there is no loader in that path.
47
+
48
+ ## Testing pre-release builds with `?mb_version=`
49
+
50
+ The CDN loader recognises an `?mb_version=` query parameter for opting into a non-default storefront build on a per-page-load basis. This is intended for testing pre-release changes on a live merchant site without changing the embed code.
51
+
52
+ - `?mb_version=next` — loads the latest `@next` snapshot from `/storefront/next/moonbase.js`
53
+ - `?mb_version=2.1.0` — pins to a specific published version from `/storefront/<version>/moonbase.js`
54
+ - `?mb_version=latest` or omitted — loads the current stable release (default)
55
+
56
+ Don't use this to pin a production embed to a specific version — pin the `<script src>` URL instead.
33
57
 
34
58
  ## Trigger intents
35
59
 
@@ -32,6 +32,7 @@ export declare enum MoonbaseEvent {
32
32
  DownloadedProduct = "downloaded-product",
33
33
  ActivatedProduct = "activated-product",
34
34
  AddedToCart = "added-to-cart",
35
+ CouponRejected = "coupon-rejected",
35
36
  CheckoutInitiated = "checkout-initiated",
36
37
  CheckoutClosed = "checkout-closed",
37
38
  CheckoutCompleted = "checkout-completed"
@@ -70,6 +71,10 @@ export declare interface MoonbaseEventArgs {
70
71
  currency: string;
71
72
  user?: User | null;
72
73
  };
74
+ [MoonbaseEvent.CouponRejected]: {
75
+ code: string;
76
+ user?: User | null;
77
+ };
73
78
  [MoonbaseEvent.CheckoutInitiated]: {
74
79
  order: OpenOrder;
75
80
  total: Money;
@@ -236,11 +241,13 @@ export declare interface MoonbaseIntentArgs {
236
241
  bundle_id?: string;
237
242
  variation_id?: string;
238
243
  quantity?: number;
244
+ coupon_code?: string;
239
245
  } | {
240
246
  product_id?: string;
241
247
  bundle_id?: string;
242
248
  variation_id?: string;
243
249
  quantity?: number;
250
+ coupon_code?: string;
244
251
  }[];
245
252
  [MoonbaseIntent.Checkout]: {
246
253
  complete?: boolean;