@plasmicpkgs/commerce-swell 0.0.257 → 0.0.258
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cart/index.d.ts +3 -3
- package/dist/cart/use-add-item.d.ts +5 -5
- package/dist/cart/use-cart.d.ts +6 -6
- package/dist/cart/use-remove-item.d.ts +21 -21
- package/dist/cart/use-update-item.d.ts +33 -33
- package/dist/cart/utils/checkout-create.d.ts +2 -2
- package/dist/cart/utils/checkout-to-cart.d.ts +5 -5
- package/dist/cart/utils/index.d.ts +2 -2
- package/dist/commerce-swell.cjs.development.js +36 -35
- package/dist/commerce-swell.cjs.development.js.map +1 -1
- package/dist/commerce-swell.cjs.production.min.js +1 -1
- package/dist/commerce-swell.cjs.production.min.js.map +1 -1
- package/dist/commerce-swell.esm.js +36 -35
- package/dist/commerce-swell.esm.js.map +1 -1
- package/dist/const.d.ts +4 -4
- package/dist/fetcher.d.ts +3 -3
- package/dist/index.d.ts +7 -7
- package/dist/product/index.d.ts +2 -2
- package/dist/product/use-price.d.ts +2 -2
- package/dist/product/use-product.d.ts +7 -7
- package/dist/product/use-search.d.ts +15 -15
- package/dist/provider.d.ts +132 -81
- package/dist/registerCommerceProvider.d.ts +12 -12
- package/dist/registerable.d.ts +6 -6
- package/dist/site/use-brands.d.ts +5 -5
- package/dist/site/use-categories.d.ts +5 -5
- package/dist/swell.d.ts +9 -9
- package/dist/types/cart.d.ts +18 -18
- package/dist/types/checkout.d.ts +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/customer.d.ts +1 -1
- package/dist/types/index.d.ts +12 -12
- package/dist/types/login.d.ts +8 -8
- package/dist/types/logout.d.ts +1 -1
- package/dist/types/page.d.ts +1 -1
- package/dist/types/product.d.ts +14 -14
- package/dist/types/signup.d.ts +1 -1
- package/dist/types/site.d.ts +8 -8
- package/dist/types/wishlist.d.ts +1 -1
- package/dist/types.d.ts +98 -98
- package/dist/utils/category-tree.d.ts +3 -3
- package/dist/utils/common.d.ts +2 -2
- package/dist/utils/customer-token.d.ts +3 -3
- package/dist/utils/fetch-swell-api.d.ts +2 -2
- package/dist/utils/get-categories.d.ts +4 -4
- package/dist/utils/get-checkout-id.d.ts +2 -2
- package/dist/utils/get-search-variables.d.ts +6 -6
- package/dist/utils/get-sort-variables.d.ts +2 -2
- package/dist/utils/get-vendors.d.ts +17 -17
- package/dist/utils/handle-fetch-response.d.ts +8 -8
- package/dist/utils/handle-login.d.ts +2 -2
- package/dist/utils/index.d.ts +8 -8
- package/dist/utils/normalize.d.ts +7 -7
- package/dist/utils/storage.d.ts +2 -2
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commerce-swell.cjs.production.min.js","sources":["../src/const.ts","../src/utils/normalize.ts","../src/utils/handle-fetch-response.ts","../src/cart/utils/checkout-to-cart.ts","../src/cart/utils/checkout-create.ts","../src/cart/use-cart.tsx","../src/cart/use-add-item.tsx","../src/utils/get-checkout-id.ts","../src/cart/use-remove-item.tsx","../src/cart/use-update-item.tsx","../src/fetcher.ts","../src/product/use-product.tsx","../src/utils/common.ts","../src/utils/category-tree.ts","../src/product/use-search.tsx","../src/site/use-brands.ts","../src/site/use-categories.ts","../src/swell.ts","../src/provider.ts","../src/registerCommerceProvider.tsx","../src/index.tsx"],"sourcesContent":["/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Removed store id and public key\n*/\nexport const SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId'\n\nexport const SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl'\n\nexport const SWELL_CUSTOMER_TOKEN_COOKIE = 'swell_customerToken'\n\nexport const SWELL_COOKIE_EXPIRE = 30\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Added \"Default Variant\" to default title when there's no product variant\n*/\nimport { MoneyV2 } from \"../schema\";\nimport type {\n Cart,\n CartLineItem,\n LineItem,\n ProductOptionValue,\n SwellCart,\n SwellImage,\n SwellProduct,\n SwellProductOptionValue,\n SwellVariant,\n} from \"../types\";\nimport { Product, ProductOption } from \"../types/product\";\nimport { Category, SwellCategoryChildren } from \"../types/site\";\n\nconst money = ({ amount, currencyCode }: MoneyV2) => {\n return {\n value: +amount,\n currencyCode,\n };\n};\n\ntype swellProductOption = {\n id: string;\n name: string;\n values: any[];\n};\n\ntype normalizedProductOption = {\n id: string;\n displayName: string;\n values: ProductOptionValue[];\n};\n\nconst normalizeProductOption = ({\n id,\n name: displayName = \"\",\n values = [],\n}: swellProductOption): ProductOption => {\n let returnValues = values.map((value) => {\n let output: any = {\n label: value.name,\n // id: value?.id || id,\n };\n if (displayName.match(/colou?r/gi)) {\n output = {\n ...output,\n hexColors: [value.name],\n };\n }\n return output;\n });\n return {\n __typename: \"MultipleChoiceOption\",\n id,\n displayName,\n values: returnValues,\n };\n};\n\nconst normalizeProductImages = (images: SwellImage[]) => {\n if (!images || images.length < 1) {\n return [{ url: \"/\" }];\n }\n return images?.map(({ file, ...rest }: SwellImage) => ({\n url: file?.url + \"\",\n height: Number(file?.height),\n width: Number(file?.width),\n ...rest,\n }));\n};\n\nconst normalizeProductVariants = (\n variants: SwellVariant[],\n productOptions: swellProductOption[]\n) => {\n return variants?.map(\n ({ id, name, price, option_value_ids: optionValueIds = [] }) => {\n const values = name\n .split(\",\")\n .map((i) => ({ name: i.trim(), label: i.trim() }));\n\n const options = optionValueIds.map((id) => {\n const matchingOption = productOptions.find((option) => {\n return option.values.find(\n (value: SwellProductOptionValue) => value.id == id\n );\n });\n return normalizeProductOption({\n id,\n name: matchingOption?.name ?? \"\",\n values,\n });\n });\n\n return {\n id,\n name,\n // sku: sku ?? id,\n price: price ?? undefined,\n // listPrice: price ?? null,\n // requiresShipping: true,\n options,\n };\n }\n );\n};\n\nexport function normalizeProduct(swellProduct: SwellProduct): Product {\n const {\n id,\n name,\n description,\n images,\n options,\n slug,\n variants,\n price: value,\n currency: currencyCode,\n } = swellProduct;\n // ProductView accesses variants for each product\n const emptyVariants = [{ options: [], id, name: \"Default variant\" }];\n\n const productOptions = options\n ? options.map((o) => normalizeProductOption(o))\n : [];\n const productVariants = variants\n ? normalizeProductVariants(variants.results, options)\n : [];\n\n const productImages = normalizeProductImages(images);\n const product = {\n ...swellProduct,\n description,\n id,\n vendor: \"\",\n path: `/${slug}`,\n images: productImages,\n variants:\n productVariants && productVariants.length\n ? productVariants\n : emptyVariants,\n options: productOptions,\n price: {\n value,\n currencyCode,\n },\n };\n return product;\n}\n\nexport function normalizeCart({\n id,\n account_id,\n date_created,\n currency,\n tax_included_total,\n items,\n sub_total,\n grand_total,\n discounts,\n}: SwellCart) {\n const cart: Cart = {\n id: id,\n customerId: account_id + \"\",\n email: \"\",\n createdAt: date_created,\n currency: { code: currency },\n taxesIncluded: tax_included_total > 0,\n lineItems: items?.map(normalizeLineItem) ?? [],\n lineItemsSubtotalPrice: +sub_total,\n subtotalPrice: +sub_total,\n totalPrice: grand_total,\n discounts: discounts?.map((discount) => ({ value: discount.amount })),\n };\n return cart;\n}\n/*\nexport function normalizeCustomer(customer: SwellCustomer): Customer {\n const { first_name: firstName, last_name: lastName } = customer\n return {\n ...customer,\n firstName,\n lastName,\n }\n}\n*/\nfunction normalizeLineItem({\n id,\n product,\n price,\n variant,\n quantity,\n}: CartLineItem): LineItem {\n const item = {\n id,\n variantId: variant?.id,\n productId: product.id ?? \"\",\n name: product?.name ?? \"\",\n quantity,\n variant: {\n id: variant?.id ?? \"\",\n sku: variant?.sku ?? \"\",\n name: variant?.name!,\n image: {\n url:\n product?.images && product.images.length > 0\n ? product?.images[0].file.url\n : \"/\",\n },\n requiresShipping: false,\n price: price,\n listPrice: price,\n },\n path: \"\",\n discounts: [],\n options: [\n {\n value: variant?.name,\n },\n ],\n };\n return item;\n}\n\nexport function normalizeChildren(children: SwellCategoryChildren) {\n return children?.results.map((ch) => ch.id);\n}\n\nexport function normalizeCategory({\n id,\n name,\n slug,\n products,\n images,\n depth,\n children,\n parent_id,\n}: any): Category {\n return {\n id,\n name,\n slug,\n path: `/${slug}`,\n isEmpty: products?.length === 0,\n images: images?.map((image: any) => ({\n url: image.file.url,\n })),\n depth,\n children: normalizeChildren(children),\n parentId: parent_id,\n };\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { CommerceError } from '@plasmicpkgs/commerce'\n\ntype SwellFetchResponse = {\n error: {\n message: string\n code?: string\n }\n}\n\nconst handleFetchResponse = async (res: SwellFetchResponse) => {\n if (res) {\n if (res.error) {\n throw new CommerceError(res.error)\n }\n return res\n }\n return null;\n}\n\nexport default handleFetchResponse\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { CommerceError } from '@plasmicpkgs/commerce'\nimport { CartType } from '@plasmicpkgs/commerce'\n\nimport {\n CheckoutLineItemsAddPayload,\n CheckoutLineItemsRemovePayload,\n CheckoutLineItemsUpdatePayload,\n Maybe,\n} from '../../schema'\nimport { normalizeCart } from '../../utils'\nexport type CheckoutPayload =\n | CheckoutLineItemsAddPayload\n | CheckoutLineItemsUpdatePayload\n | CheckoutLineItemsRemovePayload\n\nconst checkoutToCart = (checkoutPayload?: Maybe<CheckoutPayload>): CartType.Cart => {\n if (!checkoutPayload) {\n throw new CommerceError({\n message: 'Invalid response from Swell',\n })\n }\n return normalizeCart(checkoutPayload as any)\n}\n\nexport default checkoutToCart\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes:\n - Added sameSite and secure to the cookie options to allow third-party cookies.\n\t We need this to make work on the studio\n*/\nimport { SWELL_CHECKOUT_URL_COOKIE, SWELL_COOKIE_EXPIRE } from '../../const'\n\nimport Cookies from 'js-cookie'\n\nexport const checkoutCreate = async (fetch: any) => {\n const cart = await fetch({\n query: 'cart',\n method: 'get',\n })\n\n if (!cart) {\n await fetch({\n query: 'cart',\n method: 'setItems',\n variables: [[]],\n })\n }\n\n const checkoutUrl = cart?.checkout_url\n const options: Cookies.CookieAttributes = {\n expires: SWELL_COOKIE_EXPIRE,\n sameSite: \"none\",\n secure: true\n }\n if (checkoutUrl) {\n Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options)\n }\n\n return cart\n}\n\nexport default checkoutCreate\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { useCart, UseCart } from '@plasmicpkgs/commerce'\nimport { SWRHook } from '@plasmicpkgs/commerce'\nimport { useMemo } from 'react'\nimport { normalizeCart } from '../utils/normalize'\nimport { checkoutCreate, checkoutToCart } from './utils'\nimport type { CartType } from '@plasmicpkgs/commerce'\n\nexport default useCart as UseCart<typeof handler>\n\ntype GetCartHook = CartType.GetCartHook;\n\nexport const handler: SWRHook<GetCartHook> = {\n fetchOptions: {\n query: 'cart',\n method: 'get',\n },\n async fetcher({ fetch }) {\n const cart = await checkoutCreate(fetch)\n\n return cart ? normalizeCart(cart) : null\n },\n useHook:\n ({ useData }) =>\n (input) => {\n const response = useData({\n swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },\n })\n return useMemo(\n () =>\n Object.create(response, {\n isEmpty: {\n get() {\n return (response.data?.lineItems.length ?? 0) <= 0\n },\n enumerable: true,\n },\n }),\n [response]\n )\n },\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type { MutationHook } from '@plasmicpkgs/commerce'\nimport { CommerceError } from '@plasmicpkgs/commerce'\nimport { useAddItem, UseAddItem } from '@plasmicpkgs/commerce'\nimport useCart from './use-cart'\nimport { checkoutToCart } from './utils'\nimport { getCheckoutId } from '../utils'\nimport { useCallback } from 'react'\nimport { AddItemHook } from '../types/cart'\n\nexport default useAddItem as UseAddItem<typeof handler>\n\nexport const handler: MutationHook<AddItemHook> = {\n fetchOptions: {\n query: 'cart',\n method: 'addItem',\n },\n async fetcher({ input: item, options, fetch }) {\n if (\n item.quantity &&\n (!Number.isInteger(item.quantity) || item.quantity! < 1)\n ) {\n throw new CommerceError({\n message: 'The item quantity has to be a valid integer greater than 0',\n })\n }\n const variables: {\n product_id: string | undefined\n variant_id?: string\n checkoutId?: string\n quantity?: number\n } = {\n checkoutId: getCheckoutId(),\n product_id: item.productId,\n quantity: item.quantity,\n }\n if (item.productId !== item.variantId) {\n variables.variant_id = item.variantId\n }\n\n const response = await fetch({\n ...options,\n variables,\n })\n\n return checkoutToCart(response) as any\n },\n useHook:\n ({ fetch }) =>\n () => {\n const { mutate } = useCart()\n\n return useCallback(\n async function addItem(input) {\n const data = await fetch({ input })\n await mutate(data, false)\n return data\n },\n [fetch, mutate]\n )\n },\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport Cookies from 'js-cookie'\nimport { SWELL_CHECKOUT_ID_COOKIE } from '../const'\n\nconst getCheckoutId = (id?: string) => {\n return id ?? Cookies.get(SWELL_CHECKOUT_ID_COOKIE)\n}\n\nexport default getCheckoutId\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type {\n HookFetcherContext,\n MutationHookContext,\n} from \"@plasmicpkgs/commerce\";\nimport { useCallback } from \"react\";\n\nimport { CartType, useRemoveItem, UseRemoveItem } from \"@plasmicpkgs/commerce\";\nimport useCart from \"./use-cart\";\nimport { checkoutToCart } from \"./utils\";\n\ntype Cart = CartType.Cart;\ntype LineItem = CartType.LineItem;\ntype RemoveItemHook = CartType.RemoveItemHook;\n\nexport type RemoveItemFn<T = any> = T extends LineItem\n ? (input?: RemoveItemActionInput<T>) => Promise<Cart | null | undefined>\n : (input: RemoveItemActionInput<T>) => Promise<Cart | null>;\n\nexport type RemoveItemActionInput<T = any> = T extends LineItem\n ? Partial<RemoveItemHook[\"actionInput\"]>\n : RemoveItemHook[\"actionInput\"];\n\nexport default useRemoveItem as UseRemoveItem<typeof handler>;\n\nexport const handler = {\n fetchOptions: {\n query: \"cart\",\n method: \"removeItem\",\n },\n async fetcher({\n input: { itemId },\n options,\n fetch,\n }: HookFetcherContext<RemoveItemHook>) {\n const response = await fetch({ ...options, variables: [itemId] });\n\n return checkoutToCart(response);\n },\n useHook: ({ fetch }: MutationHookContext<RemoveItemHook>) => () => {\n const { mutate } = useCart();\n\n return useCallback(\n async function removeItem(input: { id: string }) {\n const data = await fetch({ input: { itemId: input.id } });\n await mutate(data, false);\n\n return data;\n },\n [fetch, mutate]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type {\n HookFetcherContext,\n MutationHookContext,\n} from \"@plasmicpkgs/commerce\";\nimport { ValidationError } from \"@plasmicpkgs/commerce\";\nimport debounce from \"debounce\";\nimport { useCallback } from \"react\";\n// import useUpdateItem, {\n// UpdateItemInput as UpdateItemInputBase,\n// UseUpdateItem,\n// } from '@vercel/commerce/cart/use-update-item'\nimport { CartType, useUpdateItem, UseUpdateItem } from \"@plasmicpkgs/commerce\";\nimport { UpdateItemHook } from \"../types/cart\";\nimport useCart from \"./use-cart\";\nimport { handler as removeItemHandler } from \"./use-remove-item\";\nimport { checkoutToCart } from \"./utils\";\n// export type UpdateItemInput<T = any> = T extends LineItem\n// ? Partial<UpdateItemInputBase<LineItem>>\n// : UpdateItemInputBase<LineItem>\n\nexport default useUpdateItem as UseUpdateItem<typeof handler>;\n\ntype CartItemBody = CartType.CartItemBody;\ntype LineItem = CartType.LineItem;\n\nexport type UpdateItemActionInput<T = any> = T extends LineItem\n ? Partial<UpdateItemHook[\"actionInput\"]>\n : UpdateItemHook[\"actionInput\"];\n\nexport const handler = {\n fetchOptions: {\n query: \"cart\",\n method: \"updateItem\",\n },\n async fetcher({\n input: { itemId, item },\n options,\n fetch,\n }: HookFetcherContext<UpdateItemHook>) {\n if (Number.isInteger(item.quantity)) {\n // Also allow the update hook to remove an item if the quantity is lower than 1\n if (item.quantity! < 1) {\n return removeItemHandler.fetcher({\n options: removeItemHandler.fetchOptions,\n input: { itemId },\n fetch,\n });\n }\n } else if (item.quantity) {\n throw new ValidationError({\n message: \"The item quantity has to be a valid integer\",\n });\n }\n const response = await fetch({\n ...options,\n variables: [itemId, { quantity: item.quantity }],\n });\n\n return checkoutToCart(response);\n },\n useHook:\n ({ fetch }: MutationHookContext<UpdateItemHook>) =>\n <T extends LineItem | undefined = undefined>(\n ctx: {\n item?: T;\n wait?: number;\n } = {}\n ) => {\n const { item } = ctx;\n const { mutate, data: cartData } = useCart() as any;\n\n return useCallback(\n debounce(async (input: UpdateItemActionInput) => {\n const itemId = input.id ?? item?.id;\n if (!itemId) {\n throw new ValidationError({\n message: \"Invalid input used for this operation\",\n });\n }\n\n const data = await fetch({\n input: {\n item: {\n quantity: input.quantity,\n },\n itemId,\n },\n });\n await mutate(data, false);\n return data;\n }, ctx.wait ?? 500),\n [fetch, mutate]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { Fetcher } from '@plasmicpkgs/commerce'\nimport { CommerceError } from '@plasmicpkgs/commerce'\nimport { handleFetchResponse } from './utils'\nimport swell from './provider'\n\nconst fetcher: Fetcher = async ({ method = 'get', variables, query }) => {\n async function callSwell() {\n if (Array.isArray(variables)) {\n const arg1 = variables[0]\n const arg2 = variables[1]\n const response = await swell[query!][method](arg1, arg2)\n return handleFetchResponse(response)\n } else {\n const response = await swell[query!][method](variables)\n return handleFetchResponse(response)\n }\n }\n\n if (query && query in swell) {\n return await callSwell()\n } else {\n throw new CommerceError({ message: 'Invalid query argument!' })\n }\n}\n\nexport default fetcher\n","import { GetProductHook, SWRHook, UseProduct, useProduct } from '@plasmicpkgs/commerce'\nimport { normalizeProduct } from '../utils'\nimport { SwellProduct } from '../types'\n\nexport type GetProductInput = {\n id?: string;\n}\n\nexport default useProduct as UseProduct<typeof handler>\n\nexport const handler: SWRHook<GetProductHook> = {\n fetchOptions: {\n query: 'products',\n method: 'get',\n },\n async fetcher({ input, options, fetch }) {\n const { id } = input;\n const product = await fetch({\n query: options.query,\n method: options.method,\n variables: [id],\n });\n if (!product) {\n return null;\n }\n return normalizeProduct(product);\n },\n useHook:\n ({ useData }) =>\n (input = {}) => {\n return useData({\n input: [\n ['id', input.id],\n ],\n swrOptions: {\n revalidateOnFocus: false,\n ...input.swrOptions,\n },\n })\n },\n}\n","export function ensure<T>(x: T | null | undefined, msg = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n\nexport const ensureNoNilFields = (\n o: Record<string, any>\n): Record<string, any> =>\n Object.fromEntries(Object.entries(o).filter(([k, v]) => v != null));\n","import { Category } from \"../types/site\";\nimport { ensure } from \"./common\";\n\nexport const walkCategoryTree = (\n category?: Category,\n categories?: Category[]\n) => {\n if (!category || !categories) {\n return [];\n }\n\n const queue: Category[] = [category];\n const result: Category[] = [];\n while (queue.length > 0) {\n const curr = ensure(queue.shift());\n result.push(curr);\n queue.push(\n ...(curr.children?.map((child) =>\n ensure(\n categories.find((category) => category.id === child),\n \"The child category must always exist in the categories list\"\n )\n ) ?? [])\n );\n }\n return result;\n};\n\nexport const topologicalSortForCategoryTree = (categories: Category[]) => {\n return categories\n .filter((category) => !category.parentId)\n .flatMap((category) => walkCategoryTree(category, categories));\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Added count as a parameter to input\n*/\nimport type { SearchProductsHook } from \"@plasmicpkgs/commerce\";\nimport {\n HookSWRInput,\n SWRHook,\n useSearch,\n UseSearch,\n} from \"@plasmicpkgs/commerce\";\nimport { SwellProduct } from \"../types\";\nimport { Category } from \"../types/site\";\nimport { normalizeProduct } from \"../utils\";\nimport { walkCategoryTree } from \"../utils/category-tree\";\nimport { ensureNoNilFields } from \"../utils/common\";\n\nexport type SearchProductsInput = {\n search?: string;\n categoryId?: string;\n brandId?: string;\n sort?: string;\n count?: number;\n includeSubCategories?: boolean;\n categories?: Category[];\n};\n\nconst useSearchTyped: UseSearch<typeof handler> = useSearch;\nexport default useSearchTyped;\n\nexport const handler: SWRHook<SearchProductsHook> = {\n fetchOptions: {\n query: \"products\",\n method: \"list\",\n },\n async fetcher({ input, options, fetch }) {\n const sortMap = new Map([\n [\"latest-desc\", \"\"],\n [\"price-asc\", \"price asc\"],\n [\"price-desc\", \"price desc\"],\n [\"trending-desc\", \"popularity\"],\n ]);\n const {\n categoryId,\n includeSubCategories,\n categories,\n brandId,\n search,\n sort = \"latest-desc\",\n count,\n } = input;\n const mappedSort = sortMap.get(sort);\n\n const includedCategories = includeSubCategories\n ? walkCategoryTree(\n categories?.find((category) => category.id === categoryId),\n categories\n )\n : undefined;\n\n const { results: products } = await fetch({\n query: options.query,\n method: options.method,\n variables: ensureNoNilFields({\n category: !includeSubCategories ? categoryId : undefined,\n brand: brandId,\n search,\n sort: mappedSort,\n expand: [\"variants\"],\n limit: count,\n $filters: {\n ...(includeSubCategories\n ? { category: includedCategories?.map((c) => c.id) }\n : {}),\n },\n }),\n });\n\n return {\n products: products.map((product: SwellProduct) =>\n normalizeProduct(product)\n ),\n found: products.length > 0,\n };\n },\n useHook:\n ({ useData }) =>\n (input = {}) => {\n return useData({\n input: [\n [\"search\", input.search],\n [\"categoryId\", input.categoryId],\n [\"includeSubCategories\", input.includeSubCategories],\n [\"categories\", input.categories],\n [\"brandId\", input.brandId],\n [\"sort\", input.sort],\n [\"count\", input.count],\n ] as HookSWRInput,\n swrOptions: {\n revalidateOnFocus: false,\n ...input.swrOptions,\n },\n });\n },\n};\n","import {\n SiteTypes,\n SWRHook,\n useBrands,\n UseBrands,\n} from \"@plasmicpkgs/commerce\";\nimport { useMemo } from \"react\";\n\nexport default useBrands as UseBrands<typeof handler>;\n\ntype GetBrandsHook = SiteTypes.GetBrandsHook;\n\nexport const handler: SWRHook<GetBrandsHook> = {\n fetchOptions: {\n query: \"attributes\",\n method: \"get\",\n },\n async fetcher({ fetch }) {\n const vendors: [string] =\n (\n await fetch({\n query: \"attributes\",\n method: \"get\",\n variables: \"brand\",\n })\n )?.values ?? [];\n return Array.from(new Set(vendors).values()).map((v) => ({\n entityId: v,\n name: v,\n path: `brands/${v}`,\n }));\n },\n useHook: ({ useData }) => (input) => {\n const response = useData({\n swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },\n });\n return useMemo(\n () =>\n Object.create(response, {\n isEmpty: {\n get() {\n return (response.data?.length ?? 0) <= 0;\n },\n enumerable: true,\n },\n }),\n [response]\n );\n },\n};\n","import {\n SiteTypes,\n SWRHook,\n useCategories,\n UseCategories,\n} from \"@plasmicpkgs/commerce\";\nimport { useMemo } from \"react\";\nimport { Category } from \"../types/site\";\nimport { normalizeCategory } from \"../utils\";\nimport { topologicalSortForCategoryTree } from \"../utils/category-tree\";\nimport { ensureNoNilFields } from \"../utils/common\";\n\nexport default useCategories as UseCategories<typeof handler>;\n\ntype GetCategoriesHook = SiteTypes.GetCategoriesHook;\n\nexport const handler: SWRHook<GetCategoriesHook> = {\n fetchOptions: {\n query: \"categories\",\n method: \"get\",\n },\n async fetcher({ input, options, fetch }) {\n const { addIsEmptyField, categoryId } = input;\n\n const data = await fetch({\n query: options.query,\n method: options.method,\n variables: ensureNoNilFields({\n expand: [\"children\", \"parent_id\"],\n id: categoryId,\n }),\n });\n\n let categories = data?.results ?? [];\n if (addIsEmptyField) {\n categories = await Promise.all(\n categories.map(async (category: any) => ({\n ...category,\n products: (\n await fetch({\n query: \"products\",\n method: \"list\",\n variables: ensureNoNilFields({\n limit: 1,\n category: category.id,\n }),\n })\n ).results,\n }))\n );\n }\n\n const normalizedCategories: Category[] = !categoryId\n ? topologicalSortForCategoryTree(categories.map(normalizeCategory))\n : categories.map(normalizeCategory);\n\n for (const category of normalizedCategories) {\n category.depth =\n (normalizedCategories.find((c) => c.id === category.parentId)?.depth ??\n -1) + 1;\n }\n return normalizedCategories;\n },\n useHook: ({ useData }) => (input) => {\n const response = useData({\n input: [\n [\"addIsEmptyField\", input?.addIsEmptyField],\n [\"categoryId\", input?.categoryId],\n ],\n swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },\n });\n return useMemo(\n () =>\n Object.create(response, {\n isEmpty: {\n get() {\n return (response.data?.length ?? 0) <= 0;\n },\n enumerable: true,\n },\n }),\n [response]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport {\n CommerceAPIConfig,\n getCommerceProvider as getCoreCommerceProvider,\n useCommerce as useCoreCommerce,\n} from '@plasmicpkgs/commerce'\nimport { SWELL_CHECKOUT_ID_COOKIE, SWELL_COOKIE_EXPIRE, SWELL_CUSTOMER_TOKEN_COOKIE } from './const'\nimport { getSwellProvider, SwellProvider } from './provider'\nimport fetchApi from './utils/fetch-swell-api'\n\nexport type { SwellProvider }\n\nexport const getCommerceProvider = (storeId: string, publicKey: string) => \n getCoreCommerceProvider(getSwellProvider(storeId, publicKey))\n\nexport const useCommerce = () => useCoreCommerce<SwellProvider>()\n\n\nexport interface SwellConfig extends CommerceAPIConfig {\n fetch: any\n}\n\nconst config: SwellConfig = {\n locale: 'en-US',\n commerceUrl: '',\n apiToken: ''!,\n cartCookie: SWELL_CHECKOUT_ID_COOKIE,\n cartCookieMaxAge: SWELL_COOKIE_EXPIRE,\n fetch: fetchApi,\n customerCookie: SWELL_CUSTOMER_TOKEN_COOKIE,\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Added storeId and publicKey parameters\n*/\nimport swell from \"swell-js\";\n\nimport { CommerceExtraFeatures, Fetcher } from \"@plasmicpkgs/commerce\";\nimport { handler as useAddItem } from \"./cart/use-add-item\";\nimport { handler as useCart } from \"./cart/use-cart\";\nimport { handler as useRemoveItem } from \"./cart/use-remove-item\";\nimport { handler as useUpdateItem } from \"./cart/use-update-item\";\nimport { SWELL_CHECKOUT_ID_COOKIE } from \"./const\";\nimport fetcher from \"./fetcher\";\nimport { handler as useProduct } from \"./product/use-product\";\nimport { handler as useSearch } from \"./product/use-search\";\nimport { handler as useBrands } from \"./site/use-brands\";\nimport { handler as useCategories } from \"./site/use-categories\";\n\nexport const getSwellProvider = (storeId: string, publicKey: string) => {\n // Their types claim `init` is a named export, but examining the JS files in\n // dist/, you can see it's actually a function on the default export.\n // @ts-expect-error swell-js types are wrong\n swell.init(storeId, publicKey);\n\n return {\n locale: \"en-us\",\n cartCookie: SWELL_CHECKOUT_ID_COOKIE,\n swell,\n fetcher,\n cart: { useCart, useAddItem, useUpdateItem, useRemoveItem },\n products: { useSearch, useProduct },\n site: { useCategories, useBrands },\n extraFeatures: {\n includeSubCategories: true,\n },\n };\n};\n\nexport type SwellProvider = {\n locale: string;\n cartCookie: string;\n fetcher: Fetcher;\n cart: {\n useCart: typeof useCart;\n useAddItem: typeof useAddItem;\n useUpdateItem: typeof useUpdateItem;\n useRemoveItem: typeof useRemoveItem;\n };\n products: {\n useSearch: typeof useSearch;\n };\n site: {\n useCategories: typeof useCategories;\n useBrands: typeof useBrands;\n };\n extraFeatures: CommerceExtraFeatures;\n swell: any;\n};\n\nexport default swell as any;\n","import { GlobalContextMeta } from \"@plasmicapp/host\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n CartActionsProvider,\n globalActionsRegistrations,\n} from \"@plasmicpkgs/commerce\";\nimport React from \"react\";\nimport { Registerable } from \"./registerable\";\nimport { getCommerceProvider } from \"./swell\";\n\ninterface CommerceProviderProps {\n children?: React.ReactNode;\n storeId: string;\n publicKey: string;\n}\n\nconst globalContextName = \"plasmic-commerce-swell-provider\";\n\nexport const commerceProviderMeta: GlobalContextMeta<CommerceProviderProps> = {\n name: \"plasmic-commerce-swell-provider\",\n displayName: \"Swell Provider\",\n props: {\n storeId: {\n type: \"string\",\n defaultValue: \"plasmic-sandbox\",\n },\n publicKey: {\n type: \"string\",\n defaultValue: \"pk_QaZeGhtpQaVbNQnWJdRlE1abE6Ezf9U9\",\n },\n },\n ...{ globalActions: globalActionsRegistrations },\n description: `Get your store ID and public storefront API key from the Swell admin UI under Developer > API Keys.\n\n[Watch how to use this integration](https://www.youtube.com/watch?v=b2mgOTbP2_8).`,\n importPath: \"@plasmicpkgs/commerce-swell\",\n importName: \"CommerceProviderComponent\",\n};\n\nexport function CommerceProviderComponent(props: CommerceProviderProps) {\n const { storeId, publicKey, children } = props;\n\n const CommerceProvider = React.useMemo(\n () => getCommerceProvider(storeId, publicKey),\n [storeId, publicKey]\n );\n\n return (\n <CommerceProvider>\n <CartActionsProvider globalContextName={globalContextName}>\n {children}\n </CartActionsProvider>\n </CommerceProvider>\n );\n}\n\nexport function registerCommerceProvider(\n loader?: Registerable,\n customCommerceProviderMeta?: GlobalContextMeta<CommerceProviderProps>\n) {\n const doRegisterComponent: typeof registerGlobalContext = (...args) =>\n loader\n ? loader.registerGlobalContext(...args)\n : registerGlobalContext(...args);\n doRegisterComponent(\n CommerceProviderComponent,\n customCommerceProviderMeta ?? commerceProviderMeta\n );\n}\n","import { Registerable } from \"./registerable\";\nimport { registerCommerceProvider } from \"./registerCommerceProvider\";\nexport * from \"./registerable\";\nexport * from \"./registerCommerceProvider\";\nexport * from \"./swell\";\nexport { registerCommerceProvider };\n\nexport function registerAll(loader?: Registerable) {\n registerCommerceProvider(loader);\n}\n"],"names":["normalizeProductOption","_ref2","id","_ref2$name","name","displayName","_ref2$values","values","returnValues","map","value","output","label","match","_extends","hexColors","__typename","normalizeProduct","swellProduct","description","images","options","slug","variants","price","currencyCode","currency","emptyVariants","productOptions","o","productVariants","_ref4","_ref4$option_value_id","option_value_ids","optionValueIds","split","i","trim","undefined","matchingOption","find","option","_matchingOption$name","normalizeProductVariants","results","productImages","length","url","_ref3","file","rest","_objectWithoutPropertiesLoose","_excluded","height","Number","width","normalizeProductImages","vendor","path","normalizeCart","_ref5","items","sub_total","grand_total","discounts","customerId","account_id","email","createdAt","date_created","code","taxesIncluded","tax_included_total","lineItems","_items$map","normalizeLineItem","lineItemsSubtotalPrice","subtotalPrice","totalPrice","discount","amount","_ref6","product","variant","variantId","productId","_product$id","_product$name","quantity","_variant$id","sku","_variant$sku","image","requiresShipping","listPrice","normalizeChildren","children","ch","normalizeCategory","_ref7","products","depth","parent_id","isEmpty","parentId","handleFetchResponse","_ref","_asyncToGenerator","_regenerator","m","_callee","res","w","_context","n","error","CommerceError","a","_x","apply","arguments","checkoutToCart","checkoutPayload","message","checkoutCreate","fetch","cart","checkoutUrl","query","method","v","variables","expires","sameSite","secure","checkout_url","Cookies","set","handler","fetchOptions","fetcher","useHook","useData","input","response","swrOptions","revalidateOnFocus","useMemo","Object","create","get","_response$data$lineIt","_response$data","data","enumerable","item","isInteger","checkoutId","product_id","variant_id","mutate","useCart","useCallback","_addItem","_callee2","_context2","itemId","_removeItem","_ref$input","removeItemHandler","ValidationError","ctx","debounce","_input$id","_ctx$wait","wait","_ref$method","callSwell","_callSwell","arg1","arg2","Array","isArray","swell","ensure","x","msg","Error","ensureNoNilFields","fromEntries","entries","filter","walkCategoryTree","category","categories","queue","result","_curr$children$map","_curr$children","curr","shift","push","child","topologicalSortForCategoryTree","flatMap","sortMap","Map","categoryId","includeSubCategories","brandId","search","count","mappedSort","_input$sort","sort","includedCategories","brand","expand","limit","$filters","c","found","_yield$fetch","_t2","_yield$fetch$values","_t4","from","Set","entityId","_response$data$length","addIsEmptyField","_context3","_data$results","Promise","all","_t","_t3","normalizedCategories","_loop","_normalizedCategories","_normalizedCategories2","_step","_iterator","_createForOfIteratorHelperLoose","done","d","_regeneratorValues","getCommerceProvider","storeId","publicKey","getCoreCommerceProvider","init","locale","cartCookie","useAddItem","useUpdateItem","useRemoveItem","useSearch","useProduct","site","useCategories","useBrands","extraFeatures","getSwellProvider","commerceProviderMeta","props","type","defaultValue","globalActions","globalActionsRegistrations","importPath","importName","CommerceProviderComponent","CommerceProvider","React","CartActionsProvider","globalContextName","registerCommerceProvider","loader","customCommerceProviderMeta","registerGlobalContext","doRegisterComponent","useCoreCommerce"],"mappings":"m8HAIO,eCkCDA,EAAyB,SAAH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AAyBC,2DHUA,WAAH,OAASI"}
|
|
1
|
+
{"version":3,"file":"commerce-swell.cjs.production.min.js","sources":["../src/const.ts","../src/utils/normalize.ts","../src/utils/handle-fetch-response.ts","../src/cart/utils/checkout-to-cart.ts","../src/cart/utils/checkout-create.ts","../src/cart/use-cart.tsx","../src/cart/use-add-item.tsx","../src/utils/get-checkout-id.ts","../src/cart/use-remove-item.tsx","../src/cart/use-update-item.tsx","../src/fetcher.ts","../src/product/use-product.tsx","../src/utils/common.ts","../src/utils/category-tree.ts","../src/product/use-search.tsx","../src/site/use-brands.ts","../src/site/use-categories.ts","../src/swell.ts","../src/provider.ts","../src/registerCommerceProvider.tsx","../src/index.tsx"],"sourcesContent":["/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Removed store id and public key\n*/\nexport const SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId'\n\nexport const SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl'\n\nexport const SWELL_CUSTOMER_TOKEN_COOKIE = 'swell_customerToken'\n\nexport const SWELL_COOKIE_EXPIRE = 30\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Added \"Default Variant\" to default title when there's no product variant\n*/\nimport { MoneyV2 } from \"../schema\";\nimport type {\n Cart,\n CartLineItem,\n LineItem,\n ProductOptionValue,\n SwellCart,\n SwellImage,\n SwellProduct,\n SwellProductOptionValue,\n SwellVariant,\n} from \"../types\";\nimport { Product, ProductOption } from \"../types/product\";\nimport { Category, SwellCategoryChildren } from \"../types/site\";\n\nconst money = ({ amount, currencyCode }: MoneyV2) => {\n return {\n value: +amount,\n currencyCode,\n };\n};\n\ntype swellProductOption = {\n id: string;\n name: string;\n values: any[];\n};\n\ntype normalizedProductOption = {\n id: string;\n displayName: string;\n values: ProductOptionValue[];\n};\n\nconst normalizeProductOption = ({\n id,\n name: displayName = \"\",\n values = [],\n}: swellProductOption): ProductOption => {\n let returnValues = values.map((value) => {\n let output: any = {\n label: value.name,\n // id: value?.id || id,\n };\n if (displayName.match(/colou?r/gi)) {\n output = {\n ...output,\n hexColors: [value.name],\n };\n }\n return output;\n });\n return {\n __typename: \"MultipleChoiceOption\",\n id,\n displayName,\n values: returnValues,\n };\n};\n\nconst normalizeProductImages = (images: SwellImage[]) => {\n if (!images || images.length < 1) {\n return [{ url: \"/\" }];\n }\n return images?.map(({ file, ...rest }: SwellImage) => ({\n url: file?.url + \"\",\n height: Number(file?.height),\n width: Number(file?.width),\n ...rest,\n }));\n};\n\nconst normalizeProductVariants = (\n variants: SwellVariant[],\n productOptions: swellProductOption[]\n) => {\n return variants?.map(\n ({ id, name, price, option_value_ids: optionValueIds = [] }) => {\n const values = name\n .split(\",\")\n .map((i) => ({ name: i.trim(), label: i.trim() }));\n\n const options = optionValueIds.map((id) => {\n const matchingOption = productOptions.find((option) => {\n return option.values.find(\n (value: SwellProductOptionValue) => value.id == id\n );\n });\n return normalizeProductOption({\n id,\n name: matchingOption?.name ?? \"\",\n values,\n });\n });\n\n return {\n id,\n name,\n // sku: sku ?? id,\n price: price ?? undefined,\n // listPrice: price ?? null,\n // requiresShipping: true,\n options,\n };\n }\n );\n};\n\nexport function normalizeProduct(swellProduct: SwellProduct): Product {\n const {\n id,\n name,\n description,\n images,\n options,\n slug,\n variants,\n price: value,\n currency: currencyCode,\n } = swellProduct;\n // ProductView accesses variants for each product\n const emptyVariants = [{ options: [], id, name: \"Default variant\" }];\n\n const productOptions = options\n ? options.map((o) => normalizeProductOption(o))\n : [];\n const productVariants = variants\n ? normalizeProductVariants(variants.results, options)\n : [];\n\n const productImages = normalizeProductImages(images);\n const product = {\n ...swellProduct,\n description,\n id,\n vendor: \"\",\n path: `/${slug}`,\n images: productImages,\n variants:\n productVariants && productVariants.length\n ? productVariants\n : emptyVariants,\n options: productOptions,\n price: {\n value,\n currencyCode,\n },\n };\n return product;\n}\n\nexport function normalizeCart({\n id,\n account_id,\n date_created,\n currency,\n tax_included_total,\n items,\n sub_total,\n grand_total,\n discounts,\n}: SwellCart) {\n const cart: Cart = {\n id: id,\n customerId: account_id + \"\",\n email: \"\",\n createdAt: date_created,\n currency: { code: currency },\n taxesIncluded: tax_included_total > 0,\n lineItems: items?.map(normalizeLineItem) ?? [],\n lineItemsSubtotalPrice: +sub_total,\n subtotalPrice: +sub_total,\n totalPrice: grand_total,\n discounts: discounts?.map((discount) => ({ value: discount.amount })),\n };\n return cart;\n}\n/*\nexport function normalizeCustomer(customer: SwellCustomer): Customer {\n const { first_name: firstName, last_name: lastName } = customer\n return {\n ...customer,\n firstName,\n lastName,\n }\n}\n*/\nfunction normalizeLineItem({\n id,\n product,\n price,\n variant,\n quantity,\n}: CartLineItem): LineItem {\n const item = {\n id,\n variantId: variant?.id,\n productId: product.id ?? \"\",\n name: product?.name ?? \"\",\n quantity,\n variant: {\n id: variant?.id ?? \"\",\n sku: variant?.sku ?? \"\",\n name: variant?.name!,\n image: {\n url:\n product?.images && product.images.length > 0\n ? product?.images[0].file.url\n : \"/\",\n },\n requiresShipping: false,\n price: price,\n listPrice: price,\n },\n path: \"\",\n discounts: [],\n options: [\n {\n value: variant?.name,\n },\n ],\n };\n return item;\n}\n\nexport function normalizeChildren(children: SwellCategoryChildren) {\n return children?.results.map((ch) => ch.id);\n}\n\nexport function normalizeCategory({\n id,\n name,\n slug,\n products,\n images,\n depth,\n children,\n parent_id,\n}: any): Category {\n return {\n id,\n name,\n slug,\n path: `/${slug}`,\n isEmpty: products?.length === 0,\n images: images?.map((image: any) => ({\n url: image.file.url,\n })),\n depth,\n children: normalizeChildren(children),\n parentId: parent_id,\n };\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { CommerceError } from '@plasmicpkgs/commerce'\n\ntype SwellFetchResponse = {\n error: {\n message: string\n code?: string\n }\n}\n\nconst handleFetchResponse = async (res: SwellFetchResponse) => {\n if (res) {\n if (res.error) {\n throw new CommerceError(res.error)\n }\n return res\n }\n return null;\n}\n\nexport default handleFetchResponse\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { CommerceError } from '@plasmicpkgs/commerce'\nimport { CartType } from '@plasmicpkgs/commerce'\n\nimport {\n CheckoutLineItemsAddPayload,\n CheckoutLineItemsRemovePayload,\n CheckoutLineItemsUpdatePayload,\n Maybe,\n} from '../../schema'\nimport { normalizeCart } from '../../utils'\nexport type CheckoutPayload =\n | CheckoutLineItemsAddPayload\n | CheckoutLineItemsUpdatePayload\n | CheckoutLineItemsRemovePayload\n\nconst checkoutToCart = (checkoutPayload?: Maybe<CheckoutPayload>): CartType.Cart => {\n if (!checkoutPayload) {\n throw new CommerceError({\n message: 'Invalid response from Swell',\n })\n }\n return normalizeCart(checkoutPayload as any)\n}\n\nexport default checkoutToCart\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes:\n - Added sameSite and secure to the cookie options to allow third-party cookies.\n\t We need this to make work on the studio\n*/\nimport { SWELL_CHECKOUT_URL_COOKIE, SWELL_COOKIE_EXPIRE } from '../../const'\n\nimport Cookies from 'js-cookie'\n\nexport const checkoutCreate = async (fetch: any) => {\n const cart = await fetch({\n query: 'cart',\n method: 'get',\n })\n\n if (!cart) {\n await fetch({\n query: 'cart',\n method: 'setItems',\n variables: [[]],\n })\n }\n\n const checkoutUrl = cart?.checkout_url\n const options: Cookies.CookieAttributes = {\n expires: SWELL_COOKIE_EXPIRE,\n sameSite: \"none\",\n secure: true\n }\n if (checkoutUrl) {\n Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options)\n }\n\n return cart\n}\n\nexport default checkoutCreate\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type { CartType } from \"@plasmicpkgs/commerce\";\nimport { SWRHook, useCart, UseCart } from \"@plasmicpkgs/commerce\";\nimport { useMemo } from \"react\";\nimport { normalizeCart } from \"../utils/normalize\";\nimport { checkoutCreate } from \"./utils\";\n\nconst _default: UseCart<typeof handler> = useCart as UseCart<typeof handler>;\nexport default _default;\n\ntype GetCartHook = CartType.GetCartHook;\n\nexport const handler: SWRHook<GetCartHook> = {\n fetchOptions: {\n query: \"cart\",\n method: \"get\",\n },\n async fetcher({ fetch }) {\n const cart = await checkoutCreate(fetch);\n\n return cart ? normalizeCart(cart) : null;\n },\n useHook:\n ({ useData }) =>\n (input) => {\n const response = useData({\n swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },\n });\n return useMemo(\n () =>\n Object.create(response, {\n isEmpty: {\n get() {\n return (response.data?.lineItems.length ?? 0) <= 0;\n },\n enumerable: true,\n },\n }),\n [response]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type { MutationHook } from '@plasmicpkgs/commerce'\nimport { CommerceError } from '@plasmicpkgs/commerce'\nimport { useAddItem, UseAddItem } from '@plasmicpkgs/commerce'\nimport useCart from './use-cart'\nimport { checkoutToCart } from './utils'\nimport { getCheckoutId } from '../utils'\nimport { useCallback } from 'react'\nimport { AddItemHook } from '../types/cart'\n\nexport default useAddItem as UseAddItem<typeof handler>\n\nexport const handler: MutationHook<AddItemHook> = {\n fetchOptions: {\n query: 'cart',\n method: 'addItem',\n },\n async fetcher({ input: item, options, fetch }) {\n if (\n item.quantity &&\n (!Number.isInteger(item.quantity) || item.quantity! < 1)\n ) {\n throw new CommerceError({\n message: 'The item quantity has to be a valid integer greater than 0',\n })\n }\n const variables: {\n product_id: string | undefined\n variant_id?: string\n checkoutId?: string\n quantity?: number\n } = {\n checkoutId: getCheckoutId(),\n product_id: item.productId,\n quantity: item.quantity,\n }\n if (item.productId !== item.variantId) {\n variables.variant_id = item.variantId\n }\n\n const response = await fetch({\n ...options,\n variables,\n })\n\n return checkoutToCart(response) as any\n },\n useHook:\n ({ fetch }) =>\n () => {\n const { mutate } = useCart()\n\n return useCallback(\n async function addItem(input) {\n const data = await fetch({ input })\n await mutate(data, false)\n return data\n },\n [fetch, mutate]\n )\n },\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport Cookies from 'js-cookie'\nimport { SWELL_CHECKOUT_ID_COOKIE } from '../const'\n\nconst getCheckoutId = (id?: string) => {\n return id ?? Cookies.get(SWELL_CHECKOUT_ID_COOKIE)\n}\n\nexport default getCheckoutId\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type {\n HookFetcherContext,\n MutationHookContext,\n} from \"@plasmicpkgs/commerce\";\nimport { useCallback } from \"react\";\n\nimport { CartType, useRemoveItem, UseRemoveItem } from \"@plasmicpkgs/commerce\";\nimport useCart from \"./use-cart\";\nimport { checkoutToCart } from \"./utils\";\n\ntype Cart = CartType.Cart;\ntype LineItem = CartType.LineItem;\ntype RemoveItemHook = CartType.RemoveItemHook;\n\nexport type RemoveItemFn<T = any> = T extends LineItem\n ? (input?: RemoveItemActionInput<T>) => Promise<Cart | null | undefined>\n : (input: RemoveItemActionInput<T>) => Promise<Cart | null>;\n\nexport type RemoveItemActionInput<T = any> = T extends LineItem\n ? Partial<RemoveItemHook[\"actionInput\"]>\n : RemoveItemHook[\"actionInput\"];\n\nexport default useRemoveItem as UseRemoveItem<typeof handler>;\n\nexport const handler = {\n fetchOptions: {\n query: \"cart\",\n method: \"removeItem\",\n },\n async fetcher({\n input: { itemId },\n options,\n fetch,\n }: HookFetcherContext<RemoveItemHook>) {\n const response = await fetch({ ...options, variables: [itemId] });\n\n return checkoutToCart(response);\n },\n useHook: ({ fetch }: MutationHookContext<RemoveItemHook>) => () => {\n const { mutate } = useCart();\n\n return useCallback(\n async function removeItem(input: { id: string }) {\n const data = await fetch({ input: { itemId: input.id } });\n await mutate(data, false);\n\n return data;\n },\n [fetch, mutate]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport type {\n HookFetcherContext,\n MutationHookContext,\n} from \"@plasmicpkgs/commerce\";\nimport { ValidationError } from \"@plasmicpkgs/commerce\";\nimport debounce from \"debounce\";\nimport { useCallback } from \"react\";\n// import useUpdateItem, {\n// UpdateItemInput as UpdateItemInputBase,\n// UseUpdateItem,\n// } from '@vercel/commerce/cart/use-update-item'\nimport { CartType, useUpdateItem, UseUpdateItem } from \"@plasmicpkgs/commerce\";\nimport { UpdateItemHook } from \"../types/cart\";\nimport useCart from \"./use-cart\";\nimport { handler as removeItemHandler } from \"./use-remove-item\";\nimport { checkoutToCart } from \"./utils\";\n// export type UpdateItemInput<T = any> = T extends LineItem\n// ? Partial<UpdateItemInputBase<LineItem>>\n// : UpdateItemInputBase<LineItem>\n\nexport default useUpdateItem as UseUpdateItem<typeof handler>;\n\ntype CartItemBody = CartType.CartItemBody;\ntype LineItem = CartType.LineItem;\n\nexport type UpdateItemActionInput<T = any> = T extends LineItem\n ? Partial<UpdateItemHook[\"actionInput\"]>\n : UpdateItemHook[\"actionInput\"];\n\nexport const handler = {\n fetchOptions: {\n query: \"cart\",\n method: \"updateItem\",\n },\n async fetcher({\n input: { itemId, item },\n options,\n fetch,\n }: HookFetcherContext<UpdateItemHook>) {\n if (Number.isInteger(item.quantity)) {\n // Also allow the update hook to remove an item if the quantity is lower than 1\n if (item.quantity! < 1) {\n return removeItemHandler.fetcher({\n options: removeItemHandler.fetchOptions,\n input: { itemId },\n fetch,\n });\n }\n } else if (item.quantity) {\n throw new ValidationError({\n message: \"The item quantity has to be a valid integer\",\n });\n }\n const response = await fetch({\n ...options,\n variables: [itemId, { quantity: item.quantity }],\n });\n\n return checkoutToCart(response);\n },\n useHook:\n ({ fetch }: MutationHookContext<UpdateItemHook>) =>\n <T extends LineItem | undefined = undefined>(\n ctx: {\n item?: T;\n wait?: number;\n } = {}\n ) => {\n const { item } = ctx;\n const { mutate, data: cartData } = useCart() as any;\n\n return useCallback(\n debounce(async (input: UpdateItemActionInput) => {\n const itemId = input.id ?? item?.id;\n if (!itemId) {\n throw new ValidationError({\n message: \"Invalid input used for this operation\",\n });\n }\n\n const data = await fetch({\n input: {\n item: {\n quantity: input.quantity,\n },\n itemId,\n },\n });\n await mutate(data, false);\n return data;\n }, ctx.wait ?? 500),\n [fetch, mutate]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport { Fetcher } from '@plasmicpkgs/commerce'\nimport { CommerceError } from '@plasmicpkgs/commerce'\nimport { handleFetchResponse } from './utils'\nimport swell from './provider'\n\nconst fetcher: Fetcher = async ({ method = 'get', variables, query }) => {\n async function callSwell() {\n if (Array.isArray(variables)) {\n const arg1 = variables[0]\n const arg2 = variables[1]\n const response = await swell[query!][method](arg1, arg2)\n return handleFetchResponse(response)\n } else {\n const response = await swell[query!][method](variables)\n return handleFetchResponse(response)\n }\n }\n\n if (query && query in swell) {\n return await callSwell()\n } else {\n throw new CommerceError({ message: 'Invalid query argument!' })\n }\n}\n\nexport default fetcher\n","import {\n GetProductHook,\n SWRHook,\n UseProduct,\n useProduct,\n} from \"@plasmicpkgs/commerce\";\nimport { normalizeProduct } from \"../utils\";\n\nexport type GetProductInput = {\n id?: string;\n};\n\nconst _default: UseProduct<typeof handler> = useProduct as UseProduct<\n typeof handler\n>;\nexport default _default;\n\nexport const handler: SWRHook<GetProductHook> = {\n fetchOptions: {\n query: \"products\",\n method: \"get\",\n },\n async fetcher({ input, options, fetch }) {\n const { id } = input;\n const product = await fetch({\n query: options.query,\n method: options.method,\n variables: [id],\n });\n if (!product) {\n return null;\n }\n return normalizeProduct(product);\n },\n useHook:\n ({ useData }) =>\n (input = {}) => {\n return useData({\n input: [[\"id\", input.id]],\n swrOptions: {\n revalidateOnFocus: false,\n ...input.swrOptions,\n },\n });\n },\n};\n","export function ensure<T>(x: T | null | undefined, msg = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n\nexport const ensureNoNilFields = (\n o: Record<string, any>\n): Record<string, any> =>\n Object.fromEntries(Object.entries(o).filter(([k, v]) => v != null));\n","import { Category } from \"../types/site\";\nimport { ensure } from \"./common\";\n\nexport const walkCategoryTree = (\n category?: Category,\n categories?: Category[]\n) => {\n if (!category || !categories) {\n return [];\n }\n\n const queue: Category[] = [category];\n const result: Category[] = [];\n while (queue.length > 0) {\n const curr = ensure(queue.shift());\n result.push(curr);\n queue.push(\n ...(curr.children?.map((child) =>\n ensure(\n categories.find((category) => category.id === child),\n \"The child category must always exist in the categories list\"\n )\n ) ?? [])\n );\n }\n return result;\n};\n\nexport const topologicalSortForCategoryTree = (categories: Category[]) => {\n return categories\n .filter((category) => !category.parentId)\n .flatMap((category) => walkCategoryTree(category, categories));\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Added count as a parameter to input\n*/\nimport type { SearchProductsHook } from \"@plasmicpkgs/commerce\";\nimport {\n HookSWRInput,\n SWRHook,\n useSearch,\n UseSearch,\n} from \"@plasmicpkgs/commerce\";\nimport { SwellProduct } from \"../types\";\nimport { Category } from \"../types/site\";\nimport { normalizeProduct } from \"../utils\";\nimport { walkCategoryTree } from \"../utils/category-tree\";\nimport { ensureNoNilFields } from \"../utils/common\";\n\nexport type SearchProductsInput = {\n search?: string;\n categoryId?: string;\n brandId?: string;\n sort?: string;\n count?: number;\n includeSubCategories?: boolean;\n categories?: Category[];\n};\n\nconst useSearchTyped: UseSearch<typeof handler> = useSearch;\nexport default useSearchTyped;\n\nexport const handler: SWRHook<SearchProductsHook> = {\n fetchOptions: {\n query: \"products\",\n method: \"list\",\n },\n async fetcher({ input, options, fetch }) {\n const sortMap = new Map([\n [\"latest-desc\", \"\"],\n [\"price-asc\", \"price asc\"],\n [\"price-desc\", \"price desc\"],\n [\"trending-desc\", \"popularity\"],\n ]);\n const {\n categoryId,\n includeSubCategories,\n categories,\n brandId,\n search,\n sort = \"latest-desc\",\n count,\n } = input;\n const mappedSort = sortMap.get(sort);\n\n const includedCategories = includeSubCategories\n ? walkCategoryTree(\n categories?.find((category) => category.id === categoryId),\n categories\n )\n : undefined;\n\n const { results: products } = await fetch({\n query: options.query,\n method: options.method,\n variables: ensureNoNilFields({\n category: !includeSubCategories ? categoryId : undefined,\n brand: brandId,\n search,\n sort: mappedSort,\n expand: [\"variants\"],\n limit: count,\n $filters: {\n ...(includeSubCategories\n ? { category: includedCategories?.map((c) => c.id) }\n : {}),\n },\n }),\n });\n\n return {\n products: products.map((product: SwellProduct) =>\n normalizeProduct(product)\n ),\n found: products.length > 0,\n };\n },\n useHook:\n ({ useData }) =>\n (input = {}) => {\n return useData({\n input: [\n [\"search\", input.search],\n [\"categoryId\", input.categoryId],\n [\"includeSubCategories\", input.includeSubCategories],\n [\"categories\", input.categories],\n [\"brandId\", input.brandId],\n [\"sort\", input.sort],\n [\"count\", input.count],\n ] as HookSWRInput,\n swrOptions: {\n revalidateOnFocus: false,\n ...input.swrOptions,\n },\n });\n },\n};\n","import {\n SiteTypes,\n SWRHook,\n useBrands,\n UseBrands,\n} from \"@plasmicpkgs/commerce\";\nimport { useMemo } from \"react\";\n\nconst _default: UseBrands<typeof handler> = useBrands as UseBrands<\n typeof handler\n>;\nexport default _default;\n\ntype GetBrandsHook = SiteTypes.GetBrandsHook;\n\nexport const handler: SWRHook<GetBrandsHook> = {\n fetchOptions: {\n query: \"attributes\",\n method: \"get\",\n },\n async fetcher({ fetch }) {\n const vendors: [string] =\n (\n await fetch({\n query: \"attributes\",\n method: \"get\",\n variables: \"brand\",\n })\n )?.values ?? [];\n return Array.from(new Set(vendors).values()).map((v) => ({\n entityId: v,\n name: v,\n path: `brands/${v}`,\n }));\n },\n useHook:\n ({ useData }) =>\n (input) => {\n const response = useData({\n swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },\n });\n return useMemo(\n () =>\n Object.create(response, {\n isEmpty: {\n get() {\n return (response.data?.length ?? 0) <= 0;\n },\n enumerable: true,\n },\n }),\n [response]\n );\n },\n};\n","import {\n SiteTypes,\n SWRHook,\n useCategories,\n UseCategories,\n} from \"@plasmicpkgs/commerce\";\nimport { useMemo } from \"react\";\nimport { Category } from \"../types/site\";\nimport { normalizeCategory } from \"../utils\";\nimport { topologicalSortForCategoryTree } from \"../utils/category-tree\";\nimport { ensureNoNilFields } from \"../utils/common\";\n\nconst _default: UseCategories<typeof handler> = useCategories as UseCategories<\n typeof handler\n>;\nexport default _default;\n\ntype GetCategoriesHook = SiteTypes.GetCategoriesHook;\n\nexport const handler: SWRHook<GetCategoriesHook> = {\n fetchOptions: {\n query: \"categories\",\n method: \"get\",\n },\n async fetcher({ input, options, fetch }) {\n const { addIsEmptyField, categoryId } = input;\n\n const data = await fetch({\n query: options.query,\n method: options.method,\n variables: ensureNoNilFields({\n expand: [\"children\", \"parent_id\"],\n id: categoryId,\n }),\n });\n\n let categories = data?.results ?? [];\n if (addIsEmptyField) {\n categories = await Promise.all(\n categories.map(async (category: any) => ({\n ...category,\n products: (\n await fetch({\n query: \"products\",\n method: \"list\",\n variables: ensureNoNilFields({\n limit: 1,\n category: category.id,\n }),\n })\n ).results,\n }))\n );\n }\n\n const normalizedCategories: Category[] = !categoryId\n ? topologicalSortForCategoryTree(categories.map(normalizeCategory))\n : categories.map(normalizeCategory);\n\n for (const category of normalizedCategories) {\n category.depth =\n (normalizedCategories.find((c) => c.id === category.parentId)?.depth ??\n -1) + 1;\n }\n return normalizedCategories;\n },\n useHook:\n ({ useData }) =>\n (input) => {\n const response = useData({\n input: [\n [\"addIsEmptyField\", input?.addIsEmptyField],\n [\"categoryId\", input?.categoryId],\n ],\n swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },\n });\n return useMemo(\n () =>\n Object.create(response, {\n isEmpty: {\n get() {\n return (response.data?.length ?? 0) <= 0;\n },\n enumerable: true,\n },\n }),\n [response]\n );\n },\n};\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: None\n*/\nimport {\n CommerceAPIConfig,\n getCommerceProvider as getCoreCommerceProvider,\n useCommerce as useCoreCommerce,\n} from '@plasmicpkgs/commerce'\nimport { SWELL_CHECKOUT_ID_COOKIE, SWELL_COOKIE_EXPIRE, SWELL_CUSTOMER_TOKEN_COOKIE } from './const'\nimport { getSwellProvider, SwellProvider } from './provider'\nimport fetchApi from './utils/fetch-swell-api'\n\nexport type { SwellProvider }\n\nexport const getCommerceProvider = (storeId: string, publicKey: string) => \n getCoreCommerceProvider(getSwellProvider(storeId, publicKey))\n\nexport const useCommerce = () => useCoreCommerce<SwellProvider>()\n\n\nexport interface SwellConfig extends CommerceAPIConfig {\n fetch: any\n}\n\nconst config: SwellConfig = {\n locale: 'en-US',\n commerceUrl: '',\n apiToken: ''!,\n cartCookie: SWELL_CHECKOUT_ID_COOKIE,\n cartCookieMaxAge: SWELL_COOKIE_EXPIRE,\n fetch: fetchApi,\n customerCookie: SWELL_CUSTOMER_TOKEN_COOKIE,\n}\n","/*\n Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src\n Changes: Added storeId and publicKey parameters\n*/\nimport swell from \"swell-js\";\n\nimport { CommerceExtraFeatures, Fetcher } from \"@plasmicpkgs/commerce\";\nimport { handler as useAddItem } from \"./cart/use-add-item\";\nimport { handler as useCart } from \"./cart/use-cart\";\nimport { handler as useRemoveItem } from \"./cart/use-remove-item\";\nimport { handler as useUpdateItem } from \"./cart/use-update-item\";\nimport { SWELL_CHECKOUT_ID_COOKIE } from \"./const\";\nimport fetcher from \"./fetcher\";\nimport { handler as useProduct } from \"./product/use-product\";\nimport { handler as useSearch } from \"./product/use-search\";\nimport { handler as useBrands } from \"./site/use-brands\";\nimport { handler as useCategories } from \"./site/use-categories\";\n\nexport const getSwellProvider = (storeId: string, publicKey: string) => {\n // swell-js exports `init` as a named function; with esModuleInterop the\n // default import resolves it as a method on the namespace, so this typechecks.\n swell.init(storeId, publicKey);\n\n return {\n locale: \"en-us\",\n cartCookie: SWELL_CHECKOUT_ID_COOKIE,\n swell,\n fetcher,\n cart: { useCart, useAddItem, useUpdateItem, useRemoveItem },\n products: { useSearch, useProduct },\n site: { useCategories, useBrands },\n extraFeatures: {\n includeSubCategories: true,\n },\n };\n};\n\nexport type SwellProvider = {\n locale: string;\n cartCookie: string;\n fetcher: Fetcher;\n cart: {\n useCart: typeof useCart;\n useAddItem: typeof useAddItem;\n useUpdateItem: typeof useUpdateItem;\n useRemoveItem: typeof useRemoveItem;\n };\n products: {\n useSearch: typeof useSearch;\n };\n site: {\n useCategories: typeof useCategories;\n useBrands: typeof useBrands;\n };\n extraFeatures: CommerceExtraFeatures;\n swell: any;\n};\n\nexport default swell as any;\n","import { GlobalContextMeta } from \"@plasmicapp/host\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n CartActionsProvider,\n globalActionsRegistrations,\n} from \"@plasmicpkgs/commerce\";\nimport React from \"react\";\nimport { Registerable } from \"./registerable\";\nimport { getCommerceProvider } from \"./swell\";\n\ninterface CommerceProviderProps {\n children?: React.ReactNode;\n storeId: string;\n publicKey: string;\n}\n\nconst globalContextName = \"plasmic-commerce-swell-provider\";\n\nexport const commerceProviderMeta: GlobalContextMeta<CommerceProviderProps> = {\n name: \"plasmic-commerce-swell-provider\",\n displayName: \"Swell Provider\",\n props: {\n storeId: {\n type: \"string\",\n defaultValue: \"plasmic-sandbox\",\n },\n publicKey: {\n type: \"string\",\n defaultValue: \"pk_QaZeGhtpQaVbNQnWJdRlE1abE6Ezf9U9\",\n },\n },\n ...{ globalActions: globalActionsRegistrations },\n description: `Get your store ID and public storefront API key from the Swell admin UI under Developer > API Keys.\n\n[Watch how to use this integration](https://www.youtube.com/watch?v=b2mgOTbP2_8).`,\n importPath: \"@plasmicpkgs/commerce-swell\",\n importName: \"CommerceProviderComponent\",\n};\n\nexport function CommerceProviderComponent(props: CommerceProviderProps) {\n const { storeId, publicKey, children } = props;\n\n const CommerceProvider = React.useMemo(\n () => getCommerceProvider(storeId, publicKey),\n [storeId, publicKey]\n );\n\n return (\n <CommerceProvider>\n <CartActionsProvider globalContextName={globalContextName}>\n {children}\n </CartActionsProvider>\n </CommerceProvider>\n );\n}\n\nexport function registerCommerceProvider(\n loader?: Registerable,\n customCommerceProviderMeta?: GlobalContextMeta<CommerceProviderProps>\n) {\n const doRegisterComponent: typeof registerGlobalContext = (...args) =>\n loader\n ? loader.registerGlobalContext(...args)\n : registerGlobalContext(...args);\n doRegisterComponent(\n CommerceProviderComponent,\n customCommerceProviderMeta ?? commerceProviderMeta\n );\n}\n","import { Registerable } from \"./registerable\";\nimport { registerCommerceProvider } from \"./registerCommerceProvider\";\nexport * from \"./registerable\";\nexport * from \"./registerCommerceProvider\";\nexport * from \"./swell\";\nexport { registerCommerceProvider };\n\nexport function registerAll(loader?: Registerable) {\n registerCommerceProvider(loader);\n}\n"],"names":["normalizeProductOption","_ref2","id","_ref2$name","name","displayName","_ref2$values","values","returnValues","map","value","output","label","match","_extends","hexColors","__typename","normalizeProduct","swellProduct","description","images","options","slug","variants","price","currencyCode","currency","emptyVariants","productOptions","o","productVariants","_ref4","_ref4$option_value_id","option_value_ids","optionValueIds","split","i","trim","undefined","matchingOption","find","option","_matchingOption$name","normalizeProductVariants","results","productImages","length","url","_ref3","file","rest","_objectWithoutPropertiesLoose","_excluded","height","Number","width","normalizeProductImages","vendor","path","normalizeCart","_ref5","items","sub_total","grand_total","discounts","customerId","account_id","email","createdAt","date_created","code","taxesIncluded","tax_included_total","lineItems","_items$map","normalizeLineItem","lineItemsSubtotalPrice","subtotalPrice","totalPrice","discount","amount","_ref6","product","variant","variantId","productId","_product$id","_product$name","quantity","_variant$id","sku","_variant$sku","image","requiresShipping","listPrice","normalizeChildren","children","ch","normalizeCategory","_ref7","products","depth","parent_id","isEmpty","parentId","handleFetchResponse","_ref","_asyncToGenerator","_regenerator","m","_callee","res","w","_context","n","error","CommerceError","a","_x","apply","arguments","checkoutToCart","checkoutPayload","message","checkoutCreate","fetch","cart","checkoutUrl","query","method","v","variables","expires","sameSite","secure","checkout_url","Cookies","set","_default","useCart","handler","fetchOptions","fetcher","useHook","useData","input","response","swrOptions","revalidateOnFocus","useMemo","Object","create","get","_response$data$lineIt","_response$data","data","enumerable","item","isInteger","checkoutId","product_id","variant_id","mutate","useCallback","_addItem","_callee2","_context2","itemId","_removeItem","_ref$input","removeItemHandler","ValidationError","ctx","debounce","_input$id","_ctx$wait","wait","_ref$method","callSwell","_callSwell","arg1","arg2","Array","isArray","swell","ensure","x","msg","Error","ensureNoNilFields","fromEntries","entries","filter","walkCategoryTree","category","categories","queue","result","_curr$children$map","_curr$children","curr","shift","push","child","topologicalSortForCategoryTree","flatMap","sortMap","Map","categoryId","includeSubCategories","brandId","search","count","mappedSort","_input$sort","sort","includedCategories","brand","expand","limit","$filters","c","found","_yield$fetch","_t2","_yield$fetch$values","_t4","from","Set","entityId","_response$data$length","addIsEmptyField","_context3","_data$results","Promise","all","_t","_t3","normalizedCategories","_loop","_normalizedCategories","_normalizedCategories2","_step","_iterator","_createForOfIteratorHelperLoose","done","d","_regeneratorValues","getCommerceProvider","storeId","publicKey","getCoreCommerceProvider","init","locale","cartCookie","useAddItem","useUpdateItem","useRemoveItem","useSearch","useProduct","site","useCategories","useBrands","extraFeatures","getSwellProvider","commerceProviderMeta","props","type","defaultValue","globalActions","globalActionsRegistrations","importPath","importName","CommerceProviderComponent","CommerceProvider","React","CartActionsProvider","globalContextName","registerCommerceProvider","loader","customCommerceProviderMeta","registerGlobalContext","doRegisterComponent","useCoreCommerce"],"mappings":"m8HAIO,eCkCDA,EAAyB,SAAHC,OAC1BC,EAAED,EAAFC,GAAEC,EAAAF,EACFG,KAAMC,WAAWF,EAAG,GAAEA,EAAAG,EAAAL,EACtBM,OAEIC,YAFEF,EAAG,GAAEA,GAEeG,KAAI,SAACC,GAC7B,IAAIC,EAAc,CAChBC,MAAOF,EAAMN,MASf,OANIC,EAAYQ,MAAM,eACpBF,EAAMG,KACDH,GACHI,UAAW,CAACL,EAAMN,SAGfO,KAET,MAAO,CACLK,WAAY,uBACZd,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AAiBC,GAKhD,OAFAlE,EAAMoE,KAAKH,EAASC,GAEb,CACLG,OAAQ,QACRC,WlBrBoC,mBkBsBpCtE,MAAAA,EACA1C,QAAAA,EACAhB,KAAM,CAAEa,QAAAA,EAASoH,WAAAA,EAAYC,cAAAA,EAAeC,cAAAA,GAC5C7J,SAAU,CAAE8J,UAAAA,EAAWC,WAAAA,GACvBC,KAAM,CAAEC,cAAAA,EAAeC,UAAAA,GACvBC,cAAe,CACbtD,sBAAsB,IDhBFuD,CAAiBf,EAASC,KEEvCe,EAAoB3P,GAC/BV,KAAM,kCACNC,YAAa,iBACbqQ,MAAO,CACLjB,QAAS,CACPkB,KAAM,SACNC,aAAc,mBAEhBlB,UAAW,CACTiB,KAAM,SACNC,aAAc,yCAGf,CAAEC,cAAeC,+BACpB3P,uMAGA4P,WAAY,8BACZC,WAAY,uCAGEC,EAA0BP,GACxC,IAAQjB,EAAiCiB,EAAjCjB,QAASC,EAAwBgB,EAAxBhB,UAAW1J,EAAa0K,EAAb1K,SAEtBkL,EAAmBC,EAAM9H,SAC7B,WAAA,OAAMmG,EAAoBC,EAASC,KACnC,CAACD,EAASC,IAGZ,OACEyB,gBAACD,OACCC,gBAACC,uBAAoBC,kBAjCD,mCAkCjBrL,aAMOsL,EACdC,EACAC,IAE0D,WACxDD,EACIA,EAAOE,sBAAqBlK,MAA5BgK,EAAM/J,WACNiK,EAAqBlK,aAAAC,WAC3BkK,CACET,QACAO,EAAAA,EAA8Bf,iIC3DNc,GAC1BD,EAAyBC,2DHUA,WAAH,OAASI"}
|
|
@@ -203,9 +203,9 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
/*
|
|
207
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
208
|
-
Changes: Removed store id and public key
|
|
206
|
+
/*
|
|
207
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
208
|
+
Changes: Removed store id and public key
|
|
209
209
|
*/
|
|
210
210
|
var SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId';
|
|
211
211
|
var SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl';
|
|
@@ -221,6 +221,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
221
221
|
var returnValues = values.map(function (value) {
|
|
222
222
|
var output = {
|
|
223
223
|
label: value.name
|
|
224
|
+
// id: value?.id || id,
|
|
224
225
|
};
|
|
225
226
|
if (displayName.match(/colou?r/gi)) {
|
|
226
227
|
output = _extends({}, output, {
|
|
@@ -356,15 +357,15 @@ function normalizeCart(_ref5) {
|
|
|
356
357
|
};
|
|
357
358
|
return cart;
|
|
358
359
|
}
|
|
359
|
-
/*
|
|
360
|
-
export function normalizeCustomer(customer: SwellCustomer): Customer {
|
|
361
|
-
const { first_name: firstName, last_name: lastName } = customer
|
|
362
|
-
return {
|
|
363
|
-
...customer,
|
|
364
|
-
firstName,
|
|
365
|
-
lastName,
|
|
366
|
-
}
|
|
367
|
-
}
|
|
360
|
+
/*
|
|
361
|
+
export function normalizeCustomer(customer: SwellCustomer): Customer {
|
|
362
|
+
const { first_name: firstName, last_name: lastName } = customer
|
|
363
|
+
return {
|
|
364
|
+
...customer,
|
|
365
|
+
firstName,
|
|
366
|
+
lastName,
|
|
367
|
+
}
|
|
368
|
+
}
|
|
368
369
|
*/
|
|
369
370
|
function normalizeLineItem(_ref6) {
|
|
370
371
|
var _product$id, _product$name, _variant$id, _variant$sku;
|
|
@@ -455,17 +456,17 @@ var handleFetchResponse = /*#__PURE__*/function () {
|
|
|
455
456
|
};
|
|
456
457
|
}();
|
|
457
458
|
|
|
458
|
-
/*
|
|
459
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
460
|
-
Changes: None
|
|
459
|
+
/*
|
|
460
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
461
|
+
Changes: None
|
|
461
462
|
*/
|
|
462
463
|
var getCheckoutId = function getCheckoutId(id) {
|
|
463
464
|
return id != null ? id : Cookies.get(SWELL_CHECKOUT_ID_COOKIE);
|
|
464
465
|
};
|
|
465
466
|
|
|
466
|
-
/*
|
|
467
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
468
|
-
Changes: None
|
|
467
|
+
/*
|
|
468
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
469
|
+
Changes: None
|
|
469
470
|
*/
|
|
470
471
|
var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
471
472
|
if (!checkoutPayload) {
|
|
@@ -518,10 +519,11 @@ var checkoutCreate = /*#__PURE__*/function () {
|
|
|
518
519
|
};
|
|
519
520
|
}();
|
|
520
521
|
|
|
522
|
+
var _default = useCart;
|
|
521
523
|
var handler = {
|
|
522
524
|
fetchOptions: {
|
|
523
|
-
query:
|
|
524
|
-
method:
|
|
525
|
+
query: "cart",
|
|
526
|
+
method: "get"
|
|
525
527
|
},
|
|
526
528
|
fetcher: function fetcher(_ref) {
|
|
527
529
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
@@ -604,7 +606,7 @@ var handler$1 = {
|
|
|
604
606
|
useHook: function useHook(_ref2) {
|
|
605
607
|
var fetch = _ref2.fetch;
|
|
606
608
|
return function () {
|
|
607
|
-
var _useCart =
|
|
609
|
+
var _useCart = _default(),
|
|
608
610
|
mutate = _useCart.mutate;
|
|
609
611
|
return useCallback(/*#__PURE__*/function () {
|
|
610
612
|
var _addItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
@@ -660,7 +662,7 @@ var handler$2 = {
|
|
|
660
662
|
useHook: function useHook(_ref2) {
|
|
661
663
|
var fetch = _ref2.fetch;
|
|
662
664
|
return function () {
|
|
663
|
-
var _useCart =
|
|
665
|
+
var _useCart = _default(),
|
|
664
666
|
mutate = _useCart.mutate;
|
|
665
667
|
return useCallback(/*#__PURE__*/function () {
|
|
666
668
|
var _removeItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
@@ -753,7 +755,7 @@ var handler$3 = {
|
|
|
753
755
|
}
|
|
754
756
|
var _ctx = ctx,
|
|
755
757
|
item = _ctx.item;
|
|
756
|
-
var _useCart =
|
|
758
|
+
var _useCart = _default(),
|
|
757
759
|
mutate = _useCart.mutate;
|
|
758
760
|
return useCallback(debounce(/*#__PURE__*/function () {
|
|
759
761
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
@@ -861,8 +863,8 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
861
863
|
|
|
862
864
|
var handler$4 = {
|
|
863
865
|
fetchOptions: {
|
|
864
|
-
query:
|
|
865
|
-
method:
|
|
866
|
+
query: "products",
|
|
867
|
+
method: "get"
|
|
866
868
|
},
|
|
867
869
|
fetcher: function fetcher(_ref) {
|
|
868
870
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
@@ -898,7 +900,7 @@ var handler$4 = {
|
|
|
898
900
|
input = {};
|
|
899
901
|
}
|
|
900
902
|
return useData({
|
|
901
|
-
input: [[
|
|
903
|
+
input: [["id", input.id]],
|
|
902
904
|
swrOptions: _extends({
|
|
903
905
|
revalidateOnFocus: false
|
|
904
906
|
}, input.swrOptions)
|
|
@@ -1213,14 +1215,13 @@ var handler$7 = {
|
|
|
1213
1215
|
}
|
|
1214
1216
|
};
|
|
1215
1217
|
|
|
1216
|
-
/*
|
|
1217
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1218
|
-
Changes: Added storeId and publicKey parameters
|
|
1218
|
+
/*
|
|
1219
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1220
|
+
Changes: Added storeId and publicKey parameters
|
|
1219
1221
|
*/
|
|
1220
1222
|
var getSwellProvider = function getSwellProvider(storeId, publicKey) {
|
|
1221
|
-
//
|
|
1222
|
-
//
|
|
1223
|
-
// @ts-expect-error swell-js types are wrong
|
|
1223
|
+
// swell-js exports `init` as a named function; with esModuleInterop the
|
|
1224
|
+
// default import resolves it as a method on the namespace, so this typechecks.
|
|
1224
1225
|
swell.init(storeId, publicKey);
|
|
1225
1226
|
return {
|
|
1226
1227
|
locale: "en-us",
|
|
@@ -1247,9 +1248,9 @@ var getSwellProvider = function getSwellProvider(storeId, publicKey) {
|
|
|
1247
1248
|
};
|
|
1248
1249
|
};
|
|
1249
1250
|
|
|
1250
|
-
/*
|
|
1251
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1252
|
-
Changes: None
|
|
1251
|
+
/*
|
|
1252
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1253
|
+
Changes: None
|
|
1253
1254
|
*/
|
|
1254
1255
|
var getCommerceProvider = function getCommerceProvider(storeId, publicKey) {
|
|
1255
1256
|
return getCommerceProvider$1(getSwellProvider(storeId, publicKey));
|