@plasmicpkgs/commerce-swell 0.0.13 → 0.0.16
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/commerce-swell.cjs.development.js +27 -21
- 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 +26 -22
- package/dist/commerce-swell.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/registerCommerceProvider.d.ts +3 -2
- package/dist/utils/normalize.d.ts +4 -4
- package/package.json +3 -3
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
+
var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
|
|
7
8
|
var React = require('react');
|
|
8
9
|
var React__default = _interopDefault(React);
|
|
9
10
|
var commerce = require('@plasmicpkgs/commerce');
|
|
10
11
|
var swell = _interopDefault(require('swell-js'));
|
|
11
12
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
12
13
|
var debounce = _interopDefault(require('lodash/debounce'));
|
|
13
|
-
var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
|
|
14
14
|
|
|
15
15
|
/*
|
|
16
16
|
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
@@ -854,7 +854,7 @@ var _excluded = ["file"];
|
|
|
854
854
|
var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
855
855
|
var id = _ref2.id,
|
|
856
856
|
_ref2$name = _ref2.name,
|
|
857
|
-
displayName = _ref2$name === void 0 ?
|
|
857
|
+
displayName = _ref2$name === void 0 ? "" : _ref2$name,
|
|
858
858
|
_ref2$values = _ref2.values,
|
|
859
859
|
values = _ref2$values === void 0 ? [] : _ref2$values;
|
|
860
860
|
var returnValues = values.map(function (value) {
|
|
@@ -871,7 +871,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
871
871
|
return output;
|
|
872
872
|
});
|
|
873
873
|
return {
|
|
874
|
-
__typename:
|
|
874
|
+
__typename: "MultipleChoiceOption",
|
|
875
875
|
id: id,
|
|
876
876
|
displayName: displayName,
|
|
877
877
|
values: returnValues
|
|
@@ -881,7 +881,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
881
881
|
var normalizeProductImages = function normalizeProductImages(images) {
|
|
882
882
|
if (!images || images.length < 1) {
|
|
883
883
|
return [{
|
|
884
|
-
url:
|
|
884
|
+
url: "/"
|
|
885
885
|
}];
|
|
886
886
|
}
|
|
887
887
|
|
|
@@ -890,7 +890,7 @@ var normalizeProductImages = function normalizeProductImages(images) {
|
|
|
890
890
|
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
891
891
|
|
|
892
892
|
return _extends({
|
|
893
|
-
url: (file == null ? void 0 : file.url) +
|
|
893
|
+
url: (file == null ? void 0 : file.url) + "",
|
|
894
894
|
height: Number(file == null ? void 0 : file.height),
|
|
895
895
|
width: Number(file == null ? void 0 : file.width)
|
|
896
896
|
}, rest);
|
|
@@ -904,7 +904,7 @@ var normalizeProductVariants = function normalizeProductVariants(variants, produ
|
|
|
904
904
|
price = _ref4.price,
|
|
905
905
|
_ref4$option_value_id = _ref4.option_value_ids,
|
|
906
906
|
optionValueIds = _ref4$option_value_id === void 0 ? [] : _ref4$option_value_id;
|
|
907
|
-
var values = name.split(
|
|
907
|
+
var values = name.split(",").map(function (i) {
|
|
908
908
|
return {
|
|
909
909
|
name: i.trim(),
|
|
910
910
|
label: i.trim()
|
|
@@ -920,7 +920,7 @@ var normalizeProductVariants = function normalizeProductVariants(variants, produ
|
|
|
920
920
|
});
|
|
921
921
|
return normalizeProductOption({
|
|
922
922
|
id: id,
|
|
923
|
-
name: (_matchingOption$name = matchingOption == null ? void 0 : matchingOption.name) != null ? _matchingOption$name :
|
|
923
|
+
name: (_matchingOption$name = matchingOption == null ? void 0 : matchingOption.name) != null ? _matchingOption$name : "",
|
|
924
924
|
values: values
|
|
925
925
|
});
|
|
926
926
|
});
|
|
@@ -960,7 +960,7 @@ function normalizeProduct(swellProduct) {
|
|
|
960
960
|
var product = _extends({}, swellProduct, {
|
|
961
961
|
description: description,
|
|
962
962
|
id: id,
|
|
963
|
-
vendor:
|
|
963
|
+
vendor: "",
|
|
964
964
|
path: "/" + slug,
|
|
965
965
|
images: productImages,
|
|
966
966
|
variants: productVariants && productVariants.length ? productVariants : emptyVariants,
|
|
@@ -987,8 +987,8 @@ function normalizeCart(_ref5) {
|
|
|
987
987
|
discounts = _ref5.discounts;
|
|
988
988
|
var cart = {
|
|
989
989
|
id: id,
|
|
990
|
-
customerId: account_id +
|
|
991
|
-
email:
|
|
990
|
+
customerId: account_id + "",
|
|
991
|
+
email: "",
|
|
992
992
|
createdAt: date_created,
|
|
993
993
|
currency: {
|
|
994
994
|
code: currency
|
|
@@ -1028,21 +1028,21 @@ function normalizeLineItem(_ref6) {
|
|
|
1028
1028
|
var item = {
|
|
1029
1029
|
id: id,
|
|
1030
1030
|
variantId: variant == null ? void 0 : variant.id,
|
|
1031
|
-
productId: (_product$id = product.id) != null ? _product$id :
|
|
1032
|
-
name: (_product$name = product == null ? void 0 : product.name) != null ? _product$name :
|
|
1031
|
+
productId: (_product$id = product.id) != null ? _product$id : "",
|
|
1032
|
+
name: (_product$name = product == null ? void 0 : product.name) != null ? _product$name : "",
|
|
1033
1033
|
quantity: quantity,
|
|
1034
1034
|
variant: {
|
|
1035
|
-
id: (_variant$id = variant == null ? void 0 : variant.id) != null ? _variant$id :
|
|
1036
|
-
sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku :
|
|
1035
|
+
id: (_variant$id = variant == null ? void 0 : variant.id) != null ? _variant$id : "",
|
|
1036
|
+
sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : "",
|
|
1037
1037
|
name: variant == null ? void 0 : variant.name,
|
|
1038
1038
|
image: {
|
|
1039
|
-
url: product != null && product.images && product.images.length > 0 ? product == null ? void 0 : product.images[0].file.url :
|
|
1039
|
+
url: product != null && product.images && product.images.length > 0 ? product == null ? void 0 : product.images[0].file.url : "/"
|
|
1040
1040
|
},
|
|
1041
1041
|
requiresShipping: false,
|
|
1042
1042
|
price: price,
|
|
1043
1043
|
listPrice: price
|
|
1044
1044
|
},
|
|
1045
|
-
path:
|
|
1045
|
+
path: "",
|
|
1046
1046
|
discounts: [],
|
|
1047
1047
|
options: [{
|
|
1048
1048
|
value: variant == null ? void 0 : variant.name
|
|
@@ -1055,13 +1055,19 @@ function normalizeCategory(_ref7) {
|
|
|
1055
1055
|
var id = _ref7.id,
|
|
1056
1056
|
name = _ref7.name,
|
|
1057
1057
|
slug = _ref7.slug,
|
|
1058
|
-
products = _ref7.products
|
|
1058
|
+
products = _ref7.products,
|
|
1059
|
+
images = _ref7.images;
|
|
1059
1060
|
return {
|
|
1060
1061
|
id: id,
|
|
1061
1062
|
name: name,
|
|
1062
1063
|
slug: slug,
|
|
1063
1064
|
path: "/" + slug,
|
|
1064
|
-
isEmpty: (products == null ? void 0 : products.length) === 0
|
|
1065
|
+
isEmpty: (products == null ? void 0 : products.length) === 0,
|
|
1066
|
+
images: images == null ? void 0 : images.map(function (image) {
|
|
1067
|
+
return {
|
|
1068
|
+
url: image.file.url
|
|
1069
|
+
};
|
|
1070
|
+
})
|
|
1065
1071
|
};
|
|
1066
1072
|
}
|
|
1067
1073
|
|
|
@@ -2127,9 +2133,8 @@ var commerceProviderMeta = {
|
|
|
2127
2133
|
publicKey: "string"
|
|
2128
2134
|
},
|
|
2129
2135
|
importPath: "commerce-providers/swell",
|
|
2130
|
-
importName: "
|
|
2136
|
+
importName: "CommerceProviderComponent"
|
|
2131
2137
|
};
|
|
2132
|
-
|
|
2133
2138
|
function CommerceProviderComponent(props) {
|
|
2134
2139
|
var storeId = props.storeId,
|
|
2135
2140
|
publicKey = props.publicKey,
|
|
@@ -2137,7 +2142,6 @@ function CommerceProviderComponent(props) {
|
|
|
2137
2142
|
var CommerceProvider = getCommerceProvider(storeId, publicKey);
|
|
2138
2143
|
return React__default.createElement(CommerceProvider, null, children);
|
|
2139
2144
|
}
|
|
2140
|
-
|
|
2141
2145
|
function registerCommerceProvider(loader, customCommerceProviderMeta) {
|
|
2142
2146
|
var doRegisterComponent = function doRegisterComponent() {
|
|
2143
2147
|
return loader ? loader.registerGlobalContext.apply(loader, arguments) : registerGlobalContext.apply(void 0, arguments);
|
|
@@ -2150,6 +2154,8 @@ function registerAll(loader) {
|
|
|
2150
2154
|
registerCommerceProvider(loader);
|
|
2151
2155
|
}
|
|
2152
2156
|
|
|
2157
|
+
exports.CommerceProviderComponent = CommerceProviderComponent;
|
|
2158
|
+
exports.commerceProviderMeta = commerceProviderMeta;
|
|
2153
2159
|
exports.getCommerceProvider = getCommerceProvider;
|
|
2154
2160
|
exports.registerAll = registerAll;
|
|
2155
2161
|
exports.registerCommerceProvider = registerCommerceProvider;
|