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