@plasmicpkgs/commerce-shopify 0.0.163 → 0.0.165
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-shopify.cjs.development.js +807 -1212
- package/dist/commerce-shopify.cjs.development.js.map +1 -1
- package/dist/commerce-shopify.cjs.production.min.js +1 -1
- package/dist/commerce-shopify.cjs.production.min.js.map +1 -1
- package/dist/commerce-shopify.esm.js +807 -1212
- package/dist/commerce-shopify.esm.js.map +1 -1
- package/dist/registerCommerceProvider.d.ts +1 -1
- package/dist/shopify.d.ts +2 -1
- package/package.json +4 -4
- package/LICENSE.md +0 -21
|
@@ -19,6 +19,307 @@ var SHOPIFY_CHECKOUT_ID_COOKIE = 'shopify_checkoutId';
|
|
|
19
19
|
var SHOPIFY_CHECKOUT_URL_COOKIE = 'shopify_checkoutUrl';
|
|
20
20
|
var SHOPIFY_COOKIE_EXPIRE = 30;
|
|
21
21
|
|
|
22
|
+
function _regeneratorRuntime() {
|
|
23
|
+
_regeneratorRuntime = function () {
|
|
24
|
+
return e;
|
|
25
|
+
};
|
|
26
|
+
var t,
|
|
27
|
+
e = {},
|
|
28
|
+
r = Object.prototype,
|
|
29
|
+
n = r.hasOwnProperty,
|
|
30
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
31
|
+
t[e] = r.value;
|
|
32
|
+
},
|
|
33
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
34
|
+
a = i.iterator || "@@iterator",
|
|
35
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
36
|
+
u = i.toStringTag || "@@toStringTag";
|
|
37
|
+
function define(t, e, r) {
|
|
38
|
+
return Object.defineProperty(t, e, {
|
|
39
|
+
value: r,
|
|
40
|
+
enumerable: !0,
|
|
41
|
+
configurable: !0,
|
|
42
|
+
writable: !0
|
|
43
|
+
}), t[e];
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
define({}, "");
|
|
47
|
+
} catch (t) {
|
|
48
|
+
define = function (t, e, r) {
|
|
49
|
+
return t[e] = r;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function wrap(t, e, r, n) {
|
|
53
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
54
|
+
a = Object.create(i.prototype),
|
|
55
|
+
c = new Context(n || []);
|
|
56
|
+
return o(a, "_invoke", {
|
|
57
|
+
value: makeInvokeMethod(t, r, c)
|
|
58
|
+
}), a;
|
|
59
|
+
}
|
|
60
|
+
function tryCatch(t, e, r) {
|
|
61
|
+
try {
|
|
62
|
+
return {
|
|
63
|
+
type: "normal",
|
|
64
|
+
arg: t.call(e, r)
|
|
65
|
+
};
|
|
66
|
+
} catch (t) {
|
|
67
|
+
return {
|
|
68
|
+
type: "throw",
|
|
69
|
+
arg: t
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
e.wrap = wrap;
|
|
74
|
+
var h = "suspendedStart",
|
|
75
|
+
l = "suspendedYield",
|
|
76
|
+
f = "executing",
|
|
77
|
+
s = "completed",
|
|
78
|
+
y = {};
|
|
79
|
+
function Generator() {}
|
|
80
|
+
function GeneratorFunction() {}
|
|
81
|
+
function GeneratorFunctionPrototype() {}
|
|
82
|
+
var p = {};
|
|
83
|
+
define(p, a, function () {
|
|
84
|
+
return this;
|
|
85
|
+
});
|
|
86
|
+
var d = Object.getPrototypeOf,
|
|
87
|
+
v = d && d(d(values([])));
|
|
88
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
89
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
90
|
+
function defineIteratorMethods(t) {
|
|
91
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
92
|
+
define(t, e, function (t) {
|
|
93
|
+
return this._invoke(e, t);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function AsyncIterator(t, e) {
|
|
98
|
+
function invoke(r, o, i, a) {
|
|
99
|
+
var c = tryCatch(t[r], t, o);
|
|
100
|
+
if ("throw" !== c.type) {
|
|
101
|
+
var u = c.arg,
|
|
102
|
+
h = u.value;
|
|
103
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
104
|
+
invoke("next", t, i, a);
|
|
105
|
+
}, function (t) {
|
|
106
|
+
invoke("throw", t, i, a);
|
|
107
|
+
}) : e.resolve(h).then(function (t) {
|
|
108
|
+
u.value = t, i(u);
|
|
109
|
+
}, function (t) {
|
|
110
|
+
return invoke("throw", t, i, a);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
a(c.arg);
|
|
114
|
+
}
|
|
115
|
+
var r;
|
|
116
|
+
o(this, "_invoke", {
|
|
117
|
+
value: function (t, n) {
|
|
118
|
+
function callInvokeWithMethodAndArg() {
|
|
119
|
+
return new e(function (e, r) {
|
|
120
|
+
invoke(t, n, e, r);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function makeInvokeMethod(e, r, n) {
|
|
128
|
+
var o = h;
|
|
129
|
+
return function (i, a) {
|
|
130
|
+
if (o === f) throw new Error("Generator is already running");
|
|
131
|
+
if (o === s) {
|
|
132
|
+
if ("throw" === i) throw a;
|
|
133
|
+
return {
|
|
134
|
+
value: t,
|
|
135
|
+
done: !0
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
for (n.method = i, n.arg = a;;) {
|
|
139
|
+
var c = n.delegate;
|
|
140
|
+
if (c) {
|
|
141
|
+
var u = maybeInvokeDelegate(c, n);
|
|
142
|
+
if (u) {
|
|
143
|
+
if (u === y) continue;
|
|
144
|
+
return u;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
148
|
+
if (o === h) throw o = s, n.arg;
|
|
149
|
+
n.dispatchException(n.arg);
|
|
150
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
151
|
+
o = f;
|
|
152
|
+
var p = tryCatch(e, r, n);
|
|
153
|
+
if ("normal" === p.type) {
|
|
154
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
155
|
+
return {
|
|
156
|
+
value: p.arg,
|
|
157
|
+
done: n.done
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function maybeInvokeDelegate(e, r) {
|
|
165
|
+
var n = r.method,
|
|
166
|
+
o = e.iterator[n];
|
|
167
|
+
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;
|
|
168
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
169
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
170
|
+
var a = i.arg;
|
|
171
|
+
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);
|
|
172
|
+
}
|
|
173
|
+
function pushTryEntry(t) {
|
|
174
|
+
var e = {
|
|
175
|
+
tryLoc: t[0]
|
|
176
|
+
};
|
|
177
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
178
|
+
}
|
|
179
|
+
function resetTryEntry(t) {
|
|
180
|
+
var e = t.completion || {};
|
|
181
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
182
|
+
}
|
|
183
|
+
function Context(t) {
|
|
184
|
+
this.tryEntries = [{
|
|
185
|
+
tryLoc: "root"
|
|
186
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
187
|
+
}
|
|
188
|
+
function values(e) {
|
|
189
|
+
if (e || "" === e) {
|
|
190
|
+
var r = e[a];
|
|
191
|
+
if (r) return r.call(e);
|
|
192
|
+
if ("function" == typeof e.next) return e;
|
|
193
|
+
if (!isNaN(e.length)) {
|
|
194
|
+
var o = -1,
|
|
195
|
+
i = function next() {
|
|
196
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
197
|
+
return next.value = t, next.done = !0, next;
|
|
198
|
+
};
|
|
199
|
+
return i.next = i;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
203
|
+
}
|
|
204
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
205
|
+
value: GeneratorFunctionPrototype,
|
|
206
|
+
configurable: !0
|
|
207
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
208
|
+
value: GeneratorFunction,
|
|
209
|
+
configurable: !0
|
|
210
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
211
|
+
var e = "function" == typeof t && t.constructor;
|
|
212
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
213
|
+
}, e.mark = function (t) {
|
|
214
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
215
|
+
}, e.awrap = function (t) {
|
|
216
|
+
return {
|
|
217
|
+
__await: t
|
|
218
|
+
};
|
|
219
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
220
|
+
return this;
|
|
221
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
222
|
+
void 0 === i && (i = Promise);
|
|
223
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
224
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
225
|
+
return t.done ? t.value : a.next();
|
|
226
|
+
});
|
|
227
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
228
|
+
return this;
|
|
229
|
+
}), define(g, "toString", function () {
|
|
230
|
+
return "[object Generator]";
|
|
231
|
+
}), e.keys = function (t) {
|
|
232
|
+
var e = Object(t),
|
|
233
|
+
r = [];
|
|
234
|
+
for (var n in e) r.push(n);
|
|
235
|
+
return r.reverse(), function next() {
|
|
236
|
+
for (; r.length;) {
|
|
237
|
+
var t = r.pop();
|
|
238
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
239
|
+
}
|
|
240
|
+
return next.done = !0, next;
|
|
241
|
+
};
|
|
242
|
+
}, e.values = values, Context.prototype = {
|
|
243
|
+
constructor: Context,
|
|
244
|
+
reset: function (e) {
|
|
245
|
+
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);
|
|
246
|
+
},
|
|
247
|
+
stop: function () {
|
|
248
|
+
this.done = !0;
|
|
249
|
+
var t = this.tryEntries[0].completion;
|
|
250
|
+
if ("throw" === t.type) throw t.arg;
|
|
251
|
+
return this.rval;
|
|
252
|
+
},
|
|
253
|
+
dispatchException: function (e) {
|
|
254
|
+
if (this.done) throw e;
|
|
255
|
+
var r = this;
|
|
256
|
+
function handle(n, o) {
|
|
257
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
258
|
+
}
|
|
259
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
260
|
+
var i = this.tryEntries[o],
|
|
261
|
+
a = i.completion;
|
|
262
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
263
|
+
if (i.tryLoc <= this.prev) {
|
|
264
|
+
var c = n.call(i, "catchLoc"),
|
|
265
|
+
u = n.call(i, "finallyLoc");
|
|
266
|
+
if (c && u) {
|
|
267
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
268
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
269
|
+
} else if (c) {
|
|
270
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
271
|
+
} else {
|
|
272
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
273
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
abrupt: function (t, e) {
|
|
279
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
280
|
+
var o = this.tryEntries[r];
|
|
281
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
282
|
+
var i = o;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
287
|
+
var a = i ? i.completion : {};
|
|
288
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
289
|
+
},
|
|
290
|
+
complete: function (t, e) {
|
|
291
|
+
if ("throw" === t.type) throw t.arg;
|
|
292
|
+
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;
|
|
293
|
+
},
|
|
294
|
+
finish: function (t) {
|
|
295
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
296
|
+
var r = this.tryEntries[e];
|
|
297
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
catch: function (t) {
|
|
301
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
302
|
+
var r = this.tryEntries[e];
|
|
303
|
+
if (r.tryLoc === t) {
|
|
304
|
+
var n = r.completion;
|
|
305
|
+
if ("throw" === n.type) {
|
|
306
|
+
var o = n.arg;
|
|
307
|
+
resetTryEntry(r);
|
|
308
|
+
}
|
|
309
|
+
return o;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
throw new Error("illegal catch attempt");
|
|
313
|
+
},
|
|
314
|
+
delegateYield: function (e, r, n) {
|
|
315
|
+
return this.delegate = {
|
|
316
|
+
iterator: values(e),
|
|
317
|
+
resultName: r,
|
|
318
|
+
nextLoc: n
|
|
319
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
320
|
+
}
|
|
321
|
+
}, e;
|
|
322
|
+
}
|
|
22
323
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
23
324
|
try {
|
|
24
325
|
var info = gen[key](arg);
|
|
@@ -76,664 +377,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
76
377
|
return target;
|
|
77
378
|
}
|
|
78
379
|
|
|
79
|
-
|
|
80
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
84
|
-
/**
|
|
85
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
86
|
-
*
|
|
87
|
-
* This source code is licensed under the MIT license found in the
|
|
88
|
-
* LICENSE file in the root directory of this source tree.
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
var runtime = function (exports) {
|
|
92
|
-
|
|
93
|
-
var Op = Object.prototype;
|
|
94
|
-
var hasOwn = Op.hasOwnProperty;
|
|
95
|
-
var undefined$1; // More compressible than void 0.
|
|
96
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
97
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
98
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
99
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
100
|
-
function define(obj, key, value) {
|
|
101
|
-
Object.defineProperty(obj, key, {
|
|
102
|
-
value: value,
|
|
103
|
-
enumerable: true,
|
|
104
|
-
configurable: true,
|
|
105
|
-
writable: true
|
|
106
|
-
});
|
|
107
|
-
return obj[key];
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
111
|
-
define({}, "");
|
|
112
|
-
} catch (err) {
|
|
113
|
-
define = function define(obj, key, value) {
|
|
114
|
-
return obj[key] = value;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
118
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
119
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
120
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
121
|
-
var context = new Context(tryLocsList || []);
|
|
122
|
-
|
|
123
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
124
|
-
// .throw, and .return methods.
|
|
125
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
126
|
-
return generator;
|
|
127
|
-
}
|
|
128
|
-
exports.wrap = wrap;
|
|
129
|
-
|
|
130
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
131
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
132
|
-
// have been (and was previously) designed to take a closure to be
|
|
133
|
-
// invoked without arguments, but in all the cases we care about we
|
|
134
|
-
// already have an existing method we want to call, so there's no need
|
|
135
|
-
// to create a new function object. We can even get away with assuming
|
|
136
|
-
// the method takes exactly one argument, since that happens to be true
|
|
137
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
138
|
-
// only additional allocation required is the completion record, which
|
|
139
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
140
|
-
function tryCatch(fn, obj, arg) {
|
|
141
|
-
try {
|
|
142
|
-
return {
|
|
143
|
-
type: "normal",
|
|
144
|
-
arg: fn.call(obj, arg)
|
|
145
|
-
};
|
|
146
|
-
} catch (err) {
|
|
147
|
-
return {
|
|
148
|
-
type: "throw",
|
|
149
|
-
arg: err
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
154
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
155
|
-
var GenStateExecuting = "executing";
|
|
156
|
-
var GenStateCompleted = "completed";
|
|
157
|
-
|
|
158
|
-
// Returning this object from the innerFn has the same effect as
|
|
159
|
-
// breaking out of the dispatch switch statement.
|
|
160
|
-
var ContinueSentinel = {};
|
|
161
|
-
|
|
162
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
163
|
-
// .constructor.prototype properties for functions that return Generator
|
|
164
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
165
|
-
// minifier not to mangle the names of these two functions.
|
|
166
|
-
function Generator() {}
|
|
167
|
-
function GeneratorFunction() {}
|
|
168
|
-
function GeneratorFunctionPrototype() {}
|
|
169
|
-
|
|
170
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
171
|
-
// don't natively support it.
|
|
172
|
-
var IteratorPrototype = {};
|
|
173
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
174
|
-
return this;
|
|
175
|
-
});
|
|
176
|
-
var getProto = Object.getPrototypeOf;
|
|
177
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
178
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
179
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
180
|
-
// of the polyfill.
|
|
181
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
182
|
-
}
|
|
183
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
184
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
185
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
186
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
187
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
188
|
-
|
|
189
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
190
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
191
|
-
function defineIteratorMethods(prototype) {
|
|
192
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
193
|
-
define(prototype, method, function (arg) {
|
|
194
|
-
return this._invoke(method, arg);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
199
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
200
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
201
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
202
|
-
// do is to check its .name property.
|
|
203
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
204
|
-
};
|
|
205
|
-
exports.mark = function (genFun) {
|
|
206
|
-
if (Object.setPrototypeOf) {
|
|
207
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
208
|
-
} else {
|
|
209
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
210
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
211
|
-
}
|
|
212
|
-
genFun.prototype = Object.create(Gp);
|
|
213
|
-
return genFun;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// Within the body of any async function, `await x` is transformed to
|
|
217
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
218
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
219
|
-
// meant to be awaited.
|
|
220
|
-
exports.awrap = function (arg) {
|
|
221
|
-
return {
|
|
222
|
-
__await: arg
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
226
|
-
function invoke(method, arg, resolve, reject) {
|
|
227
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
228
|
-
if (record.type === "throw") {
|
|
229
|
-
reject(record.arg);
|
|
230
|
-
} else {
|
|
231
|
-
var result = record.arg;
|
|
232
|
-
var value = result.value;
|
|
233
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
234
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
235
|
-
invoke("next", value, resolve, reject);
|
|
236
|
-
}, function (err) {
|
|
237
|
-
invoke("throw", err, resolve, reject);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
241
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
242
|
-
// the .value of the Promise<{value,done}> result for the
|
|
243
|
-
// current iteration.
|
|
244
|
-
result.value = unwrapped;
|
|
245
|
-
resolve(result);
|
|
246
|
-
}, function (error) {
|
|
247
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
248
|
-
// into the async generator function so it can be handled there.
|
|
249
|
-
return invoke("throw", error, resolve, reject);
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
var previousPromise;
|
|
254
|
-
function enqueue(method, arg) {
|
|
255
|
-
function callInvokeWithMethodAndArg() {
|
|
256
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
257
|
-
invoke(method, arg, resolve, reject);
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
return previousPromise =
|
|
261
|
-
// If enqueue has been called before, then we want to wait until
|
|
262
|
-
// all previous Promises have been resolved before calling invoke,
|
|
263
|
-
// so that results are always delivered in the correct order. If
|
|
264
|
-
// enqueue has not been called before, then it is important to
|
|
265
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
266
|
-
// so that the async generator function has the opportunity to do
|
|
267
|
-
// any necessary setup in a predictable way. This predictability
|
|
268
|
-
// is why the Promise constructor synchronously invokes its
|
|
269
|
-
// executor callback, and why async functions synchronously
|
|
270
|
-
// execute code before the first await. Since we implement simple
|
|
271
|
-
// async functions in terms of async generators, it is especially
|
|
272
|
-
// important to get this right, even though it requires care.
|
|
273
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
274
|
-
// Avoid propagating failures to Promises returned by later
|
|
275
|
-
// invocations of the iterator.
|
|
276
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Define the unified helper method that is used to implement .next,
|
|
280
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
281
|
-
this._invoke = enqueue;
|
|
282
|
-
}
|
|
283
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
284
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
285
|
-
return this;
|
|
286
|
-
});
|
|
287
|
-
exports.AsyncIterator = AsyncIterator;
|
|
288
|
-
|
|
289
|
-
// Note that simple async functions are implemented on top of
|
|
290
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
291
|
-
// the final result produced by the iterator.
|
|
292
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
293
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
294
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
295
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
296
|
-
: iter.next().then(function (result) {
|
|
297
|
-
return result.done ? result.value : iter.next();
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
301
|
-
var state = GenStateSuspendedStart;
|
|
302
|
-
return function invoke(method, arg) {
|
|
303
|
-
if (state === GenStateExecuting) {
|
|
304
|
-
throw new Error("Generator is already running");
|
|
305
|
-
}
|
|
306
|
-
if (state === GenStateCompleted) {
|
|
307
|
-
if (method === "throw") {
|
|
308
|
-
throw arg;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
312
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
313
|
-
return doneResult();
|
|
314
|
-
}
|
|
315
|
-
context.method = method;
|
|
316
|
-
context.arg = arg;
|
|
317
|
-
while (true) {
|
|
318
|
-
var delegate = context.delegate;
|
|
319
|
-
if (delegate) {
|
|
320
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
321
|
-
if (delegateResult) {
|
|
322
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
323
|
-
return delegateResult;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (context.method === "next") {
|
|
327
|
-
// Setting context._sent for legacy support of Babel's
|
|
328
|
-
// function.sent implementation.
|
|
329
|
-
context.sent = context._sent = context.arg;
|
|
330
|
-
} else if (context.method === "throw") {
|
|
331
|
-
if (state === GenStateSuspendedStart) {
|
|
332
|
-
state = GenStateCompleted;
|
|
333
|
-
throw context.arg;
|
|
334
|
-
}
|
|
335
|
-
context.dispatchException(context.arg);
|
|
336
|
-
} else if (context.method === "return") {
|
|
337
|
-
context.abrupt("return", context.arg);
|
|
338
|
-
}
|
|
339
|
-
state = GenStateExecuting;
|
|
340
|
-
var record = tryCatch(innerFn, self, context);
|
|
341
|
-
if (record.type === "normal") {
|
|
342
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
343
|
-
// GenStateExecuting and loop back for another invocation.
|
|
344
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
345
|
-
if (record.arg === ContinueSentinel) {
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
return {
|
|
349
|
-
value: record.arg,
|
|
350
|
-
done: context.done
|
|
351
|
-
};
|
|
352
|
-
} else if (record.type === "throw") {
|
|
353
|
-
state = GenStateCompleted;
|
|
354
|
-
// Dispatch the exception by looping back around to the
|
|
355
|
-
// context.dispatchException(context.arg) call above.
|
|
356
|
-
context.method = "throw";
|
|
357
|
-
context.arg = record.arg;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
364
|
-
// result, either by returning a { value, done } result from the
|
|
365
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
366
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
367
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
368
|
-
var method = delegate.iterator[context.method];
|
|
369
|
-
if (method === undefined$1) {
|
|
370
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
371
|
-
// method always terminates the yield* loop.
|
|
372
|
-
context.delegate = null;
|
|
373
|
-
if (context.method === "throw") {
|
|
374
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
375
|
-
if (delegate.iterator["return"]) {
|
|
376
|
-
// If the delegate iterator has a return method, give it a
|
|
377
|
-
// chance to clean up.
|
|
378
|
-
context.method = "return";
|
|
379
|
-
context.arg = undefined$1;
|
|
380
|
-
maybeInvokeDelegate(delegate, context);
|
|
381
|
-
if (context.method === "throw") {
|
|
382
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
383
|
-
// "return" to "throw", let that override the TypeError below.
|
|
384
|
-
return ContinueSentinel;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
context.method = "throw";
|
|
388
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
389
|
-
}
|
|
390
|
-
return ContinueSentinel;
|
|
391
|
-
}
|
|
392
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
393
|
-
if (record.type === "throw") {
|
|
394
|
-
context.method = "throw";
|
|
395
|
-
context.arg = record.arg;
|
|
396
|
-
context.delegate = null;
|
|
397
|
-
return ContinueSentinel;
|
|
398
|
-
}
|
|
399
|
-
var info = record.arg;
|
|
400
|
-
if (!info) {
|
|
401
|
-
context.method = "throw";
|
|
402
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
403
|
-
context.delegate = null;
|
|
404
|
-
return ContinueSentinel;
|
|
405
|
-
}
|
|
406
|
-
if (info.done) {
|
|
407
|
-
// Assign the result of the finished delegate to the temporary
|
|
408
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
409
|
-
context[delegate.resultName] = info.value;
|
|
410
|
-
|
|
411
|
-
// Resume execution at the desired location (see delegateYield).
|
|
412
|
-
context.next = delegate.nextLoc;
|
|
413
|
-
|
|
414
|
-
// If context.method was "throw" but the delegate handled the
|
|
415
|
-
// exception, let the outer generator proceed normally. If
|
|
416
|
-
// context.method was "next", forget context.arg since it has been
|
|
417
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
418
|
-
// "return", allow the original .return call to continue in the
|
|
419
|
-
// outer generator.
|
|
420
|
-
if (context.method !== "return") {
|
|
421
|
-
context.method = "next";
|
|
422
|
-
context.arg = undefined$1;
|
|
423
|
-
}
|
|
424
|
-
} else {
|
|
425
|
-
// Re-yield the result returned by the delegate method.
|
|
426
|
-
return info;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
430
|
-
// the outer generator.
|
|
431
|
-
context.delegate = null;
|
|
432
|
-
return ContinueSentinel;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
436
|
-
// unified ._invoke helper method.
|
|
437
|
-
defineIteratorMethods(Gp);
|
|
438
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
439
|
-
|
|
440
|
-
// A Generator should always return itself as the iterator object when the
|
|
441
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
442
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
443
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
444
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
445
|
-
define(Gp, iteratorSymbol, function () {
|
|
446
|
-
return this;
|
|
447
|
-
});
|
|
448
|
-
define(Gp, "toString", function () {
|
|
449
|
-
return "[object Generator]";
|
|
450
|
-
});
|
|
451
|
-
function pushTryEntry(locs) {
|
|
452
|
-
var entry = {
|
|
453
|
-
tryLoc: locs[0]
|
|
454
|
-
};
|
|
455
|
-
if (1 in locs) {
|
|
456
|
-
entry.catchLoc = locs[1];
|
|
457
|
-
}
|
|
458
|
-
if (2 in locs) {
|
|
459
|
-
entry.finallyLoc = locs[2];
|
|
460
|
-
entry.afterLoc = locs[3];
|
|
461
|
-
}
|
|
462
|
-
this.tryEntries.push(entry);
|
|
463
|
-
}
|
|
464
|
-
function resetTryEntry(entry) {
|
|
465
|
-
var record = entry.completion || {};
|
|
466
|
-
record.type = "normal";
|
|
467
|
-
delete record.arg;
|
|
468
|
-
entry.completion = record;
|
|
469
|
-
}
|
|
470
|
-
function Context(tryLocsList) {
|
|
471
|
-
// The root entry object (effectively a try statement without a catch
|
|
472
|
-
// or a finally block) gives us a place to store values thrown from
|
|
473
|
-
// locations where there is no enclosing try statement.
|
|
474
|
-
this.tryEntries = [{
|
|
475
|
-
tryLoc: "root"
|
|
476
|
-
}];
|
|
477
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
478
|
-
this.reset(true);
|
|
479
|
-
}
|
|
480
|
-
exports.keys = function (object) {
|
|
481
|
-
var keys = [];
|
|
482
|
-
for (var key in object) {
|
|
483
|
-
keys.push(key);
|
|
484
|
-
}
|
|
485
|
-
keys.reverse();
|
|
486
|
-
|
|
487
|
-
// Rather than returning an object with a next method, we keep
|
|
488
|
-
// things simple and return the next function itself.
|
|
489
|
-
return function next() {
|
|
490
|
-
while (keys.length) {
|
|
491
|
-
var key = keys.pop();
|
|
492
|
-
if (key in object) {
|
|
493
|
-
next.value = key;
|
|
494
|
-
next.done = false;
|
|
495
|
-
return next;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// To avoid creating an additional object, we just hang the .value
|
|
500
|
-
// and .done properties off the next function object itself. This
|
|
501
|
-
// also ensures that the minifier will not anonymize the function.
|
|
502
|
-
next.done = true;
|
|
503
|
-
return next;
|
|
504
|
-
};
|
|
505
|
-
};
|
|
506
|
-
function values(iterable) {
|
|
507
|
-
if (iterable) {
|
|
508
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
509
|
-
if (iteratorMethod) {
|
|
510
|
-
return iteratorMethod.call(iterable);
|
|
511
|
-
}
|
|
512
|
-
if (typeof iterable.next === "function") {
|
|
513
|
-
return iterable;
|
|
514
|
-
}
|
|
515
|
-
if (!isNaN(iterable.length)) {
|
|
516
|
-
var i = -1,
|
|
517
|
-
next = function next() {
|
|
518
|
-
while (++i < iterable.length) {
|
|
519
|
-
if (hasOwn.call(iterable, i)) {
|
|
520
|
-
next.value = iterable[i];
|
|
521
|
-
next.done = false;
|
|
522
|
-
return next;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
next.value = undefined$1;
|
|
526
|
-
next.done = true;
|
|
527
|
-
return next;
|
|
528
|
-
};
|
|
529
|
-
return next.next = next;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// Return an iterator with no values.
|
|
534
|
-
return {
|
|
535
|
-
next: doneResult
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
exports.values = values;
|
|
539
|
-
function doneResult() {
|
|
540
|
-
return {
|
|
541
|
-
value: undefined$1,
|
|
542
|
-
done: true
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
Context.prototype = {
|
|
546
|
-
constructor: Context,
|
|
547
|
-
reset: function reset(skipTempReset) {
|
|
548
|
-
this.prev = 0;
|
|
549
|
-
this.next = 0;
|
|
550
|
-
// Resetting context._sent for legacy support of Babel's
|
|
551
|
-
// function.sent implementation.
|
|
552
|
-
this.sent = this._sent = undefined$1;
|
|
553
|
-
this.done = false;
|
|
554
|
-
this.delegate = null;
|
|
555
|
-
this.method = "next";
|
|
556
|
-
this.arg = undefined$1;
|
|
557
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
558
|
-
if (!skipTempReset) {
|
|
559
|
-
for (var name in this) {
|
|
560
|
-
// Not sure about the optimal order of these conditions:
|
|
561
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
562
|
-
this[name] = undefined$1;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
},
|
|
567
|
-
stop: function stop() {
|
|
568
|
-
this.done = true;
|
|
569
|
-
var rootEntry = this.tryEntries[0];
|
|
570
|
-
var rootRecord = rootEntry.completion;
|
|
571
|
-
if (rootRecord.type === "throw") {
|
|
572
|
-
throw rootRecord.arg;
|
|
573
|
-
}
|
|
574
|
-
return this.rval;
|
|
575
|
-
},
|
|
576
|
-
dispatchException: function dispatchException(exception) {
|
|
577
|
-
if (this.done) {
|
|
578
|
-
throw exception;
|
|
579
|
-
}
|
|
580
|
-
var context = this;
|
|
581
|
-
function handle(loc, caught) {
|
|
582
|
-
record.type = "throw";
|
|
583
|
-
record.arg = exception;
|
|
584
|
-
context.next = loc;
|
|
585
|
-
if (caught) {
|
|
586
|
-
// If the dispatched exception was caught by a catch block,
|
|
587
|
-
// then let that catch block handle the exception normally.
|
|
588
|
-
context.method = "next";
|
|
589
|
-
context.arg = undefined$1;
|
|
590
|
-
}
|
|
591
|
-
return !!caught;
|
|
592
|
-
}
|
|
593
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
594
|
-
var entry = this.tryEntries[i];
|
|
595
|
-
var record = entry.completion;
|
|
596
|
-
if (entry.tryLoc === "root") {
|
|
597
|
-
// Exception thrown outside of any try block that could handle
|
|
598
|
-
// it, so set the completion value of the entire function to
|
|
599
|
-
// throw the exception.
|
|
600
|
-
return handle("end");
|
|
601
|
-
}
|
|
602
|
-
if (entry.tryLoc <= this.prev) {
|
|
603
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
604
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
605
|
-
if (hasCatch && hasFinally) {
|
|
606
|
-
if (this.prev < entry.catchLoc) {
|
|
607
|
-
return handle(entry.catchLoc, true);
|
|
608
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
609
|
-
return handle(entry.finallyLoc);
|
|
610
|
-
}
|
|
611
|
-
} else if (hasCatch) {
|
|
612
|
-
if (this.prev < entry.catchLoc) {
|
|
613
|
-
return handle(entry.catchLoc, true);
|
|
614
|
-
}
|
|
615
|
-
} else if (hasFinally) {
|
|
616
|
-
if (this.prev < entry.finallyLoc) {
|
|
617
|
-
return handle(entry.finallyLoc);
|
|
618
|
-
}
|
|
619
|
-
} else {
|
|
620
|
-
throw new Error("try statement without catch or finally");
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
abrupt: function abrupt(type, arg) {
|
|
626
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
627
|
-
var entry = this.tryEntries[i];
|
|
628
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
629
|
-
var finallyEntry = entry;
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
634
|
-
// Ignore the finally entry if control is not jumping to a
|
|
635
|
-
// location outside the try/catch block.
|
|
636
|
-
finallyEntry = null;
|
|
637
|
-
}
|
|
638
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
639
|
-
record.type = type;
|
|
640
|
-
record.arg = arg;
|
|
641
|
-
if (finallyEntry) {
|
|
642
|
-
this.method = "next";
|
|
643
|
-
this.next = finallyEntry.finallyLoc;
|
|
644
|
-
return ContinueSentinel;
|
|
645
|
-
}
|
|
646
|
-
return this.complete(record);
|
|
647
|
-
},
|
|
648
|
-
complete: function complete(record, afterLoc) {
|
|
649
|
-
if (record.type === "throw") {
|
|
650
|
-
throw record.arg;
|
|
651
|
-
}
|
|
652
|
-
if (record.type === "break" || record.type === "continue") {
|
|
653
|
-
this.next = record.arg;
|
|
654
|
-
} else if (record.type === "return") {
|
|
655
|
-
this.rval = this.arg = record.arg;
|
|
656
|
-
this.method = "return";
|
|
657
|
-
this.next = "end";
|
|
658
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
659
|
-
this.next = afterLoc;
|
|
660
|
-
}
|
|
661
|
-
return ContinueSentinel;
|
|
662
|
-
},
|
|
663
|
-
finish: function finish(finallyLoc) {
|
|
664
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
665
|
-
var entry = this.tryEntries[i];
|
|
666
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
667
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
668
|
-
resetTryEntry(entry);
|
|
669
|
-
return ContinueSentinel;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
},
|
|
673
|
-
"catch": function _catch(tryLoc) {
|
|
674
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
675
|
-
var entry = this.tryEntries[i];
|
|
676
|
-
if (entry.tryLoc === tryLoc) {
|
|
677
|
-
var record = entry.completion;
|
|
678
|
-
if (record.type === "throw") {
|
|
679
|
-
var thrown = record.arg;
|
|
680
|
-
resetTryEntry(entry);
|
|
681
|
-
}
|
|
682
|
-
return thrown;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// The context.catch method must only be called with a location
|
|
687
|
-
// argument that corresponds to a known catch block.
|
|
688
|
-
throw new Error("illegal catch attempt");
|
|
689
|
-
},
|
|
690
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
691
|
-
this.delegate = {
|
|
692
|
-
iterator: values(iterable),
|
|
693
|
-
resultName: resultName,
|
|
694
|
-
nextLoc: nextLoc
|
|
695
|
-
};
|
|
696
|
-
if (this.method === "next") {
|
|
697
|
-
// Deliberately forget the last sent value so that we don't
|
|
698
|
-
// accidentally pass it on to the delegate.
|
|
699
|
-
this.arg = undefined$1;
|
|
700
|
-
}
|
|
701
|
-
return ContinueSentinel;
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
706
|
-
// or not, return the runtime object so that we can declare the variable
|
|
707
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
708
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
709
|
-
return exports;
|
|
710
|
-
}(
|
|
711
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
712
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
713
|
-
// object. Either way, the resulting object will be used to initialize
|
|
714
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
715
|
-
module.exports );
|
|
716
|
-
try {
|
|
717
|
-
regeneratorRuntime = runtime;
|
|
718
|
-
} catch (accidentalStrictMode) {
|
|
719
|
-
// This module should not be running in strict mode, so the above
|
|
720
|
-
// assignment should always work unless something is misconfigured. Just
|
|
721
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
722
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
723
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
724
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
725
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
726
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
727
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
728
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
729
|
-
if (typeof globalThis === "object") {
|
|
730
|
-
globalThis.regeneratorRuntime = runtime;
|
|
731
|
-
} else {
|
|
732
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
|
|
380
|
+
var _getAsyncError, _ref;
|
|
737
381
|
function getError(errors, status) {
|
|
738
382
|
var _errors;
|
|
739
383
|
errors = (_errors = errors) != null ? _errors : [{
|
|
@@ -745,69 +389,58 @@ function getError(errors, status) {
|
|
|
745
389
|
});
|
|
746
390
|
}
|
|
747
391
|
function getAsyncError(_x) {
|
|
748
|
-
return _getAsyncError.
|
|
749
|
-
}
|
|
750
|
-
function _getAsyncError() {
|
|
751
|
-
_getAsyncError = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(res) {
|
|
392
|
+
return (_getAsyncError = _getAsyncError || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
|
|
752
393
|
var data;
|
|
753
|
-
return
|
|
754
|
-
while (1) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
return _context2.stop();
|
|
765
|
-
}
|
|
394
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
395
|
+
while (1) switch (_context.prev = _context.next) {
|
|
396
|
+
case 0:
|
|
397
|
+
_context.next = 2;
|
|
398
|
+
return res.json();
|
|
399
|
+
case 2:
|
|
400
|
+
data = _context.sent;
|
|
401
|
+
return _context.abrupt("return", getError(data.errors, res.status));
|
|
402
|
+
case 4:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context.stop();
|
|
766
405
|
}
|
|
767
|
-
},
|
|
768
|
-
}));
|
|
769
|
-
return _getAsyncError.apply(this, arguments);
|
|
406
|
+
}, _callee);
|
|
407
|
+
}))).apply(this, arguments);
|
|
770
408
|
}
|
|
771
|
-
var handleFetchResponse =
|
|
772
|
-
|
|
409
|
+
var handleFetchResponse = function handleFetchResponse(_x2) {
|
|
410
|
+
return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(res) {
|
|
773
411
|
var _yield$res$json, data, errors;
|
|
774
|
-
return
|
|
775
|
-
while (1) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
return _context.stop();
|
|
803
|
-
}
|
|
412
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
413
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
414
|
+
case 0:
|
|
415
|
+
if (!res.ok) {
|
|
416
|
+
_context2.next = 9;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
_context2.next = 3;
|
|
420
|
+
return res.json();
|
|
421
|
+
case 3:
|
|
422
|
+
_yield$res$json = _context2.sent;
|
|
423
|
+
data = _yield$res$json.data;
|
|
424
|
+
errors = _yield$res$json.errors;
|
|
425
|
+
if (!(errors && errors.length)) {
|
|
426
|
+
_context2.next = 8;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
throw getError(errors, res.status);
|
|
430
|
+
case 8:
|
|
431
|
+
return _context2.abrupt("return", data);
|
|
432
|
+
case 9:
|
|
433
|
+
_context2.next = 11;
|
|
434
|
+
return getAsyncError(res);
|
|
435
|
+
case 11:
|
|
436
|
+
throw _context2.sent;
|
|
437
|
+
case 12:
|
|
438
|
+
case "end":
|
|
439
|
+
return _context2.stop();
|
|
804
440
|
}
|
|
805
|
-
},
|
|
806
|
-
}));
|
|
807
|
-
|
|
808
|
-
return _ref.apply(this, arguments);
|
|
809
|
-
};
|
|
810
|
-
}();
|
|
441
|
+
}, _callee2);
|
|
442
|
+
}))).apply(this, arguments);
|
|
443
|
+
};
|
|
811
444
|
|
|
812
445
|
/*
|
|
813
446
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
@@ -893,50 +526,46 @@ var getCheckoutQuery = /* GraphQL */"\n query getCheckout($checkoutId: ID!) {\n
|
|
|
893
526
|
*/
|
|
894
527
|
var checkoutCreateMutation = /* GraphQL */"\n mutation checkoutCreate($input: CheckoutCreateInput = {}) {\n checkoutCreate(input: $input) {\n checkoutUserErrors {\n code\n field\n message\n }\n checkout {\n ...checkoutDetails\n }\n }\n }\n\n " + checkoutDetailsFragment + "\n";
|
|
895
528
|
|
|
896
|
-
var
|
|
897
|
-
|
|
529
|
+
var _ref$1;
|
|
530
|
+
var checkoutCreate = function checkoutCreate(_x, _x2) {
|
|
531
|
+
return (_ref$1 = _ref$1 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch, lineItems) {
|
|
898
532
|
var _yield$fetch, checkoutCreate, checkout, checkoutId, options;
|
|
899
|
-
return
|
|
900
|
-
while (1) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
lineItems: lineItems
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
case 2:
|
|
913
|
-
_yield$fetch = _context.sent;
|
|
914
|
-
checkoutCreate = _yield$fetch.checkoutCreate;
|
|
915
|
-
checkout = checkoutCreate == null ? void 0 : checkoutCreate.checkout;
|
|
916
|
-
if (checkout) {
|
|
917
|
-
checkoutId = checkout == null ? void 0 : checkout.id;
|
|
918
|
-
options = {
|
|
919
|
-
expires: SHOPIFY_COOKIE_EXPIRE,
|
|
920
|
-
sameSite: "none",
|
|
921
|
-
secure: true
|
|
922
|
-
};
|
|
923
|
-
Cookies.set(SHOPIFY_CHECKOUT_ID_COOKIE, checkoutId, options);
|
|
924
|
-
if (checkout != null && checkout.webUrl) {
|
|
925
|
-
Cookies.set(SHOPIFY_CHECKOUT_URL_COOKIE, checkout.webUrl, options);
|
|
533
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
534
|
+
while (1) switch (_context.prev = _context.next) {
|
|
535
|
+
case 0:
|
|
536
|
+
_context.next = 2;
|
|
537
|
+
return fetch({
|
|
538
|
+
query: checkoutCreateMutation,
|
|
539
|
+
variables: {
|
|
540
|
+
input: {
|
|
541
|
+
lineItems: lineItems
|
|
926
542
|
}
|
|
927
543
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
544
|
+
});
|
|
545
|
+
case 2:
|
|
546
|
+
_yield$fetch = _context.sent;
|
|
547
|
+
checkoutCreate = _yield$fetch.checkoutCreate;
|
|
548
|
+
checkout = checkoutCreate == null ? void 0 : checkoutCreate.checkout;
|
|
549
|
+
if (checkout) {
|
|
550
|
+
checkoutId = checkout == null ? void 0 : checkout.id;
|
|
551
|
+
options = {
|
|
552
|
+
expires: SHOPIFY_COOKIE_EXPIRE,
|
|
553
|
+
sameSite: "none",
|
|
554
|
+
secure: true
|
|
555
|
+
};
|
|
556
|
+
Cookies.set(SHOPIFY_CHECKOUT_ID_COOKIE, checkoutId, options);
|
|
557
|
+
if (checkout != null && checkout.webUrl) {
|
|
558
|
+
Cookies.set(SHOPIFY_CHECKOUT_URL_COOKIE, checkout.webUrl, options);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return _context.abrupt("return", checkoutCreate);
|
|
562
|
+
case 7:
|
|
563
|
+
case "end":
|
|
564
|
+
return _context.stop();
|
|
933
565
|
}
|
|
934
566
|
}, _callee);
|
|
935
|
-
}));
|
|
936
|
-
|
|
937
|
-
return _ref.apply(this, arguments);
|
|
938
|
-
};
|
|
939
|
-
}();
|
|
567
|
+
}))).apply(this, arguments);
|
|
568
|
+
};
|
|
940
569
|
|
|
941
570
|
/*
|
|
942
571
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
@@ -1250,13 +879,13 @@ function normalizeLineItem(_ref9) {
|
|
|
1250
879
|
sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : "",
|
|
1251
880
|
name: variant == null ? void 0 : variant.title,
|
|
1252
881
|
image: {
|
|
1253
|
-
url: (variant == null
|
|
882
|
+
url: (variant == null || (_variant$image = variant.image) == null ? void 0 : _variant$image.originalSrc) || "/product-img-placeholder.svg"
|
|
1254
883
|
},
|
|
1255
884
|
requiresShipping: (_variant$requiresShip = variant == null ? void 0 : variant.requiresShipping) != null ? _variant$requiresShip : false,
|
|
1256
|
-
price: variant == null
|
|
1257
|
-
listPrice: variant == null
|
|
885
|
+
price: variant == null || (_variant$priceV = variant.priceV2) == null ? void 0 : _variant$priceV.amount,
|
|
886
|
+
listPrice: variant == null || (_variant$compareAtPri = variant.compareAtPriceV2) == null ? void 0 : _variant$compareAtPri.amount
|
|
1258
887
|
},
|
|
1259
|
-
path: String(variant == null
|
|
888
|
+
path: String(variant == null || (_variant$product = variant.product) == null ? void 0 : _variant$product.handle),
|
|
1260
889
|
discounts: [],
|
|
1261
890
|
options: (variant == null ? void 0 : variant.title) == "Default Title" ? [] : variant == null ? void 0 : variant.selectedOptions
|
|
1262
891
|
};
|
|
@@ -1386,60 +1015,58 @@ var handler = {
|
|
|
1386
1015
|
query: getAllProductsQuery
|
|
1387
1016
|
},
|
|
1388
1017
|
fetcher: function fetcher(_ref) {
|
|
1389
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1018
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1390
1019
|
var _products, _products2;
|
|
1391
|
-
var input, options, fetch, categoryId, brandId, method, variables, products, _data$node, _data$
|
|
1392
|
-
return
|
|
1393
|
-
while (1) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
_context.next = 11;
|
|
1402
|
-
break;
|
|
1403
|
-
}
|
|
1404
|
-
_context.next = 7;
|
|
1405
|
-
return fetch({
|
|
1406
|
-
query: getCollectionProductsQuery,
|
|
1407
|
-
method: method,
|
|
1408
|
-
variables: _extends({}, variables, {
|
|
1409
|
-
first: undefined
|
|
1410
|
-
})
|
|
1411
|
-
});
|
|
1412
|
-
case 7:
|
|
1413
|
-
data = _context.sent;
|
|
1414
|
-
// filter on client when brandId & categoryId are set since is not available on collection product query
|
|
1415
|
-
products = brandId ? (_data$node = data.node) == null ? void 0 : (_data$node$products = _data$node.products) == null ? void 0 : (_data$node$products$e = _data$node$products.edges) == null ? void 0 : _data$node$products$e.filter(function (_ref2) {
|
|
1416
|
-
var vendor = _ref2.node.vendor;
|
|
1417
|
-
return vendor.replace(/\s+/g, "-").toLowerCase() === ("" + brandId).toLowerCase();
|
|
1418
|
-
}).slice(0, input.count) : (_data$node2 = data.node) == null ? void 0 : (_data$node2$products = _data$node2.products) == null ? void 0 : _data$node2$products.edges.slice(0, input.count);
|
|
1419
|
-
_context.next = 15;
|
|
1020
|
+
var input, options, fetch, categoryId, brandId, method, variables, products, _data$node, _data$node2, data, _data$products, _data;
|
|
1021
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1022
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1023
|
+
case 0:
|
|
1024
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1025
|
+
categoryId = input.categoryId, brandId = input.brandId;
|
|
1026
|
+
method = options == null ? void 0 : options.method;
|
|
1027
|
+
variables = getSearchVariables(input);
|
|
1028
|
+
if (!categoryId) {
|
|
1029
|
+
_context.next = 11;
|
|
1420
1030
|
break;
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1031
|
+
}
|
|
1032
|
+
_context.next = 7;
|
|
1033
|
+
return fetch({
|
|
1034
|
+
query: getCollectionProductsQuery,
|
|
1035
|
+
method: method,
|
|
1036
|
+
variables: _extends({}, variables, {
|
|
1037
|
+
first: undefined
|
|
1038
|
+
})
|
|
1039
|
+
});
|
|
1040
|
+
case 7:
|
|
1041
|
+
data = _context.sent;
|
|
1042
|
+
// filter on client when brandId & categoryId are set since is not available on collection product query
|
|
1043
|
+
products = brandId ? (_data$node = data.node) == null || (_data$node = _data$node.products) == null || (_data$node = _data$node.edges) == null ? void 0 : _data$node.filter(function (_ref2) {
|
|
1044
|
+
var vendor = _ref2.node.vendor;
|
|
1045
|
+
return vendor.replace(/\s+/g, "-").toLowerCase() === ("" + brandId).toLowerCase();
|
|
1046
|
+
}).slice(0, input.count) : (_data$node2 = data.node) == null || (_data$node2 = _data$node2.products) == null ? void 0 : _data$node2.edges.slice(0, input.count);
|
|
1047
|
+
_context.next = 15;
|
|
1048
|
+
break;
|
|
1049
|
+
case 11:
|
|
1050
|
+
_context.next = 13;
|
|
1051
|
+
return fetch({
|
|
1052
|
+
query: options.query,
|
|
1053
|
+
method: method,
|
|
1054
|
+
variables: variables
|
|
1055
|
+
});
|
|
1056
|
+
case 13:
|
|
1057
|
+
_data = _context.sent;
|
|
1058
|
+
products = (_data$products = _data.products) == null ? void 0 : _data$products.edges;
|
|
1059
|
+
case 15:
|
|
1060
|
+
return _context.abrupt("return", {
|
|
1061
|
+
products: (_products = products) == null ? void 0 : _products.map(function (_ref3) {
|
|
1062
|
+
var node = _ref3.node;
|
|
1063
|
+
return normalizeProduct(node);
|
|
1064
|
+
}),
|
|
1065
|
+
found: !!((_products2 = products) != null && _products2.length)
|
|
1066
|
+
});
|
|
1067
|
+
case 16:
|
|
1068
|
+
case "end":
|
|
1069
|
+
return _context.stop();
|
|
1443
1070
|
}
|
|
1444
1071
|
}, _callee);
|
|
1445
1072
|
}))();
|
|
@@ -1465,56 +1092,54 @@ var handler$1 = {
|
|
|
1465
1092
|
query: getProductQueryBySlug
|
|
1466
1093
|
},
|
|
1467
1094
|
fetcher: function fetcher(_ref) {
|
|
1468
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1095
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1469
1096
|
var input, options, fetch, id, product, data, _data;
|
|
1470
|
-
return
|
|
1471
|
-
while (1) {
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
_context.next = 4;
|
|
1478
|
-
break;
|
|
1479
|
-
}
|
|
1480
|
-
return _context.abrupt("return", null);
|
|
1481
|
-
case 4:
|
|
1482
|
-
product = null;
|
|
1483
|
-
if (!id.startsWith("gid://shopify")) {
|
|
1484
|
-
_context.next = 12;
|
|
1485
|
-
break;
|
|
1486
|
-
}
|
|
1487
|
-
_context.next = 8;
|
|
1488
|
-
return fetch({
|
|
1489
|
-
query: getProductQueryById,
|
|
1490
|
-
variables: {
|
|
1491
|
-
id: id
|
|
1492
|
-
}
|
|
1493
|
-
});
|
|
1494
|
-
case 8:
|
|
1495
|
-
data = _context.sent;
|
|
1496
|
-
product = data.product;
|
|
1497
|
-
_context.next = 16;
|
|
1097
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1098
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1099
|
+
case 0:
|
|
1100
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1101
|
+
id = input.id;
|
|
1102
|
+
if (id) {
|
|
1103
|
+
_context.next = 4;
|
|
1498
1104
|
break;
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1105
|
+
}
|
|
1106
|
+
return _context.abrupt("return", null);
|
|
1107
|
+
case 4:
|
|
1108
|
+
product = null;
|
|
1109
|
+
if (!id.startsWith("gid://shopify")) {
|
|
1110
|
+
_context.next = 12;
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1113
|
+
_context.next = 8;
|
|
1114
|
+
return fetch({
|
|
1115
|
+
query: getProductQueryById,
|
|
1116
|
+
variables: {
|
|
1117
|
+
id: id
|
|
1511
1118
|
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1119
|
+
});
|
|
1120
|
+
case 8:
|
|
1121
|
+
data = _context.sent;
|
|
1122
|
+
product = data.product;
|
|
1123
|
+
_context.next = 16;
|
|
1124
|
+
break;
|
|
1125
|
+
case 12:
|
|
1126
|
+
_context.next = 14;
|
|
1127
|
+
return fetch({
|
|
1128
|
+
query: options.query,
|
|
1129
|
+
variables: {
|
|
1130
|
+
slug: id
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
case 14:
|
|
1134
|
+
_data = _context.sent;
|
|
1135
|
+
if (_data.productByHandle) {
|
|
1136
|
+
product = _data.productByHandle;
|
|
1137
|
+
}
|
|
1138
|
+
case 16:
|
|
1139
|
+
return _context.abrupt("return", product ? normalizeProduct(product) : null);
|
|
1140
|
+
case 17:
|
|
1141
|
+
case "end":
|
|
1142
|
+
return _context.stop();
|
|
1518
1143
|
}
|
|
1519
1144
|
}, _callee);
|
|
1520
1145
|
}))();
|
|
@@ -1540,43 +1165,41 @@ var handler$2 = {
|
|
|
1540
1165
|
query: getCheckoutQuery
|
|
1541
1166
|
},
|
|
1542
1167
|
fetcher: function fetcher(_ref) {
|
|
1543
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1168
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1544
1169
|
var cartId, options, fetch, _yield$fetch, checkout;
|
|
1545
|
-
return
|
|
1546
|
-
while (1) {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
checkoutId: cartId
|
|
1558
|
-
}
|
|
1559
|
-
}));
|
|
1560
|
-
case 4:
|
|
1561
|
-
_yield$fetch = _context.sent;
|
|
1562
|
-
checkout = _yield$fetch.node;
|
|
1563
|
-
if (!(checkout != null && checkout.completedAt)) {
|
|
1564
|
-
_context.next = 12;
|
|
1565
|
-
break;
|
|
1170
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1171
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1172
|
+
case 0:
|
|
1173
|
+
cartId = _ref.input.cartId, options = _ref.options, fetch = _ref.fetch;
|
|
1174
|
+
if (!cartId) {
|
|
1175
|
+
_context.next = 13;
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
_context.next = 4;
|
|
1179
|
+
return fetch(_extends({}, options, {
|
|
1180
|
+
variables: {
|
|
1181
|
+
checkoutId: cartId
|
|
1566
1182
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1183
|
+
}));
|
|
1184
|
+
case 4:
|
|
1185
|
+
_yield$fetch = _context.sent;
|
|
1186
|
+
checkout = _yield$fetch.node;
|
|
1187
|
+
if (!(checkout != null && checkout.completedAt)) {
|
|
1188
|
+
_context.next = 12;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
Cookies.remove(SHOPIFY_CHECKOUT_ID_COOKIE);
|
|
1192
|
+
Cookies.remove(SHOPIFY_CHECKOUT_URL_COOKIE);
|
|
1193
|
+
return _context.abrupt("return", null);
|
|
1194
|
+
case 12:
|
|
1195
|
+
return _context.abrupt("return", checkoutToCart({
|
|
1196
|
+
checkout: checkout
|
|
1197
|
+
}));
|
|
1198
|
+
case 13:
|
|
1199
|
+
return _context.abrupt("return", null);
|
|
1200
|
+
case 14:
|
|
1201
|
+
case "end":
|
|
1202
|
+
return _context.stop();
|
|
1580
1203
|
}
|
|
1581
1204
|
}, _callee);
|
|
1582
1205
|
}))();
|
|
@@ -1609,53 +1232,51 @@ var handler$3 = {
|
|
|
1609
1232
|
query: checkoutLineItemAddMutation
|
|
1610
1233
|
},
|
|
1611
1234
|
fetcher: function fetcher(_ref) {
|
|
1612
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1235
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1613
1236
|
var _item$quantity;
|
|
1614
1237
|
var item, options, fetch, lineItems, checkoutId, _yield$fetch, checkoutLineItemsAdd;
|
|
1615
|
-
return
|
|
1616
|
-
while (1) {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1238
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1239
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1240
|
+
case 0:
|
|
1241
|
+
item = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1242
|
+
if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
|
|
1243
|
+
_context.next = 3;
|
|
1244
|
+
break;
|
|
1245
|
+
}
|
|
1246
|
+
throw new commerce.CommerceError({
|
|
1247
|
+
message: 'The item quantity has to be a valid integer greater than 0'
|
|
1248
|
+
});
|
|
1249
|
+
case 3:
|
|
1250
|
+
lineItems = [{
|
|
1251
|
+
variantId: item.variantId,
|
|
1252
|
+
quantity: (_item$quantity = item.quantity) != null ? _item$quantity : 1
|
|
1253
|
+
}];
|
|
1254
|
+
checkoutId = getCheckoutId();
|
|
1255
|
+
if (checkoutId) {
|
|
1256
|
+
_context.next = 13;
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
_context.t0 = checkoutToCart;
|
|
1260
|
+
_context.next = 9;
|
|
1261
|
+
return checkoutCreate(fetch, lineItems);
|
|
1262
|
+
case 9:
|
|
1263
|
+
_context.t1 = _context.sent;
|
|
1264
|
+
return _context.abrupt("return", (0, _context.t0)(_context.t1));
|
|
1265
|
+
case 13:
|
|
1266
|
+
_context.next = 15;
|
|
1267
|
+
return fetch(_extends({}, options, {
|
|
1268
|
+
variables: {
|
|
1269
|
+
checkoutId: checkoutId,
|
|
1270
|
+
lineItems: lineItems
|
|
1636
1271
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
return fetch(_extends({}, options, {
|
|
1646
|
-
variables: {
|
|
1647
|
-
checkoutId: checkoutId,
|
|
1648
|
-
lineItems: lineItems
|
|
1649
|
-
}
|
|
1650
|
-
}));
|
|
1651
|
-
case 15:
|
|
1652
|
-
_yield$fetch = _context.sent;
|
|
1653
|
-
checkoutLineItemsAdd = _yield$fetch.checkoutLineItemsAdd;
|
|
1654
|
-
return _context.abrupt("return", checkoutToCart(checkoutLineItemsAdd));
|
|
1655
|
-
case 18:
|
|
1656
|
-
case "end":
|
|
1657
|
-
return _context.stop();
|
|
1658
|
-
}
|
|
1272
|
+
}));
|
|
1273
|
+
case 15:
|
|
1274
|
+
_yield$fetch = _context.sent;
|
|
1275
|
+
checkoutLineItemsAdd = _yield$fetch.checkoutLineItemsAdd;
|
|
1276
|
+
return _context.abrupt("return", checkoutToCart(checkoutLineItemsAdd));
|
|
1277
|
+
case 18:
|
|
1278
|
+
case "end":
|
|
1279
|
+
return _context.stop();
|
|
1659
1280
|
}
|
|
1660
1281
|
}, _callee);
|
|
1661
1282
|
}))();
|
|
@@ -1663,37 +1284,32 @@ var handler$3 = {
|
|
|
1663
1284
|
useHook: function useHook(_ref2) {
|
|
1664
1285
|
var fetch = _ref2.fetch;
|
|
1665
1286
|
return function () {
|
|
1287
|
+
var _addItem;
|
|
1666
1288
|
var _useCart = commerce.useCart(),
|
|
1667
1289
|
mutate = _useCart.mutate;
|
|
1668
|
-
return React.useCallback(
|
|
1669
|
-
|
|
1290
|
+
return React.useCallback(function addItem(_x) {
|
|
1291
|
+
return (_addItem = _addItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1670
1292
|
var data;
|
|
1671
|
-
return
|
|
1672
|
-
while (1) {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
return _context2.stop();
|
|
1688
|
-
}
|
|
1293
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1294
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1295
|
+
case 0:
|
|
1296
|
+
_context2.next = 2;
|
|
1297
|
+
return fetch({
|
|
1298
|
+
input: input
|
|
1299
|
+
});
|
|
1300
|
+
case 2:
|
|
1301
|
+
data = _context2.sent;
|
|
1302
|
+
_context2.next = 5;
|
|
1303
|
+
return mutate(data, false);
|
|
1304
|
+
case 5:
|
|
1305
|
+
return _context2.abrupt("return", data);
|
|
1306
|
+
case 6:
|
|
1307
|
+
case "end":
|
|
1308
|
+
return _context2.stop();
|
|
1689
1309
|
}
|
|
1690
1310
|
}, _callee2);
|
|
1691
|
-
}));
|
|
1692
|
-
|
|
1693
|
-
return _addItem.apply(this, arguments);
|
|
1694
|
-
}
|
|
1695
|
-
return addItem;
|
|
1696
|
-
}(), [fetch, mutate]);
|
|
1311
|
+
}))).apply(this, arguments);
|
|
1312
|
+
}, [fetch, mutate]);
|
|
1697
1313
|
};
|
|
1698
1314
|
}
|
|
1699
1315
|
};
|
|
@@ -1703,27 +1319,25 @@ var handler$4 = {
|
|
|
1703
1319
|
query: checkoutLineItemRemoveMutation
|
|
1704
1320
|
},
|
|
1705
1321
|
fetcher: function fetcher(_ref) {
|
|
1706
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1322
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1707
1323
|
var itemId, options, fetch, data;
|
|
1708
|
-
return
|
|
1709
|
-
while (1) {
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
return _context.stop();
|
|
1726
|
-
}
|
|
1324
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1325
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1326
|
+
case 0:
|
|
1327
|
+
itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
|
|
1328
|
+
_context.next = 3;
|
|
1329
|
+
return fetch(_extends({}, options, {
|
|
1330
|
+
variables: {
|
|
1331
|
+
checkoutId: getCheckoutId(),
|
|
1332
|
+
lineItemIds: [itemId]
|
|
1333
|
+
}
|
|
1334
|
+
}));
|
|
1335
|
+
case 3:
|
|
1336
|
+
data = _context.sent;
|
|
1337
|
+
return _context.abrupt("return", checkoutToCart(data.checkoutLineItemsRemove));
|
|
1338
|
+
case 5:
|
|
1339
|
+
case "end":
|
|
1340
|
+
return _context.stop();
|
|
1727
1341
|
}
|
|
1728
1342
|
}, _callee);
|
|
1729
1343
|
}))();
|
|
@@ -1731,6 +1345,7 @@ var handler$4 = {
|
|
|
1731
1345
|
useHook: function useHook(_ref2) {
|
|
1732
1346
|
var fetch = _ref2.fetch;
|
|
1733
1347
|
return function (ctx) {
|
|
1348
|
+
var _ref3;
|
|
1734
1349
|
if (ctx === void 0) {
|
|
1735
1350
|
ctx = {};
|
|
1736
1351
|
}
|
|
@@ -1738,46 +1353,41 @@ var handler$4 = {
|
|
|
1738
1353
|
item = _ctx.item;
|
|
1739
1354
|
var _useCart = commerce.useCart(),
|
|
1740
1355
|
mutate = _useCart.mutate;
|
|
1741
|
-
var removeItem =
|
|
1742
|
-
|
|
1356
|
+
var removeItem = function removeItem(_x) {
|
|
1357
|
+
return (_ref3 = _ref3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1743
1358
|
var _input$id;
|
|
1744
1359
|
var itemId, data;
|
|
1745
|
-
return
|
|
1746
|
-
while (1) {
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1360
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1361
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1362
|
+
case 0:
|
|
1363
|
+
itemId = (_input$id = input == null ? void 0 : input.id) != null ? _input$id : item == null ? void 0 : item.id;
|
|
1364
|
+
if (itemId) {
|
|
1365
|
+
_context2.next = 3;
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
throw new commerce.ValidationError({
|
|
1369
|
+
message: 'Invalid input used for this operation'
|
|
1370
|
+
});
|
|
1371
|
+
case 3:
|
|
1372
|
+
_context2.next = 5;
|
|
1373
|
+
return fetch({
|
|
1374
|
+
input: {
|
|
1375
|
+
itemId: itemId
|
|
1753
1376
|
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
case 5:
|
|
1765
|
-
data = _context2.sent;
|
|
1766
|
-
_context2.next = 8;
|
|
1767
|
-
return mutate(data, false);
|
|
1768
|
-
case 8:
|
|
1769
|
-
return _context2.abrupt("return", data);
|
|
1770
|
-
case 9:
|
|
1771
|
-
case "end":
|
|
1772
|
-
return _context2.stop();
|
|
1773
|
-
}
|
|
1377
|
+
});
|
|
1378
|
+
case 5:
|
|
1379
|
+
data = _context2.sent;
|
|
1380
|
+
_context2.next = 8;
|
|
1381
|
+
return mutate(data, false);
|
|
1382
|
+
case 8:
|
|
1383
|
+
return _context2.abrupt("return", data);
|
|
1384
|
+
case 9:
|
|
1385
|
+
case "end":
|
|
1386
|
+
return _context2.stop();
|
|
1774
1387
|
}
|
|
1775
1388
|
}, _callee2);
|
|
1776
|
-
}));
|
|
1777
|
-
|
|
1778
|
-
return _ref3.apply(this, arguments);
|
|
1779
|
-
};
|
|
1780
|
-
}();
|
|
1389
|
+
}))).apply(this, arguments);
|
|
1390
|
+
};
|
|
1781
1391
|
return React.useCallback(removeItem, [fetch, mutate]);
|
|
1782
1392
|
};
|
|
1783
1393
|
}
|
|
@@ -1788,58 +1398,56 @@ var handler$5 = {
|
|
|
1788
1398
|
query: checkoutLineItemUpdateMutation
|
|
1789
1399
|
},
|
|
1790
1400
|
fetcher: function fetcher(_ref) {
|
|
1791
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1401
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1792
1402
|
var _ref$input, itemId, item, options, fetch, _yield$fetch, checkoutLineItemsUpdate;
|
|
1793
|
-
return
|
|
1794
|
-
while (1) {
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1403
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1404
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1405
|
+
case 0:
|
|
1406
|
+
_ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
|
|
1407
|
+
if (!Number.isInteger(item.quantity)) {
|
|
1408
|
+
_context.next = 6;
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
if (!(item.quantity < 1)) {
|
|
1412
|
+
_context.next = 4;
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
return _context.abrupt("return", handler$4.fetcher({
|
|
1416
|
+
options: handler$4.fetchOptions,
|
|
1417
|
+
input: {
|
|
1418
|
+
itemId: itemId
|
|
1419
|
+
},
|
|
1420
|
+
fetch: fetch
|
|
1421
|
+
}));
|
|
1422
|
+
case 4:
|
|
1423
|
+
_context.next = 8;
|
|
1424
|
+
break;
|
|
1425
|
+
case 6:
|
|
1426
|
+
if (!item.quantity) {
|
|
1814
1427
|
_context.next = 8;
|
|
1815
1428
|
break;
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1429
|
+
}
|
|
1430
|
+
throw new commerce.ValidationError({
|
|
1431
|
+
message: "The item quantity has to be a valid integer"
|
|
1432
|
+
});
|
|
1433
|
+
case 8:
|
|
1434
|
+
_context.next = 10;
|
|
1435
|
+
return fetch(_extends({}, options, {
|
|
1436
|
+
variables: {
|
|
1437
|
+
checkoutId: getCheckoutId(),
|
|
1438
|
+
lineItems: [{
|
|
1439
|
+
id: itemId,
|
|
1440
|
+
quantity: item.quantity
|
|
1441
|
+
}]
|
|
1820
1442
|
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
lineItems: [{
|
|
1830
|
-
id: itemId,
|
|
1831
|
-
quantity: item.quantity
|
|
1832
|
-
}]
|
|
1833
|
-
}
|
|
1834
|
-
}));
|
|
1835
|
-
case 10:
|
|
1836
|
-
_yield$fetch = _context.sent;
|
|
1837
|
-
checkoutLineItemsUpdate = _yield$fetch.checkoutLineItemsUpdate;
|
|
1838
|
-
return _context.abrupt("return", checkoutToCart(checkoutLineItemsUpdate));
|
|
1839
|
-
case 13:
|
|
1840
|
-
case "end":
|
|
1841
|
-
return _context.stop();
|
|
1842
|
-
}
|
|
1443
|
+
}));
|
|
1444
|
+
case 10:
|
|
1445
|
+
_yield$fetch = _context.sent;
|
|
1446
|
+
checkoutLineItemsUpdate = _yield$fetch.checkoutLineItemsUpdate;
|
|
1447
|
+
return _context.abrupt("return", checkoutToCart(checkoutLineItemsUpdate));
|
|
1448
|
+
case 13:
|
|
1449
|
+
case "end":
|
|
1450
|
+
return _context.stop();
|
|
1843
1451
|
}
|
|
1844
1452
|
}, _callee);
|
|
1845
1453
|
}))();
|
|
@@ -1847,7 +1455,7 @@ var handler$5 = {
|
|
|
1847
1455
|
useHook: function useHook(_ref2) {
|
|
1848
1456
|
var fetch = _ref2.fetch;
|
|
1849
1457
|
return function (ctx) {
|
|
1850
|
-
var _ctx$wait;
|
|
1458
|
+
var _ref3, _ctx$wait;
|
|
1851
1459
|
if (ctx === void 0) {
|
|
1852
1460
|
ctx = {};
|
|
1853
1461
|
}
|
|
@@ -1855,49 +1463,44 @@ var handler$5 = {
|
|
|
1855
1463
|
item = _ctx.item;
|
|
1856
1464
|
var _useCart = commerce.useCart(),
|
|
1857
1465
|
mutate = _useCart.mutate;
|
|
1858
|
-
return React.useCallback(debounce(
|
|
1859
|
-
|
|
1466
|
+
return React.useCallback(debounce(function (_x) {
|
|
1467
|
+
return (_ref3 = _ref3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
1860
1468
|
var _input$id;
|
|
1861
1469
|
var itemId, data;
|
|
1862
|
-
return
|
|
1863
|
-
while (1) {
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1470
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1471
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1472
|
+
case 0:
|
|
1473
|
+
itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
|
|
1474
|
+
if (!(!itemId || input.quantity == null)) {
|
|
1475
|
+
_context2.next = 3;
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1478
|
+
throw new commerce.ValidationError({
|
|
1479
|
+
message: "Invalid input used for this operation"
|
|
1480
|
+
});
|
|
1481
|
+
case 3:
|
|
1482
|
+
_context2.next = 5;
|
|
1483
|
+
return fetch({
|
|
1484
|
+
input: {
|
|
1485
|
+
item: {
|
|
1486
|
+
quantity: input.quantity
|
|
1487
|
+
},
|
|
1488
|
+
itemId: itemId
|
|
1870
1489
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
itemId: itemId
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
case 5:
|
|
1885
|
-
data = _context2.sent;
|
|
1886
|
-
_context2.next = 8;
|
|
1887
|
-
return mutate(data, false);
|
|
1888
|
-
case 8:
|
|
1889
|
-
return _context2.abrupt("return", data);
|
|
1890
|
-
case 9:
|
|
1891
|
-
case "end":
|
|
1892
|
-
return _context2.stop();
|
|
1893
|
-
}
|
|
1490
|
+
});
|
|
1491
|
+
case 5:
|
|
1492
|
+
data = _context2.sent;
|
|
1493
|
+
_context2.next = 8;
|
|
1494
|
+
return mutate(data, false);
|
|
1495
|
+
case 8:
|
|
1496
|
+
return _context2.abrupt("return", data);
|
|
1497
|
+
case 9:
|
|
1498
|
+
case "end":
|
|
1499
|
+
return _context2.stop();
|
|
1894
1500
|
}
|
|
1895
1501
|
}, _callee2);
|
|
1896
|
-
}));
|
|
1897
|
-
|
|
1898
|
-
return _ref3.apply(this, arguments);
|
|
1899
|
-
};
|
|
1900
|
-
}(), (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
|
|
1502
|
+
}))).apply(this, arguments);
|
|
1503
|
+
}, (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
|
|
1901
1504
|
};
|
|
1902
1505
|
}
|
|
1903
1506
|
};
|
|
@@ -1907,48 +1510,46 @@ var handler$6 = {
|
|
|
1907
1510
|
query: getSiteCollectionsQuery
|
|
1908
1511
|
},
|
|
1909
1512
|
fetcher: function fetcher(_ref) {
|
|
1910
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1911
|
-
var input, options, fetch, categoryId, _data$collections$edg, _data$collections,
|
|
1912
|
-
return
|
|
1913
|
-
while (1) {
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1513
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1514
|
+
var input, options, fetch, categoryId, _data$collections$edg, _data$collections, data, _data;
|
|
1515
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1516
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1517
|
+
case 0:
|
|
1518
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1519
|
+
categoryId = input.categoryId;
|
|
1520
|
+
if (categoryId) {
|
|
1521
|
+
_context.next = 9;
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
_context.next = 5;
|
|
1525
|
+
return fetch({
|
|
1526
|
+
query: options.query,
|
|
1527
|
+
variables: {
|
|
1528
|
+
first: 250
|
|
1921
1529
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
case 11:
|
|
1946
|
-
_data = _context.sent;
|
|
1947
|
-
return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
|
|
1948
|
-
case 13:
|
|
1949
|
-
case "end":
|
|
1950
|
-
return _context.stop();
|
|
1951
|
-
}
|
|
1530
|
+
});
|
|
1531
|
+
case 5:
|
|
1532
|
+
data = _context.sent;
|
|
1533
|
+
return _context.abrupt("return", (_data$collections$edg = data == null || (_data$collections = data.collections) == null || (_data$collections = _data$collections.edges) == null ? void 0 : _data$collections.map(function (_ref2) {
|
|
1534
|
+
var node = _ref2.node;
|
|
1535
|
+
return normalizeCategory(node);
|
|
1536
|
+
})) != null ? _data$collections$edg : []);
|
|
1537
|
+
case 9:
|
|
1538
|
+
_context.next = 11;
|
|
1539
|
+
return fetch({
|
|
1540
|
+
query: getCollectionQueryById,
|
|
1541
|
+
variables: _extends({}, categoryId.startsWith("gid://") ? {
|
|
1542
|
+
id: categoryId
|
|
1543
|
+
} : {
|
|
1544
|
+
handle: categoryId
|
|
1545
|
+
})
|
|
1546
|
+
});
|
|
1547
|
+
case 11:
|
|
1548
|
+
_data = _context.sent;
|
|
1549
|
+
return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
|
|
1550
|
+
case 13:
|
|
1551
|
+
case "end":
|
|
1552
|
+
return _context.stop();
|
|
1952
1553
|
}
|
|
1953
1554
|
}, _callee);
|
|
1954
1555
|
}))();
|
|
@@ -1982,38 +1583,36 @@ var handler$7 = {
|
|
|
1982
1583
|
query: getAllProductVendors
|
|
1983
1584
|
},
|
|
1984
1585
|
fetcher: function fetcher(_ref) {
|
|
1985
|
-
return _asyncToGenerator( /*#__PURE__*/
|
|
1586
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1986
1587
|
var fetch, data, vendorsStrings;
|
|
1987
|
-
return
|
|
1988
|
-
while (1) {
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
return _context.stop();
|
|
2016
|
-
}
|
|
1588
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1589
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1590
|
+
case 0:
|
|
1591
|
+
fetch = _ref.fetch;
|
|
1592
|
+
_context.next = 3;
|
|
1593
|
+
return fetch({
|
|
1594
|
+
query: getAllProductVendors,
|
|
1595
|
+
variables: {
|
|
1596
|
+
first: 250
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
case 3:
|
|
1600
|
+
data = _context.sent;
|
|
1601
|
+
vendorsStrings = data.products.edges.map(function (_ref2) {
|
|
1602
|
+
var vendor = _ref2.node.vendor;
|
|
1603
|
+
return vendor;
|
|
1604
|
+
});
|
|
1605
|
+
return _context.abrupt("return", Array.from(new Set(vendorsStrings).values()).map(function (v) {
|
|
1606
|
+
var id = v.replace(/\s+/g, '-').toLowerCase();
|
|
1607
|
+
return {
|
|
1608
|
+
entityId: id,
|
|
1609
|
+
name: v,
|
|
1610
|
+
path: "brands/" + id
|
|
1611
|
+
};
|
|
1612
|
+
}));
|
|
1613
|
+
case 6:
|
|
1614
|
+
case "end":
|
|
1615
|
+
return _context.stop();
|
|
2017
1616
|
}
|
|
2018
1617
|
}, _callee);
|
|
2019
1618
|
}))();
|
|
@@ -2043,44 +1642,40 @@ var handler$7 = {
|
|
|
2043
1642
|
|
|
2044
1643
|
var _excluded$1 = ["locale"];
|
|
2045
1644
|
var getFetcher = function getFetcher(storeDomain, accessToken) {
|
|
2046
|
-
|
|
2047
|
-
|
|
1645
|
+
var _ref2;
|
|
1646
|
+
return function (_x) {
|
|
1647
|
+
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
2048
1648
|
var _ref$url, url, _ref$method, method, variables, query, _ref3, locale, vars;
|
|
2049
|
-
return
|
|
2050
|
-
while (1) {
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
return _context.stop();
|
|
2076
|
-
}
|
|
1649
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1650
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1651
|
+
case 0:
|
|
1652
|
+
_ref$url = _ref.url, url = _ref$url === void 0 ? "https://" + storeDomain + "/api/2022-04/graphql.json" : _ref$url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, variables = _ref.variables, query = _ref.query;
|
|
1653
|
+
_ref3 = variables != null ? variables : {}, locale = _ref3.locale, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
|
|
1654
|
+
_context.t0 = handleFetchResponse;
|
|
1655
|
+
_context.next = 5;
|
|
1656
|
+
return fetch(url, {
|
|
1657
|
+
method: method,
|
|
1658
|
+
body: JSON.stringify({
|
|
1659
|
+
query: query,
|
|
1660
|
+
variables: vars
|
|
1661
|
+
}),
|
|
1662
|
+
headers: _extends({
|
|
1663
|
+
'X-Shopify-Storefront-Access-Token': accessToken,
|
|
1664
|
+
'Content-Type': 'application/json'
|
|
1665
|
+
}, locale && {
|
|
1666
|
+
'Accept-Language': locale
|
|
1667
|
+
})
|
|
1668
|
+
});
|
|
1669
|
+
case 5:
|
|
1670
|
+
_context.t1 = _context.sent;
|
|
1671
|
+
return _context.abrupt("return", (0, _context.t0)(_context.t1));
|
|
1672
|
+
case 7:
|
|
1673
|
+
case "end":
|
|
1674
|
+
return _context.stop();
|
|
2077
1675
|
}
|
|
2078
1676
|
}, _callee);
|
|
2079
|
-
}));
|
|
2080
|
-
|
|
2081
|
-
return _ref2.apply(this, arguments);
|
|
2082
|
-
};
|
|
2083
|
-
}();
|
|
1677
|
+
}))).apply(this, arguments);
|
|
1678
|
+
};
|
|
2084
1679
|
};
|
|
2085
1680
|
|
|
2086
1681
|
/*
|