@lightspeed/ecom-headless 1.1.5-rc.0 → 1.2.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/CHANGELOG.md +8 -3
- package/README.md +8 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-visualizer/bundle.html +1 -1
- package/dist/shared/ecom-headless.BF4ITfQc.cjs +2 -0
- package/dist/shared/ecom-headless.BF4ITfQc.cjs.map +1 -0
- package/dist/shared/{ecom-headless.C9ivNZI7.d.cts → ecom-headless.BeJeXdSY.d.mts} +99 -24
- package/dist/shared/{ecom-headless.DU9eDsgV.d.ts → ecom-headless.CmRks5zy.d.cts} +99 -24
- package/dist/shared/ecom-headless.CyyXXtdO.mjs +2 -0
- package/dist/shared/ecom-headless.CyyXXtdO.mjs.map +1 -0
- package/dist/shared/{ecom-headless.DGDJogyS.d.ts → ecom-headless.UNkw31Vf.d.cts} +311 -2
- package/dist/shared/{ecom-headless.DGDJogyS.d.cts → ecom-headless.UNkw31Vf.d.mts} +311 -2
- package/dist/shared/{ecom-headless.DGDJogyS.d.mts → ecom-headless.UNkw31Vf.d.ts} +311 -2
- package/dist/shared/{ecom-headless.BhIymLsJ.d.mts → ecom-headless.vv_Pbr6W.d.ts} +99 -24
- package/dist/storefront/index.cjs +1 -1
- package/dist/storefront/index.cjs.map +1 -1
- package/dist/storefront/index.d.cts +2 -2
- package/dist/storefront/index.d.mts +2 -2
- package/dist/storefront/index.d.ts +2 -2
- package/dist/storefront/index.mjs +1 -1
- package/dist/storefront/index.mjs.map +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +11 -7
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const getStoreId=require("./ecom-headless.CiGkSfL9.cjs");async function waitEcwidApiOperation({invoke:e,callback:t,getError:c}){return getStoreId.waitEcwidApiLoaded(()=>new Promise((g,l)=>{let w=!1;const E=(...C)=>{if(w)return;w=!0;let O;try{O=t?.(...C)}catch{}let p=!1,S,T;try{T=c?.(...C)}catch(A){p=!0,S=A}if(p||T!==void 0){Promise.resolve(O).catch(()=>{}),l(p?S:T);return}Promise.resolve(O).catch(()=>{}),g()};try{e(E)}catch(C){w=!0,l(C)}}))}function getEcwidApiOperationError(e,t,c){if(t)return;if(c instanceof Error)return c;const g=Array.isArray(c)?c.filter(Boolean).join(", "):typeof c=="string"?c.trim():"";return new Error(g||`${e} failed`)}const OnCartChanged={add:e=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnCartChanged").add(e))},OnConsentChanged={add:e=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnConsentChanged").add(e))},OnPageLoad={add:e=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageLoad").add(e))},OnPageLoaded={add:e=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageLoaded").add(e))},OnPageSwitch={add:e=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageSwitch").add(e))},OnSetProfile={add:e=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnSetProfile").add(e))};async function formatCurrency(e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("formatCurrency")(e))}async function getAppPublicConfig(e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getAppPublicConfig")(e))}async function getAppPublicToken(e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getAppPublicToken")(e))}async function getInitializedWidgets(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getInitializedWidgets")())}async function getStorefrontLang(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getStorefrontLang")())}async function getTrackingConsent(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getTrackingConsent")())}async function getVisitorLocation(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getVisitorLocation")())}async function isStorefrontV3(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("isStorefrontV3")())}async function openPage(e,t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("openPage")(e,t))}async function setTrackingConsent(e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("setTrackingConsent")(e))}async function get$2(e){return waitEcwidApiOperation({invoke:t=>getStoreId.getEcwidWindowMethod("Cart").get(t),callback:e})}async function addProduct(e,t){const c=typeof e=="number"?void 0:e.callback;return waitEcwidApiOperation({invoke:g=>{if(typeof e=="number"){getStoreId.getEcwidWindowMethod("Cart").addProduct(e,g);return}const l={...e,callback:g};getStoreId.getEcwidWindowMethod("Cart").addProduct(l)},callback:typeof c=="function"?c:t,getError:(g,l,w,E)=>getEcwidApiOperationError("Cart.addProduct",g,E)})}async function removeProduct(e,t){return waitEcwidApiOperation({invoke:c=>getStoreId.getEcwidWindowMethod("Cart").removeProduct(e,c),callback:t,getError:(c,g,l,w,E)=>getEcwidApiOperationError("Cart.removeProduct",c,E)})}async function removeProducts(e,t){return waitEcwidApiOperation({invoke:c=>getStoreId.getEcwidWindowMethod("Cart").removeProducts(e,c),callback:t,getError:(c,g,l,w,E)=>getEcwidApiOperationError("Cart.removeProducts",c,E)})}async function clear(e){return waitEcwidApiOperation({invoke:t=>getStoreId.getEcwidWindowMethod("Cart").clear(t),callback:e,getError:(t,c)=>getEcwidApiOperationError("Cart.clear",t,c)})}async function calculateTotal(e){return waitEcwidApiOperation({invoke:t=>getStoreId.getEcwidWindowMethod("Cart").calculateTotal(t),callback:e})}async function canGotoCheckout(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").canGotoCheckout())}async function gotoCheckout(e){return waitEcwidApiOperation({invoke:t=>getStoreId.getEcwidWindowMethod("Cart").gotoCheckout(t),callback:e})}const index$4={__proto__:null,addProduct,calculateTotal,canGotoCheckout,clear,get:get$2,gotoCheckout,removeProduct,removeProducts};async function get$1(e){return waitEcwidApiOperation({invoke:t=>getStoreId.getEcwidWindowMethod("Customer").get(t),callback:e})}async function signOut(e){return waitEcwidApiOperation({invoke:t=>getStoreId.getEcwidWindowMethod("Customer").signOut(t),callback:e,getError:(t,c)=>getEcwidApiOperationError("Customer.signOut",t,c)})}const index$3={__proto__:null,get:get$1,signOut},StorefrontRuntimeBridgeVersion=1,StorefrontRuntimeCapabilityValues={CATALOG_PAGE:"CATALOG_PAGE",CATALOG_FILTERS:"CATALOG_FILTERS",CATEGORY_MENU:"CATEGORY_MENU",CATALOG_SUBSCRIPTION:"CATALOG_SUBSCRIPTION",PRODUCT:"PRODUCT",PRODUCT_CONFIGURATION:"PRODUCT_CONFIGURATION",RELATED_PRODUCTS:"RELATED_PRODUCTS",PRODUCTS_SUBSCRIPTION:"PRODUCTS_SUBSCRIPTION",FAVORITES_STATE:"FAVORITES_STATE",FAVORITES_MUTATION:"FAVORITES_MUTATION",FAVORITES_SUBSCRIPTION:"FAVORITES_SUBSCRIPTION"};class StorefrontRuntimeError extends Error{code;cause;constructor(t,c,g){super(c),this.name="StorefrontRuntimeError",this.code=t,this.cause=g}}const d$1=new Set(["INVALID_REQUEST","NOT_FOUND","UNAUTHORIZED","OUT_OF_STOCK","INCOMPLETE_PRODUCT_SELECTION","PREVIEW_MUTATION_DISABLED","NETWORK_ERROR","UNKNOWN_ERROR"]);function s$1(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&d$1.has(e.code)}function toStorefrontRuntimeError(e){return e instanceof StorefrontRuntimeError?e:s$1(e)?new StorefrontRuntimeError(e.code,e.message):new StorefrontRuntimeError("UNKNOWN_ERROR","Storefront operation failed")}async function getStorefrontBridge(e){let t=globalThis.window?.Ecwid;if(t?.Headless===void 0&&(await getStoreId.waitEcwidApiLoaded(()=>{}),t=globalThis.window?.Ecwid),t===void 0)throw new StorefrontRuntimeError("STOREFRONT_RUNTIME_UNAVAILABLE","Ecwid Storefront runtime is not available");const c=t.Headless;if(c===void 0)throw new StorefrontRuntimeError("UNSUPPORTED_STOREFRONT_VERSION","This Storefront version does not support Headless runtime operations");if(c.version!==StorefrontRuntimeBridgeVersion)throw new StorefrontRuntimeError("UNSUPPORTED_STOREFRONT_VERSION",`Unsupported Headless Storefront bridge version: ${String(c.version)}`);if(!c.capabilities.includes(e))throw new StorefrontRuntimeError("UNSUPPORTED_CAPABILITY",`Storefront Headless capability is not available: ${e}`);return c}async function runStorefrontOperation(e,t){try{const c=await getStorefrontBridge(e);return await t(c)}catch(c){throw toStorefrontRuntimeError(c)}}const d=new Set(["DEFINED_BY_STORE_OWNER","ADDED_TIME_DESC","PRICE_ASC","PRICE_DESC","NAME_ASC","NAME_DESC","IN_STORE_RECEIVED_DATE_DESC"]);function r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function n(e){return Number.isSafeInteger(e)&&Number(e)>0}function i(e){return Number.isSafeInteger(e)&&Number(e)>=0}function o(e,t){return e===void 0||t(e)}function u(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function s(e){return r(e)&&Object.values(e).every(u)}function a(e){return r(e)&&i(e.offset)&&n(e.limit)&&e.limit<=200}function f(e){return r(e)&&o(e.categories,t=>Array.isArray(t)&&t.every(i))&&o(e.keyword,t=>typeof t=="string")&&o(e.priceFrom,t=>typeof t=="number"&&Number.isFinite(t))&&o(e.priceTo,t=>typeof t=="number"&&Number.isFinite(t))&&o(e.inventory,t=>t==="instock"||t==="outofstock")&&o(e.uncategorized,t=>typeof t=="boolean")&&o(e.onSale,t=>t==="onsale"||t==="notonsale")&&o(e.attributes,s)&&o(e.options,s)&&o(e.sku,t=>typeof t=="string")&&o(e.swatch,s)&&o(e.locations,u)}const isStorefrontCatalogPageRequest=e=>!r(e)||!r(e.listing)?!1:o(e.categoryId,i)&&o(e.isArtificialCategory,t=>typeof t=="boolean")&&f(e.listing.filters)&&typeof e.listing.sortBy=="string"&&d.has(e.listing.sortBy)&&a(e.listing.pagination),isStorefrontCatalogFiltersRequest=e=>r(e)&&o(e.categoryId,i)&&o(e.isArtificialCategory,t=>typeof t=="boolean")&&f(e.filters),isStorefrontCategoryMenuRequest=e=>r(e)&&o(e.categoryId,i)&&o(e.isArtificialCategory,t=>typeof t=="boolean")&&a(e.pagination),isStorefrontProductRequest=e=>r(e)&&n(e.productId)&&o(e.variationId,n)&&o(e.selectedOptionIndexes,t=>Array.isArray(t)&&t.every(i)),isStorefrontProductConfigurationRequest=e=>r(e)&&n(e.productId)&&r(e.selectedOptions)&&Object.values(e.selectedOptions).every(t=>typeof t=="string"||u(t))&&o(e.customPrice,t=>typeof t=="number"&&Number.isFinite(t)&&t>=0),isStorefrontRelatedProductsRequest=e=>r(e)&&n(e.productId),isProductId=n,isListener=e=>typeof e=="function";function validateRequest(e,t){if(!e(t))throw new StorefrontRuntimeError("INVALID_REQUEST","Storefront request is invalid")}async function getPage(e){return validateRequest(isStorefrontCatalogPageRequest,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.CATALOG_PAGE,t=>t.getCatalogPage(e))}async function getFilters(e){return validateRequest(isStorefrontCatalogFiltersRequest,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.CATALOG_FILTERS,t=>t.getCatalogFilters(e))}async function getCategoryMenu(e){return validateRequest(isStorefrontCategoryMenuRequest,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.CATEGORY_MENU,t=>t.getCategoryMenu(e))}function makeIdempotentDisposer(e){let t=!1;return()=>{t||(t=!0,e())}}async function subscribeChanges$1(e){return validateRequest(isListener,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.CATALOG_SUBSCRIPTION,t=>{const c=t.subscribeCatalogChanges(e);return makeIdempotentDisposer(c)})}const index$2={__proto__:null,getCategoryMenu,getFilters,getPage,subscribeChanges:subscribeChanges$1};async function get(e){return validateRequest(isStorefrontProductRequest,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.PRODUCT,t=>t.getProduct(e))}async function resolveConfiguration(e){return validateRequest(isStorefrontProductConfigurationRequest,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.PRODUCT_CONFIGURATION,t=>t.resolveProductConfiguration(e))}async function getRelated(e){return validateRequest(isStorefrontRelatedProductsRequest,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.RELATED_PRODUCTS,t=>t.getRelatedProducts(e))}async function subscribeChanges(e){return validateRequest(isListener,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.PRODUCTS_SUBSCRIPTION,t=>{const c=t.subscribeProductChanges(e);return makeIdempotentDisposer(c)})}const index$1={__proto__:null,get,getRelated,resolveConfiguration,subscribeChanges};async function getState(){return runStorefrontOperation(StorefrontRuntimeCapabilityValues.FAVORITES_STATE,e=>e.getFavoritesState())}async function add(e){return validateRequest(isProductId,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.FAVORITES_MUTATION,t=>t.addFavorite(e))}async function remove(e){return validateRequest(isProductId,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.FAVORITES_MUTATION,t=>t.removeFavorite(e))}async function subscribe(e){return validateRequest(isListener,e),runStorefrontOperation(StorefrontRuntimeCapabilityValues.FAVORITES_SUBSCRIPTION,async t=>{const c=await t.subscribeFavorites(e);return makeIdempotentDisposer(c)})}const index={__proto__:null,add,getState,remove,subscribe};exports.OnCartChanged=OnCartChanged;exports.OnConsentChanged=OnConsentChanged;exports.OnPageLoad=OnPageLoad;exports.OnPageLoaded=OnPageLoaded;exports.OnPageSwitch=OnPageSwitch;exports.OnSetProfile=OnSetProfile;exports.StorefrontRuntimeBridgeVersion=StorefrontRuntimeBridgeVersion;exports.StorefrontRuntimeCapabilityValues=StorefrontRuntimeCapabilityValues;exports.StorefrontRuntimeError=StorefrontRuntimeError;exports.formatCurrency=formatCurrency;exports.getAppPublicConfig=getAppPublicConfig;exports.getAppPublicToken=getAppPublicToken;exports.getInitializedWidgets=getInitializedWidgets;exports.getStorefrontLang=getStorefrontLang;exports.getTrackingConsent=getTrackingConsent;exports.getVisitorLocation=getVisitorLocation;exports.index=index$4;exports.index$1=index$2;exports.index$2=index$3;exports.index$3=index;exports.index$4=index$1;exports.isStorefrontV3=isStorefrontV3;exports.openPage=openPage;exports.setTrackingConsent=setTrackingConsent;
|
|
2
|
+
//# sourceMappingURL=ecom-headless.BF4ITfQc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecom-headless.BF4ITfQc.cjs","sources":["../../src/storefront/utils/wait-ecwid-api-operation.ts","../../src/storefront/callbacks/on-cart-changed.ts","../../src/storefront/callbacks/on-consent-changed.ts","../../src/storefront/callbacks/on-page-load.ts","../../src/storefront/callbacks/on-page-loaded.ts","../../src/storefront/callbacks/on-page-switch.ts","../../src/storefront/callbacks/on-set-profile.ts","../../src/storefront/methods/format-currency.ts","../../src/storefront/methods/get-app-public-config.ts","../../src/storefront/methods/get-app-public-token.ts","../../src/storefront/methods/get-initialized-widgets.ts","../../src/storefront/methods/get-storefront-lang.ts","../../src/storefront/methods/get-tracking-consent.ts","../../src/storefront/methods/get-visitor-location.ts","../../src/storefront/methods/is-storefront-v3.ts","../../src/storefront/methods/open-page.ts","../../src/storefront/methods/set-tracking-consent.ts","../../src/storefront/cart/get.ts","../../src/storefront/cart/add-product.ts","../../src/storefront/cart/remove-product.ts","../../src/storefront/cart/remove-products.ts","../../src/storefront/cart/clear.ts","../../src/storefront/cart/calculate-total.ts","../../src/storefront/cart/can-go-to-checkout.ts","../../src/storefront/cart/go-to-checkout.ts","../../src/storefront/customer/get.ts","../../src/storefront/customer/sign-out.ts","../../src/types/public/storefront/runtime.ts","../../src/storefront/runtime/storefront-runtime-error.ts","../../src/storefront/runtime/bridge.ts","../../src/storefront/runtime/request-validation.ts","../../src/storefront/catalog/get-page.ts","../../src/storefront/catalog/get-filters.ts","../../src/storefront/catalog/get-category-menu.ts","../../src/storefront/runtime/subscription.ts","../../src/storefront/catalog/subscribe-changes.ts","../../src/storefront/products/get.ts","../../src/storefront/products/resolve-configuration.ts","../../src/storefront/products/get-related.ts","../../src/storefront/products/subscribe-changes.ts","../../src/storefront/favorites/get-state.ts","../../src/storefront/favorites/mutate.ts","../../src/storefront/favorites/subscribe.ts"],"sourcesContent":["import { waitEcwidApiLoaded } from './wait-ecwid-api-loaded';\n\ntype OperationCallback<CallbackArguments extends unknown[]> = (...args: CallbackArguments) => void;\n\ninterface WaitEcwidApiOperationOptions<CallbackArguments extends unknown[]> {\n invoke: (callback: OperationCallback<CallbackArguments>) => void;\n callback?: OperationCallback<CallbackArguments>;\n getError?: (...args: CallbackArguments) => Error | undefined;\n}\n\nexport async function waitEcwidApiOperation<CallbackArguments extends unknown[]>({\n invoke,\n callback,\n getError,\n}: WaitEcwidApiOperationOptions<CallbackArguments>): Promise<void> {\n return waitEcwidApiLoaded(() => new Promise<void>((resolve, reject) => {\n let completed = false;\n\n const complete = (...args: CallbackArguments): void => {\n if (completed) {\n return;\n }\n completed = true;\n\n let callbackResult: unknown;\n try {\n callbackResult = callback?.(...args);\n } catch {\n // Consumer callback errors must not change the native operation result.\n }\n\n let getErrorThrew = false;\n let getErrorError: unknown;\n let operationError: Error | undefined;\n try {\n operationError = getError?.(...args);\n } catch (error) {\n getErrorThrew = true;\n getErrorError = error;\n }\n\n if (getErrorThrew || operationError !== undefined) {\n Promise.resolve(callbackResult).catch(() => undefined);\n reject(getErrorThrew ? getErrorError : operationError);\n return;\n }\n\n Promise.resolve(callbackResult).catch(() => undefined);\n resolve();\n };\n\n try {\n invoke(complete);\n } catch (error) {\n completed = true;\n reject(error);\n }\n }));\n}\n\nexport function getEcwidApiOperationError(\n operationName: string,\n success: boolean,\n nativeError?: unknown,\n): Error | undefined {\n if (success) {\n return undefined;\n }\n\n if (nativeError instanceof Error) {\n return nativeError;\n }\n\n const errorMessage = Array.isArray(nativeError)\n ? nativeError.filter(Boolean).join(', ')\n : typeof nativeError === 'string' ? nativeError.trim() : '';\n\n return new Error(errorMessage || `${operationName} failed`);\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, CartData } from '@/types';\n\n/**\n * This event allows tracking any cart changes excluding the payment method selection.\n * Its callback function with the cart argument contains details about the cart after the change event.\n *\n * OnCartChanged event triggers when:\n * - Cart is initialized, synced, or cleared\n * - Product has been added, updated (increased quantity, changed selected options), or removed from the cart\n * - Discount coupon or discount is applied or removed\n * - Shipping address is added or updated\n * - Shipping method is selected or changed\n *\n * @example\n *\n * ```ts\n * import { OnCartChanged } from '@lightspeed/ecom-headless';\n *\n * OnCartChanged.add((cart) => {\n * console.log(`Cart ID: ${cart.cartId}`);\n * console.log(`Items in cart: ${cart.productsQuantity}`);\n * console.log(`Cart total: ${cart.total}`);\n * });\n * ```\n */\nexport const OnCartChanged: EcwidApiPromise<CartData> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnCartChanged').add(callback),\n ),\n};\n","import { CustomerCookieConsentType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise } from '@/types';\n\n/**\n * This method allows you to catch any changes to the consent value.\n *\n * @example\n *\n * ```ts\n * import { OnConsentChanged, CustomerCookieConsent } from '@lightspeed/ecom-headless';\n *\n * OnConsentChanged.add((consent) => {\n * console.log(\"consent changed to \" + consent);\n * });\n * setTrackingConsent(CustomerCookieConsent.DECLINED);\n * // \"consent changed to DECLINED\"\n * ```\n*/\nexport const OnConsentChanged: EcwidApiPromise<CustomerCookieConsentType> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnConsentChanged').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise } from '@/types';\n\n/**\n * This event triggers instantly when the page DOM is loaded.\n *\n * This method doesn't wait for the Ecwid product browser and its contents to fully load\n * and therefore doesn't return any details about the opened page.\n *\n * @example\n *\n * ```ts\n * import { OnPageLoad } from '@lightspeed/ecom-headless';\n *\n * OnPageLoad.add(() => {\n * console.log(\"Page DOM has just loaded\");\n * });\n * ```\n*/\nexport const OnPageLoad: EcwidApiPromise<void> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageLoad').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, JsApiPage } from '@/types';\n\n/**\n * This method allows you to track the full page load –\n * a moment when both DOM and product browser are loaded and ready for customization.\n *\n * It contains a callback function with page argument containing information about a loaded page.\n *\n * @example\n *\n * ```ts\n * import { OnPageLoaded, JsApiPageValues } from '@lightspeed/ecom-headless';\n *\n * OnPageLoaded.add((page) => {\n * if (page.type === JsApiPageValues.PRODUCT) {\n * console.log(page);\n * }\n * });\n * // {\n * // \"type\":\"PRODUCT\",\n * // \"categoryId\":0,\n * // \"hasPrevious\":false,\n * // \"mainCategoryId\":0,\n * // \"name\":\"Desk Black 101x50x76.5 cm Engineered Wood\",\n * // \"nameTranslated\":{\n * // \"cs\":\"\",\n * // \"en\":\"Desk Black 101x50x76.5 cm Engineered Wood\"\n * // },\n * // \"productId\":561386461\n * // }\n * ```\n*/\nexport const OnPageLoaded: EcwidApiPromise<JsApiPage> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageLoaded').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, JsApiPage } from '@/types';\n\n/**\n * This method allows tracking and preventing page switches on the storefront.\n * It is triggered when a user is about to switch a page (a new page is not yet loaded).\n *\n * The method works synchronously and contains the page argument in its callback function.\n * Use it to identify the page where users go and prevent page loading by returning a false value.\n *\n * @example\n *\n * ```ts\n * import { OnPageSwitch, JsApiPageValues } from '@lightspeed/ecom-headless';\n *\n * OnPageSwitch.add((page) => {\n * if (page.type === JsApiPageValues.PRODUCT) {\n * console.log(page);\n * }\n * });\n * // {\n * // \"type\":\"PRODUCT\",\n * // \"categoryId\":0,\n * // \"hasPrevious\":false,\n * // \"mainCategoryId\":0,\n * // \"name\":\"Desk Black 101x50x76.5 cm Engineered Wood\",\n * // \"nameTranslated\":{\n * // \"cs\":\"\",\n * // \"en\":\"Desk Black 101x50x76.5 cm Engineered Wood\"\n * // },\n * // \"productId\":561386461\n * // }\n * ```\n*/\nexport const OnPageSwitch: EcwidApiPromise<JsApiPage> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageSwitch').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, CustomerData } from '@/types';\n\n/**\n * This method allows you to track a moment when customers log in and out on the storefront.\n * It contains a callback function with customer argument when a customer logs in, and null if a customer has logged out.\n *\n * @example\n *\n * ```ts\n * import { OnSetProfile } from '@lightspeed/ecom-headless';\n *\n * OnSetProfile.add((customer) => {\n * console.log(customer.email);\n * // \"ec.apps@lightspeedhq.com\"\n * });\n * ```\n*/\nexport const OnSetProfile: EcwidApiPromise<CustomerData | null> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnSetProfile').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method allows you to get store currency settings on the storefront.\n * It is useful if you need to add a widget that displays some price to customers.\n *\n * It accepts a numeric price as an argument and responds with a formatted price\n * using store settings: currency symbol, and delimiter symbol and precision.\n *\n * @example\n *\n * ```ts\n * import { formatCurrency } from '@lightspeed/ecom-headless';\n *\n * const formattedPrice = await formatCurrency(12.99);\n * console.log(formattedPrice);\n * // \"$12.99\"\n * ```\n*/\nexport async function formatCurrency(amount: number): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('formatCurrency')(amount),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts an app `client_id` as an argument and responds with a\n * \"public config\" for the app. This config is the data saved in App Storage\n * as a public key.\n *\n * Read more about setting up App Storage:\n * {@link https://docs.ecwid.com/launch-apps/native-and-external-apps/build-user-settings-page-for-ecwid-admin/manage-personal-user-settings-storage}.\n *\n * @example\n * ```ts\n * import { getAppPublicConfig } from '@lightspeed/ecom-headless';\n *\n * const publicConfig = await getAppPublicConfig('client_id');\n * console.log(JSON.parse(publicConfig));\n * // {\"key\": \"public\",\"value\": \"{'color':'red','text':'Email button','border-radius':'3px'}\"}\n * ```\n */\n\nexport async function getAppPublicConfig(clientId: string): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getAppPublicConfig')(clientId),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts app client_id as an argument and responds with a public access token for the app.\n * Public tokens are safe to use on the storefront, as they won't be able to reveal any private store data.\n *\n * @example\n *\n * ```ts\n * import { getAppPublicToken } from '@lightspeed/ecom-headless';\n *\n * const publicToken = await getAppPublicToken('client_id');\n * console.log(publicToken);\n * // \"public_qKsUqKkNXzcj9DejwMUqEkY2q2E6BXM9\"\n * ```\n*/\nexport async function getAppPublicToken(clientId: string): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getAppPublicToken')(clientId),\n );\n}\n","import { EcwidWidgetType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method responds with a list of widgets currently loaded on the website.\n *\n * @example\n *\n * ```ts\n * import { getInitializedWidgets } from '@lightspeed/ecom-headless';\n * const widgets = await getInitializedWidgets();\n * console.log(widgets);\n * // [\"Minicart\", \"SearchPanel\", \"ProductBrowser\"]\n * ```\n*/\nexport async function getInitializedWidgets(): Promise<EcwidWidgetType[]> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getInitializedWidgets')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method responds with the current storefront language in ISO 639-1 language code.\n * Use it to dynamically translate custom content on the page.\n *\n * @example\n *\n * ```ts\n * import { getStorefrontLang } from '@lightspeed/ecom-headless';\n *\n * const lang = await getStorefrontLang();\n * console.log(lang);\n * // \"en\"\n * ```\n*/\nexport async function getStorefrontLang(): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getStorefrontLang')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { TrackingConsent } from '@/types';\n\n/**\n * This method receives the customer's answer to the cookie consent banner.\n * Use it to define what cookies your application can collect.\n *\n * If the cookie consent value is overridden by the JS method or config,\n * getTrackingConsent() returns the new value added by JS method/config.\n *\n * @example\n *\n * ```ts\n * import { getTrackingConsent } from '@lightspeed/ecom-headless';\n *\n * const trackingConsent = await getTrackingConsent();\n * console.log(trackingConsent);\n * // { userResponse: \"ACCEPTED\", askConsent: true }\n * ```\n*/\nexport async function getTrackingConsent(): Promise<TrackingConsent> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getTrackingConsent')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { VisitorLocation } from '@/types';\n\n/**\n * This method gets the visitor's location based on their shipping or billing address (when entered), or IP.\n * The call works even for signed-out customers.\n *\n * @example\n *\n * ```ts\n * import { getVisitorLocation } from '@lightspeed/ecom-headless';\n *\n * const location = await getVisitorLocation();\n * console.log(location);\n * // { countryCode: \"US\", stateCode: \"NE\", source: \"IP_ADDRESS\" }\n * ```\n*/\nexport async function getVisitorLocation(): Promise<VisitorLocation> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getVisitorLocation')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method is useful for public applications developed before 2024.\n * It helps apps to adapt their design by detecting the old storefront version.\n *\n * All stores created in 2024 and later are using the latest storefront without the ability to switch the version.\n *\n * @example\n *\n * ```ts\n * import { isStorefrontV3 } from '@lightspeed/ecom-headless';\n *\n * const isStorefrontV3 = await isStorefrontV3();\n * console.log(isStorefrontV3);\n * // true\n * ```\n*/\nexport async function isStorefrontV3(): Promise<boolean> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('isStorefrontV3')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method allows you to open a specific page on the storefront. The function accepts page slugs and additional parameters in its arguments.\n *\n * For example, you can use these redirects in different promo activities:\n * - Create a popup with a sale product and redirect customers to this product on click.\n * - Offer customers to log in to receive some bonus.\n * - Redirect customers to the search page with pre-configured terms showing promo products.\n *\n * @example\n *\n * ```ts\n * import { openPage } from '@lightspeed/ecom-headless';\n *\n * // Redirect customers to the cart page\n * openPage('cart');\n *\n * // Open search page with shoes of one brand\n * openPage('search', {\n * keyword: 'shoes',\n * attribute_Brand: 'Nike',\n * inventory: 'instock'\n * });\n * ```\n *\n * @see Full list of available pages: https://docs.ecwid.com/storefronts/open-page-on-the-storefront/overview-of-open-page-options#full-list-of-available-pages\n *\n * Learn more about pages that can be opened with additional params:\n *\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-product-pages-with-params Open product pages with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-category-pages-with-params Open category pages with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-search-page-with-params Open search page with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-account-pages-with-params Open account pages with params}\n*/\nexport async function openPage(\n page: string,\n options?: Record<string, unknown>,\n): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('openPage')(page, options),\n );\n}\n","import { CustomerCookieConsentType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts an argument matching one of the following values:\n *\n * \"UNDEFINED\": Customer hasn't given their consent yet.\n *\n * \"ACCEPTED\": Collect all types of cookies.\n *\n * \"DECLINED\": Collect only essential cookies.\n *\n * \"ANALYTICS_ONLY\": Collect essential and analytics cookies only.\n *\n * \"PERSONALIZATION_ONLY\": Collect essential and personalization cookies.\n *\n * @example\n *\n * ```ts\n * import { setTrackingConsent, getTrackingConsent, CustomerCookieConsentValues } from '@lightspeed/ecom-headless';\n *\n * await setTrackingConsent(CustomerCookieConsentValues.DECLINED);\n * const trackingConsent = await getTrackingConsent();\n * console.log(trackingConsent);\n * // { userResponse: \"DECLINED\", askConsent: false }\n * ```\n*/\nexport async function setTrackingConsent(cookieConsent: CustomerCookieConsentType): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('setTrackingConsent')(cookieConsent),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CartGetCallback } from '@/types';\n\n/**\n * This method allows you to receive full information about the current shopping cart.\n * The response is available in the cart callback.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.get((cart) => {\n * console.log(`Cart has ${cart.productsQuantity} products`);\n * console.log(`Cart ID: ${cart.cartId}`);\n * cart.items.forEach(item => {\n * console.log(`${item.product.name} - Quantity: ${item.quantity}`);\n * });\n * });\n * ```\n */\nexport async function get(callback?: CartGetCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartGetCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').get(completionCallback),\n callback,\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { AddProductParameter, CartAddProductCallback } from '@/types';\nimport type { NativeAddProductData } from '@/types/private/native-storefront-api';\n\ntype AddProductData = Exclude<AddProductParameter, number>;\n\n/**\n * This method allows you to add a new product position to the shopping cart.\n * It accepts either a product ID or a product object with extended details including\n * product ID, quantity, selected options, or subscription product settings.\n *\n * When you use this method, it first checks the product by specified ID for stock and variations.\n * If the selected options match one of the variations, Ecwid will check its stock first.\n * If you don't have enough stock to add a product, Ecwid adds the available quantity.\n * If the product is out of stock, nothing is added to the shopping cart.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Add product by ID with default quantity\n * Cart.addProduct(10, (success, product, cart) => {\n * if (success && product !== null) {\n * console.log('Product added successfully');\n * }\n * });\n *\n * // Add product with specific options and quantity\n * Cart.addProduct({\n * id: 10,\n * quantity: 3,\n * options: {\n * \"Size\": \"L\",\n * \"Extras\": [\"Gift wrap\", \"Greeting card\"]\n * }\n * }, (success, product, cart, error) => {\n * if (success && product !== null) {\n * console.log(`Added ${product.quantity} items to cart`);\n * } else {\n * console.error('Failed to add product:', error);\n * }\n * });\n *\n * // Add subscription product\n * Cart.addProduct({\n * id: 15,\n * quantity: 1,\n * recurringChargeSettings: {\n * recurringInterval: \"MONTH\",\n * recurringIntervalCount: 1,\n * }\n * });\n * ```\n */\nexport async function addProduct(\n product: AddProductParameter,\n callback?: CartAddProductCallback,\n): Promise<void> {\n const embeddedCallback = typeof product === 'number'\n ? undefined\n : (product as AddProductData & { callback?: unknown }).callback;\n const consumerCallback = typeof embeddedCallback === 'function'\n ? embeddedCallback as CartAddProductCallback\n : callback;\n\n return waitEcwidApiOperation<Parameters<CartAddProductCallback>>({\n invoke: (completionCallback) => {\n if (typeof product === 'number') {\n getEcwidWindowMethod('Cart').addProduct(product, completionCallback);\n return;\n }\n\n const productWithCallback: NativeAddProductData = {\n ...product,\n callback: completionCallback,\n };\n getEcwidWindowMethod('Cart').addProduct(productWithCallback);\n },\n callback: consumerCallback,\n getError: (success, _product, _cart, error) => getEcwidApiOperationError('Cart.addProduct', success, error),\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CartRemoveProductCallback } from '@/types';\n\n/**\n * This method removes product position from the shopping cart entirely.\n * The specified product will be removed completely even if its quantity is greater than zero.\n *\n * This method completely removes the product from the cart. If you want to decrease its quantity,\n * use Cart.get() to save product details, then remove the product with Cart.removeProduct()\n * and add it back with all the same details except for the decreased quantity with Cart.addProduct().\n *\n * To remove a product position from the cart, first, you need to get an index with the Cart.get() method.\n * Position of the product in the items array is the index. For example, if you have two different\n * products added to the cart, the first product has an index of 0, and the second has an index of 1.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Remove the first product from cart\n * Cart.removeProduct(0, (success, product, itemsRemovedQuantity, cart, error) => {\n * if (success && product !== undefined) {\n * console.log(`Removed ${itemsRemovedQuantity} items from cart`);\n * console.log(`Product removed: ${product.name}`);\n * } else {\n * console.error('Failed to remove product:', error);\n * }\n * });\n *\n * // Remove product without callback\n * Cart.removeProduct(1);\n * ```\n */\nexport async function removeProduct(\n index: number,\n callback?: CartRemoveProductCallback,\n): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartRemoveProductCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').removeProduct(index, completionCallback),\n callback,\n getError: (success, _product, _quantity, _cart, error) => getEcwidApiOperationError('Cart.removeProduct', success, error),\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CartRemoveProductsCallback } from '@/types';\n\n/**\n * This method works in the same way as Cart.removeProduct(), but allows you to remove\n * multiple items from the cart at once by passing an array of indices.\n *\n * Each index represents the position of a product in the cart's items array.\n * All specified products will be removed completely even if their quantity is greater than zero.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Remove first and second products from cart\n * Cart.removeProducts([0, 1], (success, products, itemsRemovedQuantity, cart, error) => {\n * if (success && products !== undefined) {\n * console.log(`Removed ${itemsRemovedQuantity} total items from cart`);\n * console.log(`Removed ${products.length} cart positions`);\n * } else {\n * console.error('Failed to remove products:', error);\n * }\n * });\n *\n * // Remove multiple products without callback\n * Cart.removeProducts([0, 2, 3]);\n * ```\n */\nexport async function removeProducts(\n indices: number[],\n callback?: CartRemoveProductsCallback,\n): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartRemoveProductsCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').removeProducts(indices, completionCallback),\n callback,\n getError: (success, _products, _quantity, _cart, error) => getEcwidApiOperationError('Cart.removeProducts', success, error),\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CartClearCallback } from '@/types';\n\n/**\n * This method allows you to clear all details from the shopping cart.\n * If the method clears the cart successfully, you receive true in the success argument.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.clear((success, error) => {\n * if (success) {\n * console.log(\"Cart was cleared\");\n * } else {\n * console.log(\"Cart clear failed. Error message: \" + error);\n * }\n * });\n *\n * // Clear without callback\n * Cart.clear();\n * ```\n */\nexport async function clear(callback?: CartClearCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartClearCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').clear(completionCallback),\n callback,\n getError: (success, error) => getEcwidApiOperationError('Cart.clear', success, error),\n });\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CartCalculateTotalCallback } from '@/types';\n\n/**\n * This method calculates the current cart asynchronously and passes the result as an order\n * callback argument with a snapshot of the generated order with essential details.\n *\n * The order object includes subtotals, taxes, discounts, shipping costs, and a full cart snapshot.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.calculateTotal((order) => {\n * console.log(`Order total: ${order.total}`);\n * console.log(`Subtotal: ${order.subtotal}`);\n * console.log(`Tax: ${order.tax}`);\n * console.log(`Shipping: ${order.shipping}`);\n * console.log(`Items in cart: ${order.cart.productsQuantity}`);\n *\n * // Access individual cart items\n * order.cart.items.forEach(item => {\n * console.log(`${item.product.name} - Qty: ${item.quantity}`);\n * });\n * });\n * ```\n */\nexport async function calculateTotal(callback?: CartCalculateTotalCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartCalculateTotalCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').calculateTotal(completionCallback),\n callback,\n });\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method checks whether you can send customers to the first step of the checkout called the shopping cart.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * const canGoToCheckout = await Cart.canGotoCheckout();\n *\n * if (canGoToCheckout) {\n * Cart.gotoCheckout();\n * }\n * ```\n */\nexport async function canGotoCheckout(): Promise<boolean> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').canGotoCheckout(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CartGoToCheckoutCallback } from '@/types';\n\n/**\n * This method sends a customer to the first or second checkout step.\n *\n * This method works differently depending on the Ecwid admin > Settings > Legal > Terms & Conditions toggle\n * and whether the customer has already left an email in the shopping cart:\n *\n * - No email: the customer is sent to the shopping cart page.\n * - Email + toggle disabled: the customer is sent to the second checkout page (address details)\n * - Email + toggle disabled + no shipping: the customer is sent to the payment page.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.gotoCheckout(() => {\n * console.log(\"Checkout process started\");\n * });\n * ```\n */\nexport async function gotoCheckout(callback?: CartGoToCheckoutCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartGoToCheckoutCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').gotoCheckout(completionCallback),\n callback,\n });\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CustomerGetCallback } from '@/types';\n\n/**\n * This method receives all data on the customer currently logged in to the store.\n * If no customer is logged in, the method returns null.\n *\n * @example\n *\n * ```ts\n * import { Customer } from '@lightspeed/ecom-headless';\n *\n * Customer.get((customer) => {\n * if (customer === null) {\n * console.log('No customer is logged in');\n * } else {\n * console.log(customer.email);\n * }\n * });\n * ```\n*/\nexport async function get(callback?: CustomerGetCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CustomerGetCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Customer').get(completionCallback),\n callback,\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CustomerSignOutCallback } from '@/types';\n\n/**\n * This method signs out customer from their account.\n *\n * Error message has value only if success is false.\n *\n * @example\n *\n * ```ts\n * import { Customer } from '@lightspeed/ecom-headless';\n *\n * Customer.signOut((success, error) => {\n * if (success === true) {\n * console.log('Customer signed out');\n * } else {\n * console.log('Signout failed. Error message: ' + error);\n * }\n * });\n * ```\n*/\nexport async function signOut(callback?: CustomerSignOutCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CustomerSignOutCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Customer').signOut(completionCallback),\n callback,\n getError: (success, error) => getEcwidApiOperationError('Customer.signOut', success, error),\n });\n}\n","export const StorefrontRuntimeBridgeVersion = 1 as const;\n\nexport const StorefrontRuntimeCapabilityValues = {\n CATALOG_PAGE: 'CATALOG_PAGE',\n CATALOG_FILTERS: 'CATALOG_FILTERS',\n CATEGORY_MENU: 'CATEGORY_MENU',\n CATALOG_SUBSCRIPTION: 'CATALOG_SUBSCRIPTION',\n PRODUCT: 'PRODUCT',\n PRODUCT_CONFIGURATION: 'PRODUCT_CONFIGURATION',\n RELATED_PRODUCTS: 'RELATED_PRODUCTS',\n PRODUCTS_SUBSCRIPTION: 'PRODUCTS_SUBSCRIPTION',\n FAVORITES_STATE: 'FAVORITES_STATE',\n FAVORITES_MUTATION: 'FAVORITES_MUTATION',\n FAVORITES_SUBSCRIPTION: 'FAVORITES_SUBSCRIPTION',\n} as const;\n\nexport type StorefrontRuntimeCapability = typeof StorefrontRuntimeCapabilityValues[\n keyof typeof StorefrontRuntimeCapabilityValues\n];\n\nexport type StorefrontCatalogProductSortOrder =\n | 'DEFINED_BY_STORE_OWNER'\n | 'ADDED_TIME_DESC'\n | 'PRICE_ASC'\n | 'PRICE_DESC'\n | 'NAME_ASC'\n | 'NAME_DESC'\n | 'IN_STORE_RECEIVED_DATE_DESC';\n\nexport interface StorefrontProductFilters {\n readonly categories?: readonly number[];\n readonly keyword?: string;\n readonly priceFrom?: number;\n readonly priceTo?: number;\n readonly inventory?: 'instock' | 'outofstock';\n readonly uncategorized?: boolean;\n readonly onSale?: 'onsale' | 'notonsale';\n readonly attributes?: Readonly<Record<string, readonly string[]>>;\n readonly options?: Readonly<Record<string, readonly string[]>>;\n readonly sku?: string;\n readonly swatch?: Readonly<Record<string, readonly string[]>>;\n readonly locations?: readonly string[];\n}\n\nexport interface StorefrontPagination {\n readonly offset: number;\n readonly limit: number;\n}\n\nexport interface StorefrontListingRequest {\n readonly filters: StorefrontProductFilters;\n readonly sortBy: StorefrontCatalogProductSortOrder;\n readonly pagination: StorefrontPagination;\n}\n\nexport interface StorefrontCatalogPageRequest {\n readonly categoryId?: number;\n readonly isArtificialCategory?: boolean;\n readonly listing: StorefrontListingRequest;\n}\n\nexport interface StorefrontCatalogFiltersRequest {\n readonly categoryId?: number;\n readonly isArtificialCategory?: boolean;\n readonly filters: StorefrontProductFilters;\n}\n\nexport interface StorefrontCategoryMenuRequest {\n readonly categoryId?: number;\n readonly isArtificialCategory?: boolean;\n readonly pagination: StorefrontPagination;\n}\n\nexport interface StorefrontProductRequest {\n readonly productId: number;\n readonly variationId?: number;\n readonly selectedOptionIndexes?: readonly number[];\n}\n\nexport type StorefrontSelectedOptions = Readonly<Record<string, string | readonly string[]>>;\n\nexport interface StorefrontProductConfigurationRequest {\n readonly productId: number;\n readonly selectedOptions: StorefrontSelectedOptions;\n readonly customPrice?: number;\n}\n\nexport interface StorefrontRelatedProductsRequest {\n readonly productId: number;\n}\n\nexport interface StorefrontPicture {\n readonly alt?: string;\n readonly width: number;\n readonly height: number;\n readonly image160pxUrl?: string;\n readonly image400pxUrl?: string;\n readonly image800pxUrl?: string;\n readonly image1500pxUrl?: string;\n readonly imageOriginalUrl?: string;\n}\n\nexport interface StorefrontProductMedia extends StorefrontPicture {\n readonly id: string;\n readonly type: 'PICTURE' | 'VIDEO';\n readonly isMain: boolean;\n readonly video?: {\n readonly embedHtml: string;\n readonly url: string;\n readonly width?: number;\n readonly height?: number;\n };\n}\n\nexport interface StorefrontCategorySummary {\n readonly id: number;\n readonly name: string;\n readonly media?: StorefrontPicture;\n readonly slugs: {\n readonly forRouteWithId: string;\n readonly forRouteWithoutId?: string;\n };\n}\n\nexport interface StorefrontCategoryDetails extends StorefrontCategorySummary {\n readonly description: string;\n readonly categoryPath: readonly StorefrontCategorySummary[];\n readonly seo: {\n readonly title?: string;\n readonly description?: string;\n readonly canonicalUrl?: string;\n };\n}\n\nexport interface StorefrontProductAttribute {\n readonly id: number;\n readonly name: string;\n readonly type: string;\n readonly value: string;\n readonly separator: string;\n readonly isNameAndValueSwapped: boolean;\n}\n\nexport interface StorefrontOptionChoice {\n readonly choiceId: string;\n readonly choiceName: string;\n readonly modifierFormatted: string;\n readonly visibility?: string;\n readonly hexCodes?: readonly string[];\n}\n\nexport interface StorefrontProductOption {\n readonly type: string;\n readonly optionId: string;\n readonly optionText: string;\n readonly required: boolean;\n readonly placeholder?: string;\n readonly maxLength?: number;\n readonly useImageAsSwatchSelector?: boolean;\n readonly selected?: string | readonly string[];\n readonly choices: readonly StorefrontOptionChoice[];\n}\n\nexport interface StorefrontAppliedTax {\n readonly name: string;\n readonly percent: number;\n readonly price: number;\n}\n\nexport interface StorefrontWholesalePrice {\n readonly quantity: number;\n readonly price: number;\n readonly priceFormatted: string;\n readonly discountPercent: number;\n}\n\nexport interface StorefrontPriceRange {\n readonly minPrice: number;\n readonly maxPrice: number;\n readonly minPriceFormatted: string;\n readonly maxPriceFormatted: string;\n readonly minCompareToPrice: number;\n readonly maxCompareToPrice: number;\n}\n\nexport interface StorefrontProductPrice {\n readonly price: number;\n readonly priceFormatted: string;\n readonly compareToPrice?: number;\n readonly compareToPriceFormatted?: string;\n readonly range?: StorefrontPriceRange;\n readonly lowestPrice?: {\n readonly labelForProductList: string;\n readonly labelForProductDetails: string;\n };\n readonly appliedTaxes: readonly StorefrontAppliedTax[];\n readonly wholesalePrices: readonly StorefrontWholesalePrice[];\n}\n\nexport interface StorefrontProductInventory {\n readonly isSoldOut: boolean;\n readonly isPreorderAllowed: boolean;\n readonly isShippingRequired: boolean;\n readonly quantity?: number;\n readonly warningLimit?: number;\n readonly minPurchaseQuantity?: number;\n readonly maxPurchaseQuantity?: number;\n readonly weight?: {\n readonly value: number;\n readonly formattedValue: string;\n };\n readonly dimensions?: {\n readonly length: number;\n readonly width: number;\n readonly height: number;\n };\n}\n\nexport type StorefrontPurchaseKind = 'NORMAL' | 'CUSTOM_PRICE' | 'SUBSCRIPTION' | 'UNSUPPORTED';\n\nexport interface StorefrontProductConfiguration {\n readonly variationId?: number;\n readonly sku?: string;\n readonly selectedOptions: StorefrontSelectedOptions;\n readonly options: readonly StorefrontProductOption[];\n readonly media: readonly StorefrontProductMedia[];\n readonly price: StorefrontProductPrice;\n readonly inventory: StorefrontProductInventory;\n readonly attributes: readonly StorefrontProductAttribute[];\n readonly purchaseKind: StorefrontPurchaseKind;\n readonly isSelectionComplete: boolean;\n readonly isPurchasable: boolean;\n}\n\nexport interface StorefrontProduct {\n readonly id: number;\n readonly variationId?: number;\n readonly name: string;\n readonly subtitle: string;\n readonly description: string;\n readonly sku?: string;\n readonly urls: {\n readonly directPageUrl: string;\n readonly proxyLinkUrl: string;\n };\n readonly categoryPaths: readonly {\n readonly isDefault: boolean;\n readonly items: readonly StorefrontCategorySummary[];\n }[];\n readonly attributes: readonly StorefrontProductAttribute[];\n readonly options: readonly StorefrontProductOption[];\n readonly media: readonly StorefrontProductMedia[];\n readonly gridMedia: readonly StorefrontProductMedia[];\n readonly price: StorefrontProductPrice;\n readonly inventory: StorefrontProductInventory;\n readonly rating: number;\n readonly reviewsPublishedCount: number;\n readonly ribbon?: {\n readonly text: string;\n readonly color: string;\n };\n readonly flags: {\n readonly canAddToBagSilently: boolean;\n readonly hasRelatedProducts: boolean;\n readonly hasSizeChart: boolean;\n readonly isGiftCard: boolean;\n };\n readonly defaultConfiguration: StorefrontProductConfiguration;\n}\n\nexport interface StorefrontExpandedCategory {\n readonly category: StorefrontCategoryDetails;\n readonly subcategories: readonly StorefrontCategorySummary[];\n readonly products: readonly StorefrontProduct[];\n readonly totalProductsCount: number;\n readonly hasMoreProducts: boolean;\n}\n\nexport interface StorefrontCatalogPage {\n readonly expandedCategories: readonly StorefrontExpandedCategory[];\n readonly collapsedCategories: readonly StorefrontCategorySummary[];\n}\n\nexport interface StorefrontFilterValue {\n readonly filterId: string | number;\n readonly filterName?: string;\n readonly productCount: number;\n}\n\nexport interface StorefrontCatalogValuesFilter {\n readonly type: 'INVENTORY' | 'ON_SALE' | 'CATEGORIES' | 'LOCATIONS';\n readonly values: readonly StorefrontFilterValue[];\n readonly totalCount?: number;\n}\n\nexport interface StorefrontCatalogPriceFilter {\n readonly type: 'PRICE';\n readonly values?: {\n readonly min: number;\n readonly max: number;\n };\n}\n\nexport interface StorefrontCatalogOptionFilter {\n readonly type: 'OPTION' | 'SWATCH';\n readonly optionId: string;\n readonly optionName: string;\n readonly displayComponent?: string;\n readonly values: readonly (StorefrontFilterValue & { readonly hexCodes?: readonly string[] })[];\n}\n\nexport interface StorefrontCatalogAttributeFilter {\n readonly type: 'ATTRIBUTE';\n readonly attributeId: string;\n readonly attributeName: string;\n readonly values: readonly StorefrontFilterValue[];\n}\n\nexport interface StorefrontCatalogMarkerFilter {\n readonly type: 'SEARCH' | 'SKU';\n}\n\nexport type StorefrontCatalogFilter =\n | StorefrontCatalogValuesFilter\n | StorefrontCatalogPriceFilter\n | StorefrontCatalogOptionFilter\n | StorefrontCatalogAttributeFilter\n | StorefrontCatalogMarkerFilter;\n\nexport interface StorefrontCatalogFilters {\n readonly filters: readonly StorefrontCatalogFilter[];\n readonly productCount?: number;\n}\n\nexport interface StorefrontCategoryMenuItem {\n readonly id: number;\n readonly name: string;\n readonly slugs?: {\n readonly forRouteWithId: string;\n readonly forRouteWithoutId?: string;\n };\n readonly productCount?: number;\n readonly hasChildren?: boolean;\n readonly uncategorized?: boolean;\n}\n\nexport interface StorefrontCategoryMenu {\n readonly currentPath: readonly StorefrontCategoryMenuItem[];\n readonly totalCount: number;\n readonly limit: number;\n readonly offset: number;\n readonly page: number;\n readonly categories: readonly StorefrontCategoryMenuItem[];\n readonly productCount: number;\n}\n\nexport interface StorefrontFavoritesState {\n readonly productIds: readonly number[];\n readonly count: number;\n readonly customerState: 'GUEST' | 'AUTHENTICATED';\n}\n","export type StorefrontRuntimeErrorCode =\n | 'STOREFRONT_RUNTIME_UNAVAILABLE'\n | 'UNSUPPORTED_STOREFRONT_VERSION'\n | 'UNSUPPORTED_CAPABILITY'\n | 'INVALID_REQUEST'\n | 'NOT_FOUND'\n | 'UNAUTHORIZED'\n | 'OUT_OF_STOCK'\n | 'INCOMPLETE_PRODUCT_SELECTION'\n | 'PREVIEW_MUTATION_DISABLED'\n | 'NETWORK_ERROR'\n | 'UNKNOWN_ERROR';\n\nexport class StorefrontRuntimeError extends Error {\n public readonly code: StorefrontRuntimeErrorCode;\n\n public override readonly cause?: unknown;\n\n public constructor(code: StorefrontRuntimeErrorCode, message: string, cause?: unknown) {\n super(message);\n this.name = 'StorefrontRuntimeError';\n this.code = code;\n this.cause = cause;\n }\n}\n","import { waitEcwidApiLoaded } from '@/storefront/utils/wait-ecwid-api-loaded';\nimport type { StorefrontBridgeError, StorefrontBridgeV1 } from '@/types/private/storefront-bridge';\nimport {\n StorefrontRuntimeBridgeVersion,\n type StorefrontRuntimeCapability,\n} from '@/types/public/storefront';\n\nimport { StorefrontRuntimeError, type StorefrontRuntimeErrorCode } from './storefront-runtime-error';\n\nconst BRIDGE_ERROR_CODES = new Set<StorefrontRuntimeErrorCode>([\n 'INVALID_REQUEST',\n 'NOT_FOUND',\n 'UNAUTHORIZED',\n 'OUT_OF_STOCK',\n 'INCOMPLETE_PRODUCT_SELECTION',\n 'PREVIEW_MUTATION_DISABLED',\n 'NETWORK_ERROR',\n 'UNKNOWN_ERROR',\n]);\n\nfunction hasBridgeErrorCode(error: unknown): error is StorefrontBridgeError & { code: StorefrontRuntimeErrorCode } {\n return error instanceof Error\n && 'code' in error\n && typeof error.code === 'string'\n && BRIDGE_ERROR_CODES.has(error.code as StorefrontRuntimeErrorCode);\n}\n\nexport function toStorefrontRuntimeError(error: unknown): StorefrontRuntimeError {\n if (error instanceof StorefrontRuntimeError) {\n return error;\n }\n if (hasBridgeErrorCode(error)) {\n return new StorefrontRuntimeError(error.code, error.message);\n }\n return new StorefrontRuntimeError('UNKNOWN_ERROR', 'Storefront operation failed');\n}\n\nexport async function getStorefrontBridge(\n capability: StorefrontRuntimeCapability,\n): Promise<StorefrontBridgeV1> {\n let ecwid = globalThis.window?.Ecwid;\n if (ecwid?.Headless === undefined) {\n await waitEcwidApiLoaded(() => undefined);\n ecwid = globalThis.window?.Ecwid;\n }\n if (ecwid === undefined) {\n throw new StorefrontRuntimeError(\n 'STOREFRONT_RUNTIME_UNAVAILABLE',\n 'Ecwid Storefront runtime is not available',\n );\n }\n const bridge = ecwid.Headless;\n if (bridge === undefined) {\n throw new StorefrontRuntimeError(\n 'UNSUPPORTED_STOREFRONT_VERSION',\n 'This Storefront version does not support Headless runtime operations',\n );\n }\n if (bridge.version !== StorefrontRuntimeBridgeVersion) {\n throw new StorefrontRuntimeError(\n 'UNSUPPORTED_STOREFRONT_VERSION',\n `Unsupported Headless Storefront bridge version: ${String(bridge.version)}`,\n );\n }\n if (!bridge.capabilities.includes(capability)) {\n throw new StorefrontRuntimeError(\n 'UNSUPPORTED_CAPABILITY',\n `Storefront Headless capability is not available: ${capability}`,\n );\n }\n return bridge;\n}\n\nexport async function runStorefrontOperation<Result>(\n capability: StorefrontRuntimeCapability,\n operation: (bridge: StorefrontBridgeV1) => Promise<Result> | Result,\n): Promise<Result> {\n try {\n const bridge = await getStorefrontBridge(capability);\n return await operation(bridge);\n } catch (error) {\n throw toStorefrontRuntimeError(error);\n }\n}\n","import type {\n StorefrontCatalogFiltersRequest,\n StorefrontCatalogPageRequest,\n StorefrontCategoryMenuRequest,\n StorefrontProductConfigurationRequest,\n StorefrontProductFilters,\n StorefrontProductRequest,\n StorefrontRelatedProductsRequest,\n} from '@/types/public/storefront';\n\nimport { StorefrontRuntimeError } from './storefront-runtime-error';\n\n// Keep runtime validation dependency-free: zod/mini increased the Storefront bundle to about 9.3 KB,\n// and a full Zod import to about 58 KB, while this standalone entry point has a 3.7 KB size limit.\ntype RequestValidator<T> = (value: unknown) => value is T;\n\nconst SORT_ORDERS = new Set([\n 'DEFINED_BY_STORE_OWNER',\n 'ADDED_TIME_DESC',\n 'PRICE_ASC',\n 'PRICE_DESC',\n 'NAME_ASC',\n 'NAME_DESC',\n 'IN_STORE_RECEIVED_DATE_DESC',\n]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isPositiveInteger(value: unknown): value is number {\n return Number.isSafeInteger(value) && Number(value) > 0;\n}\n\nfunction isNonNegativeInteger(value: unknown): value is number {\n return Number.isSafeInteger(value) && Number(value) >= 0;\n}\n\nfunction isOptional<T>(value: unknown, validator: RequestValidator<T>): value is T | undefined {\n return value === undefined || validator(value);\n}\n\nfunction isStringArray(value: unknown): value is readonly string[] {\n return Array.isArray(value) && value.every((item) => typeof item === 'string');\n}\n\nfunction isStringArrayRecord(value: unknown): value is Readonly<Record<string, readonly string[]>> {\n return isRecord(value) && Object.values(value).every(isStringArray);\n}\n\nfunction isPagination(value: unknown): boolean {\n return isRecord(value)\n && isNonNegativeInteger(value.offset)\n && isPositiveInteger(value.limit)\n && value.limit <= 200;\n}\n\nfunction isProductFilters(value: unknown): value is StorefrontProductFilters {\n return isRecord(value)\n && isOptional(value.categories, (categories): categories is readonly number[] => (\n Array.isArray(categories) && categories.every(isNonNegativeInteger)\n ))\n && isOptional(value.keyword, (keyword): keyword is string => typeof keyword === 'string')\n && isOptional(value.priceFrom, (price): price is number => typeof price === 'number' && Number.isFinite(price))\n && isOptional(value.priceTo, (price): price is number => typeof price === 'number' && Number.isFinite(price))\n && isOptional(value.inventory, (inventory): inventory is 'instock' | 'outofstock' => (\n inventory === 'instock' || inventory === 'outofstock'\n ))\n && isOptional(value.uncategorized, (uncategorized): uncategorized is boolean => typeof uncategorized === 'boolean')\n && isOptional(value.onSale, (onSale): onSale is 'onsale' | 'notonsale' => (\n onSale === 'onsale' || onSale === 'notonsale'\n ))\n && isOptional(value.attributes, isStringArrayRecord)\n && isOptional(value.options, isStringArrayRecord)\n && isOptional(value.sku, (sku): sku is string => typeof sku === 'string')\n && isOptional(value.swatch, isStringArrayRecord)\n && isOptional(value.locations, isStringArray);\n}\n\nexport const isStorefrontCatalogPageRequest: RequestValidator<StorefrontCatalogPageRequest> = (value): value is StorefrontCatalogPageRequest => {\n if (!isRecord(value) || !isRecord(value.listing)) {\n return false;\n }\n return isOptional(value.categoryId, isNonNegativeInteger)\n && isOptional(value.isArtificialCategory, (flag): flag is boolean => typeof flag === 'boolean')\n && isProductFilters(value.listing.filters)\n && typeof value.listing.sortBy === 'string'\n && SORT_ORDERS.has(value.listing.sortBy)\n && isPagination(value.listing.pagination);\n};\n\nexport const isStorefrontCatalogFiltersRequest: RequestValidator<StorefrontCatalogFiltersRequest> = (value): value is StorefrontCatalogFiltersRequest => (\n isRecord(value)\n && isOptional(value.categoryId, isNonNegativeInteger)\n && isOptional(value.isArtificialCategory, (flag): flag is boolean => typeof flag === 'boolean')\n && isProductFilters(value.filters)\n);\n\nexport const isStorefrontCategoryMenuRequest: RequestValidator<StorefrontCategoryMenuRequest> = (value): value is StorefrontCategoryMenuRequest => (\n isRecord(value)\n && isOptional(value.categoryId, isNonNegativeInteger)\n && isOptional(value.isArtificialCategory, (flag): flag is boolean => typeof flag === 'boolean')\n && isPagination(value.pagination)\n);\n\nexport const isStorefrontProductRequest: RequestValidator<StorefrontProductRequest> = (value): value is StorefrontProductRequest => (\n isRecord(value)\n && isPositiveInteger(value.productId)\n && isOptional(value.variationId, isPositiveInteger)\n && isOptional(value.selectedOptionIndexes, (indexes): indexes is readonly number[] => (\n Array.isArray(indexes) && indexes.every(isNonNegativeInteger)\n ))\n);\n\nexport const isStorefrontProductConfigurationRequest: RequestValidator<StorefrontProductConfigurationRequest> = (\n value,\n): value is StorefrontProductConfigurationRequest => (\n isRecord(value)\n && isPositiveInteger(value.productId)\n && isRecord(value.selectedOptions)\n && Object.values(value.selectedOptions).every((option) => typeof option === 'string' || isStringArray(option))\n && isOptional(value.customPrice, (price): price is number => (\n typeof price === 'number' && Number.isFinite(price) && price >= 0\n ))\n);\n\nexport const isStorefrontRelatedProductsRequest: RequestValidator<StorefrontRelatedProductsRequest> = (\n value,\n): value is StorefrontRelatedProductsRequest => isRecord(value) && isPositiveInteger(value.productId);\n\nexport const isProductId: RequestValidator<number> = isPositiveInteger;\nexport const isListener: RequestValidator<(...args: unknown[]) => unknown> = (\n value,\n): value is (...args: unknown[]) => unknown => typeof value === 'function';\n\nexport function validateRequest<T>(validator: RequestValidator<T>, value: unknown): asserts value is T {\n if (!validator(value)) {\n throw new StorefrontRuntimeError('INVALID_REQUEST', 'Storefront request is invalid');\n }\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontCatalogPage, StorefrontCatalogPageRequest } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport {\n isStorefrontCatalogPageRequest,\n validateRequest,\n} from '../runtime/request-validation';\n\nexport async function getPage(request: StorefrontCatalogPageRequest): Promise<StorefrontCatalogPage> {\n validateRequest(isStorefrontCatalogPageRequest, request);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.CATALOG_PAGE,\n (bridge) => bridge.getCatalogPage(request),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type {\n StorefrontCatalogFilters,\n StorefrontCatalogFiltersRequest,\n} from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport {\n isStorefrontCatalogFiltersRequest,\n validateRequest,\n} from '../runtime/request-validation';\n\nexport async function getFilters(\n request: StorefrontCatalogFiltersRequest,\n): Promise<StorefrontCatalogFilters> {\n validateRequest(isStorefrontCatalogFiltersRequest, request);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.CATALOG_FILTERS,\n (bridge) => bridge.getCatalogFilters(request),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontCategoryMenu, StorefrontCategoryMenuRequest } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport {\n isStorefrontCategoryMenuRequest,\n validateRequest,\n} from '../runtime/request-validation';\n\nexport async function getCategoryMenu(\n request: StorefrontCategoryMenuRequest,\n): Promise<StorefrontCategoryMenu> {\n validateRequest(isStorefrontCategoryMenuRequest, request);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.CATEGORY_MENU,\n (bridge) => bridge.getCategoryMenu(request),\n );\n}\n","export function makeIdempotentDisposer(dispose: () => void): () => void {\n let disposed = false;\n\n return () => {\n if (disposed) {\n return;\n }\n disposed = true;\n dispose();\n };\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport { isListener, validateRequest } from '../runtime/request-validation';\nimport { makeIdempotentDisposer } from '../runtime/subscription';\n\n/**\n * Subscribes to Storefront changes that can make Catalog or Category data stale.\n * Route and listing-state changes remain part of the Storefront page context.\n */\nexport async function subscribeChanges(listener: () => void): Promise<() => void> {\n validateRequest(isListener, listener);\n\n return runStorefrontOperation(StorefrontRuntimeCapabilityValues.CATALOG_SUBSCRIPTION, (bridge) => {\n const disposer = bridge.subscribeCatalogChanges(listener);\n return makeIdempotentDisposer(disposer);\n });\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontProduct, StorefrontProductRequest } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport {\n isStorefrontProductRequest,\n validateRequest,\n} from '../runtime/request-validation';\n\nexport async function get(request: StorefrontProductRequest): Promise<StorefrontProduct | null> {\n validateRequest(isStorefrontProductRequest, request);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.PRODUCT,\n (bridge) => bridge.getProduct(request),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type {\n StorefrontProductConfiguration,\n StorefrontProductConfigurationRequest,\n} from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport {\n isStorefrontProductConfigurationRequest,\n validateRequest,\n} from '../runtime/request-validation';\n\nexport async function resolveConfiguration(\n request: StorefrontProductConfigurationRequest,\n): Promise<StorefrontProductConfiguration> {\n validateRequest(isStorefrontProductConfigurationRequest, request);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.PRODUCT_CONFIGURATION,\n (bridge) => bridge.resolveProductConfiguration(request),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontProduct, StorefrontRelatedProductsRequest } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport {\n isStorefrontRelatedProductsRequest,\n validateRequest,\n} from '../runtime/request-validation';\n\nexport async function getRelated(\n request: StorefrontRelatedProductsRequest,\n): Promise<readonly StorefrontProduct[]> {\n validateRequest(isStorefrontRelatedProductsRequest, request);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.RELATED_PRODUCTS,\n (bridge) => bridge.getRelatedProducts(request),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport { isListener, validateRequest } from '../runtime/request-validation';\nimport { makeIdempotentDisposer } from '../runtime/subscription';\n\n/**\n * Subscribes to Storefront changes that can make Product data stale.\n * Refetch the required Products data when the listener runs.\n */\nexport async function subscribeChanges(listener: () => void): Promise<() => void> {\n validateRequest(isListener, listener);\n\n return runStorefrontOperation(StorefrontRuntimeCapabilityValues.PRODUCTS_SUBSCRIPTION, (bridge) => {\n const disposer = bridge.subscribeProductChanges(listener);\n return makeIdempotentDisposer(disposer);\n });\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontFavoritesState } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\n\nexport async function getState(): Promise<StorefrontFavoritesState> {\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.FAVORITES_STATE,\n (bridge) => bridge.getFavoritesState(),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontFavoritesState } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport { isProductId, validateRequest } from '../runtime/request-validation';\n\nexport async function add(productId: number): Promise<StorefrontFavoritesState> {\n validateRequest(isProductId, productId);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.FAVORITES_MUTATION,\n (bridge) => bridge.addFavorite(productId),\n );\n}\n\nexport async function remove(productId: number): Promise<StorefrontFavoritesState> {\n validateRequest(isProductId, productId);\n\n return runStorefrontOperation(\n StorefrontRuntimeCapabilityValues.FAVORITES_MUTATION,\n (bridge) => bridge.removeFavorite(productId),\n );\n}\n","import { StorefrontRuntimeCapabilityValues } from '@/types/public/storefront';\nimport type { StorefrontFavoritesState } from '@/types/public/storefront';\n\nimport { runStorefrontOperation } from '../runtime/bridge';\nimport { isListener, validateRequest } from '../runtime/request-validation';\nimport { makeIdempotentDisposer } from '../runtime/subscription';\n\nexport async function subscribe(\n listener: (state: StorefrontFavoritesState) => void,\n): Promise<() => void> {\n validateRequest(isListener, listener);\n\n return runStorefrontOperation(StorefrontRuntimeCapabilityValues.FAVORITES_SUBSCRIPTION, async (bridge) => {\n const disposer = await bridge.subscribeFavorites(listener);\n return makeIdempotentDisposer(disposer);\n });\n}\n"],"names":["invoke","callback","getError","waitEcwidApiLoaded","resolve","reject","completed","complete","args","callbackResult","getErrorThrew","getErrorError","operationError","error","operationName","success","nativeError","errorMessage","getEcwidWindowMethod","amount","clientId","page","options","cookieConsent","get","waitEcwidApiOperation","completionCallback","product","embeddedCallback","productWithCallback","_product","_cart","getEcwidApiOperationError","index","_quantity","indices","_products","code","message","cause","BRIDGE_ERROR_CODES","hasBridgeErrorCode","StorefrontRuntimeError","capability","ecwid","bridge","StorefrontRuntimeBridgeVersion","operation","SORT_ORDERS","isRecord","value","isPositiveInteger","isNonNegativeInteger","isOptional","validator","isStringArray","item","isStringArrayRecord","isPagination","isProductFilters","categories","keyword","price","inventory","uncategorized","onSale","sku","flag","indexes","option","request","validateRequest","isStorefrontCatalogPageRequest","runStorefrontOperation","StorefrontRuntimeCapabilityValues","isStorefrontCatalogFiltersRequest","isStorefrontCategoryMenuRequest","dispose","disposed","subscribeChanges","listener","isListener","disposer","makeIdempotentDisposer","isStorefrontProductRequest","isStorefrontProductConfigurationRequest","isStorefrontRelatedProductsRequest","productId","isProductId"],"mappings":"sEAUA,eAAsB,sBAA2D,CAC/E,OAAAA,EACA,SAAAC,EACA,SAAAC,CACF,EAAmE,CACjE,OAAOC,WAAAA,mBAAmB,IAAM,IAAI,QAAc,CAACC,EAASC,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AO,CACvC,CACF,CCJA,eAAsB,qBACpBA,EACyC,CACzC,OAAAC,gBAAgBc,wCAAyCf,CAAO,EAEzDG,uBACLC,kCAAkC,sBACjC7B,GAAWA,EAAO,4BAA4ByB,CAAO,CACxD,CACF,CCZA,eAAsB,WACpBA,EACuC,CACvC,OAAAC,gBAAgBe,mCAAoChB,CAAO,EAEpDG,uBACLC,kCAAkC,iBACjC7B,GAAWA,EAAO,mBAAmByB,CAAO,CAC/C,CACF,CCRA,eAAsB,iBAAiBU,EAA2C,CAChF,OAAAT,gBAAgBU,WAAYD,CAAQ,EAE7BP,uBAAuBC,kCAAkC,sBAAwB7B,GAAW,CACjG,MAAMqC,EAAWrC,EAAO,wBAAwBmC,CAAQ,EACxD,OAAOG,uBAAuBD,CAAQ,CACxC,CAAC,CACH,qFCZA,eAAsB,UAA8C,CAClE,OAAOT,uBACLC,kCAAkC,gBACjC7B,GAAWA,EAAO,mBACrB,CACF,CCJA,eAAsB,IAAI0C,EAAsD,CAC9E,OAAAhB,gBAAgBiB,YAAaD,CAAS,EAE/Bd,uBACLC,kCAAkC,mBACjC7B,GAAWA,EAAO,YAAY0C,CAAS,CAC1C,CACF,CAEA,eAAsB,OAAOA,EAAsD,CACjF,OAAAhB,gBAAgBiB,YAAaD,CAAS,EAE/Bd,uBACLC,kCAAkC,mBACjC7B,GAAWA,EAAO,eAAe0C,CAAS,CAC7C,CACF,CCfA,eAAsB,UACpBP,EACqB,CACrB,OAAAT,gBAAgBU,WAAYD,CAAQ,EAE7BP,uBAAuBC,kCAAkC,uBAAwB,MAAO7B,GAAW,CACxG,MAAMqC,EAAW,MAAMrC,EAAO,mBAAmBmC,CAAQ,EACzD,OAAOG,uBAAuBD,CAAQ,CACxC,CAAC,CACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EcwidApiPromise, g as CartData,
|
|
1
|
+
import { E as EcwidApiPromise, g as CartData, ao as CustomerCookieConsentType, w as JsApiPage, t as CustomerData, al as TrackingConsent, am as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, p as CartRemoveProductsCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, u as CustomerGetCallback, v as CustomerSignOutCallback, M as StorefrontCatalogPageRequest, K as StorefrontCatalogPage, G as StorefrontCatalogFiltersRequest, F as StorefrontCatalogFilters, W as StorefrontCategoryMenuRequest, U as StorefrontCategoryMenu, ad as StorefrontProductRequest, a4 as StorefrontProduct, a7 as StorefrontProductConfigurationRequest, a6 as StorefrontProductConfiguration, af as StorefrontRelatedProductsRequest, Z as StorefrontFavoritesState } from './ecom-headless.UNkw31Vf.mjs';
|
|
2
2
|
|
|
3
3
|
declare const EcwidWidgetValues: {
|
|
4
4
|
/** Minicart widget */
|
|
@@ -402,7 +402,7 @@ declare function setTrackingConsent(cookieConsent: CustomerCookieConsentType): P
|
|
|
402
402
|
* });
|
|
403
403
|
* ```
|
|
404
404
|
*/
|
|
405
|
-
declare function get$
|
|
405
|
+
declare function get$2(callback?: CartGetCallback): Promise<void>;
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
408
|
* This method allows you to add a new product position to the shopping cart.
|
|
@@ -605,23 +605,23 @@ declare function canGotoCheckout(): Promise<boolean>;
|
|
|
605
605
|
*/
|
|
606
606
|
declare function gotoCheckout(callback?: CartGoToCheckoutCallback): Promise<void>;
|
|
607
607
|
|
|
608
|
-
declare const index$
|
|
609
|
-
declare const index$
|
|
610
|
-
declare const index$
|
|
611
|
-
declare const index$
|
|
612
|
-
declare const index$
|
|
613
|
-
declare const index$
|
|
614
|
-
declare const index$
|
|
615
|
-
declare namespace index$
|
|
608
|
+
declare const index$4_addProduct: typeof addProduct;
|
|
609
|
+
declare const index$4_calculateTotal: typeof calculateTotal;
|
|
610
|
+
declare const index$4_canGotoCheckout: typeof canGotoCheckout;
|
|
611
|
+
declare const index$4_clear: typeof clear;
|
|
612
|
+
declare const index$4_gotoCheckout: typeof gotoCheckout;
|
|
613
|
+
declare const index$4_removeProduct: typeof removeProduct;
|
|
614
|
+
declare const index$4_removeProducts: typeof removeProducts;
|
|
615
|
+
declare namespace index$4 {
|
|
616
616
|
export {
|
|
617
|
-
index$
|
|
618
|
-
index$
|
|
619
|
-
index$
|
|
620
|
-
index$
|
|
621
|
-
get$
|
|
622
|
-
index$
|
|
623
|
-
index$
|
|
624
|
-
index$
|
|
617
|
+
index$4_addProduct as addProduct,
|
|
618
|
+
index$4_calculateTotal as calculateTotal,
|
|
619
|
+
index$4_canGotoCheckout as canGotoCheckout,
|
|
620
|
+
index$4_clear as clear,
|
|
621
|
+
get$2 as get,
|
|
622
|
+
index$4_gotoCheckout as gotoCheckout,
|
|
623
|
+
index$4_removeProduct as removeProduct,
|
|
624
|
+
index$4_removeProducts as removeProducts,
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
627
|
|
|
@@ -643,7 +643,7 @@ declare namespace index$1 {
|
|
|
643
643
|
* });
|
|
644
644
|
* ```
|
|
645
645
|
*/
|
|
646
|
-
declare function get(callback?: CustomerGetCallback): Promise<void>;
|
|
646
|
+
declare function get$1(callback?: CustomerGetCallback): Promise<void>;
|
|
647
647
|
|
|
648
648
|
/**
|
|
649
649
|
* This method signs out customer from their account.
|
|
@@ -666,13 +666,88 @@ declare function get(callback?: CustomerGetCallback): Promise<void>;
|
|
|
666
666
|
*/
|
|
667
667
|
declare function signOut(callback?: CustomerSignOutCallback): Promise<void>;
|
|
668
668
|
|
|
669
|
-
declare const
|
|
670
|
-
declare
|
|
669
|
+
declare const index$3_signOut: typeof signOut;
|
|
670
|
+
declare namespace index$3 {
|
|
671
|
+
export {
|
|
672
|
+
get$1 as get,
|
|
673
|
+
index$3_signOut as signOut,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
declare function getPage(request: StorefrontCatalogPageRequest): Promise<StorefrontCatalogPage>;
|
|
678
|
+
|
|
679
|
+
declare function getFilters(request: StorefrontCatalogFiltersRequest): Promise<StorefrontCatalogFilters>;
|
|
680
|
+
|
|
681
|
+
declare function getCategoryMenu(request: StorefrontCategoryMenuRequest): Promise<StorefrontCategoryMenu>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Subscribes to Storefront changes that can make Catalog or Category data stale.
|
|
685
|
+
* Route and listing-state changes remain part of the Storefront page context.
|
|
686
|
+
*/
|
|
687
|
+
declare function subscribeChanges$1(listener: () => void): Promise<() => void>;
|
|
688
|
+
|
|
689
|
+
declare const index$2_getCategoryMenu: typeof getCategoryMenu;
|
|
690
|
+
declare const index$2_getFilters: typeof getFilters;
|
|
691
|
+
declare const index$2_getPage: typeof getPage;
|
|
692
|
+
declare namespace index$2 {
|
|
693
|
+
export {
|
|
694
|
+
index$2_getCategoryMenu as getCategoryMenu,
|
|
695
|
+
index$2_getFilters as getFilters,
|
|
696
|
+
index$2_getPage as getPage,
|
|
697
|
+
subscribeChanges$1 as subscribeChanges,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
declare function get(request: StorefrontProductRequest): Promise<StorefrontProduct | null>;
|
|
702
|
+
|
|
703
|
+
declare function resolveConfiguration(request: StorefrontProductConfigurationRequest): Promise<StorefrontProductConfiguration>;
|
|
704
|
+
|
|
705
|
+
declare function getRelated(request: StorefrontRelatedProductsRequest): Promise<readonly StorefrontProduct[]>;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Subscribes to Storefront changes that can make Product data stale.
|
|
709
|
+
* Refetch the required Products data when the listener runs.
|
|
710
|
+
*/
|
|
711
|
+
declare function subscribeChanges(listener: () => void): Promise<() => void>;
|
|
712
|
+
|
|
713
|
+
declare const index$1_get: typeof get;
|
|
714
|
+
declare const index$1_getRelated: typeof getRelated;
|
|
715
|
+
declare const index$1_resolveConfiguration: typeof resolveConfiguration;
|
|
716
|
+
declare const index$1_subscribeChanges: typeof subscribeChanges;
|
|
717
|
+
declare namespace index$1 {
|
|
718
|
+
export {
|
|
719
|
+
index$1_get as get,
|
|
720
|
+
index$1_getRelated as getRelated,
|
|
721
|
+
index$1_resolveConfiguration as resolveConfiguration,
|
|
722
|
+
index$1_subscribeChanges as subscribeChanges,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
declare function getState(): Promise<StorefrontFavoritesState>;
|
|
727
|
+
|
|
728
|
+
declare function add(productId: number): Promise<StorefrontFavoritesState>;
|
|
729
|
+
declare function remove(productId: number): Promise<StorefrontFavoritesState>;
|
|
730
|
+
|
|
731
|
+
declare function subscribe(listener: (state: StorefrontFavoritesState) => void): Promise<() => void>;
|
|
732
|
+
|
|
733
|
+
declare const index_add: typeof add;
|
|
734
|
+
declare const index_getState: typeof getState;
|
|
735
|
+
declare const index_remove: typeof remove;
|
|
736
|
+
declare const index_subscribe: typeof subscribe;
|
|
671
737
|
declare namespace index {
|
|
672
738
|
export {
|
|
673
|
-
|
|
674
|
-
|
|
739
|
+
index_add as add,
|
|
740
|
+
index_getState as getState,
|
|
741
|
+
index_remove as remove,
|
|
742
|
+
index_subscribe as subscribe,
|
|
675
743
|
};
|
|
676
744
|
}
|
|
677
745
|
|
|
678
|
-
|
|
746
|
+
type StorefrontRuntimeErrorCode = 'STOREFRONT_RUNTIME_UNAVAILABLE' | 'UNSUPPORTED_STOREFRONT_VERSION' | 'UNSUPPORTED_CAPABILITY' | 'INVALID_REQUEST' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'OUT_OF_STOCK' | 'INCOMPLETE_PRODUCT_SELECTION' | 'PREVIEW_MUTATION_DISABLED' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
|
|
747
|
+
declare class StorefrontRuntimeError extends Error {
|
|
748
|
+
readonly code: StorefrontRuntimeErrorCode;
|
|
749
|
+
readonly cause?: unknown;
|
|
750
|
+
constructor(code: StorefrontRuntimeErrorCode, message: string, cause?: unknown);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export { EcwidWidgetValues as E, OnCartChanged as O, StorefrontRuntimeError as S, index$2 as a, index$3 as b, index as c, OnConsentChanged as d, OnPageLoad as e, OnPageLoaded as f, OnPageSwitch as g, OnSetProfile as h, index$4 as i, index$1 as j, formatCurrency as k, getAppPublicConfig as l, getAppPublicToken as m, getInitializedWidgets as n, getOwnerId as o, getStoreId as p, getStorefrontLang as q, getTrackingConsent as r, getVisitorLocation as s, isStorefrontV3 as t, openPage as u, setTrackingConsent as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EcwidApiPromise, g as CartData,
|
|
1
|
+
import { E as EcwidApiPromise, g as CartData, ao as CustomerCookieConsentType, w as JsApiPage, t as CustomerData, al as TrackingConsent, am as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, p as CartRemoveProductsCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, u as CustomerGetCallback, v as CustomerSignOutCallback, M as StorefrontCatalogPageRequest, K as StorefrontCatalogPage, G as StorefrontCatalogFiltersRequest, F as StorefrontCatalogFilters, W as StorefrontCategoryMenuRequest, U as StorefrontCategoryMenu, ad as StorefrontProductRequest, a4 as StorefrontProduct, a7 as StorefrontProductConfigurationRequest, a6 as StorefrontProductConfiguration, af as StorefrontRelatedProductsRequest, Z as StorefrontFavoritesState } from './ecom-headless.UNkw31Vf.cjs';
|
|
2
2
|
|
|
3
3
|
declare const EcwidWidgetValues: {
|
|
4
4
|
/** Minicart widget */
|
|
@@ -402,7 +402,7 @@ declare function setTrackingConsent(cookieConsent: CustomerCookieConsentType): P
|
|
|
402
402
|
* });
|
|
403
403
|
* ```
|
|
404
404
|
*/
|
|
405
|
-
declare function get$
|
|
405
|
+
declare function get$2(callback?: CartGetCallback): Promise<void>;
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
408
|
* This method allows you to add a new product position to the shopping cart.
|
|
@@ -605,23 +605,23 @@ declare function canGotoCheckout(): Promise<boolean>;
|
|
|
605
605
|
*/
|
|
606
606
|
declare function gotoCheckout(callback?: CartGoToCheckoutCallback): Promise<void>;
|
|
607
607
|
|
|
608
|
-
declare const index$
|
|
609
|
-
declare const index$
|
|
610
|
-
declare const index$
|
|
611
|
-
declare const index$
|
|
612
|
-
declare const index$
|
|
613
|
-
declare const index$
|
|
614
|
-
declare const index$
|
|
615
|
-
declare namespace index$
|
|
608
|
+
declare const index$4_addProduct: typeof addProduct;
|
|
609
|
+
declare const index$4_calculateTotal: typeof calculateTotal;
|
|
610
|
+
declare const index$4_canGotoCheckout: typeof canGotoCheckout;
|
|
611
|
+
declare const index$4_clear: typeof clear;
|
|
612
|
+
declare const index$4_gotoCheckout: typeof gotoCheckout;
|
|
613
|
+
declare const index$4_removeProduct: typeof removeProduct;
|
|
614
|
+
declare const index$4_removeProducts: typeof removeProducts;
|
|
615
|
+
declare namespace index$4 {
|
|
616
616
|
export {
|
|
617
|
-
index$
|
|
618
|
-
index$
|
|
619
|
-
index$
|
|
620
|
-
index$
|
|
621
|
-
get$
|
|
622
|
-
index$
|
|
623
|
-
index$
|
|
624
|
-
index$
|
|
617
|
+
index$4_addProduct as addProduct,
|
|
618
|
+
index$4_calculateTotal as calculateTotal,
|
|
619
|
+
index$4_canGotoCheckout as canGotoCheckout,
|
|
620
|
+
index$4_clear as clear,
|
|
621
|
+
get$2 as get,
|
|
622
|
+
index$4_gotoCheckout as gotoCheckout,
|
|
623
|
+
index$4_removeProduct as removeProduct,
|
|
624
|
+
index$4_removeProducts as removeProducts,
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
627
|
|
|
@@ -643,7 +643,7 @@ declare namespace index$1 {
|
|
|
643
643
|
* });
|
|
644
644
|
* ```
|
|
645
645
|
*/
|
|
646
|
-
declare function get(callback?: CustomerGetCallback): Promise<void>;
|
|
646
|
+
declare function get$1(callback?: CustomerGetCallback): Promise<void>;
|
|
647
647
|
|
|
648
648
|
/**
|
|
649
649
|
* This method signs out customer from their account.
|
|
@@ -666,13 +666,88 @@ declare function get(callback?: CustomerGetCallback): Promise<void>;
|
|
|
666
666
|
*/
|
|
667
667
|
declare function signOut(callback?: CustomerSignOutCallback): Promise<void>;
|
|
668
668
|
|
|
669
|
-
declare const
|
|
670
|
-
declare
|
|
669
|
+
declare const index$3_signOut: typeof signOut;
|
|
670
|
+
declare namespace index$3 {
|
|
671
|
+
export {
|
|
672
|
+
get$1 as get,
|
|
673
|
+
index$3_signOut as signOut,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
declare function getPage(request: StorefrontCatalogPageRequest): Promise<StorefrontCatalogPage>;
|
|
678
|
+
|
|
679
|
+
declare function getFilters(request: StorefrontCatalogFiltersRequest): Promise<StorefrontCatalogFilters>;
|
|
680
|
+
|
|
681
|
+
declare function getCategoryMenu(request: StorefrontCategoryMenuRequest): Promise<StorefrontCategoryMenu>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Subscribes to Storefront changes that can make Catalog or Category data stale.
|
|
685
|
+
* Route and listing-state changes remain part of the Storefront page context.
|
|
686
|
+
*/
|
|
687
|
+
declare function subscribeChanges$1(listener: () => void): Promise<() => void>;
|
|
688
|
+
|
|
689
|
+
declare const index$2_getCategoryMenu: typeof getCategoryMenu;
|
|
690
|
+
declare const index$2_getFilters: typeof getFilters;
|
|
691
|
+
declare const index$2_getPage: typeof getPage;
|
|
692
|
+
declare namespace index$2 {
|
|
693
|
+
export {
|
|
694
|
+
index$2_getCategoryMenu as getCategoryMenu,
|
|
695
|
+
index$2_getFilters as getFilters,
|
|
696
|
+
index$2_getPage as getPage,
|
|
697
|
+
subscribeChanges$1 as subscribeChanges,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
declare function get(request: StorefrontProductRequest): Promise<StorefrontProduct | null>;
|
|
702
|
+
|
|
703
|
+
declare function resolveConfiguration(request: StorefrontProductConfigurationRequest): Promise<StorefrontProductConfiguration>;
|
|
704
|
+
|
|
705
|
+
declare function getRelated(request: StorefrontRelatedProductsRequest): Promise<readonly StorefrontProduct[]>;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Subscribes to Storefront changes that can make Product data stale.
|
|
709
|
+
* Refetch the required Products data when the listener runs.
|
|
710
|
+
*/
|
|
711
|
+
declare function subscribeChanges(listener: () => void): Promise<() => void>;
|
|
712
|
+
|
|
713
|
+
declare const index$1_get: typeof get;
|
|
714
|
+
declare const index$1_getRelated: typeof getRelated;
|
|
715
|
+
declare const index$1_resolveConfiguration: typeof resolveConfiguration;
|
|
716
|
+
declare const index$1_subscribeChanges: typeof subscribeChanges;
|
|
717
|
+
declare namespace index$1 {
|
|
718
|
+
export {
|
|
719
|
+
index$1_get as get,
|
|
720
|
+
index$1_getRelated as getRelated,
|
|
721
|
+
index$1_resolveConfiguration as resolveConfiguration,
|
|
722
|
+
index$1_subscribeChanges as subscribeChanges,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
declare function getState(): Promise<StorefrontFavoritesState>;
|
|
727
|
+
|
|
728
|
+
declare function add(productId: number): Promise<StorefrontFavoritesState>;
|
|
729
|
+
declare function remove(productId: number): Promise<StorefrontFavoritesState>;
|
|
730
|
+
|
|
731
|
+
declare function subscribe(listener: (state: StorefrontFavoritesState) => void): Promise<() => void>;
|
|
732
|
+
|
|
733
|
+
declare const index_add: typeof add;
|
|
734
|
+
declare const index_getState: typeof getState;
|
|
735
|
+
declare const index_remove: typeof remove;
|
|
736
|
+
declare const index_subscribe: typeof subscribe;
|
|
671
737
|
declare namespace index {
|
|
672
738
|
export {
|
|
673
|
-
|
|
674
|
-
|
|
739
|
+
index_add as add,
|
|
740
|
+
index_getState as getState,
|
|
741
|
+
index_remove as remove,
|
|
742
|
+
index_subscribe as subscribe,
|
|
675
743
|
};
|
|
676
744
|
}
|
|
677
745
|
|
|
678
|
-
|
|
746
|
+
type StorefrontRuntimeErrorCode = 'STOREFRONT_RUNTIME_UNAVAILABLE' | 'UNSUPPORTED_STOREFRONT_VERSION' | 'UNSUPPORTED_CAPABILITY' | 'INVALID_REQUEST' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'OUT_OF_STOCK' | 'INCOMPLETE_PRODUCT_SELECTION' | 'PREVIEW_MUTATION_DISABLED' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
|
|
747
|
+
declare class StorefrontRuntimeError extends Error {
|
|
748
|
+
readonly code: StorefrontRuntimeErrorCode;
|
|
749
|
+
readonly cause?: unknown;
|
|
750
|
+
constructor(code: StorefrontRuntimeErrorCode, message: string, cause?: unknown);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export { EcwidWidgetValues as E, OnCartChanged as O, StorefrontRuntimeError as S, index$2 as a, index$3 as b, index as c, OnConsentChanged as d, OnPageLoad as e, OnPageLoaded as f, OnPageSwitch as g, OnSetProfile as h, index$4 as i, index$1 as j, formatCurrency as k, getAppPublicConfig as l, getAppPublicToken as m, getInitializedWidgets as n, getOwnerId as o, getStoreId as p, getStorefrontLang as q, getTrackingConsent as r, getVisitorLocation as s, isStorefrontV3 as t, openPage as u, setTrackingConsent as v };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{w as a,b as r}from"./ecom-headless.biFHUae1.mjs";async function f({invoke:e,callback:t,getError:n}){return a(()=>new Promise((s,g)=>{let O=!1;const C=(...y)=>{if(O)return;O=!0;let R;try{R=t?.(...y)}catch{}let A=!1,N,_;try{_=n?.(...y)}catch(k){A=!0,N=k}if(A||_!==void 0){Promise.resolve(R).catch(()=>{}),g(A?N:_);return}Promise.resolve(R).catch(()=>{}),s()};try{e(C)}catch(y){O=!0,g(y)}}))}function E(e,t,n){if(t)return;if(n instanceof Error)return n;const s=Array.isArray(n)?n.filter(Boolean).join(", "):typeof n=="string"?n.trim():"";return new Error(s||`${e} failed`)}const w={add:e=>a(()=>r("OnCartChanged").add(e))},D={add:e=>a(()=>r("OnConsentChanged").add(e))},F={add:e=>a(()=>r("OnPageLoad").add(e))},L={add:e=>a(()=>r("OnPageLoaded").add(e))},V={add:e=>a(()=>r("OnPageSwitch").add(e))},G={add:e=>a(()=>r("OnSetProfile").add(e))};async function B(e){return a(()=>r("formatCurrency")(e))}async function M(e){return a(()=>r("getAppPublicConfig")(e))}async function $(e){return a(()=>r("getAppPublicToken")(e))}async function q(){return a(()=>r("getInitializedWidgets")())}async function x(){return a(()=>r("getStorefrontLang")())}async function W(){return a(()=>r("getTrackingConsent")())}async function H(){return a(()=>r("getVisitorLocation")())}async function j(){return a(()=>r("isStorefrontV3")())}async function Y(e,t){return a(()=>r("openPage")(e,t))}async function K(e){return a(()=>r("setTrackingConsent")(e))}async function z(e){return f({invoke:t=>r("Cart").get(t),callback:e})}async function Q(e,t){const n=typeof e=="number"?void 0:e.callback;return f({invoke:s=>{if(typeof e=="number"){r("Cart").addProduct(e,s);return}const g={...e,callback:s};r("Cart").addProduct(g)},callback:typeof n=="function"?n:t,getError:(s,g,O,C)=>E("Cart.addProduct",s,C)})}async function Z(e,t){return f({invoke:n=>r("Cart").removeProduct(e,n),callback:t,getError:(n,s,g,O,C)=>E("Cart.removeProduct",n,C)})}async function J(e,t){return f({invoke:n=>r("Cart").removeProducts(e,n),callback:t,getError:(n,s,g,O,C)=>E("Cart.removeProducts",n,C)})}async function X(e){return f({invoke:t=>r("Cart").clear(t),callback:e,getError:(t,n)=>E("Cart.clear",t,n)})}async function ee(e){return f({invoke:t=>r("Cart").calculateTotal(t),callback:e})}async function te(){return a(()=>r("Cart").canGotoCheckout())}async function ne(e){return f({invoke:t=>r("Cart").gotoCheckout(t),callback:e})}const re={__proto__:null,addProduct:Q,calculateTotal:ee,canGotoCheckout:te,clear:X,get:z,gotoCheckout:ne,removeProduct:Z,removeProducts:J};async function oe(e){return f({invoke:t=>r("Customer").get(t),callback:e})}async function ae(e){return f({invoke:t=>r("Customer").signOut(t),callback:e,getError:(t,n)=>E("Customer.signOut",t,n)})}const ie={__proto__:null,get:oe,signOut:ae},v=1,i={CATALOG_PAGE:"CATALOG_PAGE",CATALOG_FILTERS:"CATALOG_FILTERS",CATEGORY_MENU:"CATEGORY_MENU",CATALOG_SUBSCRIPTION:"CATALOG_SUBSCRIPTION",PRODUCT:"PRODUCT",PRODUCT_CONFIGURATION:"PRODUCT_CONFIGURATION",RELATED_PRODUCTS:"RELATED_PRODUCTS",PRODUCTS_SUBSCRIPTION:"PRODUCTS_SUBSCRIPTION",FAVORITES_STATE:"FAVORITES_STATE",FAVORITES_MUTATION:"FAVORITES_MUTATION",FAVORITES_SUBSCRIPTION:"FAVORITES_SUBSCRIPTION"};class l extends Error{code;cause;constructor(t,n,s){super(n),this.name="StorefrontRuntimeError",this.code=t,this.cause=s}}const se=new Set(["INVALID_REQUEST","NOT_FOUND","UNAUTHORIZED","OUT_OF_STOCK","INCOMPLETE_PRODUCT_SELECTION","PREVIEW_MUTATION_DISABLED","NETWORK_ERROR","UNKNOWN_ERROR"]);function ce(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&se.has(e.code)}function ue(e){return e instanceof l?e:ce(e)?new l(e.code,e.message):new l("UNKNOWN_ERROR","Storefront operation failed")}async function de(e){let t=globalThis.window?.Ecwid;if(t?.Headless===void 0&&(await a(()=>{}),t=globalThis.window?.Ecwid),t===void 0)throw new l("STOREFRONT_RUNTIME_UNAVAILABLE","Ecwid Storefront runtime is not available");const n=t.Headless;if(n===void 0)throw new l("UNSUPPORTED_STOREFRONT_VERSION","This Storefront version does not support Headless runtime operations");if(n.version!==v)throw new l("UNSUPPORTED_STOREFRONT_VERSION",`Unsupported Headless Storefront bridge version: ${String(n.version)}`);if(!n.capabilities.includes(e))throw new l("UNSUPPORTED_CAPABILITY",`Storefront Headless capability is not available: ${e}`);return n}async function c(e,t){try{const n=await de(e);return await t(n)}catch(n){throw ue(n)}}const le=new Set(["DEFINED_BY_STORE_OWNER","ADDED_TIME_DESC","PRICE_ASC","PRICE_DESC","NAME_ASC","NAME_DESC","IN_STORE_RECEIVED_DATE_DESC"]);function u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function T(e){return Number.isSafeInteger(e)&&Number(e)>0}function S(e){return Number.isSafeInteger(e)&&Number(e)>=0}function o(e,t){return e===void 0||t(e)}function I(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function P(e){return u(e)&&Object.values(e).every(I)}function m(e){return u(e)&&S(e.offset)&&T(e.limit)&&e.limit<=200}function U(e){return u(e)&&o(e.categories,t=>Array.isArray(t)&&t.every(S))&&o(e.keyword,t=>typeof t=="string")&&o(e.priceFrom,t=>typeof t=="number"&&Number.isFinite(t))&&o(e.priceTo,t=>typeof t=="number"&&Number.isFinite(t))&&o(e.inventory,t=>t==="instock"||t==="outofstock")&&o(e.uncategorized,t=>typeof t=="boolean")&&o(e.onSale,t=>t==="onsale"||t==="notonsale")&&o(e.attributes,P)&&o(e.options,P)&&o(e.sku,t=>typeof t=="string")&&o(e.swatch,P)&&o(e.locations,I)}const fe=e=>!u(e)||!u(e.listing)?!1:o(e.categoryId,S)&&o(e.isArtificialCategory,t=>typeof t=="boolean")&&U(e.listing.filters)&&typeof e.listing.sortBy=="string"&&le.has(e.listing.sortBy)&&m(e.listing.pagination),ge=e=>u(e)&&o(e.categoryId,S)&&o(e.isArtificialCategory,t=>typeof t=="boolean")&&U(e.filters),Ce=e=>u(e)&&o(e.categoryId,S)&&o(e.isArtificialCategory,t=>typeof t=="boolean")&&m(e.pagination),Oe=e=>u(e)&&T(e.productId)&&o(e.variationId,T)&&o(e.selectedOptionIndexes,t=>Array.isArray(t)&&t.every(S)),Te=e=>u(e)&&T(e.productId)&&u(e.selectedOptions)&&Object.values(e.selectedOptions).every(t=>typeof t=="string"||I(t))&&o(e.customPrice,t=>typeof t=="number"&&Number.isFinite(t)&&t>=0),Se=e=>u(e)&&T(e.productId),h=T,p=e=>typeof e=="function";function d(e,t){if(!e(t))throw new l("INVALID_REQUEST","Storefront request is invalid")}async function Ee(e){return d(fe,e),c(i.CATALOG_PAGE,t=>t.getCatalogPage(e))}async function ye(e){return d(ge,e),c(i.CATALOG_FILTERS,t=>t.getCatalogFilters(e))}async function Re(e){return d(Ce,e),c(i.CATEGORY_MENU,t=>t.getCategoryMenu(e))}function b(e){let t=!1;return()=>{t||(t=!0,e())}}async function Ae(e){return d(p,e),c(i.CATALOG_SUBSCRIPTION,t=>{const n=t.subscribeCatalogChanges(e);return b(n)})}const _e={__proto__:null,getCategoryMenu:Re,getFilters:ye,getPage:Ee,subscribeChanges:Ae};async function Pe(e){return d(Oe,e),c(i.PRODUCT,t=>t.getProduct(e))}async function Ie(e){return d(Te,e),c(i.PRODUCT_CONFIGURATION,t=>t.resolveProductConfiguration(e))}async function pe(e){return d(Se,e),c(i.RELATED_PRODUCTS,t=>t.getRelatedProducts(e))}async function be(e){return d(p,e),c(i.PRODUCTS_SUBSCRIPTION,t=>{const n=t.subscribeProductChanges(e);return b(n)})}const Ne={__proto__:null,get:Pe,getRelated:pe,resolveConfiguration:Ie,subscribeChanges:be};async function ve(){return c(i.FAVORITES_STATE,e=>e.getFavoritesState())}async function me(e){return d(h,e),c(i.FAVORITES_MUTATION,t=>t.addFavorite(e))}async function Ue(e){return d(h,e),c(i.FAVORITES_MUTATION,t=>t.removeFavorite(e))}async function he(e){return d(p,e),c(i.FAVORITES_SUBSCRIPTION,async t=>{const n=await t.subscribeFavorites(e);return b(n)})}const ke={__proto__:null,add:me,getState:ve,remove:Ue,subscribe:he};export{w as O,v as S,_e as a,ie as b,ke as c,D as d,F as e,L as f,V as g,G as h,re as i,Ne as j,i as k,l,B as m,M as n,$ as o,q as p,x as q,W as r,H as s,j as t,Y as u,K as v};
|
|
2
|
+
//# sourceMappingURL=ecom-headless.CyyXXtdO.mjs.map
|