react-shopwave-connect 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -913,11 +913,12 @@ declare const SHOPWAVE_LOOKUPS: Readonly<Record<LookupKind, LookupDefinition>>;
913
913
  //#endregion
914
914
  //#region src/core/imageFit.d.ts
915
915
  /**
916
- * Browser helpers for getting an image to an exact pixel size before upload.
916
+ * Browser helpers for getting an image to the right size before upload.
917
917
  *
918
- * Shopwave doesn't resize uploads, and the merchant image slots have fixed
919
- * sizes (adminV1 refuses any other size), so the SDK scales and centre-crops
920
- * the image in the browser instead.
918
+ * Shopwave doesn't resize uploads, so images are scaled and centre-cropped in
919
+ * the browser: to an exact size for the merchant image slots
920
+ * ({@link fitImageToSize}), or to a rule (ratio, minimum, maximum) with
921
+ * {@link prepareImage}, which apps use to give each kind of image its own rule.
921
922
  */
922
923
  /** Source rectangle to draw so the image covers `dstWidth × dstHeight` (centre crop, no stretching). */
923
924
  interface CropRect {
@@ -951,6 +952,102 @@ interface FitImageOptions {
951
952
  * input, with the output type's extension.
952
953
  */
953
954
  declare function fitImageToSize(file: Blob, width: number, height: number, options?: FitImageOptions): Promise<File>;
955
+ /**
956
+ * How an image must end up before upload. Every field is optional; give an
957
+ * exact size (`width` + `height`) or an `aspectRatio`, not both.
958
+ *
959
+ * Images are always scaled down first and then centre-cropped (never
960
+ * stretched): the kept area is the largest one with the right shape.
961
+ *
962
+ * @example
963
+ * // "Cropped to 100:77, at least 600 × 462", at most 2000 px on the long side
964
+ * { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 }
965
+ * // Exactly 600 × 462
966
+ * { width: 600, height: 462 }
967
+ * // Any shape, scaled down to fit 2000 px
968
+ * { maxLongSide: 2000 }
969
+ */
970
+ interface ImageRule {
971
+ /** Exact output width (needs `height`). */
972
+ width?: number;
973
+ /** Exact output height (needs `width`). */
974
+ height?: number;
975
+ /** Shape to crop to: `1.3`, `"100:77"`, `"100/77"` or `[100, 77]`. */
976
+ aspectRatio?: number | string | readonly [number, number];
977
+ /** Smallest acceptable output; a smaller image is refused (see `allowUpscale`). */
978
+ minWidth?: number;
979
+ minHeight?: number;
980
+ /** Largest output; a bigger image is scaled down to fit. */
981
+ maxWidth?: number;
982
+ maxHeight?: number;
983
+ /** Largest output on the longer side, whichever it is. */
984
+ maxLongSide?: number;
985
+ /** Enlarge a too-small image instead of refusing it. Default false. */
986
+ allowUpscale?: boolean;
987
+ }
988
+ /** What {@link prepareImage} will do to an image, worked out without touching it. */
989
+ interface ImageFitPlan {
990
+ /** The area of the source that's kept. */
991
+ crop: CropRect;
992
+ /** Output size. */
993
+ width: number;
994
+ height: number;
995
+ /** True when the source already fits the rule, so it can be uploaded as it is. */
996
+ unchanged: boolean;
997
+ }
998
+ /** A rule that can't be met by any image (a mistake in the rule, not the image). */
999
+ declare class ImageRuleError extends Error {
1000
+ constructor(message: string);
1001
+ }
1002
+ /** The image is smaller than the rule's minimum (and `allowUpscale` is off). */
1003
+ declare class ImageTooSmallError extends Error {
1004
+ /** The smallest size the rule accepts. */
1005
+ readonly required: ImageSize;
1006
+ /** The largest area of the right shape the image could give. */
1007
+ readonly actual: ImageSize;
1008
+ constructor(required: ImageSize, actual: ImageSize);
1009
+ }
1010
+ /**
1011
+ * An aspect ratio as width ÷ height: `"100:77"`, `"100/77"`, `[100, 77]` →
1012
+ * 1.2987…; `1.3` → 1.3. Throws {@link ImageRuleError} for anything else.
1013
+ */
1014
+ declare function parseAspectRatio(value: number | string | readonly [number, number]): number;
1015
+ /** Throws {@link ImageRuleError} when the rule contradicts itself. */
1016
+ declare function checkImageRule(rule: ImageRule): void;
1017
+ /**
1018
+ * Works out what to do to a `source`-sized image to meet `rule`: the centred
1019
+ * crop of the right shape (the largest one), then the output size (scaled
1020
+ * down to the maximum, never below the minimum). Pure: no browser needed.
1021
+ *
1022
+ * Throws {@link ImageTooSmallError} when the crop is below the minimum (or
1023
+ * the exact size) and `allowUpscale` is off, and {@link ImageRuleError} for a
1024
+ * contradictory rule.
1025
+ *
1026
+ * @example
1027
+ * planImageFit({ width: 6000, height: 4000 }, { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 })
1028
+ * // → crop { sx: 403, sy: 0, sw: 5194, sh: 4000 }, 2000 × 1540
1029
+ */
1030
+ declare function planImageFit(source: ImageSize, rule: ImageRule): ImageFitPlan;
1031
+ interface PrepareImageOptions {
1032
+ /** Output type. Default: the source's type when it's PNG, JPEG or WebP, else PNG. */
1033
+ type?: "image/png" | "image/jpeg" | "image/webp";
1034
+ /** 0–1, for JPEG and WebP. Default 0.9. */
1035
+ quality?: number;
1036
+ }
1037
+ /**
1038
+ * Returns the image meeting `rule` ({@link planImageFit}): centre-cropped to
1039
+ * the right shape and scaled in a single draw. An image that already fits is
1040
+ * returned untouched (same bytes). Browser only.
1041
+ *
1042
+ * Throws {@link ImageTooSmallError} (show `required` and `actual` to the
1043
+ * person) or {@link ImageRuleError}; an unreadable file rejects with the
1044
+ * browser's decoding error.
1045
+ *
1046
+ * @example
1047
+ * const ready = await prepareImage(file, { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 });
1048
+ * await uploadImage(ready, { kind: "product", prefix: "product" });
1049
+ */
1050
+ declare function prepareImage(file: Blob, rule: ImageRule, options?: PrepareImageOptions): Promise<File>;
954
1051
  //#endregion
955
1052
  //#region src/core/upload.d.ts
956
1053
  interface UploadImageParams {
@@ -1511,5 +1608,5 @@ interface UseBasketReportReturn {
1511
1608
  */
1512
1609
  declare function useBasketReport(options?: RequestOptions): UseBasketReportReturn;
1513
1610
  //#endregion
1514
- export { Basket, BasketFilters, BasketItem, BasketPagination, BasketReportRow, BasketSummary, Category, CategoryResponse, CombineBasketRowsParams, Consumer, ConsumerResponse, CropRect, DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, DeletableEntityKind, Employee, EmployeeResponse, EntityDefinition, EntityId, EntityInput, EntityKind, EntityTypes, ErrorMessage, Extras, FetchByIdParams, FetchCategoriesParams, FetchEmployeesParams, FetchProductsParams, FetchPromotionsParams, FetchStoresParams, FitImageOptions, ImageSize, LookupDefinition, LookupKind, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, Merchant, MerchantColourKey, MerchantColourSet, MerchantColours, MerchantImageIds, MerchantImageSlot, MerchantImageSlotDefinition, MerchantLinkKey, MerchantLinks, MerchantPatch, MerchantResponse, MessageInfo, MutationState, ParsedBasket, Product, ProductInstance, ProductInstanceInput, ProductInstances, ProductResponse, ProductSaveInput, Promotion, PromotionResponse, PromotionRuleSet, QueryState, ReportData, ReportKey, ReportQuery, ReportQueryMap, ReportResponse, RepricedInstance, RequestOptions, ResourceDefinition, ResourceKind, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, Saved, SessionStatus, ShopwaveApiError, ShopwaveErrorMap, Store, StoreResponse, SubmitEntityArgs, SubmitEntityResponse, SuccessMessage, UPLOAD_KINDS, UPLOAD_PREFIXES, UpdateMerchantOptions, UploadImageParams, UploadKind, UploadMerchantImageOptions, UploadPrefix, UploadedImage, UseBasketReportReturn, User, UserEmployee, UserResponse, WritableEntityKind, apiDelete, apiGet, apiRequest, apiResponse, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseBasketReportData, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, useBasketReport, useCategory, useConsumer, useDelete, useEmployee, useLogout, useMerchant, useProduct, useProductInstanceTags, useProductTags, usePromotion, useReport, useSession, useStore, useSubmit, useUpdateMerchant, useUploadImage, useUploadMerchantImage, useUser, validateMerchant, withToken };
1611
+ export { Basket, BasketFilters, BasketItem, BasketPagination, BasketReportRow, BasketSummary, Category, CategoryResponse, CombineBasketRowsParams, Consumer, ConsumerResponse, CropRect, DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, DeletableEntityKind, Employee, EmployeeResponse, EntityDefinition, EntityId, EntityInput, EntityKind, EntityTypes, ErrorMessage, Extras, FetchByIdParams, FetchCategoriesParams, FetchEmployeesParams, FetchProductsParams, FetchPromotionsParams, FetchStoresParams, FitImageOptions, ImageFitPlan, ImageRule, ImageRuleError, ImageSize, ImageTooSmallError, LookupDefinition, LookupKind, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, Merchant, MerchantColourKey, MerchantColourSet, MerchantColours, MerchantImageIds, MerchantImageSlot, MerchantImageSlotDefinition, MerchantLinkKey, MerchantLinks, MerchantPatch, MerchantResponse, MessageInfo, MutationState, ParsedBasket, PrepareImageOptions, Product, ProductInstance, ProductInstanceInput, ProductInstances, ProductResponse, ProductSaveInput, Promotion, PromotionResponse, PromotionRuleSet, QueryState, ReportData, ReportKey, ReportQuery, ReportQueryMap, ReportResponse, RepricedInstance, RequestOptions, ResourceDefinition, ResourceKind, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, Saved, SessionStatus, ShopwaveApiError, ShopwaveErrorMap, Store, StoreResponse, SubmitEntityArgs, SubmitEntityResponse, SuccessMessage, UPLOAD_KINDS, UPLOAD_PREFIXES, UpdateMerchantOptions, UploadImageParams, UploadKind, UploadMerchantImageOptions, UploadPrefix, UploadedImage, UseBasketReportReturn, User, UserEmployee, UserResponse, WritableEntityKind, apiDelete, apiGet, apiRequest, apiResponse, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, checkImageRule, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseAspectRatio, parseBasketReportData, planImageFit, prepareImage, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, useBasketReport, useCategory, useConsumer, useDelete, useEmployee, useLogout, useMerchant, useProduct, useProductInstanceTags, useProductTags, usePromotion, useReport, useSession, useStore, useSubmit, useUpdateMerchant, useUploadImage, useUploadMerchantImage, useUser, validateMerchant, withToken };
1515
1612
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -913,11 +913,12 @@ declare const SHOPWAVE_LOOKUPS: Readonly<Record<LookupKind, LookupDefinition>>;
913
913
  //#endregion
914
914
  //#region src/core/imageFit.d.ts
915
915
  /**
916
- * Browser helpers for getting an image to an exact pixel size before upload.
916
+ * Browser helpers for getting an image to the right size before upload.
917
917
  *
918
- * Shopwave doesn't resize uploads, and the merchant image slots have fixed
919
- * sizes (adminV1 refuses any other size), so the SDK scales and centre-crops
920
- * the image in the browser instead.
918
+ * Shopwave doesn't resize uploads, so images are scaled and centre-cropped in
919
+ * the browser: to an exact size for the merchant image slots
920
+ * ({@link fitImageToSize}), or to a rule (ratio, minimum, maximum) with
921
+ * {@link prepareImage}, which apps use to give each kind of image its own rule.
921
922
  */
922
923
  /** Source rectangle to draw so the image covers `dstWidth × dstHeight` (centre crop, no stretching). */
923
924
  interface CropRect {
@@ -951,6 +952,102 @@ interface FitImageOptions {
951
952
  * input, with the output type's extension.
952
953
  */
953
954
  declare function fitImageToSize(file: Blob, width: number, height: number, options?: FitImageOptions): Promise<File>;
955
+ /**
956
+ * How an image must end up before upload. Every field is optional; give an
957
+ * exact size (`width` + `height`) or an `aspectRatio`, not both.
958
+ *
959
+ * Images are always scaled down first and then centre-cropped (never
960
+ * stretched): the kept area is the largest one with the right shape.
961
+ *
962
+ * @example
963
+ * // "Cropped to 100:77, at least 600 × 462", at most 2000 px on the long side
964
+ * { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 }
965
+ * // Exactly 600 × 462
966
+ * { width: 600, height: 462 }
967
+ * // Any shape, scaled down to fit 2000 px
968
+ * { maxLongSide: 2000 }
969
+ */
970
+ interface ImageRule {
971
+ /** Exact output width (needs `height`). */
972
+ width?: number;
973
+ /** Exact output height (needs `width`). */
974
+ height?: number;
975
+ /** Shape to crop to: `1.3`, `"100:77"`, `"100/77"` or `[100, 77]`. */
976
+ aspectRatio?: number | string | readonly [number, number];
977
+ /** Smallest acceptable output; a smaller image is refused (see `allowUpscale`). */
978
+ minWidth?: number;
979
+ minHeight?: number;
980
+ /** Largest output; a bigger image is scaled down to fit. */
981
+ maxWidth?: number;
982
+ maxHeight?: number;
983
+ /** Largest output on the longer side, whichever it is. */
984
+ maxLongSide?: number;
985
+ /** Enlarge a too-small image instead of refusing it. Default false. */
986
+ allowUpscale?: boolean;
987
+ }
988
+ /** What {@link prepareImage} will do to an image, worked out without touching it. */
989
+ interface ImageFitPlan {
990
+ /** The area of the source that's kept. */
991
+ crop: CropRect;
992
+ /** Output size. */
993
+ width: number;
994
+ height: number;
995
+ /** True when the source already fits the rule, so it can be uploaded as it is. */
996
+ unchanged: boolean;
997
+ }
998
+ /** A rule that can't be met by any image (a mistake in the rule, not the image). */
999
+ declare class ImageRuleError extends Error {
1000
+ constructor(message: string);
1001
+ }
1002
+ /** The image is smaller than the rule's minimum (and `allowUpscale` is off). */
1003
+ declare class ImageTooSmallError extends Error {
1004
+ /** The smallest size the rule accepts. */
1005
+ readonly required: ImageSize;
1006
+ /** The largest area of the right shape the image could give. */
1007
+ readonly actual: ImageSize;
1008
+ constructor(required: ImageSize, actual: ImageSize);
1009
+ }
1010
+ /**
1011
+ * An aspect ratio as width ÷ height: `"100:77"`, `"100/77"`, `[100, 77]` →
1012
+ * 1.2987…; `1.3` → 1.3. Throws {@link ImageRuleError} for anything else.
1013
+ */
1014
+ declare function parseAspectRatio(value: number | string | readonly [number, number]): number;
1015
+ /** Throws {@link ImageRuleError} when the rule contradicts itself. */
1016
+ declare function checkImageRule(rule: ImageRule): void;
1017
+ /**
1018
+ * Works out what to do to a `source`-sized image to meet `rule`: the centred
1019
+ * crop of the right shape (the largest one), then the output size (scaled
1020
+ * down to the maximum, never below the minimum). Pure: no browser needed.
1021
+ *
1022
+ * Throws {@link ImageTooSmallError} when the crop is below the minimum (or
1023
+ * the exact size) and `allowUpscale` is off, and {@link ImageRuleError} for a
1024
+ * contradictory rule.
1025
+ *
1026
+ * @example
1027
+ * planImageFit({ width: 6000, height: 4000 }, { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 })
1028
+ * // → crop { sx: 403, sy: 0, sw: 5194, sh: 4000 }, 2000 × 1540
1029
+ */
1030
+ declare function planImageFit(source: ImageSize, rule: ImageRule): ImageFitPlan;
1031
+ interface PrepareImageOptions {
1032
+ /** Output type. Default: the source's type when it's PNG, JPEG or WebP, else PNG. */
1033
+ type?: "image/png" | "image/jpeg" | "image/webp";
1034
+ /** 0–1, for JPEG and WebP. Default 0.9. */
1035
+ quality?: number;
1036
+ }
1037
+ /**
1038
+ * Returns the image meeting `rule` ({@link planImageFit}): centre-cropped to
1039
+ * the right shape and scaled in a single draw. An image that already fits is
1040
+ * returned untouched (same bytes). Browser only.
1041
+ *
1042
+ * Throws {@link ImageTooSmallError} (show `required` and `actual` to the
1043
+ * person) or {@link ImageRuleError}; an unreadable file rejects with the
1044
+ * browser's decoding error.
1045
+ *
1046
+ * @example
1047
+ * const ready = await prepareImage(file, { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 });
1048
+ * await uploadImage(ready, { kind: "product", prefix: "product" });
1049
+ */
1050
+ declare function prepareImage(file: Blob, rule: ImageRule, options?: PrepareImageOptions): Promise<File>;
954
1051
  //#endregion
955
1052
  //#region src/core/upload.d.ts
956
1053
  interface UploadImageParams {
@@ -1511,5 +1608,5 @@ interface UseBasketReportReturn {
1511
1608
  */
1512
1609
  declare function useBasketReport(options?: RequestOptions): UseBasketReportReturn;
1513
1610
  //#endregion
1514
- export { Basket, BasketFilters, BasketItem, BasketPagination, BasketReportRow, BasketSummary, Category, CategoryResponse, CombineBasketRowsParams, Consumer, ConsumerResponse, CropRect, DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, DeletableEntityKind, Employee, EmployeeResponse, EntityDefinition, EntityId, EntityInput, EntityKind, EntityTypes, ErrorMessage, Extras, FetchByIdParams, FetchCategoriesParams, FetchEmployeesParams, FetchProductsParams, FetchPromotionsParams, FetchStoresParams, FitImageOptions, ImageSize, LookupDefinition, LookupKind, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, Merchant, MerchantColourKey, MerchantColourSet, MerchantColours, MerchantImageIds, MerchantImageSlot, MerchantImageSlotDefinition, MerchantLinkKey, MerchantLinks, MerchantPatch, MerchantResponse, MessageInfo, MutationState, ParsedBasket, Product, ProductInstance, ProductInstanceInput, ProductInstances, ProductResponse, ProductSaveInput, Promotion, PromotionResponse, PromotionRuleSet, QueryState, ReportData, ReportKey, ReportQuery, ReportQueryMap, ReportResponse, RepricedInstance, RequestOptions, ResourceDefinition, ResourceKind, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, Saved, SessionStatus, ShopwaveApiError, ShopwaveErrorMap, Store, StoreResponse, SubmitEntityArgs, SubmitEntityResponse, SuccessMessage, UPLOAD_KINDS, UPLOAD_PREFIXES, UpdateMerchantOptions, UploadImageParams, UploadKind, UploadMerchantImageOptions, UploadPrefix, UploadedImage, UseBasketReportReturn, User, UserEmployee, UserResponse, WritableEntityKind, apiDelete, apiGet, apiRequest, apiResponse, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseBasketReportData, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, useBasketReport, useCategory, useConsumer, useDelete, useEmployee, useLogout, useMerchant, useProduct, useProductInstanceTags, useProductTags, usePromotion, useReport, useSession, useStore, useSubmit, useUpdateMerchant, useUploadImage, useUploadMerchantImage, useUser, validateMerchant, withToken };
1611
+ export { Basket, BasketFilters, BasketItem, BasketPagination, BasketReportRow, BasketSummary, Category, CategoryResponse, CombineBasketRowsParams, Consumer, ConsumerResponse, CropRect, DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, DeletableEntityKind, Employee, EmployeeResponse, EntityDefinition, EntityId, EntityInput, EntityKind, EntityTypes, ErrorMessage, Extras, FetchByIdParams, FetchCategoriesParams, FetchEmployeesParams, FetchProductsParams, FetchPromotionsParams, FetchStoresParams, FitImageOptions, ImageFitPlan, ImageRule, ImageRuleError, ImageSize, ImageTooSmallError, LookupDefinition, LookupKind, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, Merchant, MerchantColourKey, MerchantColourSet, MerchantColours, MerchantImageIds, MerchantImageSlot, MerchantImageSlotDefinition, MerchantLinkKey, MerchantLinks, MerchantPatch, MerchantResponse, MessageInfo, MutationState, ParsedBasket, PrepareImageOptions, Product, ProductInstance, ProductInstanceInput, ProductInstances, ProductResponse, ProductSaveInput, Promotion, PromotionResponse, PromotionRuleSet, QueryState, ReportData, ReportKey, ReportQuery, ReportQueryMap, ReportResponse, RepricedInstance, RequestOptions, ResourceDefinition, ResourceKind, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, Saved, SessionStatus, ShopwaveApiError, ShopwaveErrorMap, Store, StoreResponse, SubmitEntityArgs, SubmitEntityResponse, SuccessMessage, UPLOAD_KINDS, UPLOAD_PREFIXES, UpdateMerchantOptions, UploadImageParams, UploadKind, UploadMerchantImageOptions, UploadPrefix, UploadedImage, UseBasketReportReturn, User, UserEmployee, UserResponse, WritableEntityKind, apiDelete, apiGet, apiRequest, apiResponse, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, checkImageRule, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseAspectRatio, parseBasketReportData, planImageFit, prepareImage, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, useBasketReport, useCategory, useConsumer, useDelete, useEmployee, useLogout, useMerchant, useProduct, useProductInstanceTags, useProductTags, usePromotion, useReport, useSession, useStore, useSubmit, useUpdateMerchant, useUploadImage, useUploadMerchantImage, useUser, validateMerchant, withToken };
1515
1612
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -638,6 +638,35 @@ async function readImageSize(file) {
638
638
  bitmap.close?.();
639
639
  }
640
640
  }
641
+ /** Draws `crop` of the bitmap at `width × height` and encodes it (one resample). */
642
+ async function drawCrop(bitmap, crop, width, height, type, quality, fn) {
643
+ const { sx, sy, sw, sh } = crop;
644
+ if (typeof OffscreenCanvas === "function") {
645
+ const canvas$1 = new OffscreenCanvas(width, height);
646
+ const ctx$1 = canvas$1.getContext("2d");
647
+ if (!ctx$1) throw new Error(`${fn}: no 2D canvas context`);
648
+ ctx$1.imageSmoothingQuality = "high";
649
+ ctx$1.drawImage(bitmap, sx, sy, sw, sh, 0, 0, width, height);
650
+ return canvas$1.convertToBlob({
651
+ type,
652
+ quality
653
+ });
654
+ }
655
+ const canvas = document.createElement("canvas");
656
+ canvas.width = width;
657
+ canvas.height = height;
658
+ const ctx = canvas.getContext("2d");
659
+ if (!ctx) throw new Error(`${fn}: no 2D canvas context`);
660
+ ctx.imageSmoothingQuality = "high";
661
+ ctx.drawImage(bitmap, sx, sy, sw, sh, 0, 0, width, height);
662
+ return new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(/* @__PURE__ */ new Error(`${fn}: encoding failed`)), type, quality));
663
+ }
664
+ /** The input's name with the output type's extension. */
665
+ function outputName(file, type) {
666
+ const name = file.name || "image";
667
+ const ext = type === "image/jpeg" ? "jpg" : type.split("/")[1];
668
+ return `${name.replace(/\.[^.]+$/, "")}.${ext}`;
669
+ }
641
670
  /**
642
671
  * Returns the image at exactly `width × height`: scaled and centre-cropped
643
672
  * (never stretched). Browser only. The result is a `File` named like the
@@ -646,39 +675,194 @@ async function readImageSize(file) {
646
675
  async function fitImageToSize(file, width, height, options = {}) {
647
676
  requireBrowserImages("fitImageToSize");
648
677
  const { type = "image/png", quality, keepIfExact = true } = options;
649
- const name = file.name || "image";
650
- const ext = type === "image/jpeg" ? "jpg" : type.split("/")[1];
651
- const outName = `${name.replace(/\.[^.]+$/, "")}.${ext}`;
678
+ const outName = outputName(file, type);
652
679
  const bitmap = await createImageBitmap(file);
653
680
  try {
654
681
  if (keepIfExact && bitmap.width === width && bitmap.height === height && file.type === type) return file instanceof File ? file : new File([file], outName, { type });
655
- const { sx, sy, sw, sh } = coverCrop(bitmap.width, bitmap.height, width, height);
656
- let blob;
657
- if (typeof OffscreenCanvas === "function") {
658
- const canvas = new OffscreenCanvas(width, height);
659
- const ctx = canvas.getContext("2d");
660
- if (!ctx) throw new Error("fitImageToSize: no 2D canvas context");
661
- ctx.imageSmoothingQuality = "high";
662
- ctx.drawImage(bitmap, sx, sy, sw, sh, 0, 0, width, height);
663
- blob = await canvas.convertToBlob({
664
- type,
665
- quality
666
- });
667
- } else {
668
- const canvas = document.createElement("canvas");
669
- canvas.width = width;
670
- canvas.height = height;
671
- const ctx = canvas.getContext("2d");
672
- if (!ctx) throw new Error("fitImageToSize: no 2D canvas context");
673
- ctx.imageSmoothingQuality = "high";
674
- ctx.drawImage(bitmap, sx, sy, sw, sh, 0, 0, width, height);
675
- blob = await new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(/* @__PURE__ */ new Error("fitImageToSize: encoding failed")), type, quality));
676
- }
682
+ const blob = await drawCrop(bitmap, coverCrop(bitmap.width, bitmap.height, width, height), width, height, type, quality, "fitImageToSize");
677
683
  return new File([blob], outName, { type });
678
684
  } finally {
679
685
  bitmap.close?.();
680
686
  }
