@plasmicpkgs/commerce-swell 0.0.92 → 0.0.94
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 +126 -352
- 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 +126 -352
- package/dist/commerce-swell.esm.js.map +1 -1
- package/package.json +4 -4
|
@@ -21,67 +21,54 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
21
21
|
reject(error);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
if (info.done) {
|
|
26
25
|
resolve(value);
|
|
27
26
|
} else {
|
|
28
27
|
Promise.resolve(value).then(_next, _throw);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
function _asyncToGenerator(fn) {
|
|
33
31
|
return function () {
|
|
34
32
|
var self = this,
|
|
35
|
-
|
|
33
|
+
args = arguments;
|
|
36
34
|
return new Promise(function (resolve, reject) {
|
|
37
35
|
var gen = fn.apply(self, args);
|
|
38
|
-
|
|
39
36
|
function _next(value) {
|
|
40
37
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
function _throw(err) {
|
|
44
40
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
_next(undefined);
|
|
48
43
|
});
|
|
49
44
|
};
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
function _extends() {
|
|
53
|
-
_extends = Object.assign
|
|
47
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
54
48
|
for (var i = 1; i < arguments.length; i++) {
|
|
55
49
|
var source = arguments[i];
|
|
56
|
-
|
|
57
50
|
for (var key in source) {
|
|
58
51
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
59
52
|
target[key] = source[key];
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
return target;
|
|
65
57
|
};
|
|
66
|
-
|
|
67
58
|
return _extends.apply(this, arguments);
|
|
68
59
|
}
|
|
69
|
-
|
|
70
60
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
71
61
|
if (source == null) return {};
|
|
72
62
|
var target = {};
|
|
73
63
|
var sourceKeys = Object.keys(source);
|
|
74
64
|
var key, i;
|
|
75
|
-
|
|
76
65
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
77
66
|
key = sourceKeys[i];
|
|
78
67
|
if (excluded.indexOf(key) >= 0) continue;
|
|
79
68
|
target[key] = source[key];
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
return target;
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
function _unsupportedIterableToArray(o, minLen) {
|
|
86
73
|
if (!o) return;
|
|
87
74
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -90,19 +77,14 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
90
77
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
91
78
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
function _arrayLikeToArray(arr, len) {
|
|
95
81
|
if (len == null || len > arr.length) len = arr.length;
|
|
96
|
-
|
|
97
82
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
98
|
-
|
|
99
83
|
return arr2;
|
|
100
84
|
}
|
|
101
|
-
|
|
102
85
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
103
86
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
104
87
|
if (it) return (it = it.call(o)).next.bind(it);
|
|
105
|
-
|
|
106
88
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
107
89
|
if (it) o = it;
|
|
108
90
|
var i = 0;
|
|
@@ -116,7 +98,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
116
98
|
};
|
|
117
99
|
};
|
|
118
100
|
}
|
|
119
|
-
|
|
120
101
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
121
102
|
}
|
|
122
103
|
|
|
@@ -131,17 +112,16 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
131
112
|
* This source code is licensed under the MIT license found in the
|
|
132
113
|
* LICENSE file in the root directory of this source tree.
|
|
133
114
|
*/
|
|
115
|
+
|
|
134
116
|
var runtime = function (exports) {
|
|
135
117
|
|
|
136
118
|
var Op = Object.prototype;
|
|
137
119
|
var hasOwn = Op.hasOwnProperty;
|
|
138
120
|
var undefined$1; // More compressible than void 0.
|
|
139
|
-
|
|
140
121
|
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
141
122
|
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
142
123
|
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
143
124
|
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
144
|
-
|
|
145
125
|
function define(obj, key, value) {
|
|
146
126
|
Object.defineProperty(obj, key, {
|
|
147
127
|
value: value,
|
|
@@ -151,7 +131,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
151
131
|
});
|
|
152
132
|
return obj[key];
|
|
153
133
|
}
|
|
154
|
-
|
|
155
134
|
try {
|
|
156
135
|
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
157
136
|
define({}, "");
|
|
@@ -160,19 +139,20 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
160
139
|
return obj[key] = value;
|
|
161
140
|
};
|
|
162
141
|
}
|
|
163
|
-
|
|
164
142
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
165
143
|
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
166
144
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
167
145
|
var generator = Object.create(protoGenerator.prototype);
|
|
168
|
-
var context = new Context(tryLocsList || []);
|
|
169
|
-
// .throw, and .return methods.
|
|
146
|
+
var context = new Context(tryLocsList || []);
|
|
170
147
|
|
|
148
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
149
|
+
// .throw, and .return methods.
|
|
171
150
|
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
172
151
|
return generator;
|
|
173
152
|
}
|
|
153
|
+
exports.wrap = wrap;
|
|
174
154
|
|
|
175
|
-
|
|
155
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
176
156
|
// record like context.tryEntries[i].completion. This interface could
|
|
177
157
|
// have been (and was previously) designed to take a closure to be
|
|
178
158
|
// invoked without arguments, but in all the cases we care about we
|
|
@@ -182,7 +162,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
182
162
|
// in every case, so we don't have to touch the arguments object. The
|
|
183
163
|
// only additional allocation required is the completion record, which
|
|
184
164
|
// has a stable shape and so hopefully should be cheap to allocate.
|
|
185
|
-
|
|
186
165
|
function tryCatch(fn, obj, arg) {
|
|
187
166
|
try {
|
|
188
167
|
return {
|
|
@@ -196,46 +175,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
196
175
|
};
|
|
197
176
|
}
|
|
198
177
|
}
|
|
199
|
-
|
|
200
178
|
var GenStateSuspendedStart = "suspendedStart";
|
|
201
179
|
var GenStateSuspendedYield = "suspendedYield";
|
|
202
180
|
var GenStateExecuting = "executing";
|
|
203
|
-
var GenStateCompleted = "completed";
|
|
181
|
+
var GenStateCompleted = "completed";
|
|
182
|
+
|
|
183
|
+
// Returning this object from the innerFn has the same effect as
|
|
204
184
|
// breaking out of the dispatch switch statement.
|
|
185
|
+
var ContinueSentinel = {};
|
|
205
186
|
|
|
206
|
-
|
|
187
|
+
// Dummy constructor functions that we use as the .constructor and
|
|
207
188
|
// .constructor.prototype properties for functions that return Generator
|
|
208
189
|
// objects. For full spec compliance, you may wish to configure your
|
|
209
190
|
// minifier not to mangle the names of these two functions.
|
|
210
|
-
|
|
211
191
|
function Generator() {}
|
|
212
|
-
|
|
213
192
|
function GeneratorFunction() {}
|
|
193
|
+
function GeneratorFunctionPrototype() {}
|
|
214
194
|
|
|
215
|
-
|
|
195
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
216
196
|
// don't natively support it.
|
|
217
|
-
|
|
218
|
-
|
|
219
197
|
var IteratorPrototype = {};
|
|
220
198
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
221
199
|
return this;
|
|
222
200
|
});
|
|
223
201
|
var getProto = Object.getPrototypeOf;
|
|
224
202
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
225
|
-
|
|
226
203
|
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
227
204
|
// This environment has a native %IteratorPrototype%; use it instead
|
|
228
205
|
// of the polyfill.
|
|
229
206
|
IteratorPrototype = NativeIteratorPrototype;
|
|
230
207
|
}
|
|
231
|
-
|
|
232
208
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
233
209
|
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
234
210
|
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
235
211
|
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
236
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
237
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
212
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
238
213
|
|
|
214
|
+
// Helper for defining the .next, .throw, and .return methods of the
|
|
215
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
239
216
|
function defineIteratorMethods(prototype) {
|
|
240
217
|
["next", "throw", "return"].forEach(function (method) {
|
|
241
218
|
define(prototype, method, function (arg) {
|
|
@@ -243,14 +220,13 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
243
220
|
});
|
|
244
221
|
});
|
|
245
222
|
}
|
|
246
|
-
|
|
247
223
|
exports.isGeneratorFunction = function (genFun) {
|
|
248
224
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
249
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
225
|
+
return ctor ? ctor === GeneratorFunction ||
|
|
226
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
250
227
|
// do is to check its .name property.
|
|
251
228
|
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
252
229
|
};
|
|
253
|
-
|
|
254
230
|
exports.mark = function (genFun) {
|
|
255
231
|
if (Object.setPrototypeOf) {
|
|
256
232
|
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
@@ -258,31 +234,27 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
258
234
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
259
235
|
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
260
236
|
}
|
|
261
|
-
|
|
262
237
|
genFun.prototype = Object.create(Gp);
|
|
263
238
|
return genFun;
|
|
264
|
-
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// Within the body of any async function, `await x` is transformed to
|
|
265
242
|
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
266
243
|
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
267
244
|
// meant to be awaited.
|
|
268
|
-
|
|
269
|
-
|
|
270
245
|
exports.awrap = function (arg) {
|
|
271
246
|
return {
|
|
272
247
|
__await: arg
|
|
273
248
|
};
|
|
274
249
|
};
|
|
275
|
-
|
|
276
250
|
function AsyncIterator(generator, PromiseImpl) {
|
|
277
251
|
function invoke(method, arg, resolve, reject) {
|
|
278
252
|
var record = tryCatch(generator[method], generator, arg);
|
|
279
|
-
|
|
280
253
|
if (record.type === "throw") {
|
|
281
254
|
reject(record.arg);
|
|
282
255
|
} else {
|
|
283
256
|
var result = record.arg;
|
|
284
257
|
var value = result.value;
|
|
285
|
-
|
|
286
258
|
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
287
259
|
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
288
260
|
invoke("next", value, resolve, reject);
|
|
@@ -290,7 +262,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
290
262
|
invoke("throw", err, resolve, reject);
|
|
291
263
|
});
|
|
292
264
|
}
|
|
293
|
-
|
|
294
265
|
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
295
266
|
// When a yielded Promise is resolved, its final value becomes
|
|
296
267
|
// the .value of the Promise<{value,done}> result for the
|
|
@@ -304,17 +275,15 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
304
275
|
});
|
|
305
276
|
}
|
|
306
277
|
}
|
|
307
|
-
|
|
308
278
|
var previousPromise;
|
|
309
|
-
|
|
310
279
|
function enqueue(method, arg) {
|
|
311
280
|
function callInvokeWithMethodAndArg() {
|
|
312
281
|
return new PromiseImpl(function (resolve, reject) {
|
|
313
282
|
invoke(method, arg, resolve, reject);
|
|
314
283
|
});
|
|
315
284
|
}
|
|
316
|
-
|
|
317
|
-
|
|
285
|
+
return previousPromise =
|
|
286
|
+
// If enqueue has been called before, then we want to wait until
|
|
318
287
|
// all previous Promises have been resolved before calling invoke,
|
|
319
288
|
// so that results are always delivered in the correct order. If
|
|
320
289
|
// enqueue has not been called before, then it is important to
|
|
@@ -326,24 +295,25 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
326
295
|
// execute code before the first await. Since we implement simple
|
|
327
296
|
// async functions in terms of async generators, it is especially
|
|
328
297
|
// important to get this right, even though it requires care.
|
|
329
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
298
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
299
|
+
// Avoid propagating failures to Promises returned by later
|
|
330
300
|
// invocations of the iterator.
|
|
331
301
|
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
332
|
-
}
|
|
333
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
334
|
-
|
|
302
|
+
}
|
|
335
303
|
|
|
304
|
+
// Define the unified helper method that is used to implement .next,
|
|
305
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
336
306
|
this._invoke = enqueue;
|
|
337
307
|
}
|
|
338
|
-
|
|
339
308
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
340
309
|
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
341
310
|
return this;
|
|
342
311
|
});
|
|
343
|
-
exports.AsyncIterator = AsyncIterator;
|
|
312
|
+
exports.AsyncIterator = AsyncIterator;
|
|
313
|
+
|
|
314
|
+
// Note that simple async functions are implemented on top of
|
|
344
315
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
345
316
|
// the final result produced by the iterator.
|
|
346
|
-
|
|
347
317
|
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
348
318
|
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
349
319
|
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
@@ -352,39 +322,32 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
352
322
|
return result.done ? result.value : iter.next();
|
|
353
323
|
});
|
|
354
324
|
};
|
|
355
|
-
|
|
356
325
|
function makeInvokeMethod(innerFn, self, context) {
|
|
357
326
|
var state = GenStateSuspendedStart;
|
|
358
327
|
return function invoke(method, arg) {
|
|
359
328
|
if (state === GenStateExecuting) {
|
|
360
329
|
throw new Error("Generator is already running");
|
|
361
330
|
}
|
|
362
|
-
|
|
363
331
|
if (state === GenStateCompleted) {
|
|
364
332
|
if (method === "throw") {
|
|
365
333
|
throw arg;
|
|
366
|
-
}
|
|
367
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
368
|
-
|
|
334
|
+
}
|
|
369
335
|
|
|
336
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
337
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
370
338
|
return doneResult();
|
|
371
339
|
}
|
|
372
|
-
|
|
373
340
|
context.method = method;
|
|
374
341
|
context.arg = arg;
|
|
375
|
-
|
|
376
342
|
while (true) {
|
|
377
343
|
var delegate = context.delegate;
|
|
378
|
-
|
|
379
344
|
if (delegate) {
|
|
380
345
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
381
|
-
|
|
382
346
|
if (delegateResult) {
|
|
383
347
|
if (delegateResult === ContinueSentinel) continue;
|
|
384
348
|
return delegateResult;
|
|
385
349
|
}
|
|
386
350
|
}
|
|
387
|
-
|
|
388
351
|
if (context.method === "next") {
|
|
389
352
|
// Setting context._sent for legacy support of Babel's
|
|
390
353
|
// function.sent implementation.
|
|
@@ -394,51 +357,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
394
357
|
state = GenStateCompleted;
|
|
395
358
|
throw context.arg;
|
|
396
359
|
}
|
|
397
|
-
|
|
398
360
|
context.dispatchException(context.arg);
|
|
399
361
|
} else if (context.method === "return") {
|
|
400
362
|
context.abrupt("return", context.arg);
|
|
401
363
|
}
|
|
402
|
-
|
|
403
364
|
state = GenStateExecuting;
|
|
404
365
|
var record = tryCatch(innerFn, self, context);
|
|
405
|
-
|
|
406
366
|
if (record.type === "normal") {
|
|
407
367
|
// If an exception is thrown from innerFn, we leave state ===
|
|
408
368
|
// GenStateExecuting and loop back for another invocation.
|
|
409
369
|
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
410
|
-
|
|
411
370
|
if (record.arg === ContinueSentinel) {
|
|
412
371
|
continue;
|
|
413
372
|
}
|
|
414
|
-
|
|
415
373
|
return {
|
|
416
374
|
value: record.arg,
|
|
417
375
|
done: context.done
|
|
418
376
|
};
|
|
419
377
|
} else if (record.type === "throw") {
|
|
420
|
-
state = GenStateCompleted;
|
|
378
|
+
state = GenStateCompleted;
|
|
379
|
+
// Dispatch the exception by looping back around to the
|
|
421
380
|
// context.dispatchException(context.arg) call above.
|
|
422
|
-
|
|
423
381
|
context.method = "throw";
|
|
424
382
|
context.arg = record.arg;
|
|
425
383
|
}
|
|
426
384
|
}
|
|
427
385
|
};
|
|
428
|
-
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
429
389
|
// result, either by returning a { value, done } result from the
|
|
430
390
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
431
391
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
432
|
-
|
|
433
|
-
|
|
434
392
|
function maybeInvokeDelegate(delegate, context) {
|
|
435
393
|
var method = delegate.iterator[context.method];
|
|
436
|
-
|
|
437
394
|
if (method === undefined$1) {
|
|
438
395
|
// A .throw or .return when the delegate iterator has no .throw
|
|
439
396
|
// method always terminates the yield* loop.
|
|
440
397
|
context.delegate = null;
|
|
441
|
-
|
|
442
398
|
if (context.method === "throw") {
|
|
443
399
|
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
444
400
|
if (delegate.iterator["return"]) {
|
|
@@ -447,51 +403,45 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
447
403
|
context.method = "return";
|
|
448
404
|
context.arg = undefined$1;
|
|
449
405
|
maybeInvokeDelegate(delegate, context);
|
|
450
|
-
|
|
451
406
|
if (context.method === "throw") {
|
|
452
407
|
// If maybeInvokeDelegate(context) changed context.method from
|
|
453
408
|
// "return" to "throw", let that override the TypeError below.
|
|
454
409
|
return ContinueSentinel;
|
|
455
410
|
}
|
|
456
411
|
}
|
|
457
|
-
|
|
458
412
|
context.method = "throw";
|
|
459
413
|
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
460
414
|
}
|
|
461
|
-
|
|
462
415
|
return ContinueSentinel;
|
|
463
416
|
}
|
|
464
|
-
|
|
465
417
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
466
|
-
|
|
467
418
|
if (record.type === "throw") {
|
|
468
419
|
context.method = "throw";
|
|
469
420
|
context.arg = record.arg;
|
|
470
421
|
context.delegate = null;
|
|
471
422
|
return ContinueSentinel;
|
|
472
423
|
}
|
|
473
|
-
|
|
474
424
|
var info = record.arg;
|
|
475
|
-
|
|
476
425
|
if (!info) {
|
|
477
426
|
context.method = "throw";
|
|
478
427
|
context.arg = new TypeError("iterator result is not an object");
|
|
479
428
|
context.delegate = null;
|
|
480
429
|
return ContinueSentinel;
|
|
481
430
|
}
|
|
482
|
-
|
|
483
431
|
if (info.done) {
|
|
484
432
|
// Assign the result of the finished delegate to the temporary
|
|
485
433
|
// variable specified by delegate.resultName (see delegateYield).
|
|
486
|
-
context[delegate.resultName] = info.value;
|
|
434
|
+
context[delegate.resultName] = info.value;
|
|
435
|
+
|
|
436
|
+
// Resume execution at the desired location (see delegateYield).
|
|
437
|
+
context.next = delegate.nextLoc;
|
|
487
438
|
|
|
488
|
-
|
|
439
|
+
// If context.method was "throw" but the delegate handled the
|
|
489
440
|
// exception, let the outer generator proceed normally. If
|
|
490
441
|
// context.method was "next", forget context.arg since it has been
|
|
491
442
|
// "consumed" by the delegate iterator. If context.method was
|
|
492
443
|
// "return", allow the original .return call to continue in the
|
|
493
444
|
// outer generator.
|
|
494
|
-
|
|
495
445
|
if (context.method !== "return") {
|
|
496
446
|
context.method = "next";
|
|
497
447
|
context.arg = undefined$1;
|
|
@@ -499,54 +449,49 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
499
449
|
} else {
|
|
500
450
|
// Re-yield the result returned by the delegate method.
|
|
501
451
|
return info;
|
|
502
|
-
}
|
|
503
|
-
// the outer generator.
|
|
504
|
-
|
|
452
|
+
}
|
|
505
453
|
|
|
454
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
455
|
+
// the outer generator.
|
|
506
456
|
context.delegate = null;
|
|
507
457
|
return ContinueSentinel;
|
|
508
|
-
}
|
|
509
|
-
// unified ._invoke helper method.
|
|
510
|
-
|
|
458
|
+
}
|
|
511
459
|
|
|
460
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
461
|
+
// unified ._invoke helper method.
|
|
512
462
|
defineIteratorMethods(Gp);
|
|
513
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
463
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
464
|
+
|
|
465
|
+
// A Generator should always return itself as the iterator object when the
|
|
514
466
|
// @@iterator function is called on it. Some browsers' implementations of the
|
|
515
467
|
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
516
468
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
517
469
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
518
|
-
|
|
519
470
|
define(Gp, iteratorSymbol, function () {
|
|
520
471
|
return this;
|
|
521
472
|
});
|
|
522
473
|
define(Gp, "toString", function () {
|
|
523
474
|
return "[object Generator]";
|
|
524
475
|
});
|
|
525
|
-
|
|
526
476
|
function pushTryEntry(locs) {
|
|
527
477
|
var entry = {
|
|
528
478
|
tryLoc: locs[0]
|
|
529
479
|
};
|
|
530
|
-
|
|
531
480
|
if (1 in locs) {
|
|
532
481
|
entry.catchLoc = locs[1];
|
|
533
482
|
}
|
|
534
|
-
|
|
535
483
|
if (2 in locs) {
|
|
536
484
|
entry.finallyLoc = locs[2];
|
|
537
485
|
entry.afterLoc = locs[3];
|
|
538
486
|
}
|
|
539
|
-
|
|
540
487
|
this.tryEntries.push(entry);
|
|
541
488
|
}
|
|
542
|
-
|
|
543
489
|
function resetTryEntry(entry) {
|
|
544
490
|
var record = entry.completion || {};
|
|
545
491
|
record.type = "normal";
|
|
546
492
|
delete record.arg;
|
|
547
493
|
entry.completion = record;
|
|
548
494
|
}
|
|
549
|
-
|
|
550
495
|
function Context(tryLocsList) {
|
|
551
496
|
// The root entry object (effectively a try statement without a catch
|
|
552
497
|
// or a finally block) gives us a place to store values thrown from
|
|
@@ -557,97 +502,84 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
557
502
|
tryLocsList.forEach(pushTryEntry, this);
|
|
558
503
|
this.reset(true);
|
|
559
504
|
}
|
|
560
|
-
|
|
561
505
|
exports.keys = function (object) {
|
|
562
506
|
var keys = [];
|
|
563
|
-
|
|
564
507
|
for (var key in object) {
|
|
565
508
|
keys.push(key);
|
|
566
509
|
}
|
|
510
|
+
keys.reverse();
|
|
567
511
|
|
|
568
|
-
|
|
512
|
+
// Rather than returning an object with a next method, we keep
|
|
569
513
|
// things simple and return the next function itself.
|
|
570
|
-
|
|
571
514
|
return function next() {
|
|
572
515
|
while (keys.length) {
|
|
573
516
|
var key = keys.pop();
|
|
574
|
-
|
|
575
517
|
if (key in object) {
|
|
576
518
|
next.value = key;
|
|
577
519
|
next.done = false;
|
|
578
520
|
return next;
|
|
579
521
|
}
|
|
580
|
-
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// To avoid creating an additional object, we just hang the .value
|
|
581
525
|
// and .done properties off the next function object itself. This
|
|
582
526
|
// also ensures that the minifier will not anonymize the function.
|
|
583
|
-
|
|
584
|
-
|
|
585
527
|
next.done = true;
|
|
586
528
|
return next;
|
|
587
529
|
};
|
|
588
530
|
};
|
|
589
|
-
|
|
590
531
|
function values(iterable) {
|
|
591
532
|
if (iterable) {
|
|
592
533
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
593
|
-
|
|
594
534
|
if (iteratorMethod) {
|
|
595
535
|
return iteratorMethod.call(iterable);
|
|
596
536
|
}
|
|
597
|
-
|
|
598
537
|
if (typeof iterable.next === "function") {
|
|
599
538
|
return iterable;
|
|
600
539
|
}
|
|
601
|
-
|
|
602
540
|
if (!isNaN(iterable.length)) {
|
|
603
541
|
var i = -1,
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
542
|
+
next = function next() {
|
|
543
|
+
while (++i < iterable.length) {
|
|
544
|
+
if (hasOwn.call(iterable, i)) {
|
|
545
|
+
next.value = iterable[i];
|
|
546
|
+
next.done = false;
|
|
547
|
+
return next;
|
|
548
|
+
}
|
|
610
549
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return next;
|
|
616
|
-
};
|
|
617
|
-
|
|
550
|
+
next.value = undefined$1;
|
|
551
|
+
next.done = true;
|
|
552
|
+
return next;
|
|
553
|
+
};
|
|
618
554
|
return next.next = next;
|
|
619
555
|
}
|
|
620
|
-
}
|
|
621
|
-
|
|
556
|
+
}
|
|
622
557
|
|
|
558
|
+
// Return an iterator with no values.
|
|
623
559
|
return {
|
|
624
560
|
next: doneResult
|
|
625
561
|
};
|
|
626
562
|
}
|
|
627
|
-
|
|
628
563
|
exports.values = values;
|
|
629
|
-
|
|
630
564
|
function doneResult() {
|
|
631
565
|
return {
|
|
632
566
|
value: undefined$1,
|
|
633
567
|
done: true
|
|
634
568
|
};
|
|
635
569
|
}
|
|
636
|
-
|
|
637
570
|
Context.prototype = {
|
|
638
571
|
constructor: Context,
|
|
639
572
|
reset: function reset(skipTempReset) {
|
|
640
573
|
this.prev = 0;
|
|
641
|
-
this.next = 0;
|
|
574
|
+
this.next = 0;
|
|
575
|
+
// Resetting context._sent for legacy support of Babel's
|
|
642
576
|
// function.sent implementation.
|
|
643
|
-
|
|
644
577
|
this.sent = this._sent = undefined$1;
|
|
645
578
|
this.done = false;
|
|
646
579
|
this.delegate = null;
|
|
647
580
|
this.method = "next";
|
|
648
581
|
this.arg = undefined$1;
|
|
649
582
|
this.tryEntries.forEach(resetTryEntry);
|
|
650
|
-
|
|
651
583
|
if (!skipTempReset) {
|
|
652
584
|
for (var name in this) {
|
|
653
585
|
// Not sure about the optimal order of these conditions:
|
|
@@ -661,50 +593,40 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
661
593
|
this.done = true;
|
|
662
594
|
var rootEntry = this.tryEntries[0];
|
|
663
595
|
var rootRecord = rootEntry.completion;
|
|
664
|
-
|
|
665
596
|
if (rootRecord.type === "throw") {
|
|
666
597
|
throw rootRecord.arg;
|
|
667
598
|
}
|
|
668
|
-
|
|
669
599
|
return this.rval;
|
|
670
600
|
},
|
|
671
601
|
dispatchException: function dispatchException(exception) {
|
|
672
602
|
if (this.done) {
|
|
673
603
|
throw exception;
|
|
674
604
|
}
|
|
675
|
-
|
|
676
605
|
var context = this;
|
|
677
|
-
|
|
678
606
|
function handle(loc, caught) {
|
|
679
607
|
record.type = "throw";
|
|
680
608
|
record.arg = exception;
|
|
681
609
|
context.next = loc;
|
|
682
|
-
|
|
683
610
|
if (caught) {
|
|
684
611
|
// If the dispatched exception was caught by a catch block,
|
|
685
612
|
// then let that catch block handle the exception normally.
|
|
686
613
|
context.method = "next";
|
|
687
614
|
context.arg = undefined$1;
|
|
688
615
|
}
|
|
689
|
-
|
|
690
616
|
return !!caught;
|
|
691
617
|
}
|
|
692
|
-
|
|
693
618
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
694
619
|
var entry = this.tryEntries[i];
|
|
695
620
|
var record = entry.completion;
|
|
696
|
-
|
|
697
621
|
if (entry.tryLoc === "root") {
|
|
698
622
|
// Exception thrown outside of any try block that could handle
|
|
699
623
|
// it, so set the completion value of the entire function to
|
|
700
624
|
// throw the exception.
|
|
701
625
|
return handle("end");
|
|
702
626
|
}
|
|
703
|
-
|
|
704
627
|
if (entry.tryLoc <= this.prev) {
|
|
705
628
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
706
629
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
707
|
-
|
|
708
630
|
if (hasCatch && hasFinally) {
|
|
709
631
|
if (this.prev < entry.catchLoc) {
|
|
710
632
|
return handle(entry.catchLoc, true);
|
|
@@ -728,36 +650,30 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
728
650
|
abrupt: function abrupt(type, arg) {
|
|
729
651
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
730
652
|
var entry = this.tryEntries[i];
|
|
731
|
-
|
|
732
653
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
733
654
|
var finallyEntry = entry;
|
|
734
655
|
break;
|
|
735
656
|
}
|
|
736
657
|
}
|
|
737
|
-
|
|
738
658
|
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
739
659
|
// Ignore the finally entry if control is not jumping to a
|
|
740
660
|
// location outside the try/catch block.
|
|
741
661
|
finallyEntry = null;
|
|
742
662
|
}
|
|
743
|
-
|
|
744
663
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
745
664
|
record.type = type;
|
|
746
665
|
record.arg = arg;
|
|
747
|
-
|
|
748
666
|
if (finallyEntry) {
|
|
749
667
|
this.method = "next";
|
|
750
668
|
this.next = finallyEntry.finallyLoc;
|
|
751
669
|
return ContinueSentinel;
|
|
752
670
|
}
|
|
753
|
-
|
|
754
671
|
return this.complete(record);
|
|
755
672
|
},
|
|
756
673
|
complete: function complete(record, afterLoc) {
|
|
757
674
|
if (record.type === "throw") {
|
|
758
675
|
throw record.arg;
|
|
759
676
|
}
|
|
760
|
-
|
|
761
677
|
if (record.type === "break" || record.type === "continue") {
|
|
762
678
|
this.next = record.arg;
|
|
763
679
|
} else if (record.type === "return") {
|
|
@@ -767,13 +683,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
767
683
|
} else if (record.type === "normal" && afterLoc) {
|
|
768
684
|
this.next = afterLoc;
|
|
769
685
|
}
|
|
770
|
-
|
|
771
686
|
return ContinueSentinel;
|
|
772
687
|
},
|
|
773
688
|
finish: function finish(finallyLoc) {
|
|
774
689
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
775
690
|
var entry = this.tryEntries[i];
|
|
776
|
-
|
|
777
691
|
if (entry.finallyLoc === finallyLoc) {
|
|
778
692
|
this.complete(entry.completion, entry.afterLoc);
|
|
779
693
|
resetTryEntry(entry);
|
|
@@ -784,21 +698,18 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
784
698
|
"catch": function _catch(tryLoc) {
|
|
785
699
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
786
700
|
var entry = this.tryEntries[i];
|
|
787
|
-
|
|
788
701
|
if (entry.tryLoc === tryLoc) {
|
|
789
702
|
var record = entry.completion;
|
|
790
|
-
|
|
791
703
|
if (record.type === "throw") {
|
|
792
704
|
var thrown = record.arg;
|
|
793
705
|
resetTryEntry(entry);
|
|
794
706
|
}
|
|
795
|
-
|
|
796
707
|
return thrown;
|
|
797
708
|
}
|
|
798
|
-
}
|
|
799
|
-
// argument that corresponds to a known catch block.
|
|
800
|
-
|
|
709
|
+
}
|
|
801
710
|
|
|
711
|
+
// The context.catch method must only be called with a location
|
|
712
|
+
// argument that corresponds to a known catch block.
|
|
802
713
|
throw new Error("illegal catch attempt");
|
|
803
714
|
},
|
|
804
715
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
@@ -807,27 +718,26 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
807
718
|
resultName: resultName,
|
|
808
719
|
nextLoc: nextLoc
|
|
809
720
|
};
|
|
810
|
-
|
|
811
721
|
if (this.method === "next") {
|
|
812
722
|
// Deliberately forget the last sent value so that we don't
|
|
813
723
|
// accidentally pass it on to the delegate.
|
|
814
724
|
this.arg = undefined$1;
|
|
815
725
|
}
|
|
816
|
-
|
|
817
726
|
return ContinueSentinel;
|
|
818
727
|
}
|
|
819
|
-
};
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
820
731
|
// or not, return the runtime object so that we can declare the variable
|
|
821
732
|
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
822
733
|
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
823
|
-
|
|
824
734
|
return exports;
|
|
825
|
-
}(
|
|
735
|
+
}(
|
|
736
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
826
737
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
827
738
|
// object. Either way, the resulting object will be used to initialize
|
|
828
739
|
// the regeneratorRuntime variable at the top of this file.
|
|
829
740
|
module.exports );
|
|
830
|
-
|
|
831
741
|
try {
|
|
832
742
|
regeneratorRuntime = runtime;
|
|
833
743
|
} catch (accidentalStrictMode) {
|
|
@@ -850,24 +760,21 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
850
760
|
});
|
|
851
761
|
|
|
852
762
|
var _excluded = ["file"];
|
|
853
|
-
|
|
854
763
|
var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
855
764
|
var id = _ref2.id,
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
765
|
+
_ref2$name = _ref2.name,
|
|
766
|
+
displayName = _ref2$name === void 0 ? "" : _ref2$name,
|
|
767
|
+
_ref2$values = _ref2.values,
|
|
768
|
+
values = _ref2$values === void 0 ? [] : _ref2$values;
|
|
860
769
|
var returnValues = values.map(function (value) {
|
|
861
770
|
var output = {
|
|
862
771
|
label: value.name
|
|
863
772
|
};
|
|
864
|
-
|
|
865
773
|
if (displayName.match(/colou?r/gi)) {
|
|
866
774
|
output = _extends({}, output, {
|
|
867
775
|
hexColors: [value.name]
|
|
868
776
|
});
|
|
869
777
|
}
|
|
870
|
-
|
|
871
778
|
return output;
|
|
872
779
|
});
|
|
873
780
|
return {
|
|
@@ -877,18 +784,15 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
877
784
|
values: returnValues
|
|
878
785
|
};
|
|
879
786
|
};
|
|
880
|
-
|
|
881
787
|
var normalizeProductImages = function normalizeProductImages(images) {
|
|
882
788
|
if (!images || images.length < 1) {
|
|
883
789
|
return [{
|
|
884
790
|
url: "/"
|
|
885
791
|
}];
|
|
886
792
|
}
|
|
887
|
-
|
|
888
793
|
return images == null ? void 0 : images.map(function (_ref3) {
|
|
889
794
|
var file = _ref3.file,
|
|
890
|
-
|
|
891
|
-
|
|
795
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
892
796
|
return _extends({
|
|
893
797
|
url: (file == null ? void 0 : file.url) + "",
|
|
894
798
|
height: Number(file == null ? void 0 : file.height),
|
|
@@ -896,14 +800,13 @@ var normalizeProductImages = function normalizeProductImages(images) {
|
|
|
896
800
|
}, rest);
|
|
897
801
|
});
|
|
898
802
|
};
|
|
899
|
-
|
|
900
803
|
var normalizeProductVariants = function normalizeProductVariants(variants, productOptions) {
|
|
901
804
|
return variants == null ? void 0 : variants.map(function (_ref4) {
|
|
902
805
|
var id = _ref4.id,
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
806
|
+
name = _ref4.name,
|
|
807
|
+
price = _ref4.price,
|
|
808
|
+
_ref4$option_value_id = _ref4.option_value_ids,
|
|
809
|
+
optionValueIds = _ref4$option_value_id === void 0 ? [] : _ref4$option_value_id;
|
|
907
810
|
var values = name.split(",").map(function (i) {
|
|
908
811
|
return {
|
|
909
812
|
name: i.trim(),
|
|
@@ -912,7 +815,6 @@ var normalizeProductVariants = function normalizeProductVariants(variants, produ
|
|
|
912
815
|
});
|
|
913
816
|
var options = optionValueIds.map(function (id) {
|
|
914
817
|
var _matchingOption$name;
|
|
915
|
-
|
|
916
818
|
var matchingOption = productOptions.find(function (option) {
|
|
917
819
|
return option.values.find(function (value) {
|
|
918
820
|
return value.id == id;
|
|
@@ -935,17 +837,16 @@ var normalizeProductVariants = function normalizeProductVariants(variants, produ
|
|
|
935
837
|
};
|
|
936
838
|
});
|
|
937
839
|
};
|
|
938
|
-
|
|
939
840
|
function normalizeProduct(swellProduct) {
|
|
940
841
|
var id = swellProduct.id,
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
842
|
+
description = swellProduct.description,
|
|
843
|
+
images = swellProduct.images,
|
|
844
|
+
options = swellProduct.options,
|
|
845
|
+
slug = swellProduct.slug,
|
|
846
|
+
variants = swellProduct.variants,
|
|
847
|
+
value = swellProduct.price,
|
|
848
|
+
currencyCode = swellProduct.currency;
|
|
849
|
+
// ProductView accesses variants for each product
|
|
949
850
|
var emptyVariants = [{
|
|
950
851
|
options: [],
|
|
951
852
|
id: id,
|
|
@@ -956,7 +857,6 @@ function normalizeProduct(swellProduct) {
|
|
|
956
857
|
}) : [];
|
|
957
858
|
var productVariants = variants ? normalizeProductVariants(variants.results, options) : [];
|
|
958
859
|
var productImages = normalizeProductImages(images);
|
|
959
|
-
|
|
960
860
|
var product = _extends({}, swellProduct, {
|
|
961
861
|
description: description,
|
|
962
862
|
id: id,
|
|
@@ -970,21 +870,19 @@ function normalizeProduct(swellProduct) {
|
|
|
970
870
|
currencyCode: currencyCode
|
|
971
871
|
}
|
|
972
872
|
});
|
|
973
|
-
|
|
974
873
|
return product;
|
|
975
874
|
}
|
|
976
875
|
function normalizeCart(_ref5) {
|
|
977
876
|
var _items$map;
|
|
978
|
-
|
|
979
877
|
var id = _ref5.id,
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
878
|
+
account_id = _ref5.account_id,
|
|
879
|
+
date_created = _ref5.date_created,
|
|
880
|
+
currency = _ref5.currency,
|
|
881
|
+
tax_included_total = _ref5.tax_included_total,
|
|
882
|
+
items = _ref5.items,
|
|
883
|
+
sub_total = _ref5.sub_total,
|
|
884
|
+
grand_total = _ref5.grand_total,
|
|
885
|
+
discounts = _ref5.discounts;
|
|
988
886
|
var cart = {
|
|
989
887
|
id: id,
|
|
990
888
|
customerId: account_id + "",
|
|
@@ -1016,15 +914,13 @@ export function normalizeCustomer(customer: SwellCustomer): Customer {
|
|
|
1016
914
|
}
|
|
1017
915
|
}
|
|
1018
916
|
*/
|
|
1019
|
-
|
|
1020
917
|
function normalizeLineItem(_ref6) {
|
|
1021
918
|
var _product$id, _product$name, _variant$id, _variant$sku;
|
|
1022
|
-
|
|
1023
919
|
var id = _ref6.id,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
920
|
+
product = _ref6.product,
|
|
921
|
+
price = _ref6.price,
|
|
922
|
+
variant = _ref6.variant,
|
|
923
|
+
quantity = _ref6.quantity;
|
|
1028
924
|
var item = {
|
|
1029
925
|
id: id,
|
|
1030
926
|
variantId: variant == null ? void 0 : variant.id,
|
|
@@ -1050,7 +946,6 @@ function normalizeLineItem(_ref6) {
|
|
|
1050
946
|
};
|
|
1051
947
|
return item;
|
|
1052
948
|
}
|
|
1053
|
-
|
|
1054
949
|
function normalizeChildren(children) {
|
|
1055
950
|
return children == null ? void 0 : children.results.map(function (ch) {
|
|
1056
951
|
return ch.id;
|
|
@@ -1058,13 +953,13 @@ function normalizeChildren(children) {
|
|
|
1058
953
|
}
|
|
1059
954
|
function normalizeCategory(_ref7) {
|
|
1060
955
|
var id = _ref7.id,
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
956
|
+
name = _ref7.name,
|
|
957
|
+
slug = _ref7.slug,
|
|
958
|
+
products = _ref7.products,
|
|
959
|
+
images = _ref7.images,
|
|
960
|
+
depth = _ref7.depth,
|
|
961
|
+
children = _ref7.children,
|
|
962
|
+
parent_id = _ref7.parent_id;
|
|
1068
963
|
return {
|
|
1069
964
|
id: id,
|
|
1070
965
|
name: name,
|
|
@@ -1092,20 +987,15 @@ var handleFetchResponse = /*#__PURE__*/function () {
|
|
|
1092
987
|
_context.next = 4;
|
|
1093
988
|
break;
|
|
1094
989
|
}
|
|
1095
|
-
|
|
1096
990
|
if (!res.error) {
|
|
1097
991
|
_context.next = 3;
|
|
1098
992
|
break;
|
|
1099
993
|
}
|
|
1100
|
-
|
|
1101
994
|
throw new CommerceError(res.error);
|
|
1102
|
-
|
|
1103
995
|
case 3:
|
|
1104
996
|
return _context.abrupt("return", res);
|
|
1105
|
-
|
|
1106
997
|
case 4:
|
|
1107
998
|
return _context.abrupt("return", null);
|
|
1108
|
-
|
|
1109
999
|
case 5:
|
|
1110
1000
|
case "end":
|
|
1111
1001
|
return _context.stop();
|
|
@@ -1113,7 +1003,6 @@ var handleFetchResponse = /*#__PURE__*/function () {
|
|
|
1113
1003
|
}
|
|
1114
1004
|
}, _callee);
|
|
1115
1005
|
}));
|
|
1116
|
-
|
|
1117
1006
|
return function handleFetchResponse(_x) {
|
|
1118
1007
|
return _ref.apply(this, arguments);
|
|
1119
1008
|
};
|
|
@@ -1123,7 +1012,6 @@ var handleFetchResponse = /*#__PURE__*/function () {
|
|
|
1123
1012
|
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1124
1013
|
Changes: None
|
|
1125
1014
|
*/
|
|
1126
|
-
|
|
1127
1015
|
var getCheckoutId = function getCheckoutId(id) {
|
|
1128
1016
|
return id != null ? id : Cookies.get(SWELL_CHECKOUT_ID_COOKIE);
|
|
1129
1017
|
};
|
|
@@ -1132,14 +1020,12 @@ var getCheckoutId = function getCheckoutId(id) {
|
|
|
1132
1020
|
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1133
1021
|
Changes: None
|
|
1134
1022
|
*/
|
|
1135
|
-
|
|
1136
1023
|
var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
1137
1024
|
if (!checkoutPayload) {
|
|
1138
1025
|
throw new CommerceError({
|
|
1139
1026
|
message: 'Invalid response from Swell'
|
|
1140
1027
|
});
|
|
1141
1028
|
}
|
|
1142
|
-
|
|
1143
1029
|
return normalizeCart(checkoutPayload);
|
|
1144
1030
|
};
|
|
1145
1031
|
|
|
@@ -1155,22 +1041,18 @@ var checkoutCreate = /*#__PURE__*/function () {
|
|
|
1155
1041
|
query: 'cart',
|
|
1156
1042
|
method: 'get'
|
|
1157
1043
|
});
|
|
1158
|
-
|
|
1159
1044
|
case 2:
|
|
1160
1045
|
cart = _context.sent;
|
|
1161
|
-
|
|
1162
1046
|
if (cart) {
|
|
1163
1047
|
_context.next = 6;
|
|
1164
1048
|
break;
|
|
1165
1049
|
}
|
|
1166
|
-
|
|
1167
1050
|
_context.next = 6;
|
|
1168
1051
|
return fetch({
|
|
1169
1052
|
query: 'cart',
|
|
1170
1053
|
method: 'setItems',
|
|
1171
1054
|
variables: [[]]
|
|
1172
1055
|
});
|
|
1173
|
-
|
|
1174
1056
|
case 6:
|
|
1175
1057
|
checkoutUrl = cart == null ? void 0 : cart.checkout_url;
|
|
1176
1058
|
options = {
|
|
@@ -1178,13 +1060,10 @@ var checkoutCreate = /*#__PURE__*/function () {
|
|
|
1178
1060
|
sameSite: "none",
|
|
1179
1061
|
secure: true
|
|
1180
1062
|
};
|
|
1181
|
-
|
|
1182
1063
|
if (checkoutUrl) {
|
|
1183
1064
|
Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options);
|
|
1184
1065
|
}
|
|
1185
|
-
|
|
1186
1066
|
return _context.abrupt("return", cart);
|
|
1187
|
-
|
|
1188
1067
|
case 10:
|
|
1189
1068
|
case "end":
|
|
1190
1069
|
return _context.stop();
|
|
@@ -1192,7 +1071,6 @@ var checkoutCreate = /*#__PURE__*/function () {
|
|
|
1192
1071
|
}
|
|
1193
1072
|
}, _callee);
|
|
1194
1073
|
}));
|
|
1195
|
-
|
|
1196
1074
|
return function checkoutCreate(_x) {
|
|
1197
1075
|
return _ref.apply(this, arguments);
|
|
1198
1076
|
};
|
|
@@ -1213,11 +1091,9 @@ var handler = {
|
|
|
1213
1091
|
fetch = _ref.fetch;
|
|
1214
1092
|
_context.next = 3;
|
|
1215
1093
|
return checkoutCreate(fetch);
|
|
1216
|
-
|
|
1217
1094
|
case 3:
|
|
1218
1095
|
cart = _context.sent;
|
|
1219
1096
|
return _context.abrupt("return", cart ? normalizeCart(cart) : null);
|
|
1220
|
-
|
|
1221
1097
|
case 5:
|
|
1222
1098
|
case "end":
|
|
1223
1099
|
return _context.stop();
|
|
@@ -1239,7 +1115,6 @@ var handler = {
|
|
|
1239
1115
|
isEmpty: {
|
|
1240
1116
|
get: function get() {
|
|
1241
1117
|
var _response$data$lineIt, _response$data;
|
|
1242
|
-
|
|
1243
1118
|
return ((_response$data$lineIt = (_response$data = response.data) == null ? void 0 : _response$data.lineItems.length) != null ? _response$data$lineIt : 0) <= 0;
|
|
1244
1119
|
},
|
|
1245
1120
|
enumerable: true
|
|
@@ -1263,36 +1138,29 @@ var handler$1 = {
|
|
|
1263
1138
|
switch (_context.prev = _context.next) {
|
|
1264
1139
|
case 0:
|
|
1265
1140
|
item = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1266
|
-
|
|
1267
1141
|
if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
|
|
1268
1142
|
_context.next = 3;
|
|
1269
1143
|
break;
|
|
1270
1144
|
}
|
|
1271
|
-
|
|
1272
1145
|
throw new CommerceError({
|
|
1273
1146
|
message: 'The item quantity has to be a valid integer greater than 0'
|
|
1274
1147
|
});
|
|
1275
|
-
|
|
1276
1148
|
case 3:
|
|
1277
1149
|
variables = {
|
|
1278
1150
|
checkoutId: getCheckoutId(),
|
|
1279
1151
|
product_id: item.productId,
|
|
1280
1152
|
quantity: item.quantity
|
|
1281
1153
|
};
|
|
1282
|
-
|
|
1283
1154
|
if (item.productId !== item.variantId) {
|
|
1284
1155
|
variables.variant_id = item.variantId;
|
|
1285
1156
|
}
|
|
1286
|
-
|
|
1287
1157
|
_context.next = 7;
|
|
1288
1158
|
return fetch(_extends({}, options, {
|
|
1289
1159
|
variables: variables
|
|
1290
1160
|
}));
|
|
1291
|
-
|
|
1292
1161
|
case 7:
|
|
1293
1162
|
response = _context.sent;
|
|
1294
1163
|
return _context.abrupt("return", checkoutToCart(response));
|
|
1295
|
-
|
|
1296
1164
|
case 9:
|
|
1297
1165
|
case "end":
|
|
1298
1166
|
return _context.stop();
|
|
@@ -1305,8 +1173,7 @@ var handler$1 = {
|
|
|
1305
1173
|
var fetch = _ref2.fetch;
|
|
1306
1174
|
return function () {
|
|
1307
1175
|
var _useCart = useCart(),
|
|
1308
|
-
|
|
1309
|
-
|
|
1176
|
+
mutate = _useCart.mutate;
|
|
1310
1177
|
return useCallback( /*#__PURE__*/function () {
|
|
1311
1178
|
var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
|
|
1312
1179
|
var data;
|
|
@@ -1318,15 +1185,12 @@ var handler$1 = {
|
|
|
1318
1185
|
return fetch({
|
|
1319
1186
|
input: input
|
|
1320
1187
|
});
|
|
1321
|
-
|
|
1322
1188
|
case 2:
|
|
1323
1189
|
data = _context2.sent;
|
|
1324
1190
|
_context2.next = 5;
|
|
1325
1191
|
return mutate(data, false);
|
|
1326
|
-
|
|
1327
1192
|
case 5:
|
|
1328
1193
|
return _context2.abrupt("return", data);
|
|
1329
|
-
|
|
1330
1194
|
case 6:
|
|
1331
1195
|
case "end":
|
|
1332
1196
|
return _context2.stop();
|
|
@@ -1334,11 +1198,9 @@ var handler$1 = {
|
|
|
1334
1198
|
}
|
|
1335
1199
|
}, _callee2);
|
|
1336
1200
|
}));
|
|
1337
|
-
|
|
1338
1201
|
function addItem(_x) {
|
|
1339
1202
|
return _addItem.apply(this, arguments);
|
|
1340
1203
|
}
|
|
1341
|
-
|
|
1342
1204
|
return addItem;
|
|
1343
1205
|
}(), [fetch, mutate]);
|
|
1344
1206
|
};
|
|
@@ -1362,11 +1224,9 @@ var handler$2 = {
|
|
|
1362
1224
|
return fetch(_extends({}, options, {
|
|
1363
1225
|
variables: [itemId]
|
|
1364
1226
|
}));
|
|
1365
|
-
|
|
1366
1227
|
case 3:
|
|
1367
1228
|
response = _context.sent;
|
|
1368
1229
|
return _context.abrupt("return", checkoutToCart(response));
|
|
1369
|
-
|
|
1370
1230
|
case 5:
|
|
1371
1231
|
case "end":
|
|
1372
1232
|
return _context.stop();
|
|
@@ -1379,8 +1239,7 @@ var handler$2 = {
|
|
|
1379
1239
|
var fetch = _ref2.fetch;
|
|
1380
1240
|
return function () {
|
|
1381
1241
|
var _useCart = useCart(),
|
|
1382
|
-
|
|
1383
|
-
|
|
1242
|
+
mutate = _useCart.mutate;
|
|
1384
1243
|
return useCallback( /*#__PURE__*/function () {
|
|
1385
1244
|
var _removeItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
|
|
1386
1245
|
var data;
|
|
@@ -1394,15 +1253,12 @@ var handler$2 = {
|
|
|
1394
1253
|
itemId: input.id
|
|
1395
1254
|
}
|
|
1396
1255
|
});
|
|
1397
|
-
|
|
1398
1256
|
case 2:
|
|
1399
1257
|
data = _context2.sent;
|
|
1400
1258
|
_context2.next = 5;
|
|
1401
1259
|
return mutate(data, false);
|
|
1402
|
-
|
|
1403
1260
|
case 5:
|
|
1404
1261
|
return _context2.abrupt("return", data);
|
|
1405
|
-
|
|
1406
1262
|
case 6:
|
|
1407
1263
|
case "end":
|
|
1408
1264
|
return _context2.stop();
|
|
@@ -1410,11 +1266,9 @@ var handler$2 = {
|
|
|
1410
1266
|
}
|
|
1411
1267
|
}, _callee2);
|
|
1412
1268
|
}));
|
|
1413
|
-
|
|
1414
1269
|
function removeItem(_x) {
|
|
1415
1270
|
return _removeItem.apply(this, arguments);
|
|
1416
1271
|
}
|
|
1417
|
-
|
|
1418
1272
|
return removeItem;
|
|
1419
1273
|
}(), [fetch, mutate]);
|
|
1420
1274
|
};
|
|
@@ -1429,23 +1283,19 @@ var handler$3 = {
|
|
|
1429
1283
|
fetcher: function fetcher(_ref) {
|
|
1430
1284
|
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1431
1285
|
var _ref$input, itemId, item, options, fetch, response;
|
|
1432
|
-
|
|
1433
1286
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1434
1287
|
while (1) {
|
|
1435
1288
|
switch (_context.prev = _context.next) {
|
|
1436
1289
|
case 0:
|
|
1437
1290
|
_ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
|
|
1438
|
-
|
|
1439
1291
|
if (!Number.isInteger(item.quantity)) {
|
|
1440
1292
|
_context.next = 6;
|
|
1441
1293
|
break;
|
|
1442
1294
|
}
|
|
1443
|
-
|
|
1444
1295
|
if (!(item.quantity < 1)) {
|
|
1445
1296
|
_context.next = 4;
|
|
1446
1297
|
break;
|
|
1447
1298
|
}
|
|
1448
|
-
|
|
1449
1299
|
return _context.abrupt("return", handler$2.fetcher({
|
|
1450
1300
|
options: handler$2.fetchOptions,
|
|
1451
1301
|
input: {
|
|
@@ -1453,21 +1303,17 @@ var handler$3 = {
|
|
|
1453
1303
|
},
|
|
1454
1304
|
fetch: fetch
|
|
1455
1305
|
}));
|
|
1456
|
-
|
|
1457
1306
|
case 4:
|
|
1458
1307
|
_context.next = 8;
|
|
1459
1308
|
break;
|
|
1460
|
-
|
|
1461
1309
|
case 6:
|
|
1462
1310
|
if (!item.quantity) {
|
|
1463
1311
|
_context.next = 8;
|
|
1464
1312
|
break;
|
|
1465
1313
|
}
|
|
1466
|
-
|
|
1467
1314
|
throw new ValidationError({
|
|
1468
1315
|
message: "The item quantity has to be a valid integer"
|
|
1469
1316
|
});
|
|
1470
|
-
|
|
1471
1317
|
case 8:
|
|
1472
1318
|
_context.next = 10;
|
|
1473
1319
|
return fetch(_extends({}, options, {
|
|
@@ -1475,11 +1321,9 @@ var handler$3 = {
|
|
|
1475
1321
|
quantity: item.quantity
|
|
1476
1322
|
}]
|
|
1477
1323
|
}));
|
|
1478
|
-
|
|
1479
1324
|
case 10:
|
|
1480
1325
|
response = _context.sent;
|
|
1481
1326
|
return _context.abrupt("return", checkoutToCart(response));
|
|
1482
|
-
|
|
1483
1327
|
case 12:
|
|
1484
1328
|
case "end":
|
|
1485
1329
|
return _context.stop();
|
|
@@ -1492,18 +1336,14 @@ var handler$3 = {
|
|
|
1492
1336
|
var fetch = _ref2.fetch;
|
|
1493
1337
|
return function (ctx) {
|
|
1494
1338
|
var _ctx$wait;
|
|
1495
|
-
|
|
1496
1339
|
if (ctx === void 0) {
|
|
1497
1340
|
ctx = {};
|
|
1498
1341
|
}
|
|
1499
|
-
|
|
1500
1342
|
var _ctx = ctx,
|
|
1501
|
-
|
|
1502
|
-
|
|
1343
|
+
item = _ctx.item;
|
|
1503
1344
|
var _useCart = useCart(),
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1345
|
+
mutate = _useCart.mutate,
|
|
1346
|
+
cartData = _useCart.data;
|
|
1507
1347
|
return useCallback(debounce( /*#__PURE__*/function () {
|
|
1508
1348
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
|
|
1509
1349
|
var firstLineItem, itemId, productId, variantId, data;
|
|
@@ -1515,16 +1355,13 @@ var handler$3 = {
|
|
|
1515
1355
|
itemId = (item == null ? void 0 : item.id) || firstLineItem.id;
|
|
1516
1356
|
productId = (item == null ? void 0 : item.productId) || firstLineItem.productId;
|
|
1517
1357
|
variantId = (item == null ? void 0 : item.variant.id) || firstLineItem.variant.id;
|
|
1518
|
-
|
|
1519
1358
|
if (!(!itemId || !productId)) {
|
|
1520
1359
|
_context2.next = 6;
|
|
1521
1360
|
break;
|
|
1522
1361
|
}
|
|
1523
|
-
|
|
1524
1362
|
throw new ValidationError({
|
|
1525
1363
|
message: "Invalid input used for this operation"
|
|
1526
1364
|
});
|
|
1527
|
-
|
|
1528
1365
|
case 6:
|
|
1529
1366
|
_context2.next = 8;
|
|
1530
1367
|
return fetch({
|
|
@@ -1537,15 +1374,12 @@ var handler$3 = {
|
|
|
1537
1374
|
itemId: itemId
|
|
1538
1375
|
}
|
|
1539
1376
|
});
|
|
1540
|
-
|
|
1541
1377
|
case 8:
|
|
1542
1378
|
data = _context2.sent;
|
|
1543
1379
|
_context2.next = 11;
|
|
1544
1380
|
return mutate(data, false);
|
|
1545
|
-
|
|
1546
1381
|
case 11:
|
|
1547
1382
|
return _context2.abrupt("return", data);
|
|
1548
|
-
|
|
1549
1383
|
case 12:
|
|
1550
1384
|
case "end":
|
|
1551
1385
|
return _context2.stop();
|
|
@@ -1553,7 +1387,6 @@ var handler$3 = {
|
|
|
1553
1387
|
}
|
|
1554
1388
|
}, _callee2);
|
|
1555
1389
|
}));
|
|
1556
|
-
|
|
1557
1390
|
return function (_x) {
|
|
1558
1391
|
return _ref3.apply(this, arguments);
|
|
1559
1392
|
};
|
|
@@ -1566,7 +1399,6 @@ function ensure(x, msg) {
|
|
|
1566
1399
|
if (msg === void 0) {
|
|
1567
1400
|
msg = "";
|
|
1568
1401
|
}
|
|
1569
|
-
|
|
1570
1402
|
if (x === null || x === undefined) {
|
|
1571
1403
|
debugger;
|
|
1572
1404
|
throw new Error("Value must not be undefined or null" + (msg ? "- " + msg : ""));
|
|
@@ -1585,13 +1417,10 @@ var walkCategoryTree = function walkCategoryTree(category, categories) {
|
|
|
1585
1417
|
if (!category || !categories) {
|
|
1586
1418
|
return [];
|
|
1587
1419
|
}
|
|
1588
|
-
|
|
1589
1420
|
var queue = [category];
|
|
1590
1421
|
var result = [];
|
|
1591
|
-
|
|
1592
1422
|
while (queue.length > 0) {
|
|
1593
1423
|
var _curr$children$map, _curr$children;
|
|
1594
|
-
|
|
1595
1424
|
var curr = ensure(queue.shift());
|
|
1596
1425
|
result.push(curr);
|
|
1597
1426
|
queue.push.apply(queue, (_curr$children$map = (_curr$children = curr.children) == null ? void 0 : _curr$children.map(function (child) {
|
|
@@ -1600,7 +1429,6 @@ var walkCategoryTree = function walkCategoryTree(category, categories) {
|
|
|
1600
1429
|
}), "The child category must always exist in the categories list");
|
|
1601
1430
|
})) != null ? _curr$children$map : []);
|
|
1602
1431
|
}
|
|
1603
|
-
|
|
1604
1432
|
return result;
|
|
1605
1433
|
};
|
|
1606
1434
|
var topologicalSortForCategoryTree = function topologicalSortForCategoryTree(categories) {
|
|
@@ -1619,7 +1447,6 @@ var handler$4 = {
|
|
|
1619
1447
|
fetcher: function fetcher(_ref) {
|
|
1620
1448
|
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1621
1449
|
var input, options, fetch, sortMap, categoryId, includeSubCategories, categories, brandId, search, _input$sort, sort, count, mappedSort, includedCategories, _yield$fetch, products;
|
|
1622
|
-
|
|
1623
1450
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1624
1451
|
while (1) {
|
|
1625
1452
|
switch (_context.prev = _context.next) {
|
|
@@ -1649,7 +1476,6 @@ var handler$4 = {
|
|
|
1649
1476
|
} : {})
|
|
1650
1477
|
})
|
|
1651
1478
|
});
|
|
1652
|
-
|
|
1653
1479
|
case 7:
|
|
1654
1480
|
_yield$fetch = _context.sent;
|
|
1655
1481
|
products = _yield$fetch.results;
|
|
@@ -1659,7 +1485,6 @@ var handler$4 = {
|
|
|
1659
1485
|
}),
|
|
1660
1486
|
found: products.length > 0
|
|
1661
1487
|
});
|
|
1662
|
-
|
|
1663
1488
|
case 10:
|
|
1664
1489
|
case "end":
|
|
1665
1490
|
return _context.stop();
|
|
@@ -1674,7 +1499,6 @@ var handler$4 = {
|
|
|
1674
1499
|
if (input === void 0) {
|
|
1675
1500
|
input = {};
|
|
1676
1501
|
}
|
|
1677
|
-
|
|
1678
1502
|
return useData({
|
|
1679
1503
|
input: [["search", input.search], ["categoryId", input.categoryId], ["includeSubCategories", input.includeSubCategories], ["categories", input.categories], ["brandId", input.brandId], ["sort", input.sort], ["count", input.count]],
|
|
1680
1504
|
swrOptions: _extends({
|
|
@@ -1705,20 +1529,15 @@ var handler$5 = {
|
|
|
1705
1529
|
method: options.method,
|
|
1706
1530
|
variables: [id]
|
|
1707
1531
|
});
|
|
1708
|
-
|
|
1709
1532
|
case 4:
|
|
1710
1533
|
product = _context.sent;
|
|
1711
|
-
|
|
1712
1534
|
if (product) {
|
|
1713
1535
|
_context.next = 7;
|
|
1714
1536
|
break;
|
|
1715
1537
|
}
|
|
1716
|
-
|
|
1717
1538
|
return _context.abrupt("return", null);
|
|
1718
|
-
|
|
1719
1539
|
case 7:
|
|
1720
1540
|
return _context.abrupt("return", normalizeProduct(product));
|
|
1721
|
-
|
|
1722
1541
|
case 8:
|
|
1723
1542
|
case "end":
|
|
1724
1543
|
return _context.stop();
|
|
@@ -1733,7 +1552,6 @@ var handler$5 = {
|
|
|
1733
1552
|
if (input === void 0) {
|
|
1734
1553
|
input = {};
|
|
1735
1554
|
}
|
|
1736
|
-
|
|
1737
1555
|
return useData({
|
|
1738
1556
|
input: [['id', input.id]],
|
|
1739
1557
|
swrOptions: _extends({
|
|
@@ -1752,9 +1570,7 @@ var handler$6 = {
|
|
|
1752
1570
|
fetcher: function fetcher(_ref) {
|
|
1753
1571
|
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1754
1572
|
var _data$results;
|
|
1755
|
-
|
|
1756
1573
|
var input, options, fetch, addIsEmptyField, categoryId, data, categories, normalizedCategories, _loop, _iterator, _step;
|
|
1757
|
-
|
|
1758
1574
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1759
1575
|
while (1) {
|
|
1760
1576
|
switch (_context2.prev = _context2.next) {
|
|
@@ -1770,16 +1586,13 @@ var handler$6 = {
|
|
|
1770
1586
|
id: categoryId
|
|
1771
1587
|
})
|
|
1772
1588
|
});
|
|
1773
|
-
|
|
1774
1589
|
case 4:
|
|
1775
1590
|
data = _context2.sent;
|
|
1776
1591
|
categories = (_data$results = data == null ? void 0 : data.results) != null ? _data$results : [];
|
|
1777
|
-
|
|
1778
1592
|
if (!addIsEmptyField) {
|
|
1779
1593
|
_context2.next = 10;
|
|
1780
1594
|
break;
|
|
1781
1595
|
}
|
|
1782
|
-
|
|
1783
1596
|
_context2.next = 9;
|
|
1784
1597
|
return Promise.all(categories.map( /*#__PURE__*/function () {
|
|
1785
1598
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(category) {
|
|
@@ -1799,14 +1612,12 @@ var handler$6 = {
|
|
|
1799
1612
|
category: category.id
|
|
1800
1613
|
})
|
|
1801
1614
|
});
|
|
1802
|
-
|
|
1803
1615
|
case 5:
|
|
1804
1616
|
_context.t3 = _context.sent.results;
|
|
1805
1617
|
_context.t4 = {
|
|
1806
1618
|
products: _context.t3
|
|
1807
1619
|
};
|
|
1808
1620
|
return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
|
|
1809
|
-
|
|
1810
1621
|
case 8:
|
|
1811
1622
|
case "end":
|
|
1812
1623
|
return _context.stop();
|
|
@@ -1814,33 +1625,25 @@ var handler$6 = {
|
|
|
1814
1625
|
}
|
|
1815
1626
|
}, _callee);
|
|
1816
1627
|
}));
|
|
1817
|
-
|
|
1818
1628
|
return function (_x) {
|
|
1819
1629
|
return _ref2.apply(this, arguments);
|
|
1820
1630
|
};
|
|
1821
1631
|
}()));
|
|
1822
|
-
|
|
1823
1632
|
case 9:
|
|
1824
1633
|
categories = _context2.sent;
|
|
1825
|
-
|
|
1826
1634
|
case 10:
|
|
1827
1635
|
normalizedCategories = !categoryId ? topologicalSortForCategoryTree(categories.map(normalizeCategory)) : categories.map(normalizeCategory);
|
|
1828
|
-
|
|
1829
1636
|
_loop = function _loop() {
|
|
1830
1637
|
var _normalizedCategories, _normalizedCategories2;
|
|
1831
|
-
|
|
1832
1638
|
var category = _step.value;
|
|
1833
1639
|
category.depth = ((_normalizedCategories = (_normalizedCategories2 = normalizedCategories.find(function (c) {
|
|
1834
1640
|
return c.id === category.parentId;
|
|
1835
1641
|
})) == null ? void 0 : _normalizedCategories2.depth) != null ? _normalizedCategories : -1) + 1;
|
|
1836
1642
|
};
|
|
1837
|
-
|
|
1838
1643
|
for (_iterator = _createForOfIteratorHelperLoose(normalizedCategories); !(_step = _iterator()).done;) {
|
|
1839
1644
|
_loop();
|
|
1840
1645
|
}
|
|
1841
|
-
|
|
1842
1646
|
return _context2.abrupt("return", normalizedCategories);
|
|
1843
|
-
|
|
1844
1647
|
case 14:
|
|
1845
1648
|
case "end":
|
|
1846
1649
|
return _context2.stop();
|
|
@@ -1863,7 +1666,6 @@ var handler$6 = {
|
|
|
1863
1666
|
isEmpty: {
|
|
1864
1667
|
get: function get() {
|
|
1865
1668
|
var _response$data$length, _response$data;
|
|
1866
|
-
|
|
1867
1669
|
return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
|
|
1868
1670
|
},
|
|
1869
1671
|
enumerable: true
|
|
@@ -1882,7 +1684,6 @@ var handler$7 = {
|
|
|
1882
1684
|
fetcher: function fetcher(_ref) {
|
|
1883
1685
|
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1884
1686
|
var _yield$fetch$values, _yield$fetch;
|
|
1885
|
-
|
|
1886
1687
|
var fetch, vendors;
|
|
1887
1688
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1888
1689
|
while (1) {
|
|
@@ -1895,37 +1696,28 @@ var handler$7 = {
|
|
|
1895
1696
|
method: "get",
|
|
1896
1697
|
variables: "brand"
|
|
1897
1698
|
});
|
|
1898
|
-
|
|
1899
1699
|
case 3:
|
|
1900
1700
|
_context.t0 = _yield$fetch = _context.sent;
|
|
1901
|
-
|
|
1902
1701
|
if (!(_context.t0 == null)) {
|
|
1903
1702
|
_context.next = 8;
|
|
1904
1703
|
break;
|
|
1905
1704
|
}
|
|
1906
|
-
|
|
1907
1705
|
_context.t1 = void 0;
|
|
1908
1706
|
_context.next = 9;
|
|
1909
1707
|
break;
|
|
1910
|
-
|
|
1911
1708
|
case 8:
|
|
1912
1709
|
_context.t1 = _yield$fetch.values;
|
|
1913
|
-
|
|
1914
1710
|
case 9:
|
|
1915
1711
|
_context.t2 = _yield$fetch$values = _context.t1;
|
|
1916
|
-
|
|
1917
1712
|
if (!(_context.t2 != null)) {
|
|
1918
1713
|
_context.next = 14;
|
|
1919
1714
|
break;
|
|
1920
1715
|
}
|
|
1921
|
-
|
|
1922
1716
|
_context.t3 = _yield$fetch$values;
|
|
1923
1717
|
_context.next = 15;
|
|
1924
1718
|
break;
|
|
1925
|
-
|
|
1926
1719
|
case 14:
|
|
1927
1720
|
_context.t3 = [];
|
|
1928
|
-
|
|
1929
1721
|
case 15:
|
|
1930
1722
|
vendors = _context.t3;
|
|
1931
1723
|
return _context.abrupt("return", Array.from(new Set(vendors).values()).map(function (v) {
|
|
@@ -1935,7 +1727,6 @@ var handler$7 = {
|
|
|
1935
1727
|
path: "brands/" + v
|
|
1936
1728
|
};
|
|
1937
1729
|
}));
|
|
1938
|
-
|
|
1939
1730
|
case 17:
|
|
1940
1731
|
case "end":
|
|
1941
1732
|
return _context.stop();
|
|
@@ -1957,7 +1748,6 @@ var handler$7 = {
|
|
|
1957
1748
|
isEmpty: {
|
|
1958
1749
|
get: function get() {
|
|
1959
1750
|
var _response$data$length, _response$data;
|
|
1960
|
-
|
|
1961
1751
|
return ((_response$data$length = (_response$data = response.data) == null ? void 0 : _response$data.length) != null ? _response$data$length : 0) <= 0;
|
|
1962
1752
|
},
|
|
1963
1753
|
enumerable: true
|
|
@@ -1971,7 +1761,6 @@ var handler$7 = {
|
|
|
1971
1761
|
var fetcher = /*#__PURE__*/function () {
|
|
1972
1762
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref) {
|
|
1973
1763
|
var _ref$method, method, variables, query, callSwell, _callSwell;
|
|
1974
|
-
|
|
1975
1764
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1976
1765
|
while (1) {
|
|
1977
1766
|
switch (_context2.prev = _context2.next) {
|
|
@@ -1979,7 +1768,6 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
1979
1768
|
_callSwell = function _callSwell3() {
|
|
1980
1769
|
_callSwell = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1981
1770
|
var arg1, arg2, response, _response;
|
|
1982
|
-
|
|
1983
1771
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1984
1772
|
while (1) {
|
|
1985
1773
|
switch (_context.prev = _context.next) {
|
|
@@ -1988,24 +1776,19 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
1988
1776
|
_context.next = 9;
|
|
1989
1777
|
break;
|
|
1990
1778
|
}
|
|
1991
|
-
|
|
1992
1779
|
arg1 = variables[0];
|
|
1993
1780
|
arg2 = variables[1];
|
|
1994
1781
|
_context.next = 5;
|
|
1995
1782
|
return swell[query][method](arg1, arg2);
|
|
1996
|
-
|
|
1997
1783
|
case 5:
|
|
1998
1784
|
response = _context.sent;
|
|
1999
1785
|
return _context.abrupt("return", handleFetchResponse(response));
|
|
2000
|
-
|
|
2001
1786
|
case 9:
|
|
2002
1787
|
_context.next = 11;
|
|
2003
1788
|
return swell[query][method](variables);
|
|
2004
|
-
|
|
2005
1789
|
case 11:
|
|
2006
1790
|
_response = _context.sent;
|
|
2007
1791
|
return _context.abrupt("return", handleFetchResponse(_response));
|
|
2008
|
-
|
|
2009
1792
|
case 13:
|
|
2010
1793
|
case "end":
|
|
2011
1794
|
return _context.stop();
|
|
@@ -2015,29 +1798,22 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
2015
1798
|
}));
|
|
2016
1799
|
return _callSwell.apply(this, arguments);
|
|
2017
1800
|
};
|
|
2018
|
-
|
|
2019
1801
|
callSwell = function _callSwell2() {
|
|
2020
1802
|
return _callSwell.apply(this, arguments);
|
|
2021
1803
|
};
|
|
2022
|
-
|
|
2023
1804
|
_ref$method = _ref.method, method = _ref$method === void 0 ? 'get' : _ref$method, variables = _ref.variables, query = _ref.query;
|
|
2024
|
-
|
|
2025
1805
|
if (!(query && query in swell)) {
|
|
2026
1806
|
_context2.next = 9;
|
|
2027
1807
|
break;
|
|
2028
1808
|
}
|
|
2029
|
-
|
|
2030
1809
|
_context2.next = 6;
|
|
2031
1810
|
return callSwell();
|
|
2032
|
-
|
|
2033
1811
|
case 6:
|
|
2034
1812
|
return _context2.abrupt("return", _context2.sent);
|
|
2035
|
-
|
|
2036
1813
|
case 9:
|
|
2037
1814
|
throw new CommerceError({
|
|
2038
1815
|
message: 'Invalid query argument!'
|
|
2039
1816
|
});
|
|
2040
|
-
|
|
2041
1817
|
case 10:
|
|
2042
1818
|
case "end":
|
|
2043
1819
|
return _context2.stop();
|
|
@@ -2045,7 +1821,6 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
2045
1821
|
}
|
|
2046
1822
|
}, _callee2);
|
|
2047
1823
|
}));
|
|
2048
|
-
|
|
2049
1824
|
return function fetcher(_x) {
|
|
2050
1825
|
return _ref2.apply(this, arguments);
|
|
2051
1826
|
};
|
|
@@ -2112,8 +1887,8 @@ var commerceProviderMeta = {
|
|
|
2112
1887
|
};
|
|
2113
1888
|
function CommerceProviderComponent(props) {
|
|
2114
1889
|
var storeId = props.storeId,
|
|
2115
|
-
|
|
2116
|
-
|
|
1890
|
+
publicKey = props.publicKey,
|
|
1891
|
+
children = props.children;
|
|
2117
1892
|
var CommerceProvider = React.useMemo(function () {
|
|
2118
1893
|
return getCommerceProvider(storeId, publicKey);
|
|
2119
1894
|
}, [storeId, publicKey]);
|
|
@@ -2123,7 +1898,6 @@ function registerCommerceProvider(loader, customCommerceProviderMeta) {
|
|
|
2123
1898
|
var doRegisterComponent = function doRegisterComponent() {
|
|
2124
1899
|
return loader ? loader.registerGlobalContext.apply(loader, arguments) : registerGlobalContext.apply(void 0, arguments);
|
|
2125
1900
|
};
|
|
2126
|
-
|
|
2127
1901
|
doRegisterComponent(CommerceProviderComponent, customCommerceProviderMeta != null ? customCommerceProviderMeta : commerceProviderMeta);
|
|
2128
1902
|
}
|
|
2129
1903
|
|