@plasmicpkgs/commerce 0.0.158 → 0.0.160
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.cjs.development.js +403 -772
- package/dist/commerce.cjs.development.js.map +1 -1
- package/dist/commerce.cjs.production.min.js +1 -1
- package/dist/commerce.cjs.production.min.js.map +1 -1
- package/dist/commerce.d.ts +3 -3
- package/dist/commerce.esm.js +403 -772
- package/dist/commerce.esm.js.map +1 -1
- package/dist/contexts.d.ts +4 -4
- package/dist/registerAddToCartButton.d.ts +1 -1
- package/dist/registerCart.d.ts +2 -1
- package/dist/registerCartProvider.d.ts +1 -1
- package/dist/registerCategoryCollection.d.ts +1 -1
- package/dist/registerCategoryField.d.ts +2 -1
- package/dist/registerCategoryLink.d.ts +1 -1
- package/dist/registerProductBox.d.ts +1 -1
- package/dist/registerProductCollection.d.ts +1 -1
- package/dist/registerProductLink.d.ts +1 -1
- package/dist/registerProductMediaCollection.d.ts +1 -1
- package/dist/registerProductPrice.d.ts +2 -1
- package/dist/registerProductQuantity.d.ts +1 -1
- package/dist/registerProductSlider.d.ts +1 -1
- package/dist/registerProductTextField.d.ts +2 -1
- package/dist/registerProductVariantPicker.d.ts +2 -1
- package/package.json +3 -3
- package/LICENSE.md +0 -21
|
@@ -13,6 +13,307 @@ var host = require('@plasmicapp/host');
|
|
|
13
13
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
14
14
|
var debounce = _interopDefault(require('debounce'));
|
|
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);
|
|
@@ -174,664 +475,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
174
475
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
175
476
|
}
|
|
176
477
|
|
|
177
|
-
function createCommonjsModule(fn, module) {
|
|
178
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
182
|
-
/**
|
|
183
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
184
|
-
*
|
|
185
|
-
* This source code is licensed under the MIT license found in the
|
|
186
|
-
* LICENSE file in the root directory of this source tree.
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
var runtime = function (exports) {
|
|
190
|
-
|
|
191
|
-
var Op = Object.prototype;
|
|
192
|
-
var hasOwn = Op.hasOwnProperty;
|
|
193
|
-
var undefined$1; // More compressible than void 0.
|
|
194
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
195
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
196
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
197
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
198
|
-
function define(obj, key, value) {
|
|
199
|
-
Object.defineProperty(obj, key, {
|
|
200
|
-
value: value,
|
|
201
|
-
enumerable: true,
|
|
202
|
-
configurable: true,
|
|
203
|
-
writable: true
|
|
204
|
-
});
|
|
205
|
-
return obj[key];
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
209
|
-
define({}, "");
|
|
210
|
-
} catch (err) {
|
|
211
|
-
define = function define(obj, key, value) {
|
|
212
|
-
return obj[key] = value;
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
216
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
217
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
218
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
219
|
-
var context = new Context(tryLocsList || []);
|
|
220
|
-
|
|
221
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
222
|
-
// .throw, and .return methods.
|
|
223
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
224
|
-
return generator;
|
|
225
|
-
}
|
|
226
|
-
exports.wrap = wrap;
|
|
227
|
-
|
|
228
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
229
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
230
|
-
// have been (and was previously) designed to take a closure to be
|
|
231
|
-
// invoked without arguments, but in all the cases we care about we
|
|
232
|
-
// already have an existing method we want to call, so there's no need
|
|
233
|
-
// to create a new function object. We can even get away with assuming
|
|
234
|
-
// the method takes exactly one argument, since that happens to be true
|
|
235
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
236
|
-
// only additional allocation required is the completion record, which
|
|
237
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
238
|
-
function tryCatch(fn, obj, arg) {
|
|
239
|
-
try {
|
|
240
|
-
return {
|
|
241
|
-
type: "normal",
|
|
242
|
-
arg: fn.call(obj, arg)
|
|
243
|
-
};
|
|
244
|
-
} catch (err) {
|
|
245
|
-
return {
|
|
246
|
-
type: "throw",
|
|
247
|
-
arg: err
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
252
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
253
|
-
var GenStateExecuting = "executing";
|
|
254
|
-
var GenStateCompleted = "completed";
|
|
255
|
-
|
|
256
|
-
// Returning this object from the innerFn has the same effect as
|
|
257
|
-
// breaking out of the dispatch switch statement.
|
|
258
|
-
var ContinueSentinel = {};
|
|
259
|
-
|
|
260
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
261
|
-
// .constructor.prototype properties for functions that return Generator
|
|
262
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
263
|
-
// minifier not to mangle the names of these two functions.
|
|
264
|
-
function Generator() {}
|
|
265
|
-
function GeneratorFunction() {}
|
|
266
|
-
function GeneratorFunctionPrototype() {}
|
|
267
|
-
|
|
268
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
269
|
-
// don't natively support it.
|
|
270
|
-
var IteratorPrototype = {};
|
|
271
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
272
|
-
return this;
|
|
273
|
-
});
|
|
274
|
-
var getProto = Object.getPrototypeOf;
|
|
275
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
276
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
277
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
278
|
-
// of the polyfill.
|
|
279
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
280
|
-
}
|
|
281
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
282
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
283
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
284
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
285
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
286
|
-
|
|
287
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
288
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
289
|
-
function defineIteratorMethods(prototype) {
|
|
290
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
291
|
-
define(prototype, method, function (arg) {
|
|
292
|
-
return this._invoke(method, arg);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
297
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
298
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
299
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
300
|
-
// do is to check its .name property.
|
|
301
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
302
|
-
};
|
|
303
|
-
exports.mark = function (genFun) {
|
|
304
|
-
if (Object.setPrototypeOf) {
|
|
305
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
306
|
-
} else {
|
|
307
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
308
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
309
|
-
}
|
|
310
|
-
genFun.prototype = Object.create(Gp);
|
|
311
|
-
return genFun;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
// Within the body of any async function, `await x` is transformed to
|
|
315
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
316
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
317
|
-
// meant to be awaited.
|
|
318
|
-
exports.awrap = function (arg) {
|
|
319
|
-
return {
|
|
320
|
-
__await: arg
|
|
321
|
-
};
|
|
322
|
-
};
|
|
323
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
324
|
-
function invoke(method, arg, resolve, reject) {
|
|
325
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
326
|
-
if (record.type === "throw") {
|
|
327
|
-
reject(record.arg);
|
|
328
|
-
} else {
|
|
329
|
-
var result = record.arg;
|
|
330
|
-
var value = result.value;
|
|
331
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
332
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
333
|
-
invoke("next", value, resolve, reject);
|
|
334
|
-
}, function (err) {
|
|
335
|
-
invoke("throw", err, resolve, reject);
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
339
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
340
|
-
// the .value of the Promise<{value,done}> result for the
|
|
341
|
-
// current iteration.
|
|
342
|
-
result.value = unwrapped;
|
|
343
|
-
resolve(result);
|
|
344
|
-
}, function (error) {
|
|
345
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
346
|
-
// into the async generator function so it can be handled there.
|
|
347
|
-
return invoke("throw", error, resolve, reject);
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
var previousPromise;
|
|
352
|
-
function enqueue(method, arg) {
|
|
353
|
-
function callInvokeWithMethodAndArg() {
|
|
354
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
355
|
-
invoke(method, arg, resolve, reject);
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
return previousPromise =
|
|
359
|
-
// If enqueue has been called before, then we want to wait until
|
|
360
|
-
// all previous Promises have been resolved before calling invoke,
|
|
361
|
-
// so that results are always delivered in the correct order. If
|
|
362
|
-
// enqueue has not been called before, then it is important to
|
|
363
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
364
|
-
// so that the async generator function has the opportunity to do
|
|
365
|
-
// any necessary setup in a predictable way. This predictability
|
|
366
|
-
// is why the Promise constructor synchronously invokes its
|
|
367
|
-
// executor callback, and why async functions synchronously
|
|
368
|
-
// execute code before the first await. Since we implement simple
|
|
369
|
-
// async functions in terms of async generators, it is especially
|
|
370
|
-
// important to get this right, even though it requires care.
|
|
371
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
372
|
-
// Avoid propagating failures to Promises returned by later
|
|
373
|
-
// invocations of the iterator.
|
|
374
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Define the unified helper method that is used to implement .next,
|
|
378
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
379
|
-
this._invoke = enqueue;
|
|
380
|
-
}
|
|
381
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
382
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
383
|
-
return this;
|
|
384
|
-
});
|
|
385
|
-
exports.AsyncIterator = AsyncIterator;
|
|
386
|
-
|
|
387
|
-
// Note that simple async functions are implemented on top of
|
|
388
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
389
|
-
// the final result produced by the iterator.
|
|
390
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
391
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
392
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
393
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
394
|
-
: iter.next().then(function (result) {
|
|
395
|
-
return result.done ? result.value : iter.next();
|
|
396
|
-
});
|
|
397
|
-
};
|
|
398
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
399
|
-
var state = GenStateSuspendedStart;
|
|
400
|
-
return function invoke(method, arg) {
|
|
401
|
-
if (state === GenStateExecuting) {
|
|
402
|
-
throw new Error("Generator is already running");
|
|
403
|
-
}
|
|
404
|
-
if (state === GenStateCompleted) {
|
|
405
|
-
if (method === "throw") {
|
|
406
|
-
throw arg;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
410
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
411
|
-
return doneResult();
|
|
412
|
-
}
|
|
413
|
-
context.method = method;
|
|
414
|
-
context.arg = arg;
|
|
415
|
-
while (true) {
|
|
416
|
-
var delegate = context.delegate;
|
|
417
|
-
if (delegate) {
|
|
418
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
419
|
-
if (delegateResult) {
|
|
420
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
421
|
-
return delegateResult;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (context.method === "next") {
|
|
425
|
-
// Setting context._sent for legacy support of Babel's
|
|
426
|
-
// function.sent implementation.
|
|
427
|
-
context.sent = context._sent = context.arg;
|
|
428
|
-
} else if (context.method === "throw") {
|
|
429
|
-
if (state === GenStateSuspendedStart) {
|
|
430
|
-
state = GenStateCompleted;
|
|
431
|
-
throw context.arg;
|
|
432
|
-
}
|
|
433
|
-
context.dispatchException(context.arg);
|
|
434
|
-
} else if (context.method === "return") {
|
|
435
|
-
context.abrupt("return", context.arg);
|
|
436
|
-
}
|
|
437
|
-
state = GenStateExecuting;
|
|
438
|
-
var record = tryCatch(innerFn, self, context);
|
|
439
|
-
if (record.type === "normal") {
|
|
440
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
441
|
-
// GenStateExecuting and loop back for another invocation.
|
|
442
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
443
|
-
if (record.arg === ContinueSentinel) {
|
|
444
|
-
continue;
|
|
445
|
-
}
|
|
446
|
-
return {
|
|
447
|
-
value: record.arg,
|
|
448
|
-
done: context.done
|
|
449
|
-
};
|
|
450
|
-
} else if (record.type === "throw") {
|
|
451
|
-
state = GenStateCompleted;
|
|
452
|
-
// Dispatch the exception by looping back around to the
|
|
453
|
-
// context.dispatchException(context.arg) call above.
|
|
454
|
-
context.method = "throw";
|
|
455
|
-
context.arg = record.arg;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
462
|
-
// result, either by returning a { value, done } result from the
|
|
463
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
464
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
465
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
466
|
-
var method = delegate.iterator[context.method];
|
|
467
|
-
if (method === undefined$1) {
|
|
468
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
469
|
-
// method always terminates the yield* loop.
|
|
470
|
-
context.delegate = null;
|
|
471
|
-
if (context.method === "throw") {
|
|
472
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
473
|
-
if (delegate.iterator["return"]) {
|
|
474
|
-
// If the delegate iterator has a return method, give it a
|
|
475
|
-
// chance to clean up.
|
|
476
|
-
context.method = "return";
|
|
477
|
-
context.arg = undefined$1;
|
|
478
|
-
maybeInvokeDelegate(delegate, context);
|
|
479
|
-
if (context.method === "throw") {
|
|
480
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
481
|
-
// "return" to "throw", let that override the TypeError below.
|
|
482
|
-
return ContinueSentinel;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
context.method = "throw";
|
|
486
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
487
|
-
}
|
|
488
|
-
return ContinueSentinel;
|
|
489
|
-
}
|
|
490
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
491
|
-
if (record.type === "throw") {
|
|
492
|
-
context.method = "throw";
|
|
493
|
-
context.arg = record.arg;
|
|
494
|
-
context.delegate = null;
|
|
495
|
-
return ContinueSentinel;
|
|
496
|
-
}
|
|
497
|
-
var info = record.arg;
|
|
498
|
-
if (!info) {
|
|
499
|
-
context.method = "throw";
|
|
500
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
501
|
-
context.delegate = null;
|
|
502
|
-
return ContinueSentinel;
|
|
503
|
-
}
|
|
504
|
-
if (info.done) {
|
|
505
|
-
// Assign the result of the finished delegate to the temporary
|
|
506
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
507
|
-
context[delegate.resultName] = info.value;
|
|
508
|
-
|
|
509
|
-
// Resume execution at the desired location (see delegateYield).
|
|
510
|
-
context.next = delegate.nextLoc;
|
|
511
|
-
|
|
512
|
-
// If context.method was "throw" but the delegate handled the
|
|
513
|
-
// exception, let the outer generator proceed normally. If
|
|
514
|
-
// context.method was "next", forget context.arg since it has been
|
|
515
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
516
|
-
// "return", allow the original .return call to continue in the
|
|
517
|
-
// outer generator.
|
|
518
|
-
if (context.method !== "return") {
|
|
519
|
-
context.method = "next";
|
|
520
|
-
context.arg = undefined$1;
|
|
521
|
-
}
|
|
522
|
-
} else {
|
|
523
|
-
// Re-yield the result returned by the delegate method.
|
|
524
|
-
return info;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
528
|
-
// the outer generator.
|
|
529
|
-
context.delegate = null;
|
|
530
|
-
return ContinueSentinel;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
534
|
-
// unified ._invoke helper method.
|
|
535
|
-
defineIteratorMethods(Gp);
|
|
536
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
537
|
-
|
|
538
|
-
// A Generator should always return itself as the iterator object when the
|
|
539
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
540
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
541
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
542
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
543
|
-
define(Gp, iteratorSymbol, function () {
|
|
544
|
-
return this;
|
|
545
|
-
});
|
|
546
|
-
define(Gp, "toString", function () {
|
|
547
|
-
return "[object Generator]";
|
|
548
|
-
});
|
|
549
|
-
function pushTryEntry(locs) {
|
|
550
|
-
var entry = {
|
|
551
|
-
tryLoc: locs[0]
|
|
552
|
-
};
|
|
553
|
-
if (1 in locs) {
|
|
554
|
-
entry.catchLoc = locs[1];
|
|
555
|
-
}
|
|
556
|
-
if (2 in locs) {
|
|
557
|
-
entry.finallyLoc = locs[2];
|
|
558
|
-
entry.afterLoc = locs[3];
|
|
559
|
-
}
|
|
560
|
-
this.tryEntries.push(entry);
|
|
561
|
-
}
|
|
562
|
-
function resetTryEntry(entry) {
|
|
563
|
-
var record = entry.completion || {};
|
|
564
|
-
record.type = "normal";
|
|
565
|
-
delete record.arg;
|
|
566
|
-
entry.completion = record;
|
|
567
|
-
}
|
|
568
|
-
function Context(tryLocsList) {
|
|
569
|
-
// The root entry object (effectively a try statement without a catch
|
|
570
|
-
// or a finally block) gives us a place to store values thrown from
|
|
571
|
-
// locations where there is no enclosing try statement.
|
|
572
|
-
this.tryEntries = [{
|
|
573
|
-
tryLoc: "root"
|
|
574
|
-
}];
|
|
575
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
576
|
-
this.reset(true);
|
|
577
|
-
}
|
|
578
|
-
exports.keys = function (object) {
|
|
579
|
-
var keys = [];
|
|
580
|
-
for (var key in object) {
|
|
581
|
-
keys.push(key);
|
|
582
|
-
}
|
|
583
|
-
keys.reverse();
|
|
584
|
-
|
|
585
|
-
// Rather than returning an object with a next method, we keep
|
|
586
|
-
// things simple and return the next function itself.
|
|
587
|
-
return function next() {
|
|
588
|
-
while (keys.length) {
|
|
589
|
-
var key = keys.pop();
|
|
590
|
-
if (key in object) {
|
|
591
|
-
next.value = key;
|
|
592
|
-
next.done = false;
|
|
593
|
-
return next;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
// To avoid creating an additional object, we just hang the .value
|
|
598
|
-
// and .done properties off the next function object itself. This
|
|
599
|
-
// also ensures that the minifier will not anonymize the function.
|
|
600
|
-
next.done = true;
|
|
601
|
-
return next;
|
|
602
|
-
};
|
|
603
|
-
};
|
|
604
|
-
function values(iterable) {
|
|
605
|
-
if (iterable) {
|
|
606
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
607
|
-
if (iteratorMethod) {
|
|
608
|
-
return iteratorMethod.call(iterable);
|
|
609
|
-
}
|
|
610
|
-
if (typeof iterable.next === "function") {
|
|
611
|
-
return iterable;
|
|
612
|
-
}
|
|
613
|
-
if (!isNaN(iterable.length)) {
|
|
614
|
-
var i = -1,
|
|
615
|
-
next = function next() {
|
|
616
|
-
while (++i < iterable.length) {
|
|
617
|
-
if (hasOwn.call(iterable, i)) {
|
|
618
|
-
next.value = iterable[i];
|
|
619
|
-
next.done = false;
|
|
620
|
-
return next;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
next.value = undefined$1;
|
|
624
|
-
next.done = true;
|
|
625
|
-
return next;
|
|
626
|
-
};
|
|
627
|
-
return next.next = next;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// Return an iterator with no values.
|
|
632
|
-
return {
|
|
633
|
-
next: doneResult
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
exports.values = values;
|
|
637
|
-
function doneResult() {
|
|
638
|
-
return {
|
|
639
|
-
value: undefined$1,
|
|
640
|
-
done: true
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
Context.prototype = {
|
|
644
|
-
constructor: Context,
|
|
645
|
-
reset: function reset(skipTempReset) {
|
|
646
|
-
this.prev = 0;
|
|
647
|
-
this.next = 0;
|
|
648
|
-
// Resetting context._sent for legacy support of Babel's
|
|
649
|
-
// function.sent implementation.
|
|
650
|
-
this.sent = this._sent = undefined$1;
|
|
651
|
-
this.done = false;
|
|
652
|
-
this.delegate = null;
|
|
653
|
-
this.method = "next";
|
|
654
|
-
this.arg = undefined$1;
|
|
655
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
656
|
-
if (!skipTempReset) {
|
|
657
|
-
for (var name in this) {
|
|
658
|
-
// Not sure about the optimal order of these conditions:
|
|
659
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
660
|
-
this[name] = undefined$1;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
},
|
|
665
|
-
stop: function stop() {
|
|
666
|
-
this.done = true;
|
|
667
|
-
var rootEntry = this.tryEntries[0];
|
|
668
|
-
var rootRecord = rootEntry.completion;
|
|
669
|
-
if (rootRecord.type === "throw") {
|
|
670
|
-
throw rootRecord.arg;
|
|
671
|
-
}
|
|
672
|
-
return this.rval;
|
|
673
|
-
},
|
|
674
|
-
dispatchException: function dispatchException(exception) {
|
|
675
|
-
if (this.done) {
|
|
676
|
-
throw exception;
|
|
677
|
-
}
|
|
678
|
-
var context = this;
|
|
679
|
-
function handle(loc, caught) {
|
|
680
|
-
record.type = "throw";
|
|
681
|
-
record.arg = exception;
|
|
682
|
-
context.next = loc;
|
|
683
|
-
if (caught) {
|
|
684
|
-
// If the dispatched exception was caught by a catch block,
|
|
685
|
-
// then let that catch block handle the exception normally.
|
|
686
|
-
context.method = "next";
|
|
687
|
-
context.arg = undefined$1;
|
|
688
|
-
}
|
|
689
|
-
return !!caught;
|
|
690
|
-
}
|
|
691
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
692
|
-
var entry = this.tryEntries[i];
|
|
693
|
-
var record = entry.completion;
|
|
694
|
-
if (entry.tryLoc === "root") {
|
|
695
|
-
// Exception thrown outside of any try block that could handle
|
|
696
|
-
// it, so set the completion value of the entire function to
|
|
697
|
-
// throw the exception.
|
|
698
|
-
return handle("end");
|
|
699
|
-
}
|
|
700
|
-
if (entry.tryLoc <= this.prev) {
|
|
701
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
702
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
703
|
-
if (hasCatch && hasFinally) {
|
|
704
|
-
if (this.prev < entry.catchLoc) {
|
|
705
|
-
return handle(entry.catchLoc, true);
|
|
706
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
707
|
-
return handle(entry.finallyLoc);
|
|
708
|
-
}
|
|
709
|
-
} else if (hasCatch) {
|
|
710
|
-
if (this.prev < entry.catchLoc) {
|
|
711
|
-
return handle(entry.catchLoc, true);
|
|
712
|
-
}
|
|
713
|
-
} else if (hasFinally) {
|
|
714
|
-
if (this.prev < entry.finallyLoc) {
|
|
715
|
-
return handle(entry.finallyLoc);
|
|
716
|
-
}
|
|
717
|
-
} else {
|
|
718
|
-
throw new Error("try statement without catch or finally");
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
},
|
|
723
|
-
abrupt: function abrupt(type, arg) {
|
|
724
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
725
|
-
var entry = this.tryEntries[i];
|
|
726
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
727
|
-
var finallyEntry = entry;
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
732
|
-
// Ignore the finally entry if control is not jumping to a
|
|
733
|
-
// location outside the try/catch block.
|
|
734
|
-
finallyEntry = null;
|
|
735
|
-
}
|
|
736
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
737
|
-
record.type = type;
|
|
738
|
-
record.arg = arg;
|
|
739
|
-
if (finallyEntry) {
|
|
740
|
-
this.method = "next";
|
|
741
|
-
this.next = finallyEntry.finallyLoc;
|
|
742
|
-
return ContinueSentinel;
|
|
743
|
-
}
|
|
744
|
-
return this.complete(record);
|
|
745
|
-
},
|
|
746
|
-
complete: function complete(record, afterLoc) {
|
|
747
|
-
if (record.type === "throw") {
|
|
748
|
-
throw record.arg;
|
|
749
|
-
}
|
|
750
|
-
if (record.type === "break" || record.type === "continue") {
|
|
751
|
-
this.next = record.arg;
|
|
752
|
-
} else if (record.type === "return") {
|
|
753
|
-
this.rval = this.arg = record.arg;
|
|
754
|
-
this.method = "return";
|
|
755
|
-
this.next = "end";
|
|
756
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
757
|
-
this.next = afterLoc;
|
|
758
|
-
}
|
|
759
|
-
return ContinueSentinel;
|
|
760
|
-
},
|
|
761
|
-
finish: function finish(finallyLoc) {
|
|
762
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
763
|
-
var entry = this.tryEntries[i];
|
|
764
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
765
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
766
|
-
resetTryEntry(entry);
|
|
767
|
-
return ContinueSentinel;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
},
|
|
771
|
-
"catch": function _catch(tryLoc) {
|
|
772
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
773
|
-
var entry = this.tryEntries[i];
|
|
774
|
-
if (entry.tryLoc === tryLoc) {
|
|
775
|
-
var record = entry.completion;
|
|
776
|
-
if (record.type === "throw") {
|
|
777
|
-
var thrown = record.arg;
|
|
778
|
-
resetTryEntry(entry);
|
|
779
|
-
}
|
|
780
|
-
return thrown;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// The context.catch method must only be called with a location
|
|
785
|
-
// argument that corresponds to a known catch block.
|
|
786
|
-
throw new Error("illegal catch attempt");
|
|
787
|
-
},
|
|
788
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
789
|
-
this.delegate = {
|
|
790
|
-
iterator: values(iterable),
|
|
791
|
-
resultName: resultName,
|
|
792
|
-
nextLoc: nextLoc
|
|
793
|
-
};
|
|
794
|
-
if (this.method === "next") {
|
|
795
|
-
// Deliberately forget the last sent value so that we don't
|
|
796
|
-
// accidentally pass it on to the delegate.
|
|
797
|
-
this.arg = undefined$1;
|
|
798
|
-
}
|
|
799
|
-
return ContinueSentinel;
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
804
|
-
// or not, return the runtime object so that we can declare the variable
|
|
805
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
806
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
807
|
-
return exports;
|
|
808
|
-
}(
|
|
809
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
810
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
811
|
-
// object. Either way, the resulting object will be used to initialize
|
|
812
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
813
|
-
module.exports );
|
|
814
|
-
try {
|
|
815
|
-
regeneratorRuntime = runtime;
|
|
816
|
-
} catch (accidentalStrictMode) {
|
|
817
|
-
// This module should not be running in strict mode, so the above
|
|
818
|
-
// assignment should always work unless something is misconfigured. Just
|
|
819
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
820
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
821
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
822
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
823
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
824
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
825
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
826
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
827
|
-
if (typeof globalThis === "object") {
|
|
828
|
-
globalThis.regeneratorRuntime = runtime;
|
|
829
|
-
} else {
|
|
830
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
|
|
835
478
|
var _excluded = ["children"];
|
|
836
479
|
var Commerce = /*#__PURE__*/React.createContext({});
|
|
837
480
|
function CoreCommerceProvider(_ref) {
|
|
@@ -921,58 +564,54 @@ var FetcherError = /*#__PURE__*/function (_CommerceError2) {
|
|
|
921
564
|
}(CommerceError);
|
|
922
565
|
|
|
923
566
|
var useData = function useData(options, input, fetcherFn, swrOptions, provider) {
|
|
567
|
+
var _ref;
|
|
924
568
|
var hookInput = Array.isArray(input) ? input : Object.entries(input);
|
|
925
|
-
var fetcher =
|
|
926
|
-
|
|
569
|
+
var fetcher = function fetcher(_x, _x2, _x3) {
|
|
570
|
+
return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, query, method) {
|
|
927
571
|
var _len,
|
|
928
572
|
args,
|
|
929
573
|
_key,
|
|
930
574
|
_args = arguments;
|
|
931
|
-
return
|
|
932
|
-
while (1) {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
return _context.stop();
|
|
968
|
-
}
|
|
575
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
576
|
+
while (1) switch (_context.prev = _context.next) {
|
|
577
|
+
case 0:
|
|
578
|
+
_context.prev = 0;
|
|
579
|
+
for (_len = _args.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
580
|
+
args[_key - 3] = _args[_key];
|
|
581
|
+
}
|
|
582
|
+
_context.next = 4;
|
|
583
|
+
return options.fetcher({
|
|
584
|
+
options: {
|
|
585
|
+
url: url,
|
|
586
|
+
query: query,
|
|
587
|
+
method: method
|
|
588
|
+
},
|
|
589
|
+
// Transform the input array into an object
|
|
590
|
+
input: args.reduce(function (obj, val, i) {
|
|
591
|
+
obj[hookInput[i][0]] = val;
|
|
592
|
+
return obj;
|
|
593
|
+
}, {}),
|
|
594
|
+
fetch: fetcherFn,
|
|
595
|
+
provider: provider
|
|
596
|
+
});
|
|
597
|
+
case 4:
|
|
598
|
+
return _context.abrupt("return", _context.sent);
|
|
599
|
+
case 7:
|
|
600
|
+
_context.prev = 7;
|
|
601
|
+
_context.t0 = _context["catch"](0);
|
|
602
|
+
// SWR will not log errors, but any error that's not an instance
|
|
603
|
+
// of CommerceError is not welcomed by this hook
|
|
604
|
+
if (!(_context.t0 instanceof CommerceError)) {
|
|
605
|
+
console.error(_context.t0);
|
|
606
|
+
}
|
|
607
|
+
throw _context.t0;
|
|
608
|
+
case 11:
|
|
609
|
+
case "end":
|
|
610
|
+
return _context.stop();
|
|
969
611
|
}
|
|
970
612
|
}, _callee, null, [[0, 7]]);
|
|
971
|
-
}));
|
|
972
|
-
|
|
973
|
-
return _ref.apply(this, arguments);
|
|
974
|
-
};
|
|
975
|
-
}();
|
|
613
|
+
}))).apply(this, arguments);
|
|
614
|
+
};
|
|
976
615
|
var response = query.useMutablePlasmicQueryData(function () {
|
|
977
616
|
var opts = options.fetchOptions;
|
|
978
617
|
return opts ? [opts.url, opts.query, opts.method].concat(hookInput.map(function (e) {
|
|
@@ -1264,49 +903,45 @@ var addToCartButtonMeta = {
|
|
|
1264
903
|
importName: "AddToCartButton"
|
|
1265
904
|
};
|
|
1266
905
|
function AddToCartButton(props) {
|
|
906
|
+
var _ref;
|
|
1267
907
|
var children = props.children;
|
|
1268
908
|
var product = useProduct();
|
|
1269
909
|
var form = reactHookForm.useFormContext();
|
|
1270
910
|
var addItem = useAddItem();
|
|
1271
|
-
var addToCart =
|
|
1272
|
-
|
|
911
|
+
var addToCart = function addToCart() {
|
|
912
|
+
return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1273
913
|
var _form$getValues$Produ;
|
|
1274
914
|
var quantity, _form$getValues$Produ2, variantId;
|
|
1275
|
-
return
|
|
1276
|
-
while (1) {
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
if (!product) {
|
|
1289
|
-
_context.next = 7;
|
|
1290
|
-
break;
|
|
1291
|
-
}
|
|
1292
|
-
variantId = (_form$getValues$Produ2 = form.getValues()["ProductVariant"]) != null ? _form$getValues$Produ2 : product.variants[0].id;
|
|
915
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
916
|
+
while (1) switch (_context.prev = _context.next) {
|
|
917
|
+
case 0:
|
|
918
|
+
quantity = +((_form$getValues$Produ = form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1);
|
|
919
|
+
if (!(isNaN(quantity) || quantity < 1)) {
|
|
920
|
+
_context.next = 3;
|
|
921
|
+
break;
|
|
922
|
+
}
|
|
923
|
+
throw new CommerceError({
|
|
924
|
+
message: "The item quantity has to be a valid integer greater than 0"
|
|
925
|
+
});
|
|
926
|
+
case 3:
|
|
927
|
+
if (!product) {
|
|
1293
928
|
_context.next = 7;
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
variantId = (_form$getValues$Produ2 = form.getValues()["ProductVariant"]) != null ? _form$getValues$Produ2 : product.variants[0].id;
|
|
932
|
+
_context.next = 7;
|
|
933
|
+
return addItem({
|
|
934
|
+
productId: product.id,
|
|
935
|
+
variantId: variantId,
|
|
936
|
+
quantity: quantity
|
|
937
|
+
});
|
|
938
|
+
case 7:
|
|
939
|
+
case "end":
|
|
940
|
+
return _context.stop();
|
|
1303
941
|
}
|
|
1304
942
|
}, _callee);
|
|
1305
|
-
}));
|
|
1306
|
-
|
|
1307
|
-
return _ref.apply(this, arguments);
|
|
1308
|
-
};
|
|
1309
|
-
}();
|
|
943
|
+
}))).apply(this, arguments);
|
|
944
|
+
};
|
|
1310
945
|
return React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
1311
946
|
onClick: function onClick(e) {
|
|
1312
947
|
if (children.props.onClick && typeof children.props.onClick === "function") {
|
|
@@ -1323,39 +958,35 @@ function registerAddToCartButton(loader, customAddToCartButtonMeta) {
|
|
|
1323
958
|
doRegisterComponent(AddToCartButton, customAddToCartButtonMeta != null ? customAddToCartButtonMeta : addToCartButtonMeta);
|
|
1324
959
|
}
|
|
1325
960
|
|
|
1326
|
-
var
|
|
1327
|
-
|
|
961
|
+
var _ref2;
|
|
962
|
+
var fetcher$3 = function fetcher(_x) {
|
|
963
|
+
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
1328
964
|
var options, cartId, fetch;
|
|
1329
|
-
return
|
|
1330
|
-
while (1) {
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
_context.next = 7;
|
|
1336
|
-
break;
|
|
1337
|
-
}
|
|
1338
|
-
_context.next = 4;
|
|
1339
|
-
return fetch(options);
|
|
1340
|
-
case 4:
|
|
1341
|
-
_context.t0 = _context.sent;
|
|
1342
|
-
_context.next = 8;
|
|
965
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
966
|
+
while (1) switch (_context.prev = _context.next) {
|
|
967
|
+
case 0:
|
|
968
|
+
options = _ref.options, cartId = _ref.input.cartId, fetch = _ref.fetch;
|
|
969
|
+
if (!cartId) {
|
|
970
|
+
_context.next = 7;
|
|
1343
971
|
break;
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
972
|
+
}
|
|
973
|
+
_context.next = 4;
|
|
974
|
+
return fetch(options);
|
|
975
|
+
case 4:
|
|
976
|
+
_context.t0 = _context.sent;
|
|
977
|
+
_context.next = 8;
|
|
978
|
+
break;
|
|
979
|
+
case 7:
|
|
980
|
+
_context.t0 = null;
|
|
981
|
+
case 8:
|
|
982
|
+
return _context.abrupt("return", _context.t0);
|
|
983
|
+
case 9:
|
|
984
|
+
case "end":
|
|
985
|
+
return _context.stop();
|
|
1352
986
|
}
|
|
1353
987
|
}, _callee);
|
|
1354
|
-
}));
|
|
1355
|
-
|
|
1356
|
-
return _ref2.apply(this, arguments);
|
|
1357
|
-
};
|
|
1358
|
-
}();
|
|
988
|
+
}))).apply(this, arguments);
|
|
989
|
+
};
|
|
1359
990
|
var fn$3 = function fn(provider) {
|
|
1360
991
|
var _provider$cart;
|
|
1361
992
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useCart;
|
|
@@ -1623,7 +1254,7 @@ function CategoryCollection(props) {
|
|
|
1623
1254
|
categories = _useCategories2.data,
|
|
1624
1255
|
isLoading = _useCategories2.isLoading;
|
|
1625
1256
|
if (allCategories) {
|
|
1626
|
-
setControlContextData == null
|
|
1257
|
+
setControlContextData == null || setControlContextData({
|
|
1627
1258
|
categories: allCategories
|
|
1628
1259
|
});
|
|
1629
1260
|
}
|
|
@@ -1869,7 +1500,7 @@ function ProductBox(props) {
|
|
|
1869
1500
|
return setProductSearch(value);
|
|
1870
1501
|
}, 300), []);
|
|
1871
1502
|
if (allProducts) {
|
|
1872
|
-
setControlContextData == null
|
|
1503
|
+
setControlContextData == null || setControlContextData({
|
|
1873
1504
|
products: allProducts.products,
|
|
1874
1505
|
onSearch: onSearch
|
|
1875
1506
|
});
|
|
@@ -1981,7 +1612,7 @@ var productCollectionMeta = {
|
|
|
1981
1612
|
},
|
|
1982
1613
|
defaultValueHint: function defaultValueHint(props, ctx) {
|
|
1983
1614
|
var _ctx$categoryCtx;
|
|
1984
|
-
return ctx == null
|
|
1615
|
+
return ctx == null || (_ctx$categoryCtx = ctx.categoryCtx) == null ? void 0 : _ctx$categoryCtx.name;
|
|
1985
1616
|
},
|
|
1986
1617
|
readOnly: function readOnly(props, ctx) {
|
|
1987
1618
|
return !!(ctx != null && ctx.categoryCtx);
|
|
@@ -2084,7 +1715,7 @@ function ProductCollection(props) {
|
|
|
2084
1715
|
var features = useCommerceExtraFeatures();
|
|
2085
1716
|
var primaryCategory = usePrimaryCategory();
|
|
2086
1717
|
if (categories && brands) {
|
|
2087
|
-
setControlContextData == null
|
|
1718
|
+
setControlContextData == null || setControlContextData({
|
|
2088
1719
|
categories: categories,
|
|
2089
1720
|
brands: brands,
|
|
2090
1721
|
features: features,
|
|
@@ -2195,7 +1826,7 @@ var ProductMedia = /*#__PURE__*/React__default.forwardRef(function (props, ref)
|
|
|
2195
1826
|
setControlContextData = props.setControlContextData;
|
|
2196
1827
|
var product = useProduct();
|
|
2197
1828
|
var mediaContext = useProductMediaContext();
|
|
2198
|
-
setControlContextData == null
|
|
1829
|
+
setControlContextData == null || setControlContextData({
|
|
2199
1830
|
inMediaContext: mediaContext !== undefined
|
|
2200
1831
|
});
|
|
2201
1832
|
var image = product == null ? void 0 : product.images[mediaContext != null ? mediaContext : mediaIndex];
|
|
@@ -2483,7 +2114,7 @@ function ProductVariantPicker(props) {
|
|
|
2483
2114
|
return React__default.createElement(reactHookForm.Controller, {
|
|
2484
2115
|
name: "ProductVariant",
|
|
2485
2116
|
control: form == null ? void 0 : form.control,
|
|
2486
|
-
defaultValue: product == null
|
|
2117
|
+
defaultValue: product == null || (_product$variants$fin = product.variants.find(function (v) {
|
|
2487
2118
|
return v.price === product.price.value;
|
|
2488
2119
|
})) == null ? void 0 : _product$variants$fin.id,
|
|
2489
2120
|
render: function render(_ref) {
|