@plasmicpkgs/commerce-commercetools 0.0.107 → 0.0.108
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-commercetools.cjs.development.js +599 -987
- package/dist/commerce-commercetools.cjs.development.js.map +1 -1
- package/dist/commerce-commercetools.cjs.production.min.js +1 -1
- package/dist/commerce-commercetools.cjs.production.min.js.map +1 -1
- package/dist/commerce-commercetools.esm.js +599 -987
- package/dist/commerce-commercetools.esm.js.map +1 -1
- package/dist/commercetools.d.ts +2 -1
- package/dist/registerCommerceProvider.d.ts +1 -1
- package/package.json +3 -3
- package/LICENSE.md +0 -21
|
@@ -13,6 +13,307 @@ var Cookies = _interopDefault(require('js-cookie'));
|
|
|
13
13
|
var platformSdk = require('@commercetools/platform-sdk');
|
|
14
14
|
var sdkClientV2 = require('@commercetools/sdk-client-v2');
|
|
15
15
|
|
|
16
|
+
function _regeneratorRuntime() {
|
|
17
|
+
_regeneratorRuntime = function () {
|
|
18
|
+
return e;
|
|
19
|
+
};
|
|
20
|
+
var t,
|
|
21
|
+
e = {},
|
|
22
|
+
r = Object.prototype,
|
|
23
|
+
n = r.hasOwnProperty,
|
|
24
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
25
|
+
t[e] = r.value;
|
|
26
|
+
},
|
|
27
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
28
|
+
a = i.iterator || "@@iterator",
|
|
29
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
30
|
+
u = i.toStringTag || "@@toStringTag";
|
|
31
|
+
function define(t, e, r) {
|
|
32
|
+
return Object.defineProperty(t, e, {
|
|
33
|
+
value: r,
|
|
34
|
+
enumerable: !0,
|
|
35
|
+
configurable: !0,
|
|
36
|
+
writable: !0
|
|
37
|
+
}), t[e];
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
define({}, "");
|
|
41
|
+
} catch (t) {
|
|
42
|
+
define = function (t, e, r) {
|
|
43
|
+
return t[e] = r;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function wrap(t, e, r, n) {
|
|
47
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
48
|
+
a = Object.create(i.prototype),
|
|
49
|
+
c = new Context(n || []);
|
|
50
|
+
return o(a, "_invoke", {
|
|
51
|
+
value: makeInvokeMethod(t, r, c)
|
|
52
|
+
}), a;
|
|
53
|
+
}
|
|
54
|
+
function tryCatch(t, e, r) {
|
|
55
|
+
try {
|
|
56
|
+
return {
|
|
57
|
+
type: "normal",
|
|
58
|
+
arg: t.call(e, r)
|
|
59
|
+
};
|
|
60
|
+
} catch (t) {
|
|
61
|
+
return {
|
|
62
|
+
type: "throw",
|
|
63
|
+
arg: t
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
e.wrap = wrap;
|
|
68
|
+
var h = "suspendedStart",
|
|
69
|
+
l = "suspendedYield",
|
|
70
|
+
f = "executing",
|
|
71
|
+
s = "completed",
|
|
72
|
+
y = {};
|
|
73
|
+
function Generator() {}
|
|
74
|
+
function GeneratorFunction() {}
|
|
75
|
+
function GeneratorFunctionPrototype() {}
|
|
76
|
+
var p = {};
|
|
77
|
+
define(p, a, function () {
|
|
78
|
+
return this;
|
|
79
|
+
});
|
|
80
|
+
var d = Object.getPrototypeOf,
|
|
81
|
+
v = d && d(d(values([])));
|
|
82
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
83
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
84
|
+
function defineIteratorMethods(t) {
|
|
85
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
86
|
+
define(t, e, function (t) {
|
|
87
|
+
return this._invoke(e, t);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function AsyncIterator(t, e) {
|
|
92
|
+
function invoke(r, o, i, a) {
|
|
93
|
+
var c = tryCatch(t[r], t, o);
|
|
94
|
+
if ("throw" !== c.type) {
|
|
95
|
+
var u = c.arg,
|
|
96
|
+
h = u.value;
|
|
97
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
98
|
+
invoke("next", t, i, a);
|
|
99
|
+
}, function (t) {
|
|
100
|
+
invoke("throw", t, i, a);
|
|
101
|
+
}) : e.resolve(h).then(function (t) {
|
|
102
|
+
u.value = t, i(u);
|
|
103
|
+
}, function (t) {
|
|
104
|
+
return invoke("throw", t, i, a);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
a(c.arg);
|
|
108
|
+
}
|
|
109
|
+
var r;
|
|
110
|
+
o(this, "_invoke", {
|
|
111
|
+
value: function (t, n) {
|
|
112
|
+
function callInvokeWithMethodAndArg() {
|
|
113
|
+
return new e(function (e, r) {
|
|
114
|
+
invoke(t, n, e, r);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function makeInvokeMethod(e, r, n) {
|
|
122
|
+
var o = h;
|
|
123
|
+
return function (i, a) {
|
|
124
|
+
if (o === f) throw new Error("Generator is already running");
|
|
125
|
+
if (o === s) {
|
|
126
|
+
if ("throw" === i) throw a;
|
|
127
|
+
return {
|
|
128
|
+
value: t,
|
|
129
|
+
done: !0
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
for (n.method = i, n.arg = a;;) {
|
|
133
|
+
var c = n.delegate;
|
|
134
|
+
if (c) {
|
|
135
|
+
var u = maybeInvokeDelegate(c, n);
|
|
136
|
+
if (u) {
|
|
137
|
+
if (u === y) continue;
|
|
138
|
+
return u;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
142
|
+
if (o === h) throw o = s, n.arg;
|
|
143
|
+
n.dispatchException(n.arg);
|
|
144
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
145
|
+
o = f;
|
|
146
|
+
var p = tryCatch(e, r, n);
|
|
147
|
+
if ("normal" === p.type) {
|
|
148
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
149
|
+
return {
|
|
150
|
+
value: p.arg,
|
|
151
|
+
done: n.done
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function maybeInvokeDelegate(e, r) {
|
|
159
|
+
var n = r.method,
|
|
160
|
+
o = e.iterator[n];
|
|
161
|
+
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;
|
|
162
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
163
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
164
|
+
var a = i.arg;
|
|
165
|
+
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);
|
|
166
|
+
}
|
|
167
|
+
function pushTryEntry(t) {
|
|
168
|
+
var e = {
|
|
169
|
+
tryLoc: t[0]
|
|
170
|
+
};
|
|
171
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
172
|
+
}
|
|
173
|
+
function resetTryEntry(t) {
|
|
174
|
+
var e = t.completion || {};
|
|
175
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
176
|
+
}
|
|
177
|
+
function Context(t) {
|
|
178
|
+
this.tryEntries = [{
|
|
179
|
+
tryLoc: "root"
|
|
180
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
181
|
+
}
|
|
182
|
+
function values(e) {
|
|
183
|
+
if (e || "" === e) {
|
|
184
|
+
var r = e[a];
|
|
185
|
+
if (r) return r.call(e);
|
|
186
|
+
if ("function" == typeof e.next) return e;
|
|
187
|
+
if (!isNaN(e.length)) {
|
|
188
|
+
var o = -1,
|
|
189
|
+
i = function next() {
|
|
190
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
191
|
+
return next.value = t, next.done = !0, next;
|
|
192
|
+
};
|
|
193
|
+
return i.next = i;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
197
|
+
}
|
|
198
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
199
|
+
value: GeneratorFunctionPrototype,
|
|
200
|
+
configurable: !0
|
|
201
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
202
|
+
value: GeneratorFunction,
|
|
203
|
+
configurable: !0
|
|
204
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
205
|
+
var e = "function" == typeof t && t.constructor;
|
|
206
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
207
|
+
}, e.mark = function (t) {
|
|
208
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
209
|
+
}, e.awrap = function (t) {
|
|
210
|
+
return {
|
|
211
|
+
__await: t
|
|
212
|
+
};
|
|
213
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
214
|
+
return this;
|
|
215
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
216
|
+
void 0 === i && (i = Promise);
|
|
217
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
218
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
219
|
+
return t.done ? t.value : a.next();
|
|
220
|
+
});
|
|
221
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
222
|
+
return this;
|
|
223
|
+
}), define(g, "toString", function () {
|
|
224
|
+
return "[object Generator]";
|
|
225
|
+
}), e.keys = function (t) {
|
|
226
|
+
var e = Object(t),
|
|
227
|
+
r = [];
|
|
228
|
+
for (var n in e) r.push(n);
|
|
229
|
+
return r.reverse(), function next() {
|
|
230
|
+
for (; r.length;) {
|
|
231
|
+
var t = r.pop();
|
|
232
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
233
|
+
}
|
|
234
|
+
return next.done = !0, next;
|
|
235
|
+
};
|
|
236
|
+
}, e.values = values, Context.prototype = {
|
|
237
|
+
constructor: Context,
|
|
238
|
+
reset: function (e) {
|
|
239
|
+
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);
|
|
240
|
+
},
|
|
241
|
+
stop: function () {
|
|
242
|
+
this.done = !0;
|
|
243
|
+
var t = this.tryEntries[0].completion;
|
|
244
|
+
if ("throw" === t.type) throw t.arg;
|
|
245
|
+
return this.rval;
|
|
246
|
+
},
|
|
247
|
+
dispatchException: function (e) {
|
|
248
|
+
if (this.done) throw e;
|
|
249
|
+
var r = this;
|
|
250
|
+
function handle(n, o) {
|
|
251
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
252
|
+
}
|
|
253
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
254
|
+
var i = this.tryEntries[o],
|
|
255
|
+
a = i.completion;
|
|
256
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
257
|
+
if (i.tryLoc <= this.prev) {
|
|
258
|
+
var c = n.call(i, "catchLoc"),
|
|
259
|
+
u = n.call(i, "finallyLoc");
|
|
260
|
+
if (c && u) {
|
|
261
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
262
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
263
|
+
} else if (c) {
|
|
264
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
265
|
+
} else {
|
|
266
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
267
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
abrupt: function (t, e) {
|
|
273
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
274
|
+
var o = this.tryEntries[r];
|
|
275
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
276
|
+
var i = o;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
281
|
+
var a = i ? i.completion : {};
|
|
282
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
283
|
+
},
|
|
284
|
+
complete: function (t, e) {
|
|
285
|
+
if ("throw" === t.type) throw t.arg;
|
|
286
|
+
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;
|
|
287
|
+
},
|
|
288
|
+
finish: function (t) {
|
|
289
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
290
|
+
var r = this.tryEntries[e];
|
|
291
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
catch: function (t) {
|
|
295
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
296
|
+
var r = this.tryEntries[e];
|
|
297
|
+
if (r.tryLoc === t) {
|
|
298
|
+
var n = r.completion;
|
|
299
|
+
if ("throw" === n.type) {
|
|
300
|
+
var o = n.arg;
|
|
301
|
+
resetTryEntry(r);
|
|
302
|
+
}
|
|
303
|
+
return o;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
throw new Error("illegal catch attempt");
|
|
307
|
+
},
|
|
308
|
+
delegateYield: function (e, r, n) {
|
|
309
|
+
return this.delegate = {
|
|
310
|
+
iterator: values(e),
|
|
311
|
+
resultName: r,
|
|
312
|
+
nextLoc: n
|
|
313
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
314
|
+
}
|
|
315
|
+
}, e;
|
|
316
|
+
}
|
|
16
317
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
318
|
try {
|
|
18
319
|
var info = gen[key](arg);
|
|
@@ -58,664 +359,6 @@ function _extends() {
|
|
|
58
359
|
return _extends.apply(this, arguments);
|
|
59
360
|
}
|
|
60
361
|
|
|
61
|
-
function createCommonjsModule(fn, module) {
|
|
62
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
66
|
-
/**
|
|
67
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the MIT license found in the
|
|
70
|
-
* LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
var runtime = function (exports) {
|
|
74
|
-
|
|
75
|
-
var Op = Object.prototype;
|
|
76
|
-
var hasOwn = Op.hasOwnProperty;
|
|
77
|
-
var undefined$1; // More compressible than void 0.
|
|
78
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
79
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
80
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
81
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
82
|
-
function define(obj, key, value) {
|
|
83
|
-
Object.defineProperty(obj, key, {
|
|
84
|
-
value: value,
|
|
85
|
-
enumerable: true,
|
|
86
|
-
configurable: true,
|
|
87
|
-
writable: true
|
|
88
|
-
});
|
|
89
|
-
return obj[key];
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
93
|
-
define({}, "");
|
|
94
|
-
} catch (err) {
|
|
95
|
-
define = function define(obj, key, value) {
|
|
96
|
-
return obj[key] = value;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
100
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
101
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
102
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
103
|
-
var context = new Context(tryLocsList || []);
|
|
104
|
-
|
|
105
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
106
|
-
// .throw, and .return methods.
|
|
107
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
108
|
-
return generator;
|
|
109
|
-
}
|
|
110
|
-
exports.wrap = wrap;
|
|
111
|
-
|
|
112
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
113
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
114
|
-
// have been (and was previously) designed to take a closure to be
|
|
115
|
-
// invoked without arguments, but in all the cases we care about we
|
|
116
|
-
// already have an existing method we want to call, so there's no need
|
|
117
|
-
// to create a new function object. We can even get away with assuming
|
|
118
|
-
// the method takes exactly one argument, since that happens to be true
|
|
119
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
120
|
-
// only additional allocation required is the completion record, which
|
|
121
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
122
|
-
function tryCatch(fn, obj, arg) {
|
|
123
|
-
try {
|
|
124
|
-
return {
|
|
125
|
-
type: "normal",
|
|
126
|
-
arg: fn.call(obj, arg)
|
|
127
|
-
};
|
|
128
|
-
} catch (err) {
|
|
129
|
-
return {
|
|
130
|
-
type: "throw",
|
|
131
|
-
arg: err
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
136
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
137
|
-
var GenStateExecuting = "executing";
|
|
138
|
-
var GenStateCompleted = "completed";
|
|
139
|
-
|
|
140
|
-
// Returning this object from the innerFn has the same effect as
|
|
141
|
-
// breaking out of the dispatch switch statement.
|
|
142
|
-
var ContinueSentinel = {};
|
|
143
|
-
|
|
144
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
145
|
-
// .constructor.prototype properties for functions that return Generator
|
|
146
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
147
|
-
// minifier not to mangle the names of these two functions.
|
|
148
|
-
function Generator() {}
|
|
149
|
-
function GeneratorFunction() {}
|
|
150
|
-
function GeneratorFunctionPrototype() {}
|
|
151
|
-
|
|
152
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
153
|
-
// don't natively support it.
|
|
154
|
-
var IteratorPrototype = {};
|
|
155
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
156
|
-
return this;
|
|
157
|
-
});
|
|
158
|
-
var getProto = Object.getPrototypeOf;
|
|
159
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
160
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
161
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
162
|
-
// of the polyfill.
|
|
163
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
164
|
-
}
|
|
165
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
166
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
167
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
168
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
169
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
170
|
-
|
|
171
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
172
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
173
|
-
function defineIteratorMethods(prototype) {
|
|
174
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
175
|
-
define(prototype, method, function (arg) {
|
|
176
|
-
return this._invoke(method, arg);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
181
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
182
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
183
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
184
|
-
// do is to check its .name property.
|
|
185
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
186
|
-
};
|
|
187
|
-
exports.mark = function (genFun) {
|
|
188
|
-
if (Object.setPrototypeOf) {
|
|
189
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
190
|
-
} else {
|
|
191
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
192
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
193
|
-
}
|
|
194
|
-
genFun.prototype = Object.create(Gp);
|
|
195
|
-
return genFun;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// Within the body of any async function, `await x` is transformed to
|
|
199
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
200
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
201
|
-
// meant to be awaited.
|
|
202
|
-
exports.awrap = function (arg) {
|
|
203
|
-
return {
|
|
204
|
-
__await: arg
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
208
|
-
function invoke(method, arg, resolve, reject) {
|
|
209
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
210
|
-
if (record.type === "throw") {
|
|
211
|
-
reject(record.arg);
|
|
212
|
-
} else {
|
|
213
|
-
var result = record.arg;
|
|
214
|
-
var value = result.value;
|
|
215
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
216
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
217
|
-
invoke("next", value, resolve, reject);
|
|
218
|
-
}, function (err) {
|
|
219
|
-
invoke("throw", err, resolve, reject);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
223
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
224
|
-
// the .value of the Promise<{value,done}> result for the
|
|
225
|
-
// current iteration.
|
|
226
|
-
result.value = unwrapped;
|
|
227
|
-
resolve(result);
|
|
228
|
-
}, function (error) {
|
|
229
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
230
|
-
// into the async generator function so it can be handled there.
|
|
231
|
-
return invoke("throw", error, resolve, reject);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
var previousPromise;
|
|
236
|
-
function enqueue(method, arg) {
|
|
237
|
-
function callInvokeWithMethodAndArg() {
|
|
238
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
239
|
-
invoke(method, arg, resolve, reject);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
return previousPromise =
|
|
243
|
-
// If enqueue has been called before, then we want to wait until
|
|
244
|
-
// all previous Promises have been resolved before calling invoke,
|
|
245
|
-
// so that results are always delivered in the correct order. If
|
|
246
|
-
// enqueue has not been called before, then it is important to
|
|
247
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
248
|
-
// so that the async generator function has the opportunity to do
|
|
249
|
-
// any necessary setup in a predictable way. This predictability
|
|
250
|
-
// is why the Promise constructor synchronously invokes its
|
|
251
|
-
// executor callback, and why async functions synchronously
|
|
252
|
-
// execute code before the first await. Since we implement simple
|
|
253
|
-
// async functions in terms of async generators, it is especially
|
|
254
|
-
// important to get this right, even though it requires care.
|
|
255
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
256
|
-
// Avoid propagating failures to Promises returned by later
|
|
257
|
-
// invocations of the iterator.
|
|
258
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Define the unified helper method that is used to implement .next,
|
|
262
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
263
|
-
this._invoke = enqueue;
|
|
264
|
-
}
|
|
265
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
266
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
267
|
-
return this;
|
|
268
|
-
});
|
|
269
|
-
exports.AsyncIterator = AsyncIterator;
|
|
270
|
-
|
|
271
|
-
// Note that simple async functions are implemented on top of
|
|
272
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
273
|
-
// the final result produced by the iterator.
|
|
274
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
275
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
276
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
277
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
278
|
-
: iter.next().then(function (result) {
|
|
279
|
-
return result.done ? result.value : iter.next();
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
283
|
-
var state = GenStateSuspendedStart;
|
|
284
|
-
return function invoke(method, arg) {
|
|
285
|
-
if (state === GenStateExecuting) {
|
|
286
|
-
throw new Error("Generator is already running");
|
|
287
|
-
}
|
|
288
|
-
if (state === GenStateCompleted) {
|
|
289
|
-
if (method === "throw") {
|
|
290
|
-
throw arg;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
294
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
295
|
-
return doneResult();
|
|
296
|
-
}
|
|
297
|
-
context.method = method;
|
|
298
|
-
context.arg = arg;
|
|
299
|
-
while (true) {
|
|
300
|
-
var delegate = context.delegate;
|
|
301
|
-
if (delegate) {
|
|
302
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
303
|
-
if (delegateResult) {
|
|
304
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
305
|
-
return delegateResult;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (context.method === "next") {
|
|
309
|
-
// Setting context._sent for legacy support of Babel's
|
|
310
|
-
// function.sent implementation.
|
|
311
|
-
context.sent = context._sent = context.arg;
|
|
312
|
-
} else if (context.method === "throw") {
|
|
313
|
-
if (state === GenStateSuspendedStart) {
|
|
314
|
-
state = GenStateCompleted;
|
|
315
|
-
throw context.arg;
|
|
316
|
-
}
|
|
317
|
-
context.dispatchException(context.arg);
|
|
318
|
-
} else if (context.method === "return") {
|
|
319
|
-
context.abrupt("return", context.arg);
|
|
320
|
-
}
|
|
321
|
-
state = GenStateExecuting;
|
|
322
|
-
var record = tryCatch(innerFn, self, context);
|
|
323
|
-
if (record.type === "normal") {
|
|
324
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
325
|
-
// GenStateExecuting and loop back for another invocation.
|
|
326
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
327
|
-
if (record.arg === ContinueSentinel) {
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
value: record.arg,
|
|
332
|
-
done: context.done
|
|
333
|
-
};
|
|
334
|
-
} else if (record.type === "throw") {
|
|
335
|
-
state = GenStateCompleted;
|
|
336
|
-
// Dispatch the exception by looping back around to the
|
|
337
|
-
// context.dispatchException(context.arg) call above.
|
|
338
|
-
context.method = "throw";
|
|
339
|
-
context.arg = record.arg;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
346
|
-
// result, either by returning a { value, done } result from the
|
|
347
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
348
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
349
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
350
|
-
var method = delegate.iterator[context.method];
|
|
351
|
-
if (method === undefined$1) {
|
|
352
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
353
|
-
// method always terminates the yield* loop.
|
|
354
|
-
context.delegate = null;
|
|
355
|
-
if (context.method === "throw") {
|
|
356
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
357
|
-
if (delegate.iterator["return"]) {
|
|
358
|
-
// If the delegate iterator has a return method, give it a
|
|
359
|
-
// chance to clean up.
|
|
360
|
-
context.method = "return";
|
|
361
|
-
context.arg = undefined$1;
|
|
362
|
-
maybeInvokeDelegate(delegate, context);
|
|
363
|
-
if (context.method === "throw") {
|
|
364
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
365
|
-
// "return" to "throw", let that override the TypeError below.
|
|
366
|
-
return ContinueSentinel;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
context.method = "throw";
|
|
370
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
371
|
-
}
|
|
372
|
-
return ContinueSentinel;
|
|
373
|
-
}
|
|
374
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
375
|
-
if (record.type === "throw") {
|
|
376
|
-
context.method = "throw";
|
|
377
|
-
context.arg = record.arg;
|
|
378
|
-
context.delegate = null;
|
|
379
|
-
return ContinueSentinel;
|
|
380
|
-
}
|
|
381
|
-
var info = record.arg;
|
|
382
|
-
if (!info) {
|
|
383
|
-
context.method = "throw";
|
|
384
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
385
|
-
context.delegate = null;
|
|
386
|
-
return ContinueSentinel;
|
|
387
|
-
}
|
|
388
|
-
if (info.done) {
|
|
389
|
-
// Assign the result of the finished delegate to the temporary
|
|
390
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
391
|
-
context[delegate.resultName] = info.value;
|
|
392
|
-
|
|
393
|
-
// Resume execution at the desired location (see delegateYield).
|
|
394
|
-
context.next = delegate.nextLoc;
|
|
395
|
-
|
|
396
|
-
// If context.method was "throw" but the delegate handled the
|
|
397
|
-
// exception, let the outer generator proceed normally. If
|
|
398
|
-
// context.method was "next", forget context.arg since it has been
|
|
399
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
400
|
-
// "return", allow the original .return call to continue in the
|
|
401
|
-
// outer generator.
|
|
402
|
-
if (context.method !== "return") {
|
|
403
|
-
context.method = "next";
|
|
404
|
-
context.arg = undefined$1;
|
|
405
|
-
}
|
|
406
|
-
} else {
|
|
407
|
-
// Re-yield the result returned by the delegate method.
|
|
408
|
-
return info;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
412
|
-
// the outer generator.
|
|
413
|
-
context.delegate = null;
|
|
414
|
-
return ContinueSentinel;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
418
|
-
// unified ._invoke helper method.
|
|
419
|
-
defineIteratorMethods(Gp);
|
|
420
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
421
|
-
|
|
422
|
-
// A Generator should always return itself as the iterator object when the
|
|
423
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
424
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
425
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
426
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
427
|
-
define(Gp, iteratorSymbol, function () {
|
|
428
|
-
return this;
|
|
429
|
-
});
|
|
430
|
-
define(Gp, "toString", function () {
|
|
431
|
-
return "[object Generator]";
|
|
432
|
-
});
|
|
433
|
-
function pushTryEntry(locs) {
|
|
434
|
-
var entry = {
|
|
435
|
-
tryLoc: locs[0]
|
|
436
|
-
};
|
|
437
|
-
if (1 in locs) {
|
|
438
|
-
entry.catchLoc = locs[1];
|
|
439
|
-
}
|
|
440
|
-
if (2 in locs) {
|
|
441
|
-
entry.finallyLoc = locs[2];
|
|
442
|
-
entry.afterLoc = locs[3];
|
|
443
|
-
}
|
|
444
|
-
this.tryEntries.push(entry);
|
|
445
|
-
}
|
|
446
|
-
function resetTryEntry(entry) {
|
|
447
|
-
var record = entry.completion || {};
|
|
448
|
-
record.type = "normal";
|
|
449
|
-
delete record.arg;
|
|
450
|
-
entry.completion = record;
|
|
451
|
-
}
|
|
452
|
-
function Context(tryLocsList) {
|
|
453
|
-
// The root entry object (effectively a try statement without a catch
|
|
454
|
-
// or a finally block) gives us a place to store values thrown from
|
|
455
|
-
// locations where there is no enclosing try statement.
|
|
456
|
-
this.tryEntries = [{
|
|
457
|
-
tryLoc: "root"
|
|
458
|
-
}];
|
|
459
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
460
|
-
this.reset(true);
|
|
461
|
-
}
|
|
462
|
-
exports.keys = function (object) {
|
|
463
|
-
var keys = [];
|
|
464
|
-
for (var key in object) {
|
|
465
|
-
keys.push(key);
|
|
466
|
-
}
|
|
467
|
-
keys.reverse();
|
|
468
|
-
|
|
469
|
-
// Rather than returning an object with a next method, we keep
|
|
470
|
-
// things simple and return the next function itself.
|
|
471
|
-
return function next() {
|
|
472
|
-
while (keys.length) {
|
|
473
|
-
var key = keys.pop();
|
|
474
|
-
if (key in object) {
|
|
475
|
-
next.value = key;
|
|
476
|
-
next.done = false;
|
|
477
|
-
return next;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
// To avoid creating an additional object, we just hang the .value
|
|
482
|
-
// and .done properties off the next function object itself. This
|
|
483
|
-
// also ensures that the minifier will not anonymize the function.
|
|
484
|
-
next.done = true;
|
|
485
|
-
return next;
|
|
486
|
-
};
|
|
487
|
-
};
|
|
488
|
-
function values(iterable) {
|
|
489
|
-
if (iterable) {
|
|
490
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
491
|
-
if (iteratorMethod) {
|
|
492
|
-
return iteratorMethod.call(iterable);
|
|
493
|
-
}
|
|
494
|
-
if (typeof iterable.next === "function") {
|
|
495
|
-
return iterable;
|
|
496
|
-
}
|
|
497
|
-
if (!isNaN(iterable.length)) {
|
|
498
|
-
var i = -1,
|
|
499
|
-
next = function next() {
|
|
500
|
-
while (++i < iterable.length) {
|
|
501
|
-
if (hasOwn.call(iterable, i)) {
|
|
502
|
-
next.value = iterable[i];
|
|
503
|
-
next.done = false;
|
|
504
|
-
return next;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
next.value = undefined$1;
|
|
508
|
-
next.done = true;
|
|
509
|
-
return next;
|
|
510
|
-
};
|
|
511
|
-
return next.next = next;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// Return an iterator with no values.
|
|
516
|
-
return {
|
|
517
|
-
next: doneResult
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
exports.values = values;
|
|
521
|
-
function doneResult() {
|
|
522
|
-
return {
|
|
523
|
-
value: undefined$1,
|
|
524
|
-
done: true
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
Context.prototype = {
|
|
528
|
-
constructor: Context,
|
|
529
|
-
reset: function reset(skipTempReset) {
|
|
530
|
-
this.prev = 0;
|
|
531
|
-
this.next = 0;
|
|
532
|
-
// Resetting context._sent for legacy support of Babel's
|
|
533
|
-
// function.sent implementation.
|
|
534
|
-
this.sent = this._sent = undefined$1;
|
|
535
|
-
this.done = false;
|
|
536
|
-
this.delegate = null;
|
|
537
|
-
this.method = "next";
|
|
538
|
-
this.arg = undefined$1;
|
|
539
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
540
|
-
if (!skipTempReset) {
|
|
541
|
-
for (var name in this) {
|
|
542
|
-
// Not sure about the optimal order of these conditions:
|
|
543
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
544
|
-
this[name] = undefined$1;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
},
|
|
549
|
-
stop: function stop() {
|
|
550
|
-
this.done = true;
|
|
551
|
-
var rootEntry = this.tryEntries[0];
|
|
552
|
-
var rootRecord = rootEntry.completion;
|
|
553
|
-
if (rootRecord.type === "throw") {
|
|
554
|
-
throw rootRecord.arg;
|
|
555
|
-
}
|
|
556
|
-
return this.rval;
|
|
557
|
-
},
|
|
558
|
-
dispatchException: function dispatchException(exception) {
|
|
559
|
-
if (this.done) {
|
|
560
|
-
throw exception;
|
|
561
|
-
}
|
|
562
|
-
var context = this;
|
|
563
|
-
function handle(loc, caught) {
|
|
564
|
-
record.type = "throw";
|
|
565
|
-
record.arg = exception;
|
|
566
|
-
context.next = loc;
|
|
567
|
-
if (caught) {
|
|
568
|
-
// If the dispatched exception was caught by a catch block,
|
|
569
|
-
// then let that catch block handle the exception normally.
|
|
570
|
-
context.method = "next";
|
|
571
|
-
context.arg = undefined$1;
|
|
572
|
-
}
|
|
573
|
-
return !!caught;
|
|
574
|
-
}
|
|
575
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
576
|
-
var entry = this.tryEntries[i];
|
|
577
|
-
var record = entry.completion;
|
|
578
|
-
if (entry.tryLoc === "root") {
|
|
579
|
-
// Exception thrown outside of any try block that could handle
|
|
580
|
-
// it, so set the completion value of the entire function to
|
|
581
|
-
// throw the exception.
|
|
582
|
-
return handle("end");
|
|
583
|
-
}
|
|
584
|
-
if (entry.tryLoc <= this.prev) {
|
|
585
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
586
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
587
|
-
if (hasCatch && hasFinally) {
|
|
588
|
-
if (this.prev < entry.catchLoc) {
|
|
589
|
-
return handle(entry.catchLoc, true);
|
|
590
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
591
|
-
return handle(entry.finallyLoc);
|
|
592
|
-
}
|
|
593
|
-
} else if (hasCatch) {
|
|
594
|
-
if (this.prev < entry.catchLoc) {
|
|
595
|
-
return handle(entry.catchLoc, true);
|
|
596
|
-
}
|
|
597
|
-
} else if (hasFinally) {
|
|
598
|
-
if (this.prev < entry.finallyLoc) {
|
|
599
|
-
return handle(entry.finallyLoc);
|
|
600
|
-
}
|
|
601
|
-
} else {
|
|
602
|
-
throw new Error("try statement without catch or finally");
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
},
|
|
607
|
-
abrupt: function abrupt(type, arg) {
|
|
608
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
609
|
-
var entry = this.tryEntries[i];
|
|
610
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
611
|
-
var finallyEntry = entry;
|
|
612
|
-
break;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
616
|
-
// Ignore the finally entry if control is not jumping to a
|
|
617
|
-
// location outside the try/catch block.
|
|
618
|
-
finallyEntry = null;
|
|
619
|
-
}
|
|
620
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
621
|
-
record.type = type;
|
|
622
|
-
record.arg = arg;
|
|
623
|
-
if (finallyEntry) {
|
|
624
|
-
this.method = "next";
|
|
625
|
-
this.next = finallyEntry.finallyLoc;
|
|
626
|
-
return ContinueSentinel;
|
|
627
|
-
}
|
|
628
|
-
return this.complete(record);
|
|
629
|
-
},
|
|
630
|
-
complete: function complete(record, afterLoc) {
|
|
631
|
-
if (record.type === "throw") {
|
|
632
|
-
throw record.arg;
|
|
633
|
-
}
|
|
634
|
-
if (record.type === "break" || record.type === "continue") {
|
|
635
|
-
this.next = record.arg;
|
|
636
|
-
} else if (record.type === "return") {
|
|
637
|
-
this.rval = this.arg = record.arg;
|
|
638
|
-
this.method = "return";
|
|
639
|
-
this.next = "end";
|
|
640
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
641
|
-
this.next = afterLoc;
|
|
642
|
-
}
|
|
643
|
-
return ContinueSentinel;
|
|
644
|
-
},
|
|
645
|
-
finish: function finish(finallyLoc) {
|
|
646
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
647
|
-
var entry = this.tryEntries[i];
|
|
648
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
649
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
650
|
-
resetTryEntry(entry);
|
|
651
|
-
return ContinueSentinel;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
},
|
|
655
|
-
"catch": function _catch(tryLoc) {
|
|
656
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
657
|
-
var entry = this.tryEntries[i];
|
|
658
|
-
if (entry.tryLoc === tryLoc) {
|
|
659
|
-
var record = entry.completion;
|
|
660
|
-
if (record.type === "throw") {
|
|
661
|
-
var thrown = record.arg;
|
|
662
|
-
resetTryEntry(entry);
|
|
663
|
-
}
|
|
664
|
-
return thrown;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// The context.catch method must only be called with a location
|
|
669
|
-
// argument that corresponds to a known catch block.
|
|
670
|
-
throw new Error("illegal catch attempt");
|
|
671
|
-
},
|
|
672
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
673
|
-
this.delegate = {
|
|
674
|
-
iterator: values(iterable),
|
|
675
|
-
resultName: resultName,
|
|
676
|
-
nextLoc: nextLoc
|
|
677
|
-
};
|
|
678
|
-
if (this.method === "next") {
|
|
679
|
-
// Deliberately forget the last sent value so that we don't
|
|
680
|
-
// accidentally pass it on to the delegate.
|
|
681
|
-
this.arg = undefined$1;
|
|
682
|
-
}
|
|
683
|
-
return ContinueSentinel;
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
688
|
-
// or not, return the runtime object so that we can declare the variable
|
|
689
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
690
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
691
|
-
return exports;
|
|
692
|
-
}(
|
|
693
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
694
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
695
|
-
// object. Either way, the resulting object will be used to initialize
|
|
696
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
697
|
-
module.exports );
|
|
698
|
-
try {
|
|
699
|
-
regeneratorRuntime = runtime;
|
|
700
|
-
} catch (accidentalStrictMode) {
|
|
701
|
-
// This module should not be running in strict mode, so the above
|
|
702
|
-
// assignment should always work unless something is misconfigured. Just
|
|
703
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
704
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
705
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
706
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
707
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
708
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
709
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
710
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
711
|
-
if (typeof globalThis === "object") {
|
|
712
|
-
globalThis.regeneratorRuntime = runtime;
|
|
713
|
-
} else {
|
|
714
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
|
|
719
362
|
var getSortVariables = function getSortVariables(sort, isCategory) {
|
|
720
363
|
var output = undefined;
|
|
721
364
|
switch (sort) {
|
|
@@ -765,90 +408,82 @@ var removeCartCookie = function removeCartCookie() {
|
|
|
765
408
|
return removeCookies(COMMERCETOOLS_CART_COOKIE);
|
|
766
409
|
};
|
|
767
410
|
|
|
768
|
-
var
|
|
769
|
-
|
|
411
|
+
var _ref;
|
|
412
|
+
var createCart = function createCart(_x) {
|
|
413
|
+
return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch) {
|
|
770
414
|
var draft, cart;
|
|
771
|
-
return
|
|
772
|
-
while (1) {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return _context.stop();
|
|
796
|
-
}
|
|
415
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
416
|
+
while (1) switch (_context.prev = _context.next) {
|
|
417
|
+
case 0:
|
|
418
|
+
draft = {
|
|
419
|
+
currency: 'USD',
|
|
420
|
+
country: 'US'
|
|
421
|
+
};
|
|
422
|
+
_context.next = 3;
|
|
423
|
+
return fetch({
|
|
424
|
+
query: 'carts',
|
|
425
|
+
method: 'post',
|
|
426
|
+
body: draft
|
|
427
|
+
});
|
|
428
|
+
case 3:
|
|
429
|
+
cart = _context.sent;
|
|
430
|
+
if (!cart.body) {
|
|
431
|
+
removeCartCookie();
|
|
432
|
+
} else {
|
|
433
|
+
setCartId(cart.body.id);
|
|
434
|
+
}
|
|
435
|
+
return _context.abrupt("return", cart.body);
|
|
436
|
+
case 6:
|
|
437
|
+
case "end":
|
|
438
|
+
return _context.stop();
|
|
797
439
|
}
|
|
798
440
|
}, _callee);
|
|
799
|
-
}));
|
|
800
|
-
|
|
801
|
-
return _ref.apply(this, arguments);
|
|
802
|
-
};
|
|
803
|
-
}();
|
|
441
|
+
}))).apply(this, arguments);
|
|
442
|
+
};
|
|
804
443
|
|
|
805
|
-
var
|
|
806
|
-
|
|
444
|
+
var _ref$1;
|
|
445
|
+
var getActiveCart = function getActiveCart(_x) {
|
|
446
|
+
return (_ref$1 = _ref$1 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch) {
|
|
807
447
|
var cartId, activeCart;
|
|
808
|
-
return
|
|
809
|
-
while (1) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
_context.next = 7;
|
|
815
|
-
break;
|
|
816
|
-
}
|
|
817
|
-
_context.next = 4;
|
|
818
|
-
return fetch({
|
|
819
|
-
query: 'carts',
|
|
820
|
-
method: 'get',
|
|
821
|
-
variables: {
|
|
822
|
-
id: cartId
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
case 4:
|
|
826
|
-
activeCart = _context.sent.body;
|
|
827
|
-
_context.next = 10;
|
|
448
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
449
|
+
while (1) switch (_context.prev = _context.next) {
|
|
450
|
+
case 0:
|
|
451
|
+
cartId = getCartId();
|
|
452
|
+
if (!cartId) {
|
|
453
|
+
_context.next = 7;
|
|
828
454
|
break;
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
removeCartCookie();
|
|
837
|
-
} else {
|
|
838
|
-
setCartId(activeCart.id);
|
|
455
|
+
}
|
|
456
|
+
_context.next = 4;
|
|
457
|
+
return fetch({
|
|
458
|
+
query: 'carts',
|
|
459
|
+
method: 'get',
|
|
460
|
+
variables: {
|
|
461
|
+
id: cartId
|
|
839
462
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
463
|
+
});
|
|
464
|
+
case 4:
|
|
465
|
+
activeCart = _context.sent.body;
|
|
466
|
+
_context.next = 10;
|
|
467
|
+
break;
|
|
468
|
+
case 7:
|
|
469
|
+
_context.next = 9;
|
|
470
|
+
return createCart(fetch);
|
|
471
|
+
case 9:
|
|
472
|
+
activeCart = _context.sent;
|
|
473
|
+
case 10:
|
|
474
|
+
if (!activeCart) {
|
|
475
|
+
removeCartCookie();
|
|
476
|
+
} else {
|
|
477
|
+
setCartId(activeCart.id);
|
|
478
|
+
}
|
|
479
|
+
return _context.abrupt("return", activeCart);
|
|
480
|
+
case 12:
|
|
481
|
+
case "end":
|
|
482
|
+
return _context.stop();
|
|
845
483
|
}
|
|
846
484
|
}, _callee);
|
|
847
|
-
}));
|
|
848
|
-
|
|
849
|
-
return _ref.apply(this, arguments);
|
|
850
|
-
};
|
|
851
|
-
}();
|
|
485
|
+
}))).apply(this, arguments);
|
|
486
|
+
};
|
|
852
487
|
|
|
853
488
|
var getLocalizedString = function getLocalizedString(localizedString, locale) {
|
|
854
489
|
return !localizedString || !locale ? undefined : locale in localizedString ? localizedString[locale] : Object.values(localizedString)[0];
|
|
@@ -908,10 +543,10 @@ var normalizeProductImages = function normalizeProductImages(images) {
|
|
|
908
543
|
});
|
|
909
544
|
};
|
|
910
545
|
var normalizeProductVariant = function normalizeProductVariant(variant) {
|
|
911
|
-
var _variant$prices$find$, _variant$prices, _variant$
|
|
912
|
-
var price = money((_variant$prices$find$ = (_variant$prices = variant.prices) == null
|
|
546
|
+
var _variant$prices$find$, _variant$prices, _variant$prices2, _variant$sku, _variant$attributes$m, _variant$attributes;
|
|
547
|
+
var price = money((_variant$prices$find$ = (_variant$prices = variant.prices) == null || (_variant$prices = _variant$prices.find(function (price) {
|
|
913
548
|
return price.value.currencyCode === currencyCode;
|
|
914
|
-
})) == null ? void 0 : _variant$prices
|
|
549
|
+
})) == null ? void 0 : _variant$prices.value) != null ? _variant$prices$find$ : (_variant$prices2 = variant.prices) == null || (_variant$prices2 = _variant$prices2[0]) == null ? void 0 : _variant$prices2.value).value;
|
|
915
550
|
return {
|
|
916
551
|
id: "" + variant.id,
|
|
917
552
|
name: "" + variant.id,
|
|
@@ -928,16 +563,16 @@ var normalizeProductVariant = function normalizeProductVariant(variant) {
|
|
|
928
563
|
};
|
|
929
564
|
};
|
|
930
565
|
var normalizeProduct = function normalizeProduct(product, locale) {
|
|
931
|
-
var _getLocalizedString, _getLocalizedString2, _product$masterVarian, _product$masterVarian2, _product$masterVarian3
|
|
566
|
+
var _getLocalizedString, _getLocalizedString2, _product$masterVarian, _product$masterVarian2, _product$masterVarian3;
|
|
932
567
|
return {
|
|
933
568
|
id: product.id,
|
|
934
569
|
name: (_getLocalizedString = getLocalizedString(product.name, locale)) != null ? _getLocalizedString : "",
|
|
935
570
|
slug: getLocalizedString(product.slug, locale),
|
|
936
571
|
path: "/" + getLocalizedString(product.slug, locale),
|
|
937
572
|
description: (_getLocalizedString2 = getLocalizedString(product.description, locale)) != null ? _getLocalizedString2 : '',
|
|
938
|
-
price: money((_product$masterVarian = (_product$masterVarian2 = product.masterVariant.prices) == null
|
|
573
|
+
price: money((_product$masterVarian = (_product$masterVarian2 = product.masterVariant.prices) == null || (_product$masterVarian2 = _product$masterVarian2.find(function (price) {
|
|
939
574
|
return price.value.currencyCode === currencyCode;
|
|
940
|
-
})) == null ? void 0 : _product$
|
|
575
|
+
})) == null ? void 0 : _product$masterVarian2.value) != null ? _product$masterVarian : (_product$masterVarian3 = product.masterVariant.prices) == null || (_product$masterVarian3 = _product$masterVarian3[0]) == null ? void 0 : _product$masterVarian3.value),
|
|
941
576
|
images: normalizeProductImages(withoutNils([].concat(product.masterVariant.images ? product.masterVariant.images : [], product.variants.flatMap(function (variant) {
|
|
942
577
|
return variant.images;
|
|
943
578
|
})))),
|
|
@@ -1015,41 +650,39 @@ var handler = {
|
|
|
1015
650
|
query: "productProjections"
|
|
1016
651
|
},
|
|
1017
652
|
fetcher: function fetcher(_ref) {
|
|
1018
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
653
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1019
654
|
var _search;
|
|
1020
655
|
var input, options, fetch, provider, search, categoryId, sort, count, response;
|
|
1021
|
-
return
|
|
1022
|
-
while (1) {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
{
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
return _context.stop();
|
|
1052
|
-
}
|
|
656
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
657
|
+
while (1) switch (_context.prev = _context.next) {
|
|
658
|
+
case 0:
|
|
659
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch, provider = _ref.provider;
|
|
660
|
+
search = input.search, categoryId = input.categoryId, sort = input.sort, count = input.count;
|
|
661
|
+
_context.next = 4;
|
|
662
|
+
return fetch(_extends({}, options, {
|
|
663
|
+
variables: _extends({
|
|
664
|
+
expand: ["masterData.current"],
|
|
665
|
+
sort: getSortVariables(sort),
|
|
666
|
+
limit: count
|
|
667
|
+
}, search ?
|
|
668
|
+
// eslint-disable-next-line
|
|
669
|
+
{
|
|
670
|
+
search: (_search = {}, _search["text." + (provider == null ? void 0 : provider.locale)] = search, _search)
|
|
671
|
+
} : {}, categoryId ? {
|
|
672
|
+
filters: "categories.id: subtree(\"" + categoryId + "\")"
|
|
673
|
+
} : {})
|
|
674
|
+
}));
|
|
675
|
+
case 4:
|
|
676
|
+
response = _context.sent;
|
|
677
|
+
return _context.abrupt("return", {
|
|
678
|
+
products: response.body.results.map(function (product) {
|
|
679
|
+
return normalizeProduct(product, provider.locale);
|
|
680
|
+
}),
|
|
681
|
+
found: response.body.count > 0
|
|
682
|
+
});
|
|
683
|
+
case 6:
|
|
684
|
+
case "end":
|
|
685
|
+
return _context.stop();
|
|
1053
686
|
}
|
|
1054
687
|
}, _callee);
|
|
1055
688
|
}))();
|
|
@@ -1076,33 +709,31 @@ var handler$1 = {
|
|
|
1076
709
|
method: "get"
|
|
1077
710
|
},
|
|
1078
711
|
fetcher: function fetcher(_ref) {
|
|
1079
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
712
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1080
713
|
var input, options, fetch, provider, id, product;
|
|
1081
|
-
return
|
|
1082
|
-
while (1) {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
714
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
715
|
+
while (1) switch (_context.prev = _context.next) {
|
|
716
|
+
case 0:
|
|
717
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch, provider = _ref.provider;
|
|
718
|
+
id = input.id;
|
|
719
|
+
if (id) {
|
|
720
|
+
_context.next = 4;
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
return _context.abrupt("return", null);
|
|
724
|
+
case 4:
|
|
725
|
+
_context.next = 6;
|
|
726
|
+
return fetch(_extends({}, options, {
|
|
727
|
+
variables: {
|
|
728
|
+
id: id
|
|
1090
729
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}));
|
|
1099
|
-
case 6:
|
|
1100
|
-
product = _context.sent;
|
|
1101
|
-
return _context.abrupt("return", product.body ? normalizeProduct(product.body, provider.locale) : null);
|
|
1102
|
-
case 8:
|
|
1103
|
-
case "end":
|
|
1104
|
-
return _context.stop();
|
|
1105
|
-
}
|
|
730
|
+
}));
|
|
731
|
+
case 6:
|
|
732
|
+
product = _context.sent;
|
|
733
|
+
return _context.abrupt("return", product.body ? normalizeProduct(product.body, provider.locale) : null);
|
|
734
|
+
case 8:
|
|
735
|
+
case "end":
|
|
736
|
+
return _context.stop();
|
|
1106
737
|
}
|
|
1107
738
|
}, _callee);
|
|
1108
739
|
}))();
|
|
@@ -1129,22 +760,20 @@ var handler$2 = {
|
|
|
1129
760
|
method: "get"
|
|
1130
761
|
},
|
|
1131
762
|
fetcher: function fetcher(_ref) {
|
|
1132
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
763
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1133
764
|
var fetch, provider, activeCart;
|
|
1134
|
-
return
|
|
1135
|
-
while (1) {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
return _context.stop();
|
|
1147
|
-
}
|
|
765
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
766
|
+
while (1) switch (_context.prev = _context.next) {
|
|
767
|
+
case 0:
|
|
768
|
+
fetch = _ref.fetch, provider = _ref.provider;
|
|
769
|
+
_context.next = 3;
|
|
770
|
+
return getActiveCart(fetch);
|
|
771
|
+
case 3:
|
|
772
|
+
activeCart = _context.sent;
|
|
773
|
+
return _context.abrupt("return", activeCart ? normalizeCart(activeCart, provider.locale) : null);
|
|
774
|
+
case 5:
|
|
775
|
+
case "end":
|
|
776
|
+
return _context.stop();
|
|
1148
777
|
}
|
|
1149
778
|
}, _callee);
|
|
1150
779
|
}))();
|
|
@@ -1178,54 +807,52 @@ var handler$3 = {
|
|
|
1178
807
|
method: "post"
|
|
1179
808
|
},
|
|
1180
809
|
fetcher: function fetcher(_ref) {
|
|
1181
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
810
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1182
811
|
var _item$quantity;
|
|
1183
812
|
var item, fetch, provider, activeCart, lineItem, updatedCart;
|
|
1184
|
-
return
|
|
1185
|
-
while (1) {
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
return _context.stop();
|
|
1228
|
-
}
|
|
813
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
814
|
+
while (1) switch (_context.prev = _context.next) {
|
|
815
|
+
case 0:
|
|
816
|
+
item = _ref.input, fetch = _ref.fetch, provider = _ref.provider;
|
|
817
|
+
_context.next = 3;
|
|
818
|
+
return getActiveCart(fetch);
|
|
819
|
+
case 3:
|
|
820
|
+
activeCart = _context.sent;
|
|
821
|
+
if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1) || !activeCart)) {
|
|
822
|
+
_context.next = 6;
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
return _context.abrupt("return", undefined);
|
|
826
|
+
case 6:
|
|
827
|
+
lineItem = {
|
|
828
|
+
version: activeCart.version,
|
|
829
|
+
actions: [{
|
|
830
|
+
action: 'addLineItem',
|
|
831
|
+
variantId: +item.variantId,
|
|
832
|
+
productId: item.productId,
|
|
833
|
+
quantity: (_item$quantity = item.quantity) != null ? _item$quantity : 1
|
|
834
|
+
}]
|
|
835
|
+
};
|
|
836
|
+
_context.next = 9;
|
|
837
|
+
return fetch({
|
|
838
|
+
query: 'carts',
|
|
839
|
+
method: 'post',
|
|
840
|
+
variables: {
|
|
841
|
+
id: activeCart.id
|
|
842
|
+
},
|
|
843
|
+
body: lineItem
|
|
844
|
+
});
|
|
845
|
+
case 9:
|
|
846
|
+
updatedCart = _context.sent;
|
|
847
|
+
if (updatedCart.body) {
|
|
848
|
+
setCartId(updatedCart.body.id);
|
|
849
|
+
} else {
|
|
850
|
+
removeCartCookie();
|
|
851
|
+
}
|
|
852
|
+
return _context.abrupt("return", updatedCart.body ? normalizeCart(updatedCart.body, provider.locale) : undefined);
|
|
853
|
+
case 12:
|
|
854
|
+
case "end":
|
|
855
|
+
return _context.stop();
|
|
1229
856
|
}
|
|
1230
857
|
}, _callee);
|
|
1231
858
|
}))();
|
|
@@ -1233,37 +860,32 @@ var handler$3 = {
|
|
|
1233
860
|
useHook: function useHook(_ref2) {
|
|
1234
861
|
var fetch = _ref2.fetch;
|
|
1235
862
|
return function () {
|
|
863
|
+
var _addItem;
|
|
1236
864
|
var _useCart = commerce.useCart(),
|
|
1237
865
|
mutate = _useCart.mutate;
|
|
1238
|
-
return React.useCallback(
|
|
1239
|
-
|
|
866
|
+
return React.useCallback(function addItem(_x) {
|
|
867
|
+
return (_addItem = _addItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1240
868
|
var data;
|
|
1241
|
-
return
|
|
1242
|
-
while (1) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
return _context2.stop();
|
|
1258
|
-
}
|
|
869
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
870
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
871
|
+
case 0:
|
|
872
|
+
_context2.next = 2;
|
|
873
|
+
return fetch({
|
|
874
|
+
input: input
|
|
875
|
+
});
|
|
876
|
+
case 2:
|
|
877
|
+
data = _context2.sent;
|
|
878
|
+
_context2.next = 5;
|
|
879
|
+
return mutate(data, false);
|
|
880
|
+
case 5:
|
|
881
|
+
return _context2.abrupt("return", data);
|
|
882
|
+
case 6:
|
|
883
|
+
case "end":
|
|
884
|
+
return _context2.stop();
|
|
1259
885
|
}
|
|
1260
886
|
}, _callee2);
|
|
1261
|
-
}));
|
|
1262
|
-
|
|
1263
|
-
return _addItem.apply(this, arguments);
|
|
1264
|
-
}
|
|
1265
|
-
return addItem;
|
|
1266
|
-
}(), [fetch, mutate]);
|
|
887
|
+
}))).apply(this, arguments);
|
|
888
|
+
}, [fetch, mutate]);
|
|
1267
889
|
};
|
|
1268
890
|
}
|
|
1269
891
|
};
|
|
@@ -1274,39 +896,37 @@ var handler$4 = {
|
|
|
1274
896
|
method: "get"
|
|
1275
897
|
},
|
|
1276
898
|
fetcher: function fetcher(_ref) {
|
|
1277
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
899
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1278
900
|
var input, options, fetch, provider, categoryId, categories, category;
|
|
1279
|
-
return
|
|
1280
|
-
while (1) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
return
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
return _context.stop();
|
|
1309
|
-
}
|
|
901
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
902
|
+
while (1) switch (_context.prev = _context.next) {
|
|
903
|
+
case 0:
|
|
904
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch, provider = _ref.provider;
|
|
905
|
+
categoryId = input.categoryId;
|
|
906
|
+
if (categoryId) {
|
|
907
|
+
_context.next = 9;
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
_context.next = 5;
|
|
911
|
+
return fetch(_extends({}, options));
|
|
912
|
+
case 5:
|
|
913
|
+
categories = _context.sent;
|
|
914
|
+
return _context.abrupt("return", categories.body ? categories.body.results.map(function (category) {
|
|
915
|
+
return normalizeCategory(category, provider.locale);
|
|
916
|
+
}) : []);
|
|
917
|
+
case 9:
|
|
918
|
+
_context.next = 11;
|
|
919
|
+
return fetch(_extends({}, options, {
|
|
920
|
+
variables: _extends({}, categoryId ? {
|
|
921
|
+
id: categoryId
|
|
922
|
+
} : {})
|
|
923
|
+
}));
|
|
924
|
+
case 11:
|
|
925
|
+
category = _context.sent;
|
|
926
|
+
return _context.abrupt("return", category.body ? [normalizeCategory(category.body, provider.locale)] : []);
|
|
927
|
+
case 13:
|
|
928
|
+
case "end":
|
|
929
|
+
return _context.stop();
|
|
1310
930
|
}
|
|
1311
931
|
}, _callee);
|
|
1312
932
|
}))();
|
|
@@ -1340,16 +960,14 @@ var handler$5 = {
|
|
|
1340
960
|
query: ""
|
|
1341
961
|
},
|
|
1342
962
|
fetcher: function fetcher(_ref) {
|
|
1343
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1344
|
-
return
|
|
1345
|
-
while (1) {
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
return _context.stop();
|
|
1352
|
-
}
|
|
963
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
964
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
965
|
+
while (1) switch (_context.prev = _context.next) {
|
|
966
|
+
case 0:
|
|
967
|
+
return _context.abrupt("return", null);
|
|
968
|
+
case 2:
|
|
969
|
+
case "end":
|
|
970
|
+
return _context.stop();
|
|
1353
971
|
}
|
|
1354
972
|
}, _callee);
|
|
1355
973
|
}))();
|
|
@@ -1400,57 +1018,53 @@ var initCommercetoolsSDKClient = function initCommercetoolsSDKClient(creds) {
|
|
|
1400
1018
|
};
|
|
1401
1019
|
|
|
1402
1020
|
var getFetcher = function getFetcher(creds) {
|
|
1021
|
+
var _ref2;
|
|
1403
1022
|
var client = initCommercetoolsSDKClient(creds);
|
|
1404
1023
|
var apiRoot = platformSdk.createApiBuilderFromCtpClient(client).withProjectKey({
|
|
1405
1024
|
projectKey: creds.projectKey
|
|
1406
1025
|
});
|
|
1407
|
-
return
|
|
1408
|
-
|
|
1026
|
+
return function (_x) {
|
|
1027
|
+
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
1409
1028
|
var method, variables, query, body, queryBuilder;
|
|
1410
|
-
return
|
|
1411
|
-
while (1) {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
return _context.stop();
|
|
1446
|
-
}
|
|
1029
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1030
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1031
|
+
case 0:
|
|
1032
|
+
method = _ref.method, variables = _ref.variables, query = _ref.query, body = _ref.body;
|
|
1033
|
+
queryBuilder = apiRoot;
|
|
1034
|
+
if (query) {
|
|
1035
|
+
queryBuilder = queryBuilder[query]();
|
|
1036
|
+
}
|
|
1037
|
+
if (variables != null && variables.id) {
|
|
1038
|
+
queryBuilder = queryBuilder.withId({
|
|
1039
|
+
ID: variables.id
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
if (variables != null && variables.search) {
|
|
1043
|
+
queryBuilder = queryBuilder.search();
|
|
1044
|
+
}
|
|
1045
|
+
_context.next = 7;
|
|
1046
|
+
return queryBuilder[method]({
|
|
1047
|
+
body: body,
|
|
1048
|
+
queryArgs: _extends({
|
|
1049
|
+
expand: variables == null ? void 0 : variables.expand,
|
|
1050
|
+
limit: variables == null ? void 0 : variables.limit
|
|
1051
|
+
}, variables != null && variables.sort ? {
|
|
1052
|
+
sort: variables.sort
|
|
1053
|
+
} : {}, variables != null && variables.search ? variables.search : {}, variables != null && variables.filters ? {
|
|
1054
|
+
filter: variables.filters
|
|
1055
|
+
} : {}, variables != null && variables.where ? {
|
|
1056
|
+
where: variables.where
|
|
1057
|
+
} : {})
|
|
1058
|
+
}).execute();
|
|
1059
|
+
case 7:
|
|
1060
|
+
return _context.abrupt("return", _context.sent);
|
|
1061
|
+
case 8:
|
|
1062
|
+
case "end":
|
|
1063
|
+
return _context.stop();
|
|
1447
1064
|
}
|
|
1448
1065
|
}, _callee);
|
|
1449
|
-
}));
|
|
1450
|
-
|
|
1451
|
-
return _ref2.apply(this, arguments);
|
|
1452
|
-
};
|
|
1453
|
-
}();
|
|
1066
|
+
}))).apply(this, arguments);
|
|
1067
|
+
};
|
|
1454
1068
|
};
|
|
1455
1069
|
|
|
1456
1070
|
var getCommercetoolsProvider = function getCommercetoolsProvider(creds, locale) {
|
|
@@ -1523,24 +1137,22 @@ function CommerceProviderComponent(props) {
|
|
|
1523
1137
|
}, [projectKey, clientId, clientSecret, region]);
|
|
1524
1138
|
var _usePlasmicQueryData = query.usePlasmicQueryData(JSON.stringify({
|
|
1525
1139
|
creds: creds
|
|
1526
|
-
}) + "locale", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
1140
|
+
}) + "locale", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1527
1141
|
var fetcher, project;
|
|
1528
|
-
return
|
|
1529
|
-
while (1) {
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
return _context.stop();
|
|
1543
|
-
}
|
|
1142
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1143
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1144
|
+
case 0:
|
|
1145
|
+
fetcher = getFetcher(creds);
|
|
1146
|
+
_context.next = 3;
|
|
1147
|
+
return fetcher({
|
|
1148
|
+
method: "get"
|
|
1149
|
+
});
|
|
1150
|
+
case 3:
|
|
1151
|
+
project = _context.sent;
|
|
1152
|
+
return _context.abrupt("return", project.body ? project.body.languages[0] : undefined);
|
|
1153
|
+
case 5:
|
|
1154
|
+
case "end":
|
|
1155
|
+
return _context.stop();
|
|
1544
1156
|
}
|
|
1545
1157
|
}, _callee);
|
|
1546
1158
|
}))),
|