@plasmicpkgs/commerce-swell 0.0.166 → 0.0.167
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/LICENSE.app.md +661 -0
- package/dist/commerce-swell.cjs.development.js +798 -1190
- 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 +797 -1190
- package/dist/commerce-swell.esm.js.map +1 -1
- package/dist/provider.d.ts +11 -10
- package/dist/registerCommerceProvider.d.ts +1 -1
- package/dist/swell.d.ts +2 -1
- package/package.json +2 -2
- package/LICENSE.md +0 -21
|
@@ -8,7 +8,8 @@ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGl
|
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var React__default = _interopDefault(React);
|
|
10
10
|
var commerce = require('@plasmicpkgs/commerce');
|
|
11
|
-
var swell =
|
|
11
|
+
var swell = require('swell-js');
|
|
12
|
+
var swell__default = _interopDefault(swell);
|
|
12
13
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
13
14
|
var debounce = _interopDefault(require('debounce'));
|
|
14
15
|
|
|
@@ -20,6 +21,307 @@ var SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId';
|
|
|
20
21
|
var SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl';
|
|
21
22
|
var SWELL_COOKIE_EXPIRE = 30;
|
|
22
23
|
|
|
24
|
+
function _regeneratorRuntime() {
|
|
25
|
+
_regeneratorRuntime = function () {
|
|
26
|
+
return e;
|
|
27
|
+
};
|
|
28
|
+
var t,
|
|
29
|
+
e = {},
|
|
30
|
+
r = Object.prototype,
|
|
31
|
+
n = r.hasOwnProperty,
|
|
32
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
33
|
+
t[e] = r.value;
|
|
34
|
+
},
|
|
35
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
36
|
+
a = i.iterator || "@@iterator",
|
|
37
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
38
|
+
u = i.toStringTag || "@@toStringTag";
|
|
39
|
+
function define(t, e, r) {
|
|
40
|
+
return Object.defineProperty(t, e, {
|
|
41
|
+
value: r,
|
|
42
|
+
enumerable: !0,
|
|
43
|
+
configurable: !0,
|
|
44
|
+
writable: !0
|
|
45
|
+
}), t[e];
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
define({}, "");
|
|
49
|
+
} catch (t) {
|
|
50
|
+
define = function (t, e, r) {
|
|
51
|
+
return t[e] = r;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function wrap(t, e, r, n) {
|
|
55
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
56
|
+
a = Object.create(i.prototype),
|
|
57
|
+
c = new Context(n || []);
|
|
58
|
+
return o(a, "_invoke", {
|
|
59
|
+
value: makeInvokeMethod(t, r, c)
|
|
60
|
+
}), a;
|
|
61
|
+
}
|
|
62
|
+
function tryCatch(t, e, r) {
|
|
63
|
+
try {
|
|
64
|
+
return {
|
|
65
|
+
type: "normal",
|
|
66
|
+
arg: t.call(e, r)
|
|
67
|
+
};
|
|
68
|
+
} catch (t) {
|
|
69
|
+
return {
|
|
70
|
+
type: "throw",
|
|
71
|
+
arg: t
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
e.wrap = wrap;
|
|
76
|
+
var h = "suspendedStart",
|
|
77
|
+
l = "suspendedYield",
|
|
78
|
+
f = "executing",
|
|
79
|
+
s = "completed",
|
|
80
|
+
y = {};
|
|
81
|
+
function Generator() {}
|
|
82
|
+
function GeneratorFunction() {}
|
|
83
|
+
function GeneratorFunctionPrototype() {}
|
|
84
|
+
var p = {};
|
|
85
|
+
define(p, a, function () {
|
|
86
|
+
return this;
|
|
87
|
+
});
|
|
88
|
+
var d = Object.getPrototypeOf,
|
|
89
|
+
v = d && d(d(values([])));
|
|
90
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
91
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
92
|
+
function defineIteratorMethods(t) {
|
|
93
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
94
|
+
define(t, e, function (t) {
|
|
95
|
+
return this._invoke(e, t);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function AsyncIterator(t, e) {
|
|
100
|
+
function invoke(r, o, i, a) {
|
|
101
|
+
var c = tryCatch(t[r], t, o);
|
|
102
|
+
if ("throw" !== c.type) {
|
|
103
|
+
var u = c.arg,
|
|
104
|
+
h = u.value;
|
|
105
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
106
|
+
invoke("next", t, i, a);
|
|
107
|
+
}, function (t) {
|
|
108
|
+
invoke("throw", t, i, a);
|
|
109
|
+
}) : e.resolve(h).then(function (t) {
|
|
110
|
+
u.value = t, i(u);
|
|
111
|
+
}, function (t) {
|
|
112
|
+
return invoke("throw", t, i, a);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
a(c.arg);
|
|
116
|
+
}
|
|
117
|
+
var r;
|
|
118
|
+
o(this, "_invoke", {
|
|
119
|
+
value: function (t, n) {
|
|
120
|
+
function callInvokeWithMethodAndArg() {
|
|
121
|
+
return new e(function (e, r) {
|
|
122
|
+
invoke(t, n, e, r);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function makeInvokeMethod(e, r, n) {
|
|
130
|
+
var o = h;
|
|
131
|
+
return function (i, a) {
|
|
132
|
+
if (o === f) throw new Error("Generator is already running");
|
|
133
|
+
if (o === s) {
|
|
134
|
+
if ("throw" === i) throw a;
|
|
135
|
+
return {
|
|
136
|
+
value: t,
|
|
137
|
+
done: !0
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
for (n.method = i, n.arg = a;;) {
|
|
141
|
+
var c = n.delegate;
|
|
142
|
+
if (c) {
|
|
143
|
+
var u = maybeInvokeDelegate(c, n);
|
|
144
|
+
if (u) {
|
|
145
|
+
if (u === y) continue;
|
|
146
|
+
return u;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
150
|
+
if (o === h) throw o = s, n.arg;
|
|
151
|
+
n.dispatchException(n.arg);
|
|
152
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
153
|
+
o = f;
|
|
154
|
+
var p = tryCatch(e, r, n);
|
|
155
|
+
if ("normal" === p.type) {
|
|
156
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
157
|
+
return {
|
|
158
|
+
value: p.arg,
|
|
159
|
+
done: n.done
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function maybeInvokeDelegate(e, r) {
|
|
167
|
+
var n = r.method,
|
|
168
|
+
o = e.iterator[n];
|
|
169
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
170
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
171
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
172
|
+
var a = i.arg;
|
|
173
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
174
|
+
}
|
|
175
|
+
function pushTryEntry(t) {
|
|
176
|
+
var e = {
|
|
177
|
+
tryLoc: t[0]
|
|
178
|
+
};
|
|
179
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
180
|
+
}
|
|
181
|
+
function resetTryEntry(t) {
|
|
182
|
+
var e = t.completion || {};
|
|
183
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
184
|
+
}
|
|
185
|
+
function Context(t) {
|
|
186
|
+
this.tryEntries = [{
|
|
187
|
+
tryLoc: "root"
|
|
188
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
189
|
+
}
|
|
190
|
+
function values(e) {
|
|
191
|
+
if (e || "" === e) {
|
|
192
|
+
var r = e[a];
|
|
193
|
+
if (r) return r.call(e);
|
|
194
|
+
if ("function" == typeof e.next) return e;
|
|
195
|
+
if (!isNaN(e.length)) {
|
|
196
|
+
var o = -1,
|
|
197
|
+
i = function next() {
|
|
198
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
199
|
+
return next.value = t, next.done = !0, next;
|
|
200
|
+
};
|
|
201
|
+
return i.next = i;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
205
|
+
}
|
|
206
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
207
|
+
value: GeneratorFunctionPrototype,
|
|
208
|
+
configurable: !0
|
|
209
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
210
|
+
value: GeneratorFunction,
|
|
211
|
+
configurable: !0
|
|
212
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
213
|
+
var e = "function" == typeof t && t.constructor;
|
|
214
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
215
|
+
}, e.mark = function (t) {
|
|
216
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
217
|
+
}, e.awrap = function (t) {
|
|
218
|
+
return {
|
|
219
|
+
__await: t
|
|
220
|
+
};
|
|
221
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
222
|
+
return this;
|
|
223
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
224
|
+
void 0 === i && (i = Promise);
|
|
225
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
226
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
227
|
+
return t.done ? t.value : a.next();
|
|
228
|
+
});
|
|
229
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
230
|
+
return this;
|
|
231
|
+
}), define(g, "toString", function () {
|
|
232
|
+
return "[object Generator]";
|
|
233
|
+
}), e.keys = function (t) {
|
|
234
|
+
var e = Object(t),
|
|
235
|
+
r = [];
|
|
236
|
+
for (var n in e) r.push(n);
|
|
237
|
+
return r.reverse(), function next() {
|
|
238
|
+
for (; r.length;) {
|
|
239
|
+
var t = r.pop();
|
|
240
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
241
|
+
}
|
|
242
|
+
return next.done = !0, next;
|
|
243
|
+
};
|
|
244
|
+
}, e.values = values, Context.prototype = {
|
|
245
|
+
constructor: Context,
|
|
246
|
+
reset: function (e) {
|
|
247
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
248
|
+
},
|
|
249
|
+
stop: function () {
|
|
250
|
+
this.done = !0;
|
|
251
|
+
var t = this.tryEntries[0].completion;
|
|
252
|
+
if ("throw" === t.type) throw t.arg;
|
|
253
|
+
return this.rval;
|
|
254
|
+
},
|
|
255
|
+
dispatchException: function (e) {
|
|
256
|
+
if (this.done) throw e;
|
|
257
|
+
var r = this;
|
|
258
|
+
function handle(n, o) {
|
|
259
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
260
|
+
}
|
|
261
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
262
|
+
var i = this.tryEntries[o],
|
|
263
|
+
a = i.completion;
|
|
264
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
265
|
+
if (i.tryLoc <= this.prev) {
|
|
266
|
+
var c = n.call(i, "catchLoc"),
|
|
267
|
+
u = n.call(i, "finallyLoc");
|
|
268
|
+
if (c && u) {
|
|
269
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
270
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
271
|
+
} else if (c) {
|
|
272
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
273
|
+
} else {
|
|
274
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
275
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
abrupt: function (t, e) {
|
|
281
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
282
|
+
var o = this.tryEntries[r];
|
|
283
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
284
|
+
var i = o;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
289
|
+
var a = i ? i.completion : {};
|
|
290
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
291
|
+
},
|
|
292
|
+
complete: function (t, e) {
|
|
293
|
+
if ("throw" === t.type) throw t.arg;
|
|
294
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
295
|
+
},
|
|
296
|
+
finish: function (t) {
|
|
297
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
298
|
+
var r = this.tryEntries[e];
|
|
299
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
catch: function (t) {
|
|
303
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
304
|
+
var r = this.tryEntries[e];
|
|
305
|
+
if (r.tryLoc === t) {
|
|
306
|
+
var n = r.completion;
|
|
307
|
+
if ("throw" === n.type) {
|
|
308
|
+
var o = n.arg;
|
|
309
|
+
resetTryEntry(r);
|
|
310
|
+
}
|
|
311
|
+
return o;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
throw new Error("illegal catch attempt");
|
|
315
|
+
},
|
|
316
|
+
delegateYield: function (e, r, n) {
|
|
317
|
+
return this.delegate = {
|
|
318
|
+
iterator: values(e),
|
|
319
|
+
resultName: r,
|
|
320
|
+
nextLoc: n
|
|
321
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
322
|
+
}
|
|
323
|
+
}, e;
|
|
324
|
+
}
|
|
23
325
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
24
326
|
try {
|
|
25
327
|
var info = gen[key](arg);
|
|
@@ -108,664 +410,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
108
410
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
109
411
|
}
|
|
110
412
|
|
|
111
|
-
function createCommonjsModule(fn, module) {
|
|
112
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
116
|
-
/**
|
|
117
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
118
|
-
*
|
|
119
|
-
* This source code is licensed under the MIT license found in the
|
|
120
|
-
* LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
var runtime = function (exports) {
|
|
124
|
-
|
|
125
|
-
var Op = Object.prototype;
|
|
126
|
-
var hasOwn = Op.hasOwnProperty;
|
|
127
|
-
var undefined$1; // More compressible than void 0.
|
|
128
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
129
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
130
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
131
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
132
|
-
function define(obj, key, value) {
|
|
133
|
-
Object.defineProperty(obj, key, {
|
|
134
|
-
value: value,
|
|
135
|
-
enumerable: true,
|
|
136
|
-
configurable: true,
|
|
137
|
-
writable: true
|
|
138
|
-
});
|
|
139
|
-
return obj[key];
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
143
|
-
define({}, "");
|
|
144
|
-
} catch (err) {
|
|
145
|
-
define = function define(obj, key, value) {
|
|
146
|
-
return obj[key] = value;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
150
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
151
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
152
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
153
|
-
var context = new Context(tryLocsList || []);
|
|
154
|
-
|
|
155
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
156
|
-
// .throw, and .return methods.
|
|
157
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
158
|
-
return generator;
|
|
159
|
-
}
|
|
160
|
-
exports.wrap = wrap;
|
|
161
|
-
|
|
162
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
163
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
164
|
-
// have been (and was previously) designed to take a closure to be
|
|
165
|
-
// invoked without arguments, but in all the cases we care about we
|
|
166
|
-
// already have an existing method we want to call, so there's no need
|
|
167
|
-
// to create a new function object. We can even get away with assuming
|
|
168
|
-
// the method takes exactly one argument, since that happens to be true
|
|
169
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
170
|
-
// only additional allocation required is the completion record, which
|
|
171
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
172
|
-
function tryCatch(fn, obj, arg) {
|
|
173
|
-
try {
|
|
174
|
-
return {
|
|
175
|
-
type: "normal",
|
|
176
|
-
arg: fn.call(obj, arg)
|
|
177
|
-
};
|
|
178
|
-
} catch (err) {
|
|
179
|
-
return {
|
|
180
|
-
type: "throw",
|
|
181
|
-
arg: err
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
186
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
187
|
-
var GenStateExecuting = "executing";
|
|
188
|
-
var GenStateCompleted = "completed";
|
|
189
|
-
|
|
190
|
-
// Returning this object from the innerFn has the same effect as
|
|
191
|
-
// breaking out of the dispatch switch statement.
|
|
192
|
-
var ContinueSentinel = {};
|
|
193
|
-
|
|
194
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
195
|
-
// .constructor.prototype properties for functions that return Generator
|
|
196
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
197
|
-
// minifier not to mangle the names of these two functions.
|
|
198
|
-
function Generator() {}
|
|
199
|
-
function GeneratorFunction() {}
|
|
200
|
-
function GeneratorFunctionPrototype() {}
|
|
201
|
-
|
|
202
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
203
|
-
// don't natively support it.
|
|
204
|
-
var IteratorPrototype = {};
|
|
205
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
206
|
-
return this;
|
|
207
|
-
});
|
|
208
|
-
var getProto = Object.getPrototypeOf;
|
|
209
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
210
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
211
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
212
|
-
// of the polyfill.
|
|
213
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
214
|
-
}
|
|
215
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
216
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
217
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
218
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
219
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
220
|
-
|
|
221
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
222
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
223
|
-
function defineIteratorMethods(prototype) {
|
|
224
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
225
|
-
define(prototype, method, function (arg) {
|
|
226
|
-
return this._invoke(method, arg);
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
231
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
232
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
233
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
234
|
-
// do is to check its .name property.
|
|
235
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
236
|
-
};
|
|
237
|
-
exports.mark = function (genFun) {
|
|
238
|
-
if (Object.setPrototypeOf) {
|
|
239
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
240
|
-
} else {
|
|
241
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
242
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
243
|
-
}
|
|
244
|
-
genFun.prototype = Object.create(Gp);
|
|
245
|
-
return genFun;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// Within the body of any async function, `await x` is transformed to
|
|
249
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
250
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
251
|
-
// meant to be awaited.
|
|
252
|
-
exports.awrap = function (arg) {
|
|
253
|
-
return {
|
|
254
|
-
__await: arg
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
258
|
-
function invoke(method, arg, resolve, reject) {
|
|
259
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
260
|
-
if (record.type === "throw") {
|
|
261
|
-
reject(record.arg);
|
|
262
|
-
} else {
|
|
263
|
-
var result = record.arg;
|
|
264
|
-
var value = result.value;
|
|
265
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
266
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
267
|
-
invoke("next", value, resolve, reject);
|
|
268
|
-
}, function (err) {
|
|
269
|
-
invoke("throw", err, resolve, reject);
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
273
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
274
|
-
// the .value of the Promise<{value,done}> result for the
|
|
275
|
-
// current iteration.
|
|
276
|
-
result.value = unwrapped;
|
|
277
|
-
resolve(result);
|
|
278
|
-
}, function (error) {
|
|
279
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
280
|
-
// into the async generator function so it can be handled there.
|
|
281
|
-
return invoke("throw", error, resolve, reject);
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
var previousPromise;
|
|
286
|
-
function enqueue(method, arg) {
|
|
287
|
-
function callInvokeWithMethodAndArg() {
|
|
288
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
289
|
-
invoke(method, arg, resolve, reject);
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
return previousPromise =
|
|
293
|
-
// If enqueue has been called before, then we want to wait until
|
|
294
|
-
// all previous Promises have been resolved before calling invoke,
|
|
295
|
-
// so that results are always delivered in the correct order. If
|
|
296
|
-
// enqueue has not been called before, then it is important to
|
|
297
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
298
|
-
// so that the async generator function has the opportunity to do
|
|
299
|
-
// any necessary setup in a predictable way. This predictability
|
|
300
|
-
// is why the Promise constructor synchronously invokes its
|
|
301
|
-
// executor callback, and why async functions synchronously
|
|
302
|
-
// execute code before the first await. Since we implement simple
|
|
303
|
-
// async functions in terms of async generators, it is especially
|
|
304
|
-
// important to get this right, even though it requires care.
|
|
305
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
306
|
-
// Avoid propagating failures to Promises returned by later
|
|
307
|
-
// invocations of the iterator.
|
|
308
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Define the unified helper method that is used to implement .next,
|
|
312
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
313
|
-
this._invoke = enqueue;
|
|
314
|
-
}
|
|
315
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
316
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
317
|
-
return this;
|
|
318
|
-
});
|
|
319
|
-
exports.AsyncIterator = AsyncIterator;
|
|
320
|
-
|
|
321
|
-
// Note that simple async functions are implemented on top of
|
|
322
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
323
|
-
// the final result produced by the iterator.
|
|
324
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
325
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
326
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
327
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
328
|
-
: iter.next().then(function (result) {
|
|
329
|
-
return result.done ? result.value : iter.next();
|
|
330
|
-
});
|
|
331
|
-
};
|
|
332
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
333
|
-
var state = GenStateSuspendedStart;
|
|
334
|
-
return function invoke(method, arg) {
|
|
335
|
-
if (state === GenStateExecuting) {
|
|
336
|
-
throw new Error("Generator is already running");
|
|
337
|
-
}
|
|
338
|
-
if (state === GenStateCompleted) {
|
|
339
|
-
if (method === "throw") {
|
|
340
|
-
throw arg;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
344
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
345
|
-
return doneResult();
|
|
346
|
-
}
|
|
347
|
-
context.method = method;
|
|
348
|
-
context.arg = arg;
|
|
349
|
-
while (true) {
|
|
350
|
-
var delegate = context.delegate;
|
|
351
|
-
if (delegate) {
|
|
352
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
353
|
-
if (delegateResult) {
|
|
354
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
355
|
-
return delegateResult;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (context.method === "next") {
|
|
359
|
-
// Setting context._sent for legacy support of Babel's
|
|
360
|
-
// function.sent implementation.
|
|
361
|
-
context.sent = context._sent = context.arg;
|
|
362
|
-
} else if (context.method === "throw") {
|
|
363
|
-
if (state === GenStateSuspendedStart) {
|
|
364
|
-
state = GenStateCompleted;
|
|
365
|
-
throw context.arg;
|
|
366
|
-
}
|
|
367
|
-
context.dispatchException(context.arg);
|
|
368
|
-
} else if (context.method === "return") {
|
|
369
|
-
context.abrupt("return", context.arg);
|
|
370
|
-
}
|
|
371
|
-
state = GenStateExecuting;
|
|
372
|
-
var record = tryCatch(innerFn, self, context);
|
|
373
|
-
if (record.type === "normal") {
|
|
374
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
375
|
-
// GenStateExecuting and loop back for another invocation.
|
|
376
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
377
|
-
if (record.arg === ContinueSentinel) {
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
return {
|
|
381
|
-
value: record.arg,
|
|
382
|
-
done: context.done
|
|
383
|
-
};
|
|
384
|
-
} else if (record.type === "throw") {
|
|
385
|
-
state = GenStateCompleted;
|
|
386
|
-
// Dispatch the exception by looping back around to the
|
|
387
|
-
// context.dispatchException(context.arg) call above.
|
|
388
|
-
context.method = "throw";
|
|
389
|
-
context.arg = record.arg;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
396
|
-
// result, either by returning a { value, done } result from the
|
|
397
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
398
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
399
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
400
|
-
var method = delegate.iterator[context.method];
|
|
401
|
-
if (method === undefined$1) {
|
|
402
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
403
|
-
// method always terminates the yield* loop.
|
|
404
|
-
context.delegate = null;
|
|
405
|
-
if (context.method === "throw") {
|
|
406
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
407
|
-
if (delegate.iterator["return"]) {
|
|
408
|
-
// If the delegate iterator has a return method, give it a
|
|
409
|
-
// chance to clean up.
|
|
410
|
-
context.method = "return";
|
|
411
|
-
context.arg = undefined$1;
|
|
412
|
-
maybeInvokeDelegate(delegate, context);
|
|
413
|
-
if (context.method === "throw") {
|
|
414
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
415
|
-
// "return" to "throw", let that override the TypeError below.
|
|
416
|
-
return ContinueSentinel;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
context.method = "throw";
|
|
420
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
421
|
-
}
|
|
422
|
-
return ContinueSentinel;
|
|
423
|
-
}
|
|
424
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
425
|
-
if (record.type === "throw") {
|
|
426
|
-
context.method = "throw";
|
|
427
|
-
context.arg = record.arg;
|
|
428
|
-
context.delegate = null;
|
|
429
|
-
return ContinueSentinel;
|
|
430
|
-
}
|
|
431
|
-
var info = record.arg;
|
|
432
|
-
if (!info) {
|
|
433
|
-
context.method = "throw";
|
|
434
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
435
|
-
context.delegate = null;
|
|
436
|
-
return ContinueSentinel;
|
|
437
|
-
}
|
|
438
|
-
if (info.done) {
|
|
439
|
-
// Assign the result of the finished delegate to the temporary
|
|
440
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
441
|
-
context[delegate.resultName] = info.value;
|
|
442
|
-
|
|
443
|
-
// Resume execution at the desired location (see delegateYield).
|
|
444
|
-
context.next = delegate.nextLoc;
|
|
445
|
-
|
|
446
|
-
// If context.method was "throw" but the delegate handled the
|
|
447
|
-
// exception, let the outer generator proceed normally. If
|
|
448
|
-
// context.method was "next", forget context.arg since it has been
|
|
449
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
450
|
-
// "return", allow the original .return call to continue in the
|
|
451
|
-
// outer generator.
|
|
452
|
-
if (context.method !== "return") {
|
|
453
|
-
context.method = "next";
|
|
454
|
-
context.arg = undefined$1;
|
|
455
|
-
}
|
|
456
|
-
} else {
|
|
457
|
-
// Re-yield the result returned by the delegate method.
|
|
458
|
-
return info;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
462
|
-
// the outer generator.
|
|
463
|
-
context.delegate = null;
|
|
464
|
-
return ContinueSentinel;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
468
|
-
// unified ._invoke helper method.
|
|
469
|
-
defineIteratorMethods(Gp);
|
|
470
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
471
|
-
|
|
472
|
-
// A Generator should always return itself as the iterator object when the
|
|
473
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
474
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
475
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
476
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
477
|
-
define(Gp, iteratorSymbol, function () {
|
|
478
|
-
return this;
|
|
479
|
-
});
|
|
480
|
-
define(Gp, "toString", function () {
|
|
481
|
-
return "[object Generator]";
|
|
482
|
-
});
|
|
483
|
-
function pushTryEntry(locs) {
|
|
484
|
-
var entry = {
|
|
485
|
-
tryLoc: locs[0]
|
|
486
|
-
};
|
|
487
|
-
if (1 in locs) {
|
|
488
|
-
entry.catchLoc = locs[1];
|
|
489
|
-
}
|
|
490
|
-
if (2 in locs) {
|
|
491
|
-
entry.finallyLoc = locs[2];
|
|
492
|
-
entry.afterLoc = locs[3];
|
|
493
|
-
}
|
|
494
|
-
this.tryEntries.push(entry);
|
|
495
|
-
}
|
|
496
|
-
function resetTryEntry(entry) {
|
|
497
|
-
var record = entry.completion || {};
|
|
498
|
-
record.type = "normal";
|
|
499
|
-
delete record.arg;
|
|
500
|
-
entry.completion = record;
|
|
501
|
-
}
|
|
502
|
-
function Context(tryLocsList) {
|
|
503
|
-
// The root entry object (effectively a try statement without a catch
|
|
504
|
-
// or a finally block) gives us a place to store values thrown from
|
|
505
|
-
// locations where there is no enclosing try statement.
|
|
506
|
-
this.tryEntries = [{
|
|
507
|
-
tryLoc: "root"
|
|
508
|
-
}];
|
|
509
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
510
|
-
this.reset(true);
|
|
511
|
-
}
|
|
512
|
-
exports.keys = function (object) {
|
|
513
|
-
var keys = [];
|
|
514
|
-
for (var key in object) {
|
|
515
|
-
keys.push(key);
|
|
516
|
-
}
|
|
517
|
-
keys.reverse();
|
|
518
|
-
|
|
519
|
-
// Rather than returning an object with a next method, we keep
|
|
520
|
-
// things simple and return the next function itself.
|
|
521
|
-
return function next() {
|
|
522
|
-
while (keys.length) {
|
|
523
|
-
var key = keys.pop();
|
|
524
|
-
if (key in object) {
|
|
525
|
-
next.value = key;
|
|
526
|
-
next.done = false;
|
|
527
|
-
return next;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
// To avoid creating an additional object, we just hang the .value
|
|
532
|
-
// and .done properties off the next function object itself. This
|
|
533
|
-
// also ensures that the minifier will not anonymize the function.
|
|
534
|
-
next.done = true;
|
|
535
|
-
return next;
|
|
536
|
-
};
|
|
537
|
-
};
|
|
538
|
-
function values(iterable) {
|
|
539
|
-
if (iterable) {
|
|
540
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
541
|
-
if (iteratorMethod) {
|
|
542
|
-
return iteratorMethod.call(iterable);
|
|
543
|
-
}
|
|
544
|
-
if (typeof iterable.next === "function") {
|
|
545
|
-
return iterable;
|
|
546
|
-
}
|
|
547
|
-
if (!isNaN(iterable.length)) {
|
|
548
|
-
var i = -1,
|
|
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
|
-
}
|
|
556
|
-
}
|
|
557
|
-
next.value = undefined$1;
|
|
558
|
-
next.done = true;
|
|
559
|
-
return next;
|
|
560
|
-
};
|
|
561
|
-
return next.next = next;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// Return an iterator with no values.
|
|
566
|
-
return {
|
|
567
|
-
next: doneResult
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
exports.values = values;
|
|
571
|
-
function doneResult() {
|
|
572
|
-
return {
|
|
573
|
-
value: undefined$1,
|
|
574
|
-
done: true
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
Context.prototype = {
|
|
578
|
-
constructor: Context,
|
|
579
|
-
reset: function reset(skipTempReset) {
|
|
580
|
-
this.prev = 0;
|
|
581
|
-
this.next = 0;
|
|
582
|
-
// Resetting context._sent for legacy support of Babel's
|
|
583
|
-
// function.sent implementation.
|
|
584
|
-
this.sent = this._sent = undefined$1;
|
|
585
|
-
this.done = false;
|
|
586
|
-
this.delegate = null;
|
|
587
|
-
this.method = "next";
|
|
588
|
-
this.arg = undefined$1;
|
|
589
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
590
|
-
if (!skipTempReset) {
|
|
591
|
-
for (var name in this) {
|
|
592
|
-
// Not sure about the optimal order of these conditions:
|
|
593
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
594
|
-
this[name] = undefined$1;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
},
|
|
599
|
-
stop: function stop() {
|
|
600
|
-
this.done = true;
|
|
601
|
-
var rootEntry = this.tryEntries[0];
|
|
602
|
-
var rootRecord = rootEntry.completion;
|
|
603
|
-
if (rootRecord.type === "throw") {
|
|
604
|
-
throw rootRecord.arg;
|
|
605
|
-
}
|
|
606
|
-
return this.rval;
|
|
607
|
-
},
|
|
608
|
-
dispatchException: function dispatchException(exception) {
|
|
609
|
-
if (this.done) {
|
|
610
|
-
throw exception;
|
|
611
|
-
}
|
|
612
|
-
var context = this;
|
|
613
|
-
function handle(loc, caught) {
|
|
614
|
-
record.type = "throw";
|
|
615
|
-
record.arg = exception;
|
|
616
|
-
context.next = loc;
|
|
617
|
-
if (caught) {
|
|
618
|
-
// If the dispatched exception was caught by a catch block,
|
|
619
|
-
// then let that catch block handle the exception normally.
|
|
620
|
-
context.method = "next";
|
|
621
|
-
context.arg = undefined$1;
|
|
622
|
-
}
|
|
623
|
-
return !!caught;
|
|
624
|
-
}
|
|
625
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
626
|
-
var entry = this.tryEntries[i];
|
|
627
|
-
var record = entry.completion;
|
|
628
|
-
if (entry.tryLoc === "root") {
|
|
629
|
-
// Exception thrown outside of any try block that could handle
|
|
630
|
-
// it, so set the completion value of the entire function to
|
|
631
|
-
// throw the exception.
|
|
632
|
-
return handle("end");
|
|
633
|
-
}
|
|
634
|
-
if (entry.tryLoc <= this.prev) {
|
|
635
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
636
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
637
|
-
if (hasCatch && hasFinally) {
|
|
638
|
-
if (this.prev < entry.catchLoc) {
|
|
639
|
-
return handle(entry.catchLoc, true);
|
|
640
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
641
|
-
return handle(entry.finallyLoc);
|
|
642
|
-
}
|
|
643
|
-
} else if (hasCatch) {
|
|
644
|
-
if (this.prev < entry.catchLoc) {
|
|
645
|
-
return handle(entry.catchLoc, true);
|
|
646
|
-
}
|
|
647
|
-
} else if (hasFinally) {
|
|
648
|
-
if (this.prev < entry.finallyLoc) {
|
|
649
|
-
return handle(entry.finallyLoc);
|
|
650
|
-
}
|
|
651
|
-
} else {
|
|
652
|
-
throw new Error("try statement without catch or finally");
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
abrupt: function abrupt(type, arg) {
|
|
658
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
659
|
-
var entry = this.tryEntries[i];
|
|
660
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
661
|
-
var finallyEntry = entry;
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
666
|
-
// Ignore the finally entry if control is not jumping to a
|
|
667
|
-
// location outside the try/catch block.
|
|
668
|
-
finallyEntry = null;
|
|
669
|
-
}
|
|
670
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
671
|
-
record.type = type;
|
|
672
|
-
record.arg = arg;
|
|
673
|
-
if (finallyEntry) {
|
|
674
|
-
this.method = "next";
|
|
675
|
-
this.next = finallyEntry.finallyLoc;
|
|
676
|
-
return ContinueSentinel;
|
|
677
|
-
}
|
|
678
|
-
return this.complete(record);
|
|
679
|
-
},
|
|
680
|
-
complete: function complete(record, afterLoc) {
|
|
681
|
-
if (record.type === "throw") {
|
|
682
|
-
throw record.arg;
|
|
683
|
-
}
|
|
684
|
-
if (record.type === "break" || record.type === "continue") {
|
|
685
|
-
this.next = record.arg;
|
|
686
|
-
} else if (record.type === "return") {
|
|
687
|
-
this.rval = this.arg = record.arg;
|
|
688
|
-
this.method = "return";
|
|
689
|
-
this.next = "end";
|
|
690
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
691
|
-
this.next = afterLoc;
|
|
692
|
-
}
|
|
693
|
-
return ContinueSentinel;
|
|
694
|
-
},
|
|
695
|
-
finish: function finish(finallyLoc) {
|
|
696
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
697
|
-
var entry = this.tryEntries[i];
|
|
698
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
699
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
700
|
-
resetTryEntry(entry);
|
|
701
|
-
return ContinueSentinel;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
},
|
|
705
|
-
"catch": function _catch(tryLoc) {
|
|
706
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
707
|
-
var entry = this.tryEntries[i];
|
|
708
|
-
if (entry.tryLoc === tryLoc) {
|
|
709
|
-
var record = entry.completion;
|
|
710
|
-
if (record.type === "throw") {
|
|
711
|
-
var thrown = record.arg;
|
|
712
|
-
resetTryEntry(entry);
|
|
713
|
-
}
|
|
714
|
-
return thrown;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
// The context.catch method must only be called with a location
|
|
719
|
-
// argument that corresponds to a known catch block.
|
|
720
|
-
throw new Error("illegal catch attempt");
|
|
721
|
-
},
|
|
722
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
723
|
-
this.delegate = {
|
|
724
|
-
iterator: values(iterable),
|
|
725
|
-
resultName: resultName,
|
|
726
|
-
nextLoc: nextLoc
|
|
727
|
-
};
|
|
728
|
-
if (this.method === "next") {
|
|
729
|
-
// Deliberately forget the last sent value so that we don't
|
|
730
|
-
// accidentally pass it on to the delegate.
|
|
731
|
-
this.arg = undefined$1;
|
|
732
|
-
}
|
|
733
|
-
return ContinueSentinel;
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
738
|
-
// or not, return the runtime object so that we can declare the variable
|
|
739
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
740
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
741
|
-
return exports;
|
|
742
|
-
}(
|
|
743
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
744
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
745
|
-
// object. Either way, the resulting object will be used to initialize
|
|
746
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
747
|
-
module.exports );
|
|
748
|
-
try {
|
|
749
|
-
regeneratorRuntime = runtime;
|
|
750
|
-
} catch (accidentalStrictMode) {
|
|
751
|
-
// This module should not be running in strict mode, so the above
|
|
752
|
-
// assignment should always work unless something is misconfigured. Just
|
|
753
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
754
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
755
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
756
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
757
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
758
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
759
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
760
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
761
|
-
if (typeof globalThis === "object") {
|
|
762
|
-
globalThis.regeneratorRuntime = runtime;
|
|
763
|
-
} else {
|
|
764
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
|
|
769
413
|
var _excluded = ["file"];
|
|
770
414
|
var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
771
415
|
var id = _ref2.id,
|
|
@@ -984,36 +628,32 @@ function normalizeCategory(_ref7) {
|
|
|
984
628
|
};
|
|
985
629
|
}
|
|
986
630
|
|
|
987
|
-
var
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}
|
|
631
|
+
var _ref;
|
|
632
|
+
var handleFetchResponse = function handleFetchResponse(_x) {
|
|
633
|
+
return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
|
|
634
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
635
|
+
while (1) switch (_context.prev = _context.next) {
|
|
636
|
+
case 0:
|
|
637
|
+
if (!res) {
|
|
638
|
+
_context.next = 4;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
if (!res.error) {
|
|
642
|
+
_context.next = 3;
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
throw new commerce.CommerceError(res.error);
|
|
646
|
+
case 3:
|
|
647
|
+
return _context.abrupt("return", res);
|
|
648
|
+
case 4:
|
|
649
|
+
return _context.abrupt("return", null);
|
|
650
|
+
case 5:
|
|
651
|
+
case "end":
|
|
652
|
+
return _context.stop();
|
|
1010
653
|
}
|
|
1011
654
|
}, _callee);
|
|
1012
|
-
}));
|
|
1013
|
-
|
|
1014
|
-
return _ref.apply(this, arguments);
|
|
1015
|
-
};
|
|
1016
|
-
}();
|
|
655
|
+
}))).apply(this, arguments);
|
|
656
|
+
};
|
|
1017
657
|
|
|
1018
658
|
/*
|
|
1019
659
|
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
@@ -1036,52 +676,48 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
|
1036
676
|
return normalizeCart(checkoutPayload);
|
|
1037
677
|
};
|
|
1038
678
|
|
|
1039
|
-
var
|
|
1040
|
-
|
|
679
|
+
var _ref$1;
|
|
680
|
+
var checkoutCreate = function checkoutCreate(_x) {
|
|
681
|
+
return (_ref$1 = _ref$1 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch) {
|
|
1041
682
|
var cart, checkoutUrl, options;
|
|
1042
|
-
return
|
|
1043
|
-
while (1) {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
if (cart) {
|
|
1054
|
-
_context.next = 6;
|
|
1055
|
-
break;
|
|
1056
|
-
}
|
|
683
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
684
|
+
while (1) switch (_context.prev = _context.next) {
|
|
685
|
+
case 0:
|
|
686
|
+
_context.next = 2;
|
|
687
|
+
return fetch({
|
|
688
|
+
query: 'cart',
|
|
689
|
+
method: 'get'
|
|
690
|
+
});
|
|
691
|
+
case 2:
|
|
692
|
+
cart = _context.sent;
|
|
693
|
+
if (cart) {
|
|
1057
694
|
_context.next = 6;
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
_context.next = 6;
|
|
698
|
+
return fetch({
|
|
699
|
+
query: 'cart',
|
|
700
|
+
method: 'setItems',
|
|
701
|
+
variables: [[]]
|
|
702
|
+
});
|
|
703
|
+
case 6:
|
|
704
|
+
checkoutUrl = cart == null ? void 0 : cart.checkout_url;
|
|
705
|
+
options = {
|
|
706
|
+
expires: SWELL_COOKIE_EXPIRE,
|
|
707
|
+
sameSite: "none",
|
|
708
|
+
secure: true
|
|
709
|
+
};
|
|
710
|
+
if (checkoutUrl) {
|
|
711
|
+
Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options);
|
|
712
|
+
}
|
|
713
|
+
return _context.abrupt("return", cart);
|
|
714
|
+
case 10:
|
|
715
|
+
case "end":
|
|
716
|
+
return _context.stop();
|
|
1078
717
|
}
|
|
1079
718
|
}, _callee);
|
|
1080
|
-
}));
|
|
1081
|
-
|
|
1082
|
-
return _ref.apply(this, arguments);
|
|
1083
|
-
};
|
|
1084
|
-
}();
|
|
719
|
+
}))).apply(this, arguments);
|
|
720
|
+
};
|
|
1085
721
|
|
|
1086
722
|
var handler = {
|
|
1087
723
|
fetchOptions: {
|
|
@@ -1089,22 +725,20 @@ var handler = {
|
|
|
1089
725
|
method: 'get'
|
|
1090
726
|
},
|
|
1091
727
|
fetcher: function fetcher(_ref) {
|
|
1092
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
728
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1093
729
|
var fetch, cart;
|
|
1094
|
-
return
|
|
1095
|
-
while (1) {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
return _context.stop();
|
|
1107
|
-
}
|
|
730
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
731
|
+
while (1) switch (_context.prev = _context.next) {
|
|
732
|
+
case 0:
|
|
733
|
+
fetch = _ref.fetch;
|
|
734
|
+
_context.next = 3;
|
|
735
|
+
return checkoutCreate(fetch);
|
|
736
|
+
case 3:
|
|
737
|
+
cart = _context.sent;
|
|
738
|
+
return _context.abrupt("return", cart ? normalizeCart(cart) : null);
|
|
739
|
+
case 5:
|
|
740
|
+
case "end":
|
|
741
|
+
return _context.stop();
|
|
1108
742
|
}
|
|
1109
743
|
}, _callee);
|
|
1110
744
|
}))();
|
|
@@ -1138,40 +772,38 @@ var handler$1 = {
|
|
|
1138
772
|
method: 'addItem'
|
|
1139
773
|
},
|
|
1140
774
|
fetcher: function fetcher(_ref) {
|
|
1141
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
775
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1142
776
|
var item, options, fetch, variables, response;
|
|
1143
|
-
return
|
|
1144
|
-
while (1) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
return _context.stop();
|
|
1174
|
-
}
|
|
777
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
778
|
+
while (1) switch (_context.prev = _context.next) {
|
|
779
|
+
case 0:
|
|
780
|
+
item = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
781
|
+
if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
|
|
782
|
+
_context.next = 3;
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
785
|
+
throw new commerce.CommerceError({
|
|
786
|
+
message: 'The item quantity has to be a valid integer greater than 0'
|
|
787
|
+
});
|
|
788
|
+
case 3:
|
|
789
|
+
variables = {
|
|
790
|
+
checkoutId: getCheckoutId(),
|
|
791
|
+
product_id: item.productId,
|
|
792
|
+
quantity: item.quantity
|
|
793
|
+
};
|
|
794
|
+
if (item.productId !== item.variantId) {
|
|
795
|
+
variables.variant_id = item.variantId;
|
|
796
|
+
}
|
|
797
|
+
_context.next = 7;
|
|
798
|
+
return fetch(_extends({}, options, {
|
|
799
|
+
variables: variables
|
|
800
|
+
}));
|
|
801
|
+
case 7:
|
|
802
|
+
response = _context.sent;
|
|
803
|
+
return _context.abrupt("return", checkoutToCart(response));
|
|
804
|
+
case 9:
|
|
805
|
+
case "end":
|
|
806
|
+
return _context.stop();
|
|
1175
807
|
}
|
|
1176
808
|
}, _callee);
|
|
1177
809
|
}))();
|
|
@@ -1179,37 +811,32 @@ var handler$1 = {
|
|
|
1179
811
|
useHook: function useHook(_ref2) {
|
|
1180
812
|
var fetch = _ref2.fetch;
|
|
1181
813
|
return function () {
|
|
814
|
+
var _addItem;
|
|
1182
815
|
var _useCart = commerce.useCart(),
|
|
1183
816
|
mutate = _useCart.mutate;
|
|
1184
|
-
return React.useCallback(
|
|
1185
|
-
|
|
817
|
+
return React.useCallback(function addItem(_x) {
|
|
818
|
+
return (_addItem = _addItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1186
819
|
var data;
|
|
1187
|
-
return
|
|
1188
|
-
while (1) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
return _context2.stop();
|
|
1204
|
-
}
|
|
820
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
821
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
822
|
+
case 0:
|
|
823
|
+
_context2.next = 2;
|
|
824
|
+
return fetch({
|
|
825
|
+
input: input
|
|
826
|
+
});
|
|
827
|
+
case 2:
|
|
828
|
+
data = _context2.sent;
|
|
829
|
+
_context2.next = 5;
|
|
830
|
+
return mutate(data, false);
|
|
831
|
+
case 5:
|
|
832
|
+
return _context2.abrupt("return", data);
|
|
833
|
+
case 6:
|
|
834
|
+
case "end":
|
|
835
|
+
return _context2.stop();
|
|
1205
836
|
}
|
|
1206
837
|
}, _callee2);
|
|
1207
|
-
}));
|
|
1208
|
-
|
|
1209
|
-
return _addItem.apply(this, arguments);
|
|
1210
|
-
}
|
|
1211
|
-
return addItem;
|
|
1212
|
-
}(), [fetch, mutate]);
|
|
838
|
+
}))).apply(this, arguments);
|
|
839
|
+
}, [fetch, mutate]);
|
|
1213
840
|
};
|
|
1214
841
|
}
|
|
1215
842
|
};
|
|
@@ -1220,24 +847,22 @@ var handler$2 = {
|
|
|
1220
847
|
method: "removeItem"
|
|
1221
848
|
},
|
|
1222
849
|
fetcher: function fetcher(_ref) {
|
|
1223
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
850
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1224
851
|
var itemId, options, fetch, response;
|
|
1225
|
-
return
|
|
1226
|
-
while (1) {
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
return _context.stop();
|
|
1240
|
-
}
|
|
852
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
853
|
+
while (1) switch (_context.prev = _context.next) {
|
|
854
|
+
case 0:
|
|
855
|
+
itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
|
|
856
|
+
_context.next = 3;
|
|
857
|
+
return fetch(_extends({}, options, {
|
|
858
|
+
variables: [itemId]
|
|
859
|
+
}));
|
|
860
|
+
case 3:
|
|
861
|
+
response = _context.sent;
|
|
862
|
+
return _context.abrupt("return", checkoutToCart(response));
|
|
863
|
+
case 5:
|
|
864
|
+
case "end":
|
|
865
|
+
return _context.stop();
|
|
1241
866
|
}
|
|
1242
867
|
}, _callee);
|
|
1243
868
|
}))();
|
|
@@ -1245,39 +870,34 @@ var handler$2 = {
|
|
|
1245
870
|
useHook: function useHook(_ref2) {
|
|
1246
871
|
var fetch = _ref2.fetch;
|
|
1247
872
|
return function () {
|
|
873
|
+
var _removeItem;
|
|
1248
874
|
var _useCart = commerce.useCart(),
|
|
1249
875
|
mutate = _useCart.mutate;
|
|
1250
|
-
return React.useCallback(
|
|
1251
|
-
|
|
876
|
+
return React.useCallback(function removeItem(_x) {
|
|
877
|
+
return (_removeItem = _removeItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1252
878
|
var data;
|
|
1253
|
-
return
|
|
1254
|
-
while (1) {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
return _context2.stop();
|
|
1272
|
-
}
|
|
879
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
880
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
881
|
+
case 0:
|
|
882
|
+
_context2.next = 2;
|
|
883
|
+
return fetch({
|
|
884
|
+
input: {
|
|
885
|
+
itemId: input.id
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
case 2:
|
|
889
|
+
data = _context2.sent;
|
|
890
|
+
_context2.next = 5;
|
|
891
|
+
return mutate(data, false);
|
|
892
|
+
case 5:
|
|
893
|
+
return _context2.abrupt("return", data);
|
|
894
|
+
case 6:
|
|
895
|
+
case "end":
|
|
896
|
+
return _context2.stop();
|
|
1273
897
|
}
|
|
1274
898
|
}, _callee2);
|
|
1275
|
-
}));
|
|
1276
|
-
|
|
1277
|
-
return _removeItem.apply(this, arguments);
|
|
1278
|
-
}
|
|
1279
|
-
return removeItem;
|
|
1280
|
-
}(), [fetch, mutate]);
|
|
899
|
+
}))).apply(this, arguments);
|
|
900
|
+
}, [fetch, mutate]);
|
|
1281
901
|
};
|
|
1282
902
|
}
|
|
1283
903
|
};
|
|
@@ -1288,53 +908,51 @@ var handler$3 = {
|
|
|
1288
908
|
method: "updateItem"
|
|
1289
909
|
},
|
|
1290
910
|
fetcher: function fetcher(_ref) {
|
|
1291
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
911
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1292
912
|
var _ref$input, itemId, item, options, fetch, response;
|
|
1293
|
-
return
|
|
1294
|
-
while (1) {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
913
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
914
|
+
while (1) switch (_context.prev = _context.next) {
|
|
915
|
+
case 0:
|
|
916
|
+
_ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
|
|
917
|
+
if (!Number.isInteger(item.quantity)) {
|
|
918
|
+
_context.next = 6;
|
|
919
|
+
break;
|
|
920
|
+
}
|
|
921
|
+
if (!(item.quantity < 1)) {
|
|
922
|
+
_context.next = 4;
|
|
923
|
+
break;
|
|
924
|
+
}
|
|
925
|
+
return _context.abrupt("return", handler$2.fetcher({
|
|
926
|
+
options: handler$2.fetchOptions,
|
|
927
|
+
input: {
|
|
928
|
+
itemId: itemId
|
|
929
|
+
},
|
|
930
|
+
fetch: fetch
|
|
931
|
+
}));
|
|
932
|
+
case 4:
|
|
933
|
+
_context.next = 8;
|
|
934
|
+
break;
|
|
935
|
+
case 6:
|
|
936
|
+
if (!item.quantity) {
|
|
1314
937
|
_context.next = 8;
|
|
1315
938
|
break;
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
return _context.abrupt("return", checkoutToCart(response));
|
|
1334
|
-
case 12:
|
|
1335
|
-
case "end":
|
|
1336
|
-
return _context.stop();
|
|
1337
|
-
}
|
|
939
|
+
}
|
|
940
|
+
throw new commerce.ValidationError({
|
|
941
|
+
message: "The item quantity has to be a valid integer"
|
|
942
|
+
});
|
|
943
|
+
case 8:
|
|
944
|
+
_context.next = 10;
|
|
945
|
+
return fetch(_extends({}, options, {
|
|
946
|
+
variables: [itemId, {
|
|
947
|
+
quantity: item.quantity
|
|
948
|
+
}]
|
|
949
|
+
}));
|
|
950
|
+
case 10:
|
|
951
|
+
response = _context.sent;
|
|
952
|
+
return _context.abrupt("return", checkoutToCart(response));
|
|
953
|
+
case 12:
|
|
954
|
+
case "end":
|
|
955
|
+
return _context.stop();
|
|
1338
956
|
}
|
|
1339
957
|
}, _callee);
|
|
1340
958
|
}))();
|
|
@@ -1342,7 +960,7 @@ var handler$3 = {
|
|
|
1342
960
|
useHook: function useHook(_ref2) {
|
|
1343
961
|
var fetch = _ref2.fetch;
|
|
1344
962
|
return function (ctx) {
|
|
1345
|
-
var _ctx$wait;
|
|
963
|
+
var _ref3, _ctx$wait;
|
|
1346
964
|
if (ctx === void 0) {
|
|
1347
965
|
ctx = {};
|
|
1348
966
|
}
|
|
@@ -1350,49 +968,44 @@ var handler$3 = {
|
|
|
1350
968
|
item = _ctx.item;
|
|
1351
969
|
var _useCart = commerce.useCart(),
|
|
1352
970
|
mutate = _useCart.mutate;
|
|
1353
|
-
return React.useCallback(debounce(
|
|
1354
|
-
|
|
971
|
+
return React.useCallback(debounce(function (_x) {
|
|
972
|
+
return (_ref3 = _ref3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1355
973
|
var _input$id;
|
|
1356
974
|
var itemId, data;
|
|
1357
|
-
return
|
|
1358
|
-
while (1) {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
975
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
976
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
977
|
+
case 0:
|
|
978
|
+
itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
|
|
979
|
+
if (itemId) {
|
|
980
|
+
_context2.next = 3;
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
throw new commerce.ValidationError({
|
|
984
|
+
message: "Invalid input used for this operation"
|
|
985
|
+
});
|
|
986
|
+
case 3:
|
|
987
|
+
_context2.next = 5;
|
|
988
|
+
return fetch({
|
|
989
|
+
input: {
|
|
990
|
+
item: {
|
|
991
|
+
quantity: input.quantity
|
|
992
|
+
},
|
|
993
|
+
itemId: itemId
|
|
1365
994
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
itemId: itemId
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
|
-
case 5:
|
|
1380
|
-
data = _context2.sent;
|
|
1381
|
-
_context2.next = 8;
|
|
1382
|
-
return mutate(data, false);
|
|
1383
|
-
case 8:
|
|
1384
|
-
return _context2.abrupt("return", data);
|
|
1385
|
-
case 9:
|
|
1386
|
-
case "end":
|
|
1387
|
-
return _context2.stop();
|
|
1388
|
-
}
|
|
995
|
+
});
|
|
996
|
+
case 5:
|
|
997
|
+
data = _context2.sent;
|
|
998
|
+
_context2.next = 8;
|
|
999
|
+
return mutate(data, false);
|
|
1000
|
+
case 8:
|
|
1001
|
+
return _context2.abrupt("return", data);
|
|
1002
|
+
case 9:
|
|
1003
|
+
case "end":
|
|
1004
|
+
return _context2.stop();
|
|
1389
1005
|
}
|
|
1390
1006
|
}, _callee2);
|
|
1391
|
-
}));
|
|
1392
|
-
|
|
1393
|
-
return _ref3.apply(this, arguments);
|
|
1394
|
-
};
|
|
1395
|
-
}(), (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
|
|
1007
|
+
}))).apply(this, arguments);
|
|
1008
|
+
}, (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
|
|
1396
1009
|
};
|
|
1397
1010
|
}
|
|
1398
1011
|
};
|
|
@@ -1447,50 +1060,48 @@ var handler$4 = {
|
|
|
1447
1060
|
method: "list"
|
|
1448
1061
|
},
|
|
1449
1062
|
fetcher: function fetcher(_ref) {
|
|
1450
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1063
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1451
1064
|
var input, options, fetch, sortMap, categoryId, includeSubCategories, categories, brandId, search, _input$sort, sort, count, mappedSort, includedCategories, _yield$fetch, products;
|
|
1452
|
-
return
|
|
1453
|
-
while (1) {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
return _context.stop();
|
|
1493
|
-
}
|
|
1065
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1066
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1067
|
+
case 0:
|
|
1068
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1069
|
+
sortMap = new Map([["latest-desc", ""], ["price-asc", "price asc"], ["price-desc", "price desc"], ["trending-desc", "popularity"]]);
|
|
1070
|
+
categoryId = input.categoryId, includeSubCategories = input.includeSubCategories, categories = input.categories, brandId = input.brandId, search = input.search, _input$sort = input.sort, sort = _input$sort === void 0 ? "latest-desc" : _input$sort, count = input.count;
|
|
1071
|
+
mappedSort = sortMap.get(sort);
|
|
1072
|
+
includedCategories = includeSubCategories ? walkCategoryTree(categories == null ? void 0 : categories.find(function (category) {
|
|
1073
|
+
return category.id === categoryId;
|
|
1074
|
+
}), categories) : undefined;
|
|
1075
|
+
_context.next = 7;
|
|
1076
|
+
return fetch({
|
|
1077
|
+
query: options.query,
|
|
1078
|
+
method: options.method,
|
|
1079
|
+
variables: ensureNoNilFields({
|
|
1080
|
+
category: !includeSubCategories ? categoryId : undefined,
|
|
1081
|
+
brand: brandId,
|
|
1082
|
+
search: search,
|
|
1083
|
+
sort: mappedSort,
|
|
1084
|
+
expand: ["variants"],
|
|
1085
|
+
limit: count,
|
|
1086
|
+
$filters: _extends({}, includeSubCategories ? {
|
|
1087
|
+
category: includedCategories == null ? void 0 : includedCategories.map(function (c) {
|
|
1088
|
+
return c.id;
|
|
1089
|
+
})
|
|
1090
|
+
} : {})
|
|
1091
|
+
})
|
|
1092
|
+
});
|
|
1093
|
+
case 7:
|
|
1094
|
+
_yield$fetch = _context.sent;
|
|
1095
|
+
products = _yield$fetch.results;
|
|
1096
|
+
return _context.abrupt("return", {
|
|
1097
|
+
products: products.map(function (product) {
|
|
1098
|
+
return normalizeProduct(product);
|
|
1099
|
+
}),
|
|
1100
|
+
found: products.length > 0
|
|
1101
|
+
});
|
|
1102
|
+
case 10:
|
|
1103
|
+
case "end":
|
|
1104
|
+
return _context.stop();
|
|
1494
1105
|
}
|
|
1495
1106
|
}, _callee);
|
|
1496
1107
|
}))();
|
|
@@ -1517,33 +1128,31 @@ var handler$5 = {
|
|
|
1517
1128
|
method: 'get'
|
|
1518
1129
|
},
|
|
1519
1130
|
fetcher: function fetcher(_ref) {
|
|
1520
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1131
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1521
1132
|
var input, options, fetch, id, product;
|
|
1522
|
-
return
|
|
1523
|
-
while (1) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
return _context.stop();
|
|
1546
|
-
}
|
|
1133
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1134
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1135
|
+
case 0:
|
|
1136
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1137
|
+
id = input.id;
|
|
1138
|
+
_context.next = 4;
|
|
1139
|
+
return fetch({
|
|
1140
|
+
query: options.query,
|
|
1141
|
+
method: options.method,
|
|
1142
|
+
variables: [id]
|
|
1143
|
+
});
|
|
1144
|
+
case 4:
|
|
1145
|
+
product = _context.sent;
|
|
1146
|
+
if (product) {
|
|
1147
|
+
_context.next = 7;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
return _context.abrupt("return", null);
|
|
1151
|
+
case 7:
|
|
1152
|
+
return _context.abrupt("return", normalizeProduct(product));
|
|
1153
|
+
case 8:
|
|
1154
|
+
case "end":
|
|
1155
|
+
return _context.stop();
|
|
1547
1156
|
}
|
|
1548
1157
|
}, _callee);
|
|
1549
1158
|
}))();
|
|
@@ -1570,86 +1179,96 @@ var handler$6 = {
|
|
|
1570
1179
|
method: "get"
|
|
1571
1180
|
},
|
|
1572
1181
|
fetcher: function fetcher(_ref) {
|
|
1573
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1182
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1574
1183
|
var _data$results;
|
|
1575
|
-
var input, options, fetch, addIsEmptyField, categoryId, data, categories, normalizedCategories, _loop, _iterator, _step;
|
|
1576
|
-
return
|
|
1577
|
-
while (1) {
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
return
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1184
|
+
var input, options, fetch, addIsEmptyField, categoryId, data, categories, _ref2, normalizedCategories, _loop, _iterator, _step;
|
|
1185
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
1186
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1187
|
+
case 0:
|
|
1188
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1189
|
+
addIsEmptyField = input.addIsEmptyField, categoryId = input.categoryId;
|
|
1190
|
+
_context3.next = 4;
|
|
1191
|
+
return fetch({
|
|
1192
|
+
query: options.query,
|
|
1193
|
+
method: options.method,
|
|
1194
|
+
variables: ensureNoNilFields({
|
|
1195
|
+
expand: ["children", "parent_id"],
|
|
1196
|
+
id: categoryId
|
|
1197
|
+
})
|
|
1198
|
+
});
|
|
1199
|
+
case 4:
|
|
1200
|
+
data = _context3.sent;
|
|
1201
|
+
categories = (_data$results = data == null ? void 0 : data.results) != null ? _data$results : [];
|
|
1202
|
+
if (!addIsEmptyField) {
|
|
1203
|
+
_context3.next = 10;
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
_context3.next = 9;
|
|
1207
|
+
return Promise.all(categories.map(function (_x) {
|
|
1208
|
+
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(category) {
|
|
1209
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1210
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1211
|
+
case 0:
|
|
1212
|
+
_context.t0 = _extends;
|
|
1213
|
+
_context.t1 = {};
|
|
1214
|
+
_context.t2 = category;
|
|
1215
|
+
_context.next = 5;
|
|
1216
|
+
return fetch({
|
|
1217
|
+
query: "products",
|
|
1218
|
+
method: "list",
|
|
1219
|
+
variables: ensureNoNilFields({
|
|
1220
|
+
limit: 1,
|
|
1221
|
+
category: category.id
|
|
1222
|
+
})
|
|
1223
|
+
});
|
|
1224
|
+
case 5:
|
|
1225
|
+
_context.t3 = _context.sent.results;
|
|
1226
|
+
_context.t4 = {
|
|
1227
|
+
products: _context.t3
|
|
1228
|
+
};
|
|
1229
|
+
return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
|
|
1230
|
+
case 8:
|
|
1231
|
+
case "end":
|
|
1232
|
+
return _context.stop();
|
|
1233
|
+
}
|
|
1234
|
+
}, _callee);
|
|
1235
|
+
}))).apply(this, arguments);
|
|
1236
|
+
}));
|
|
1237
|
+
case 9:
|
|
1238
|
+
categories = _context3.sent;
|
|
1239
|
+
case 10:
|
|
1240
|
+
normalizedCategories = !categoryId ? topologicalSortForCategoryTree(categories.map(normalizeCategory)) : categories.map(normalizeCategory);
|
|
1241
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1242
|
+
var _normalizedCategories, _normalizedCategories2;
|
|
1243
|
+
var category;
|
|
1244
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
1245
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1246
|
+
case 0:
|
|
1247
|
+
category = _step.value;
|
|
1248
|
+
category.depth = ((_normalizedCategories = (_normalizedCategories2 = normalizedCategories.find(function (c) {
|
|
1249
|
+
return c.id === category.parentId;
|
|
1250
|
+
})) == null ? void 0 : _normalizedCategories2.depth) != null ? _normalizedCategories : -1) + 1;
|
|
1251
|
+
case 2:
|
|
1252
|
+
case "end":
|
|
1253
|
+
return _context2.stop();
|
|
1254
|
+
}
|
|
1255
|
+
}, _loop);
|
|
1256
|
+
});
|
|
1257
|
+
_iterator = _createForOfIteratorHelperLoose(normalizedCategories);
|
|
1258
|
+
case 13:
|
|
1259
|
+
if ((_step = _iterator()).done) {
|
|
1260
|
+
_context3.next = 17;
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
return _context3.delegateYield(_loop(), "t0", 15);
|
|
1264
|
+
case 15:
|
|
1265
|
+
_context3.next = 13;
|
|
1266
|
+
break;
|
|
1267
|
+
case 17:
|
|
1268
|
+
return _context3.abrupt("return", normalizedCategories);
|
|
1269
|
+
case 18:
|
|
1270
|
+
case "end":
|
|
1271
|
+
return _context3.stop();
|
|
1653
1272
|
}
|
|
1654
1273
|
}, _callee2);
|
|
1655
1274
|
}))();
|
|
@@ -1684,55 +1303,53 @@ var handler$7 = {
|
|
|
1684
1303
|
method: "get"
|
|
1685
1304
|
},
|
|
1686
1305
|
fetcher: function fetcher(_ref) {
|
|
1687
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1306
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1688
1307
|
var _yield$fetch$values, _yield$fetch;
|
|
1689
1308
|
var fetch, vendors;
|
|
1690
|
-
return
|
|
1691
|
-
while (1) {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
_context.next = 8;
|
|
1705
|
-
break;
|
|
1706
|
-
}
|
|
1707
|
-
_context.t1 = void 0;
|
|
1708
|
-
_context.next = 9;
|
|
1309
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1310
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1311
|
+
case 0:
|
|
1312
|
+
fetch = _ref.fetch;
|
|
1313
|
+
_context.next = 3;
|
|
1314
|
+
return fetch({
|
|
1315
|
+
query: "attributes",
|
|
1316
|
+
method: "get",
|
|
1317
|
+
variables: "brand"
|
|
1318
|
+
});
|
|
1319
|
+
case 3:
|
|
1320
|
+
_context.t0 = _yield$fetch = _context.sent;
|
|
1321
|
+
if (!(_context.t0 == null)) {
|
|
1322
|
+
_context.next = 8;
|
|
1709
1323
|
break;
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
_context.next =
|
|
1324
|
+
}
|
|
1325
|
+
_context.t1 = void 0;
|
|
1326
|
+
_context.next = 9;
|
|
1327
|
+
break;
|
|
1328
|
+
case 8:
|
|
1329
|
+
_context.t1 = _yield$fetch.values;
|
|
1330
|
+
case 9:
|
|
1331
|
+
_context.t2 = _yield$fetch$values = _context.t1;
|
|
1332
|
+
if (!(_context.t2 != null)) {
|
|
1333
|
+
_context.next = 14;
|
|
1720
1334
|
break;
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1335
|
+
}
|
|
1336
|
+
_context.t3 = _yield$fetch$values;
|
|
1337
|
+
_context.next = 15;
|
|
1338
|
+
break;
|
|
1339
|
+
case 14:
|
|
1340
|
+
_context.t3 = [];
|
|
1341
|
+
case 15:
|
|
1342
|
+
vendors = _context.t3;
|
|
1343
|
+
return _context.abrupt("return", Array.from(new Set(vendors).values()).map(function (v) {
|
|
1344
|
+
return {
|
|
1345
|
+
entityId: v,
|
|
1346
|
+
name: v,
|
|
1347
|
+
path: "brands/" + v
|
|
1348
|
+
};
|
|
1349
|
+
}));
|
|
1350
|
+
case 17:
|
|
1351
|
+
case "end":
|
|
1352
|
+
return _context.stop();
|
|
1736
1353
|
}
|
|
1737
1354
|
}, _callee);
|
|
1738
1355
|
}))();
|
|
@@ -1760,73 +1377,64 @@ var handler$7 = {
|
|
|
1760
1377
|
}
|
|
1761
1378
|
};
|
|
1762
1379
|
|
|
1763
|
-
var
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}
|
|
1781
|
-
arg1 = variables[0];
|
|
1782
|
-
arg2 = variables[1];
|
|
1783
|
-
_context.next = 5;
|
|
1784
|
-
return swell[query][method](arg1, arg2);
|
|
1785
|
-
case 5:
|
|
1786
|
-
response = _context.sent;
|
|
1787
|
-
return _context.abrupt("return", handleFetchResponse(response));
|
|
1788
|
-
case 9:
|
|
1789
|
-
_context.next = 11;
|
|
1790
|
-
return swell[query][method](variables);
|
|
1791
|
-
case 11:
|
|
1792
|
-
_response = _context.sent;
|
|
1793
|
-
return _context.abrupt("return", handleFetchResponse(_response));
|
|
1794
|
-
case 13:
|
|
1795
|
-
case "end":
|
|
1796
|
-
return _context.stop();
|
|
1380
|
+
var _ref2;
|
|
1381
|
+
var fetcher = function fetcher(_x) {
|
|
1382
|
+
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
1383
|
+
var _callSwell;
|
|
1384
|
+
var _ref$method, method, variables, query, callSwell;
|
|
1385
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1386
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1387
|
+
case 0:
|
|
1388
|
+
callSwell = function _callSwell2() {
|
|
1389
|
+
return (_callSwell = _callSwell || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1390
|
+
var arg1, arg2, response, _response;
|
|
1391
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1392
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1393
|
+
case 0:
|
|
1394
|
+
if (!Array.isArray(variables)) {
|
|
1395
|
+
_context.next = 9;
|
|
1396
|
+
break;
|
|
1797
1397
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1398
|
+
arg1 = variables[0];
|
|
1399
|
+
arg2 = variables[1];
|
|
1400
|
+
_context.next = 5;
|
|
1401
|
+
return swell__default[query][method](arg1, arg2);
|
|
1402
|
+
case 5:
|
|
1403
|
+
response = _context.sent;
|
|
1404
|
+
return _context.abrupt("return", handleFetchResponse(response));
|
|
1405
|
+
case 9:
|
|
1406
|
+
_context.next = 11;
|
|
1407
|
+
return swell__default[query][method](variables);
|
|
1408
|
+
case 11:
|
|
1409
|
+
_response = _context.sent;
|
|
1410
|
+
return _context.abrupt("return", handleFetchResponse(_response));
|
|
1411
|
+
case 13:
|
|
1412
|
+
case "end":
|
|
1413
|
+
return _context.stop();
|
|
1414
|
+
}
|
|
1415
|
+
}, _callee);
|
|
1416
|
+
}))).apply(this, arguments);
|
|
1417
|
+
};
|
|
1418
|
+
_ref$method = _ref.method, method = _ref$method === void 0 ? 'get' : _ref$method, variables = _ref.variables, query = _ref.query;
|
|
1419
|
+
if (!(query && query in swell__default)) {
|
|
1420
|
+
_context2.next = 8;
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1423
|
+
_context2.next = 5;
|
|
1424
|
+
return callSwell();
|
|
1425
|
+
case 5:
|
|
1426
|
+
return _context2.abrupt("return", _context2.sent);
|
|
1427
|
+
case 8:
|
|
1428
|
+
throw new commerce.CommerceError({
|
|
1429
|
+
message: 'Invalid query argument!'
|
|
1430
|
+
});
|
|
1431
|
+
case 9:
|
|
1432
|
+
case "end":
|
|
1433
|
+
return _context2.stop();
|
|
1823
1434
|
}
|
|
1824
1435
|
}, _callee2);
|
|
1825
|
-
}));
|
|
1826
|
-
|
|
1827
|
-
return _ref2.apply(this, arguments);
|
|
1828
|
-
};
|
|
1829
|
-
}();
|
|
1436
|
+
}))).apply(this, arguments);
|
|
1437
|
+
};
|
|
1830
1438
|
|
|
1831
1439
|
/*
|
|
1832
1440
|
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
@@ -1835,9 +1443,9 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
1835
1443
|
var getSwellProvider = function getSwellProvider(storeId, publicKey) {
|
|
1836
1444
|
swell.init(storeId, publicKey);
|
|
1837
1445
|
return {
|
|
1838
|
-
locale:
|
|
1446
|
+
locale: "en-us",
|
|
1839
1447
|
cartCookie: SWELL_CHECKOUT_ID_COOKIE,
|
|
1840
|
-
swell:
|
|
1448
|
+
swell: swell__default,
|
|
1841
1449
|
fetcher: fetcher,
|
|
1842
1450
|
cart: {
|
|
1843
1451
|
useCart: handler,
|