681
687
  }
688
+ /** A rule that can't be met by any image (a mistake in the rule, not the image). */
689
+ var ImageRuleError = class extends Error {
690
+ constructor(message) {
691
+ super(message);
692
+ this.name = "ImageRuleError";
693
+ }
694
+ };
695
+ /** The image is smaller than the rule's minimum (and `allowUpscale` is off). */
696
+ var ImageTooSmallError = class extends Error {
697
+ /** The smallest size the rule accepts. */
698
+ required;
699
+ /** The largest area of the right shape the image could give. */
700
+ actual;
701
+ constructor(required, actual) {
702
+ super(`The image is too small: it needs to be at least ${required.width} × ${required.height}, and it's ${actual.width} × ${actual.height}`);
703
+ this.name = "ImageTooSmallError";
704
+ this.required = required;
705
+ this.actual = actual;
706
+ }
707
+ };
708
+ const isPositive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0;
709
+ /**
710
+ * An aspect ratio as width ÷ height: `"100:77"`, `"100/77"`, `[100, 77]` →
711
+ * 1.2987…; `1.3` → 1.3. Throws {@link ImageRuleError} for anything else.
712
+ */
713
+ function parseAspectRatio(value) {
714
+ let parts = null;
715
+ if (typeof value === "number") return isPositive(value) ? value : badRatio(value);
716
+ if (Array.isArray(value)) parts = [value[0], value[1]];
717
+ else if (typeof value === "string") {
718
+ const text$1 = value.trim();
719
+ const match = /^(\d+(?:\.\d+)?)\s*[:/x×]\s*(\d+(?:\.\d+)?)$/i.exec(text$1);
720
+ if (match) parts = [Number(match[1]), Number(match[2])];
721
+ else if (/^\d+(?:\.\d+)?$/.test(text$1)) return isPositive(Number(text$1)) ? Number(text$1) : badRatio(value);
722
+ }
723
+ if (parts && isPositive(parts[0]) && isPositive(parts[1])) return parts[0] / parts[1];
724
+ return badRatio(value);
725
+ }
726
+ function badRatio(value) {
727
+ throw new ImageRuleError(`Not an aspect ratio: ${JSON.stringify(value)} (use e.g. "100:77", [100, 77] or 1.3)`);
728
+ }
729
+ /** Throws {@link ImageRuleError} when the rule contradicts itself. */
730
+ function checkImageRule(rule) {
731
+ if (!rule || typeof rule !== "object") throw new ImageRuleError("An image rule must be an object");
732
+ for (const key of [
733
+ "width",
734
+ "height",
735
+ "minWidth",
736
+ "minHeight",
737
+ "maxWidth",
738
+ "maxHeight",
739
+ "maxLongSide"
740
+ ]) if (rule[key] != null && !isPositive(rule[key])) throw new ImageRuleError(`${key} must be a positive number`);
741
+ if (rule.width != null || rule.height != null) {
742
+ if (rule.width == null || rule.height == null) throw new ImageRuleError("An exact size needs both width and height");
743
+ if (rule.aspectRatio != null) throw new ImageRuleError("Give an exact size or an aspectRatio, not both (the size sets the ratio)");
744
+ const extra = [
745
+ "minWidth",
746
+ "minHeight",
747
+ "maxWidth",
748
+ "maxHeight",
749
+ "maxLongSide"
750
+ ].filter((key) => rule[key] != null);
751
+ if (extra.length > 0) throw new ImageRuleError(`An exact size is already the minimum and the maximum; remove ${extra.join(", ")}`);
752
+ return;
753
+ }
754
+ if (rule.aspectRatio != null) parseAspectRatio(rule.aspectRatio);
755
+ if (rule.minWidth != null && rule.maxWidth != null && rule.minWidth > rule.maxWidth) throw new ImageRuleError("minWidth is larger than maxWidth");
756
+ if (rule.minHeight != null && rule.maxHeight != null && rule.minHeight > rule.maxHeight) throw new ImageRuleError("minHeight is larger than maxHeight");
757
+ if (rule.maxLongSide != null && Math.max(rule.minWidth ?? 0, rule.minHeight ?? 0) > rule.maxLongSide) throw new ImageRuleError("The minimum size is larger than maxLongSide");
758
+ }
759
+ /**
760
+ * Works out what to do to a `source`-sized image to meet `rule`: the centred
761
+ * crop of the right shape (the largest one), then the output size (scaled
762
+ * down to the maximum, never below the minimum). Pure: no browser needed.
763
+ *
764
+ * Throws {@link ImageTooSmallError} when the crop is below the minimum (or
765
+ * the exact size) and `allowUpscale` is off, and {@link ImageRuleError} for a
766
+ * contradictory rule.
767
+ *
768
+ * @example
769
+ * planImageFit({ width: 6000, height: 4000 }, { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 })
770
+ * // → crop { sx: 403, sy: 0, sw: 5194, sh: 4000 }, 2000 × 1540
771
+ */
772
+ function planImageFit(source, rule) {
773
+ checkImageRule(rule);
774
+ const { width: W, height: H } = source ?? {};
775
+ if (!isPositive(W) || !isPositive(H)) throw new Error("planImageFit: the image has no size");
776
+ const exact = rule.width != null && rule.height != null;
777
+ const ratio = exact ? rule.width / rule.height : rule.aspectRatio != null ? parseAspectRatio(rule.aspectRatio) : null;
778
+ const crop = ratio == null ? {
779
+ sx: 0,
780
+ sy: 0,
781
+ sw: W,
782
+ sh: H
783
+ } : coverCrop(W, H, ratio, 1);
784
+ const { sw, sh } = crop;
785
+ const kept = {
786
+ width: sw,
787
+ height: sh
788
+ };
789
+ let width;
790
+ let height;
791
+ if (exact) {
792
+ width = rule.width;
793
+ height = rule.height;
794
+ if ((sw < width || sh < height) && !rule.allowUpscale) throw new ImageTooSmallError({
795
+ width,
796
+ height
797
+ }, kept);
798
+ } else {
799
+ const minW = rule.minWidth ?? 0;
800
+ const minH = rule.minHeight ?? 0;
801
+ if ((sw < minW || sh < minH) && !rule.allowUpscale) throw new ImageTooSmallError(requiredSize(minW, minH, ratio), kept);
802
+ let scale = 1;
803
+ if (rule.maxWidth != null) scale = Math.min(scale, rule.maxWidth / sw);
804
+ if (rule.maxHeight != null) scale = Math.min(scale, rule.maxHeight / sh);
805
+ if (rule.maxLongSide != null) scale = Math.min(scale, rule.maxLongSide / Math.max(sw, sh));
806
+ scale = Math.max(scale, minW / sw, minH / sh);
807
+ width = Math.max(1, Math.round(sw * scale));
808
+ height = Math.max(1, Math.round(sh * scale));
809
+ }
810
+ const unchanged = crop.sx === 0 && crop.sy === 0 && sw === W && sh === H && width === W && height === H;
811
+ return {
812
+ crop,
813
+ width,
814
+ height,
815
+ unchanged
816
+ };
817
+ }
818
+ /** The minimum as a full size: a ratio rule with only one minimum implies the other. */
819
+ function requiredSize(minW, minH, ratio) {
820
+ if (ratio == null) return {
821
+ width: minW,
822
+ height: minH
823
+ };
824
+ return {
825
+ width: Math.max(minW, Math.ceil(minH * ratio)),
826
+ height: Math.max(minH, Math.ceil(minW / ratio))
827
+ };
828
+ }
829
+ const OUTPUT_TYPES = [
830
+ "image/png",
831
+ "image/jpeg",
832
+ "image/webp"
833
+ ];
834
+ /**
835
+ * Returns the image meeting `rule` ({@link planImageFit}): centre-cropped to
836
+ * the right shape and scaled in a single draw. An image that already fits is
837
+ * returned untouched (same bytes). Browser only.
838
+ *
839
+ * Throws {@link ImageTooSmallError} (show `required` and `actual` to the
840
+ * person) or {@link ImageRuleError}; an unreadable file rejects with the
841
+ * browser's decoding error.
842
+ *
843
+ * @example
844
+ * const ready = await prepareImage(file, { aspectRatio: "100:77", minWidth: 600, minHeight: 462, maxLongSide: 2000 });
845
+ * await uploadImage(ready, { kind: "product", prefix: "product" });
846
+ */
847
+ async function prepareImage(file, rule, options = {}) {
848
+ checkImageRule(rule);
849
+ requireBrowserImages("prepareImage");
850
+ const sourceType = file.type && OUTPUT_TYPES.includes(file.type) ? file.type : "image/png";
851
+ const type = options.type ?? sourceType;
852
+ const quality = options.quality ?? (type === "image/png" ? void 0 : .9);
853
+ const bitmap = await createImageBitmap(file);
854
+ try {
855
+ const plan = planImageFit({
856
+ width: bitmap.width,
857
+ height: bitmap.height
858
+ }, rule);
859
+ if (plan.unchanged && type === file.type) return file instanceof File ? file : new File([file], outputName(file, type), { type });
860
+ const blob = await drawCrop(bitmap, plan.crop, plan.width, plan.height, type, quality, "prepareImage");
861
+ return new File([blob], outputName(file, type), { type });
862
+ } finally {
863
+ bitmap.close?.();
864
+ }
865
+ }
682
866
 
