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