@moonbase.sh/vue 0.2.42 → 0.2.43

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/dist/index.cjs CHANGED
@@ -34,7 +34,7 @@ __export(src_exports, {
34
34
  useVoucher: () => useVoucher
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
- var import_storefront_api5 = require("@moonbase.sh/storefront-api");
37
+ var import_storefront_api6 = require("@moonbase.sh/storefront-api");
38
38
  var import_vue11 = require("vue");
39
39
 
40
40
  // src/context.ts
@@ -518,6 +518,7 @@ function useVoucher(context) {
518
518
 
519
519
  // src/composables/useCart.ts
520
520
  var import_vue9 = require("vue");
521
+ var import_storefront_api5 = require("@moonbase.sh/storefront-api");
521
522
  function useCart(context) {
522
523
  const storefront = context != null ? context : (0, import_vue9.inject)(storefrontKey);
523
524
  if (!storefront)
@@ -604,11 +605,14 @@ function useCart(context) {
604
605
  appliedDiscount: variation.discount
605
606
  };
606
607
  storefront.currentOrder.value.items.push(lineItem);
608
+ } else {
609
+ throw new import_storefront_api5.MoonbaseError("Invalid input", `Could not handle item of type '${item.type}'`);
607
610
  }
608
611
  } else {
609
612
  lineItem.quantity += 1;
610
613
  }
611
614
  const _ = storefront.pushOrderContent();
615
+ return lineItem;
612
616
  },
613
617
  setQuantity: (cartItem, quantity) => {
614
618
  const cartItemRef = storefront.currentOrder.value.items.find((i) => i.id === cartItem.id);
@@ -620,6 +624,7 @@ function useCart(context) {
620
624
  storefront.currentOrder.value.items.splice(index, 1);
621
625
  }
622
626
  const _ = storefront.pushOrderContent();
627
+ return cartItem;
623
628
  },
624
629
  removeFromCart: (cartItem) => {
625
630
  const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
@@ -722,7 +727,7 @@ function createStorefront(endpoint, stateFactory) {
722
727
  };
723
728
  return new StorefrontContextImpl(
724
729
  configuration,
725
- new import_storefront_api5.MoonbaseClient(configuration),
730
+ new import_storefront_api6.MoonbaseClient(configuration),
726
731
  // Default to vue refs but allow stuff like Nuxt useState wrappers
727
732
  stateFactory || ((_, state) => (0, import_vue11.ref)(state))
728
733
  );
package/dist/index.d.cts CHANGED
@@ -698,8 +698,8 @@ declare function useCart(context?: StorefrontContext): {
698
698
  amount: number;
699
699
  currency: string;
700
700
  }>;
701
- addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => void;
702
- setQuantity: (cartItem: CartItem, quantity: number) => void;
701
+ addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => CartItem;
702
+ setQuantity: (cartItem: CartItem, quantity: number) => CartItem;
703
703
  removeFromCart: (cartItem: CartItem) => void;
704
704
  checkout: (options: {
705
705
  redirect: boolean;
package/dist/index.d.ts CHANGED
@@ -698,8 +698,8 @@ declare function useCart(context?: StorefrontContext): {
698
698
  amount: number;
699
699
  currency: string;
700
700
  }>;
701
- addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => void;
702
- setQuantity: (cartItem: CartItem, quantity: number) => void;
701
+ addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => CartItem;
702
+ setQuantity: (cartItem: CartItem, quantity: number) => CartItem;
703
703
  removeFromCart: (cartItem: CartItem) => void;
704
704
  checkout: (options: {
705
705
  redirect: boolean;
package/dist/index.js CHANGED
@@ -483,6 +483,7 @@ function useVoucher(context) {
483
483
 
484
484
  // src/composables/useCart.ts
485
485
  import { computed as computed7, inject as inject8, unref } from "vue";
486
+ import { MoonbaseError as MoonbaseError2 } from "@moonbase.sh/storefront-api";
486
487
  function useCart(context) {
487
488
  const storefront = context != null ? context : inject8(storefrontKey);
488
489
  if (!storefront)
@@ -569,11 +570,14 @@ function useCart(context) {
569
570
  appliedDiscount: variation.discount
570
571
  };
571
572
  storefront.currentOrder.value.items.push(lineItem);
573
+ } else {
574
+ throw new MoonbaseError2("Invalid input", `Could not handle item of type '${item.type}'`);
572
575
  }
573
576
  } else {
574
577
  lineItem.quantity += 1;
575
578
  }
576
579
  const _ = storefront.pushOrderContent();
580
+ return lineItem;
577
581
  },
578
582
  setQuantity: (cartItem, quantity) => {
579
583
  const cartItemRef = storefront.currentOrder.value.items.find((i) => i.id === cartItem.id);
@@ -585,6 +589,7 @@ function useCart(context) {
585
589
  storefront.currentOrder.value.items.splice(index, 1);
586
590
  }
587
591
  const _ = storefront.pushOrderContent();
592
+ return cartItem;
588
593
  },
589
594
  removeFromCart: (cartItem) => {
590
595
  const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.2.42",
4
+ "version": "0.2.43",
5
5
  "description": "Package to let you build vue.js storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "@vue/devtools-api": "^6.6.3",
20
20
  "uuid": "^9.0.1",
21
21
  "zod": "^3.23.8",
22
- "@moonbase.sh/storefront-api": "0.2.42"
22
+ "@moonbase.sh/storefront-api": "0.2.43"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/uuid": "^9.0.8",