683
867
  //#endregion
684
868
  //#region src/core/upload.ts
@@ -1971,5 +2155,5 @@ function useBasketReport(options) {
1971
2155
  }
1972
2156
 
1973
2157
  //#endregion
1974
- export { DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, PromotionRuleSet, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, ShopwaveApiError, UPLOAD_KINDS, UPLOAD_PREFIXES, apiDelete, apiGet, apiRequest, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseBasketReportData, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, useBasketReport, useCategory, useConsumer, useDelete, useEmployee, useLogout, useMerchant, useProduct, useProductInstanceTags, useProductTags, usePromotion, useReport, useSession, useStore, useSubmit, useUpdateMerchant, useUploadImage, useUploadMerchantImage, useUser, validateMerchant, withToken };
2158
+ export { DEFAULT_BASKET_FILTERS, DEFAULT_PAGINATION, ImageRuleError, ImageTooSmallError, MERCHANT_COLOUR_KEYS, MERCHANT_FIELD_MAX_LENGTH, MERCHANT_IMAGE_SLOTS, MERCHANT_IMAGE_SLOT_KEYS, MERCHANT_LINK_KEYS, MERCHANT_LINK_PATHS, MERCHANT_OBJECT_FIELDS, MERCHANT_READ_ONLY_FIELDS, PromotionRuleSet, SHOPWAVE_ENTITIES, SHOPWAVE_IMAGE_BASE_URL, SHOPWAVE_LOOKUPS, SHOPWAVE_RESOURCES, SHOPWAVE_UPLOAD, ShopwaveApiError, UPLOAD_KINDS, UPLOAD_PREFIXES, apiDelete, apiGet, apiRequest, apiSend, assertNoApiErrors, authorizationFor, buildBasketReportQuery, buildConsumerMap, checkImageRule, collectConsumerIds, collectProductIds, combineBasketRows, computeBasketSummary, coverCrop, deleteCategory, deleteEmployee, deleteEntity, deleteEntityById, deleteProduct, deletePromotion, deleteStore, fetchCategories, fetchCategory, fetchConsumer, fetchConsumers, fetchEmployee, fetchEmployees, fetchEntityById, fetchMerchant, fetchProduct, fetchProductInstanceTags, fetchProductTags, fetchProducts, fetchProductsMap, fetchPromotion, fetchPromotions, fetchReport, fetchSession, fetchStore, fetchStores, fetchUser, findRepricedInstances, fitImageToSize, formatDateForQuery, getApiErrorMap, getApiErrors, getImageUrl, getMerchantImage, getMerchantImageUrl, imageFileName, isSameInstancePrice, isUploadKind, isUploadPrefix, loginPath, logout, logoutPath, merchantLinksFromForm, merchantLinksToForm, normalizeMerchantLinks, normalizeTagList, parseAspectRatio, parseBasketReportData, planImageFit, prepareImage, productImageRole, readImageSize, rolesById, saveCategory, saveEmployee, saveEntities, saveEntity, saveProduct, savePromotion, saveStore, setMerchantImage, submitEntity, toProductInstancesForSave, toShopwaveApiError, toStoredImageIds, toStoredProductImages, updateMerchant, uploadImage, uploadMerchantImage, useBasketReport, useCategory, useConsumer, useDelete, useEmployee, useLogout, useMerchant, useProduct, useProductInstanceTags, useProductTags, usePromotion, useReport, useSession, useStore, useSubmit, useUpdateMerchant, useUploadImage, useUploadMerchantImage, useUser, validateMerchant, withToken };
1975
2159
  //# sourceMappingURL=index.js.map