@nextblock-cms/ecom 0.20.1 → 0.21.0
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/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../payment-config.cjs.js"),t=require("./client.cjs.js"),n=require("./order-sync.cjs.js");var r=async(r,i)=>{let a=await e.resolveStripeWebhookSecret();if(!a)return console.error(`Missing Stripe webhook secret (configure it in CMS or STRIPE_WEBHOOK_SECRET)`),{received:!1,error:`Server configuration error`};let o=await t.getStripeClient(),s;try{s=o.webhooks.constructEvent(i,r,a)}catch(e){return console.error(`Webhook signature verification failed: ${e.message}`),{received:!1,error:`Webhook Error: ${e.message}`}}switch(s.type){case`checkout.session.completed`:{let e=s.data.object;try{await n.syncStripeOrderFromSession(e)}catch(e){return console.error(`[Stripe Webhook Error] Failed to sync completed session:`,e),{received:!1,error:e.message||`Failed to sync Stripe session`}}break}default:console.log(`Unhandled event type ${s.type}`)}return{received:!0}};exports.handleStripeWebhook=r;
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { syncStripeOrderFromSession as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { resolveStripeWebhookSecret as e } from "../payment-config.es.js";
|
|
2
|
+
import { getStripeClient as t } from "./client.es.js";
|
|
3
|
+
import { syncStripeOrderFromSession as n } from "./order-sync.es.js";
|
|
4
|
+
//#region libs/ecommerce/src/lib/stripe/webhooks.ts
|
|
5
|
+
var r = async (r, i) => {
|
|
6
|
+
let a = await e();
|
|
7
|
+
if (!a) return console.error("Missing Stripe webhook secret (configure it in CMS or STRIPE_WEBHOOK_SECRET)"), {
|
|
8
|
+
received: !1,
|
|
9
|
+
error: "Server configuration error"
|
|
10
|
+
};
|
|
11
|
+
let o = await t(), s;
|
|
12
|
+
try {
|
|
13
|
+
s = o.webhooks.constructEvent(i, r, a);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return console.error(`Webhook signature verification failed: ${e.message}`), {
|
|
16
|
+
received: !1,
|
|
17
|
+
error: `Webhook Error: ${e.message}`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
switch (s.type) {
|
|
21
|
+
case "checkout.session.completed": {
|
|
22
|
+
let e = s.data.object;
|
|
23
|
+
try {
|
|
24
|
+
await n(e);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return console.error("[Stripe Webhook Error] Failed to sync completed session:", e), {
|
|
27
|
+
received: !1,
|
|
28
|
+
error: e.message || "Failed to sync Stripe session"
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
default: console.log(`Unhandled event type ${s.type}`);
|
|
34
|
+
}
|
|
35
|
+
return { received: !0 };
|
|
32
36
|
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { r as handleStripeWebhook };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./currency.cjs.js"),t=require("./coupons.cjs.js"),n=require("./countries.cjs.js"),r=require("./states.cjs.js"),i=require("./inventory-settings.cjs.js");var a=`txcd_99999999`,o=`txcd_00000000`,s=`txcd_92010001`;function c(e){return e?a:o}async function l(n,r,i,a,o){if(!r.length)return[];let s=[...new Set(r.map(e=>e.product_id))],{data:c,error:l}=await n.from(`products`).select(`id, is_taxable`).in(`id`,s);if(l)throw Error(l.message);let u=new Map((c||[]).map(e=>[e.id,e]));return r.reduce((n,r)=>{let s=u.get(r.product_id);if(!s)return n;let c=e.resolveEffectivePriceForCurrency({prices:r.prices,salePrices:r.sale_prices,fallbackPrice:r.price,fallbackSalePrice:r.sale_price,saleStartAt:r.sale_start_at,saleEndAt:r.sale_end_at,scheduledPrice:r.scheduled_price,scheduledPrices:r.scheduled_prices,scheduledPriceAt:r.scheduled_price_at,currencyCode:i,currencies:a});return n.push({product_id:s.id,quantity:r.quantity,unit_amount:c.sale_price??c.price,discount_amount:o?.get(t.getCartLineCouponKey(r))??0,is_taxable:s.is_taxable??!0}),n},[])}async function u(e,t){let a=await i.getEcommerceInventorySettings(e),o=t.items.reduce((e,t)=>t.is_taxable?e+Math.max(0,t.unit_amount*t.quantity-(t.discount_amount??0)):e,0);if(!a.enableTaxes||o<=0)return{enabled:!1,mode:a.taxCalculationMode,amount:0,taxableSubtotal:o,lines:[]};if(a.taxCalculationMode===`automatic`)return{enabled:!0,mode:`automatic`,amount:0,taxableSubtotal:o,lines:[],isPendingExternalCalculation:!0};let s=n.normalizeCountryCode(t.destination?.country_code),c=r.normalizeSubdivisionCode(s,t.destination?.state)||null;if(!s)return{enabled:!0,mode:`manual`,amount:0,taxableSubtotal:o,lines:[]};let l=e.from(`tax_rates`).select(`id, country_code, state_code, tax_name, tax_rate, created_at, updated_at`).eq(`country_code`,s);l=c?l.or(`state_code.is.null,state_code.eq.${c}`):l.is(`state_code`,null);let{data:u,error:d}=await l;if(d)throw Error(d.message);let f=(u||[]).map(e=>({id:e.id,name:e.tax_name,rate:Number(e.tax_rate),amount:Math.round(o*Number(e.tax_rate)/100),country_code:e.country_code,state_code:e.state_code??null}));return{enabled:!0,mode:`manual`,amount:f.reduce((e,t)=>e+t.amount,0),taxableSubtotal:o,lines:f}}exports.STRIPE_TAX_CODE_NONTAXABLE=o,exports.STRIPE_TAX_CODE_SHIPPING=s,exports.STRIPE_TAX_CODE_TAXABLE_GOODS=a,exports.buildCheckoutTaxableItemsFromCart=l,exports.calculateCheckoutTaxes=u,exports.getStripeTaxCodeForProduct=c;
|
|
@@ -1,101 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { normalizeSubdivisionCode as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { resolveEffectivePriceForCurrency as e } from "./currency.es.js";
|
|
2
|
+
import { getCartLineCouponKey as t } from "./coupons.es.js";
|
|
3
|
+
import { normalizeCountryCode as n } from "./countries.es.js";
|
|
4
|
+
import { normalizeSubdivisionCode as r } from "./states.es.js";
|
|
5
|
+
import { getEcommerceInventorySettings as i } from "./inventory-settings.es.js";
|
|
6
|
+
//#region libs/ecommerce/src/lib/tax-calculation.ts
|
|
7
|
+
var a = "txcd_99999999", o = "txcd_00000000", s = "txcd_92010001";
|
|
8
|
+
function c(e) {
|
|
9
|
+
return e ? a : o;
|
|
9
10
|
}
|
|
10
|
-
async function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
unit_amount: a.sale_price ?? a.price,
|
|
40
|
-
discount_amount: c?.get(C(e)) ?? 0,
|
|
41
|
-
is_taxable: t.is_taxable ?? !0
|
|
42
|
-
}), o;
|
|
43
|
-
}, []);
|
|
11
|
+
async function l(n, r, i, a, o) {
|
|
12
|
+
if (!r.length) return [];
|
|
13
|
+
let s = [...new Set(r.map((e) => e.product_id))], { data: c, error: l } = await n.from("products").select("id, is_taxable").in("id", s);
|
|
14
|
+
if (l) throw Error(l.message);
|
|
15
|
+
let u = new Map((c || []).map((e) => [e.id, e]));
|
|
16
|
+
return r.reduce((n, r) => {
|
|
17
|
+
let s = u.get(r.product_id);
|
|
18
|
+
if (!s) return n;
|
|
19
|
+
let c = e({
|
|
20
|
+
prices: r.prices,
|
|
21
|
+
salePrices: r.sale_prices,
|
|
22
|
+
fallbackPrice: r.price,
|
|
23
|
+
fallbackSalePrice: r.sale_price,
|
|
24
|
+
saleStartAt: r.sale_start_at,
|
|
25
|
+
saleEndAt: r.sale_end_at,
|
|
26
|
+
scheduledPrice: r.scheduled_price,
|
|
27
|
+
scheduledPrices: r.scheduled_prices,
|
|
28
|
+
scheduledPriceAt: r.scheduled_price_at,
|
|
29
|
+
currencyCode: i,
|
|
30
|
+
currencies: a
|
|
31
|
+
});
|
|
32
|
+
return n.push({
|
|
33
|
+
product_id: s.id,
|
|
34
|
+
quantity: r.quantity,
|
|
35
|
+
unit_amount: c.sale_price ?? c.price,
|
|
36
|
+
discount_amount: o?.get(t(r)) ?? 0,
|
|
37
|
+
is_taxable: s.is_taxable ?? !0
|
|
38
|
+
}), n;
|
|
39
|
+
}, []);
|
|
44
40
|
}
|
|
45
|
-
async function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
amount: e.reduce((t, a) => t + a.amount, 0),
|
|
90
|
-
taxableSubtotal: n,
|
|
91
|
-
lines: e
|
|
92
|
-
};
|
|
41
|
+
async function u(e, t) {
|
|
42
|
+
let a = await i(e), o = t.items.reduce((e, t) => t.is_taxable ? e + Math.max(0, t.unit_amount * t.quantity - (t.discount_amount ?? 0)) : e, 0);
|
|
43
|
+
if (!a.enableTaxes || o <= 0) return {
|
|
44
|
+
enabled: !1,
|
|
45
|
+
mode: a.taxCalculationMode,
|
|
46
|
+
amount: 0,
|
|
47
|
+
taxableSubtotal: o,
|
|
48
|
+
lines: []
|
|
49
|
+
};
|
|
50
|
+
if (a.taxCalculationMode === "automatic") return {
|
|
51
|
+
enabled: !0,
|
|
52
|
+
mode: "automatic",
|
|
53
|
+
amount: 0,
|
|
54
|
+
taxableSubtotal: o,
|
|
55
|
+
lines: [],
|
|
56
|
+
isPendingExternalCalculation: !0
|
|
57
|
+
};
|
|
58
|
+
let s = n(t.destination?.country_code), c = r(s, t.destination?.state) || null;
|
|
59
|
+
if (!s) return {
|
|
60
|
+
enabled: !0,
|
|
61
|
+
mode: "manual",
|
|
62
|
+
amount: 0,
|
|
63
|
+
taxableSubtotal: o,
|
|
64
|
+
lines: []
|
|
65
|
+
};
|
|
66
|
+
let l = e.from("tax_rates").select("id, country_code, state_code, tax_name, tax_rate, created_at, updated_at").eq("country_code", s);
|
|
67
|
+
l = c ? l.or(`state_code.is.null,state_code.eq.${c}`) : l.is("state_code", null);
|
|
68
|
+
let { data: u, error: d } = await l;
|
|
69
|
+
if (d) throw Error(d.message);
|
|
70
|
+
let f = (u || []).map((e) => ({
|
|
71
|
+
id: e.id,
|
|
72
|
+
name: e.tax_name,
|
|
73
|
+
rate: Number(e.tax_rate),
|
|
74
|
+
amount: Math.round(o * Number(e.tax_rate) / 100),
|
|
75
|
+
country_code: e.country_code,
|
|
76
|
+
state_code: e.state_code ?? null
|
|
77
|
+
}));
|
|
78
|
+
return {
|
|
79
|
+
enabled: !0,
|
|
80
|
+
mode: "manual",
|
|
81
|
+
amount: f.reduce((e, t) => e + t.amount, 0),
|
|
82
|
+
taxableSubtotal: o,
|
|
83
|
+
lines: f
|
|
84
|
+
};
|
|
93
85
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
g as STRIPE_TAX_CODE_SHIPPING,
|
|
97
|
-
b as STRIPE_TAX_CODE_TAXABLE_GOODS,
|
|
98
|
-
w as buildCheckoutTaxableItemsFromCart,
|
|
99
|
-
q as calculateCheckoutTaxes,
|
|
100
|
-
A as getStripeTaxCodeForProduct
|
|
101
|
-
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { o as STRIPE_TAX_CODE_NONTAXABLE, s as STRIPE_TAX_CODE_SHIPPING, a as STRIPE_TAX_CODE_TAXABLE_GOODS, l as buildCheckoutTaxableItemsFromCart, u as calculateCheckoutTaxes, c as getStripeTaxCodeForProduct };
|
package/lib/trials.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){let t=Number(e?.trial_period_days??0);return!Number.isFinite(t)||t<=0?0:Math.round(t)}function t(t){return e(t)===0?null:t?.trial_requires_payment_method?`paid`:`free`}function n(e,t,n,r){if(!e)return n;let i=e(t,r);return i===t?n:i}function r(t,r){let i=e(typeof t==`number`?{trial_period_days:t}:t);return i>0?n(r,`ecommerce.trial_days`,`${i}-day free trial`,{count:i}):null}function i(e,t){return e?.trial_requires_payment_method?n(t,`ecommerce.trial_payment_required`,`Payment method required`):n(t,`ecommerce.trial_no_card`,`No credit card required`)}function a(e,n){let a=r(e,n);return a?{label:a,paymentRequirementLabel:i(e,n),checkoutMode:t(e)}:null}exports.getTrialCheckoutMode=t,exports.getTrialLabel=r,exports.getTrialPaymentRequirementLabel=i,exports.getTrialPeriodDays=e,exports.getTrialSummary=a;
|
package/lib/trials.es.js
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region libs/ecommerce/src/lib/trials.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = Number(e?.trial_period_days ?? 0);
|
|
4
|
+
return !Number.isFinite(t) || t <= 0 ? 0 : Math.round(t);
|
|
4
5
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
6
|
+
function t(t) {
|
|
7
|
+
return e(t) === 0 ? null : t?.trial_requires_payment_method ? "paid" : "free";
|
|
7
8
|
}
|
|
8
|
-
function n(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function n(e, t, n, r) {
|
|
10
|
+
if (!e) return n;
|
|
11
|
+
let i = e(t, r);
|
|
12
|
+
return i === t ? n : i;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
count: t
|
|
17
|
-
}) : null;
|
|
14
|
+
function r(t, r) {
|
|
15
|
+
let i = e(typeof t == "number" ? { trial_period_days: t } : t);
|
|
16
|
+
return i > 0 ? n(r, "ecommerce.trial_days", `${i}-day free trial`, { count: i }) : null;
|
|
18
17
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
18
|
+
function i(e, t) {
|
|
19
|
+
return e?.trial_requires_payment_method ? n(t, "ecommerce.trial_payment_required", "Payment method required") : n(t, "ecommerce.trial_no_card", "No credit card required");
|
|
21
20
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
function a(e, n) {
|
|
22
|
+
let a = r(e, n);
|
|
23
|
+
return a ? {
|
|
24
|
+
label: a,
|
|
25
|
+
paymentRequirementLabel: i(e, n),
|
|
26
|
+
checkoutMode: t(e)
|
|
27
|
+
} : null;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
d as getTrialLabel,
|
|
33
|
-
l as getTrialPaymentRequirementLabel,
|
|
34
|
-
i as getTrialPeriodDays,
|
|
35
|
-
c as getTrialSummary
|
|
36
|
-
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { t as getTrialCheckoutMode, r as getTrialLabel, i as getTrialPaymentRequirementLabel, e as getTrialPeriodDays, a as getTrialSummary };
|
package/lib/types.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={stripe:!1,freemius:!1};function t(t){if(!t||typeof t!=`object`||Array.isArray(t))return{...e};let n=t;return{stripe:n.stripe===!0,freemius:n.freemius===!0}}function n(e){return e===`digital`?`freemius`:`stripe`}function r(e){return e?`provider`in e&&e.provider?e.provider:e.payment_provider?e.payment_provider:e.product_type?n(e.product_type):`freemius_product_id`in e&&e.freemius_product_id?`freemius`:null:null}function i(e){return r(e)===`freemius`}function a(e){return i(e)}exports.DEFAULT_ENABLED_PAYMENT_PROVIDERS=e,exports.derivePaymentProviderFromProductType=n,exports.getProductPaymentProvider=r,exports.isDigitalItem=a,exports.isDigitalProduct=i,exports.normalizeEnabledPaymentProviders=t;
|
package/lib/types.es.js
CHANGED
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region libs/ecommerce/src/lib/types.ts
|
|
2
|
+
var e = {
|
|
3
|
+
stripe: !1,
|
|
4
|
+
freemius: !1
|
|
4
5
|
};
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
6
|
+
function t(t) {
|
|
7
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return { ...e };
|
|
8
|
+
let n = t;
|
|
9
|
+
return {
|
|
10
|
+
stripe: n.stripe === !0,
|
|
11
|
+
freemius: n.freemius === !0
|
|
12
|
+
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
14
|
+
function n(e) {
|
|
15
|
+
return e === "digital" ? "freemius" : "stripe";
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
17
|
+
function r(e) {
|
|
18
|
+
return e ? "provider" in e && e.provider ? e.provider : e.payment_provider ? e.payment_provider : e.product_type ? n(e.product_type) : "freemius_product_id" in e && e.freemius_product_id ? "freemius" : null : null;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
20
|
+
function i(e) {
|
|
21
|
+
return r(e) === "freemius";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
23
|
+
function a(e) {
|
|
24
|
+
return i(e);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
t as derivePaymentProviderFromProductType,
|
|
29
|
-
n as getProductPaymentProvider,
|
|
30
|
-
d as isDigitalItem,
|
|
31
|
-
o as isDigitalProduct,
|
|
32
|
-
u as normalizeEnabledPaymentProviders
|
|
33
|
-
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { e as DEFAULT_ENABLED_PAYMENT_PROVIDERS, n as derivePaymentProviderFromProductType, r as getProductPaymentProvider, a as isDigitalItem, i as isDigitalProduct, t as normalizeEnabledPaymentProviders };
|
package/lib/use-cart.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./cart-store.cjs.js");let t=require("react");var n=null;function r(){return e.useCartStore.persist}function i(){return r()?.hasHydrated?.()??!1}function a(){if(typeof window>`u`)return Promise.resolve();let e=r();return!e||e.hasHydrated()?Promise.resolve():(n||=Promise.resolve().then(()=>e.rehydrate()).finally(()=>{n=null}),n)}var o=n=>{let o=e.useCartStore(n),[s,c]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let e=r();if(i()){c(!0);return}let t=e?.onFinishHydration(()=>c(!0));return a(),()=>{t?.()}},[]),s?o:void 0},s=()=>{let[e,n]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let e=r()?.onFinishHydration(()=>n(!0));return n(i()),i()||a(),()=>{e?.()}},[]),e};exports.useCart=o,exports.useIsCartHydrated=s;
|
package/lib/use-cart.es.js
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return d.persist;
|
|
7
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCartStore as e } from "./cart-store.es.js";
|
|
3
|
+
import { useEffect as t, useState as n } from "react";
|
|
4
|
+
//#region libs/ecommerce/src/lib/use-cart.ts
|
|
5
|
+
var r = null;
|
|
8
6
|
function i() {
|
|
9
|
-
|
|
7
|
+
return e.persist;
|
|
10
8
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
return Promise.resolve();
|
|
14
|
-
const t = n();
|
|
15
|
-
return !t || t.hasHydrated() ? Promise.resolve() : (s || (s = Promise.resolve().then(() => t.rehydrate()).finally(() => {
|
|
16
|
-
s = null;
|
|
17
|
-
})), s);
|
|
9
|
+
function a() {
|
|
10
|
+
return i()?.hasHydrated?.() ?? !1;
|
|
18
11
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
12
|
+
function o() {
|
|
13
|
+
if (typeof window > "u") return Promise.resolve();
|
|
14
|
+
let e = i();
|
|
15
|
+
return !e || e.hasHydrated() ? Promise.resolve() : (r ||= Promise.resolve().then(() => e.rehydrate()).finally(() => {
|
|
16
|
+
r = null;
|
|
17
|
+
}), r);
|
|
18
|
+
}
|
|
19
|
+
var s = (r) => {
|
|
20
|
+
let s = e(r), [c, l] = n(!1);
|
|
21
|
+
return t(() => {
|
|
22
|
+
let e = i();
|
|
23
|
+
if (a()) {
|
|
24
|
+
l(!0);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let t = e?.onFinishHydration(() => l(!0));
|
|
28
|
+
return o(), () => {
|
|
29
|
+
t?.();
|
|
30
|
+
};
|
|
31
|
+
}, []), c ? s : void 0;
|
|
32
|
+
}, c = () => {
|
|
33
|
+
let [e, r] = n(!1);
|
|
34
|
+
return t(() => {
|
|
35
|
+
let e = i()?.onFinishHydration(() => r(!0));
|
|
36
|
+
return r(a()), a() || o(), () => {
|
|
37
|
+
e?.();
|
|
38
|
+
};
|
|
39
|
+
}, []), e;
|
|
44
40
|
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { s as useCart, c as useIsCartHydrated };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use client";let e=require("@nextblock-cms/utils");function t(e){return e?e===`fr`?`fr-CA`:e===`en`?`en-US`:e:`en-US`}function n(){let{lang:n}=(0,e.useTranslations)(),r=t(n);return(t,n)=>(0,e.formatPrice)(t,n,r)}exports.getPriceLocale=t,exports.usePriceFormatter=n;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { formatPrice as e, useTranslations as t } from "@nextblock-cms/utils";
|
|
3
|
+
//#region libs/ecommerce/src/lib/use-price-formatter.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return e ? e === "fr" ? "fr-CA" : e === "en" ? "en-US" : e : "en-US";
|
|
5
6
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
function r() {
|
|
8
|
+
let { lang: r } = t(), i = n(r);
|
|
9
|
+
return (t, n) => e(t, n, i);
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
u as usePriceFormatter
|
|
13
|
-
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { n as getPriceLocale, r as usePriceFormatter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./currency.cjs.js");function t(e){return!e||typeof e!=`object`||Array.isArray(e)?null:Object.entries(e).reduce((e,[t,n])=>(typeof n==`string`&&n.trim()&&(e[t]=n.trim()),e),{})}function n(e,t,n){return!n||!t?e:t[n]?.trim()||e}function r(e,t){return n(e.name,e.name_translations,t)}function i(e,t){return n(e.value,e.value_translations,t)}function a(e){return e?e.startsWith(`http`)?e:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}`:e:null}function o(e){return e.toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function s(e){return[...e].sort().join(`__`)}function c(e){return e.map(e=>e.term_value).join(` / `)}function l(e){return e.length===0?[]:e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),[[]])}function u(t){let{baseSku:n,basePrice:r,basePrices:i={},baseSalePrice:a=null,baseSalePrices:u={},selectedAttributes:d,previousVariants:f=[]}=t;if(d.length===0||d.some(e=>e.terms.length===0))return[];let p=new Map(f.map(e=>[e.combination_key,e]));return l(d.map(e=>e.terms.map(t=>({attribute_id:e.attribute_id,attribute_name:e.attribute_name,term:t})))).map(t=>{let l=t.map(({attribute_id:e,attribute_name:t,term:n})=>({attribute_id:e,attribute_name:t,term_id:n.id,term_value:n.value,term_slug:n.slug})),d=l.map(e=>e.term_id),f=s(d),m=p.get(f),h=l.map(e=>(e.term_slug?e.term_slug:o(e.term_value)).toUpperCase()).filter(Boolean).join(`-`);return{id:m?.id,combination_key:f,sku:m?.sku||[n.trim(),h].filter(Boolean).join(`-`),upc:m?.upc??null,price:m?.price??r,prices:m?.prices??e.normalizePriceMap(i),sale_price:m?.sale_price??a,sale_prices:m?.sale_prices??e.normalizeSalePriceMap(u),sale_start_at:m?.sale_start_at??null,sale_end_at:m?.sale_end_at??null,stock_quantity:m?.stock_quantity??0,main_media_id:m?.main_media_id??null,main_image_url:m?.main_image_url??null,attribute_term_ids:d,selected_options:l,label:c(l)}})}function d(e){let t={};for(let n of e)for(let e of n.selected_options??[]){let n=new Set(t[e.attribute_id]??[]);n.add(e.term_id),t[e.attribute_id]=[...n]}return t}function f(e,t){let n=Object.values(t).filter(Boolean);return n.length===0?null:e.find(e=>e.attribute_term_ids.length===n.length&&n.every(t=>e.attribute_term_ids.includes(t)))??null}function p(e,t,n){let r=new Set;for(let i of e){if(!Object.entries(n).every(([e,n])=>!n||e===t||i.attribute_term_ids.includes(n)))continue;let e=i.selected_options.find(e=>e.attribute_id===t);e&&r.add(e.term_id)}return r}function m(e,t){let n=t.find(e=>e.stock_quantity>0)??t[0]??null;return n?n.selected_options.reduce((e,t)=>(e[t.attribute_id]=t.term_id,e),{}):e.reduce((e,t)=>{let n=t.terms[0];return n&&(e[t.id]=n.id),e},{})}function h(e,t,n,r,i){let a={[r]:i};for(let i of e){if(i.id===r)continue;let e=p(t,i.id,a),o=n[i.id];if(o&&e.has(o)){a[i.id]=o;continue}let s=i.terms.find(t=>e.has(t.id));s&&(a[i.id]=s.id)}return a}function g(e,t,n){let r={...n};for(let n of e){let e=p(t,n.id,r);if(e.size===0){delete r[n.id];continue}let i=r[n.id];if(i&&e.has(i))continue;let a=n.terms.find(t=>e.has(t.id));a&&(r[n.id]=a.id)}return r}function _(r=[],i){let o=new Map,l=r.map(r=>{let l=(r.variant_attribute_mapping||[]).map(e=>{let r=e.product_attribute_terms,a=r?.product_attributes;if(!r||!a)return null;let s=o.get(a.id)||{id:a.id,name:n(a.name,t(a.name_translations),i),slug:a.slug,name_translations:t(a.name_translations),terms:[],_termIds:new Set};return s._termIds.has(r.id)||(s.terms.push({id:r.id,attribute_id:r.attribute_id,value:n(r.value,t(r.value_translations),i),slug:r.slug,sort_order:r.sort_order??null,value_translations:t(r.value_translations)}),s._termIds.add(r.id)),o.set(a.id,s),{attribute_id:a.id,attribute_name:n(a.name,t(a.name_translations),i),term_id:r.id,term_value:n(r.value,t(r.value_translations),i),term_slug:r.slug}}).filter(e=>e!==null).sort((e,t)=>e.attribute_name.localeCompare(t.attribute_name)),u=l.map(e=>e.term_id);return{id:r.id,combination_key:s(u),sku:r.sku,upc:r.upc??null,price:r.price??0,prices:e.normalizePriceMap(r.prices),sale_price:r.sale_price??null,sale_prices:e.normalizeSalePriceMap(r.sale_prices),sale_start_at:r.sale_start_at??null,sale_end_at:r.sale_end_at??null,scheduled_price:r.scheduled_price??null,scheduled_prices:e.normalizePriceMap(r.scheduled_prices),scheduled_price_at:r.scheduled_price_at??null,stock_quantity:r.stock_quantity??0,main_media_id:r.main_media_id??null,image_url:a(r.media?.file_path??r.media?.object_key??null),attribute_term_ids:u,selected_options:l,label:c(l)}});return{attributes:[...o.values()].map(e=>({id:e.id,name:e.name,slug:e.slug,name_translations:e.name_translations,terms:[...e.terms].sort((e,t)=>{let n=e.sort_order??2**53-1,r=t.sort_order??2**53-1;return n===r?e.value.localeCompare(t.value):n-r})})).sort((e,t)=>e.name.localeCompare(t.name)),variants:l}}function v(t,n){if(!t.length)return null;let r=t.map(t=>e.isSaleWindowActive({saleStartAt:t.sale_start_at,saleEndAt:t.sale_end_at,now:n})&&typeof t.sale_price==`number`?t.sale_price:t.price);return{min:Math.min(...r),max:Math.max(...r)}}exports.applyVariantSelection=h,exports.buildCombinationKey=s,exports.buildVariantLabel=c,exports.chooseInitialVariantSelections=m,exports.extractSelectedTermsByAttribute=d,exports.findMatchingVariant=f,exports.generateVariantDrafts=u,exports.getAvailableTermIdsForAttribute=p,exports.getVariantEffectivePriceRange=v,exports.mapRawVariantRelations=_,exports.normalizeSelectionsToAvailableVariants=g,exports.resolveAttributeName=r,exports.resolveTermValue=i,exports.resolveTranslatedText=n;
|