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