@plasmicpkgs/commerce 0.0.242 → 0.0.244
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/dist/commerce.cjs.development.js +139 -336
- package/dist/commerce.cjs.development.js.map +1 -1
- package/dist/commerce.cjs.production.min.js +1 -1
- package/dist/commerce.cjs.production.min.js.map +1 -1
- package/dist/commerce.esm.js +139 -336
- package/dist/commerce.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -108,306 +108,113 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
108
108
|
}
|
|
109
109
|
return t;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return o(a, "_invoke", {
|
|
146
|
-
value: makeInvokeMethod(t, r, c)
|
|
147
|
-
}), a;
|
|
148
|
-
}
|
|
149
|
-
function tryCatch(t, e, r) {
|
|
150
|
-
try {
|
|
151
|
-
return {
|
|
152
|
-
type: "normal",
|
|
153
|
-
arg: t.call(e, r)
|
|
154
|
-
};
|
|
155
|
-
} catch (t) {
|
|
156
|
-
return {
|
|
157
|
-
type: "throw",
|
|
158
|
-
arg: t
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
e.wrap = wrap;
|
|
163
|
-
var h = "suspendedStart",
|
|
164
|
-
l = "suspendedYield",
|
|
165
|
-
f = "executing",
|
|
166
|
-
s = "completed",
|
|
167
|
-
y = {};
|
|
168
|
-
function Generator() {}
|
|
169
|
-
function GeneratorFunction() {}
|
|
170
|
-
function GeneratorFunctionPrototype() {}
|
|
171
|
-
var p = {};
|
|
172
|
-
define(p, a, function () {
|
|
173
|
-
return this;
|
|
174
|
-
});
|
|
175
|
-
var d = Object.getPrototypeOf,
|
|
176
|
-
v = d && d(d(values([])));
|
|
177
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
178
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
179
|
-
function defineIteratorMethods(t) {
|
|
180
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
181
|
-
define(t, e, function (t) {
|
|
182
|
-
return this._invoke(e, t);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
function AsyncIterator(t, e) {
|
|
187
|
-
function invoke(r, o, i, a) {
|
|
188
|
-
var c = tryCatch(t[r], t, o);
|
|
189
|
-
if ("throw" !== c.type) {
|
|
190
|
-
var u = c.arg,
|
|
191
|
-
h = u.value;
|
|
192
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
193
|
-
invoke("next", t, i, a);
|
|
194
|
-
}, function (t) {
|
|
195
|
-
invoke("throw", t, i, a);
|
|
196
|
-
}) : e.resolve(h).then(function (t) {
|
|
197
|
-
u.value = t, i(u);
|
|
198
|
-
}, function (t) {
|
|
199
|
-
return invoke("throw", t, i, a);
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
a(c.arg);
|
|
203
|
-
}
|
|
204
|
-
var r;
|
|
205
|
-
o(this, "_invoke", {
|
|
206
|
-
value: function (t, n) {
|
|
207
|
-
function callInvokeWithMethodAndArg() {
|
|
208
|
-
return new e(function (e, r) {
|
|
209
|
-
invoke(t, n, e, r);
|
|
210
|
-
});
|
|
111
|
+
function _regenerator() {
|
|
112
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
113
|
+
var e,
|
|
114
|
+
t,
|
|
115
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
116
|
+
n = r.iterator || "@@iterator",
|
|
117
|
+
o = r.toStringTag || "@@toStringTag";
|
|
118
|
+
function i(r, n, o, i) {
|
|
119
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
120
|
+
u = Object.create(c.prototype);
|
|
121
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
122
|
+
var i,
|
|
123
|
+
c,
|
|
124
|
+
u,
|
|
125
|
+
f = 0,
|
|
126
|
+
p = o || [],
|
|
127
|
+
y = !1,
|
|
128
|
+
G = {
|
|
129
|
+
p: 0,
|
|
130
|
+
n: 0,
|
|
131
|
+
v: e,
|
|
132
|
+
a: d,
|
|
133
|
+
f: d.bind(e, 4),
|
|
134
|
+
d: function (t, r) {
|
|
135
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
function d(r, n) {
|
|
139
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
140
|
+
var o,
|
|
141
|
+
i = p[t],
|
|
142
|
+
d = G.p,
|
|
143
|
+
l = i[2];
|
|
144
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
211
145
|
}
|
|
212
|
-
|
|
146
|
+
if (o || r > 1) return a;
|
|
147
|
+
throw y = !0, n;
|
|
213
148
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
149
|
+
return function (o, p, l) {
|
|
150
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
151
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
152
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
153
|
+
try {
|
|
154
|
+
if (f = 2, i) {
|
|
155
|
+
if (c || (o = "next"), t = i[o]) {
|
|
156
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
157
|
+
if (!t.done) return t;
|
|
158
|
+
u = t.value, c < 2 && (c = 0);
|
|
159
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
160
|
+
i = e;
|
|
161
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
162
|
+
} catch (t) {
|
|
163
|
+
i = e, c = 1, u = t;
|
|
164
|
+
} finally {
|
|
165
|
+
f = 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
222
168
|
return {
|
|
223
169
|
value: t,
|
|
224
|
-
done:
|
|
170
|
+
done: y
|
|
225
171
|
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
var c = n.delegate;
|
|
229
|
-
if (c) {
|
|
230
|
-
var u = maybeInvokeDelegate(c, n);
|
|
231
|
-
if (u) {
|
|
232
|
-
if (u === y) continue;
|
|
233
|
-
return u;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
237
|
-
if (o === h) throw o = s, n.arg;
|
|
238
|
-
n.dispatchException(n.arg);
|
|
239
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
240
|
-
o = f;
|
|
241
|
-
var p = tryCatch(e, r, n);
|
|
242
|
-
if ("normal" === p.type) {
|
|
243
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
244
|
-
return {
|
|
245
|
-
value: p.arg,
|
|
246
|
-
done: n.done
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function maybeInvokeDelegate(e, r) {
|
|
254
|
-
var n = r.method,
|
|
255
|
-
o = e.iterator[n];
|
|
256
|
-
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;
|
|
257
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
258
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
259
|
-
var a = i.arg;
|
|
260
|
-
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);
|
|
261
|
-
}
|
|
262
|
-
function pushTryEntry(t) {
|
|
263
|
-
var e = {
|
|
264
|
-
tryLoc: t[0]
|
|
265
|
-
};
|
|
266
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
267
|
-
}
|
|
268
|
-
function resetTryEntry(t) {
|
|
269
|
-
var e = t.completion || {};
|
|
270
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
271
|
-
}
|
|
272
|
-
function Context(t) {
|
|
273
|
-
this.tryEntries = [{
|
|
274
|
-
tryLoc: "root"
|
|
275
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
172
|
+
};
|
|
173
|
+
}(r, o, i), !0), u;
|
|
276
174
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return i.next = i;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
175
|
+
var a = {};
|
|
176
|
+
function Generator() {}
|
|
177
|
+
function GeneratorFunction() {}
|
|
178
|
+
function GeneratorFunctionPrototype() {}
|
|
179
|
+
t = Object.getPrototypeOf;
|
|
180
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
181
|
+
return this;
|
|
182
|
+
}), t),
|
|
183
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
184
|
+
function f(e) {
|
|
185
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
292
186
|
}
|
|
293
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
294
|
-
value: GeneratorFunctionPrototype,
|
|
295
|
-
configurable: !0
|
|
296
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
297
|
-
value: GeneratorFunction,
|
|
298
|
-
configurable: !0
|
|
299
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
300
|
-
var e = "function" == typeof t && t.constructor;
|
|
301
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
302
|
-
}, e.mark = function (t) {
|
|
303
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
304
|
-
}, e.awrap = function (t) {
|
|
305
|
-
return {
|
|
306
|
-
__await: t
|
|
307
|
-
};
|
|
308
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
309
|
-
return this;
|
|
310
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
311
|
-
void 0 === i && (i = Promise);
|
|
312
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
313
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
314
|
-
return t.done ? t.value : a.next();
|
|
315
|
-
});
|
|
316
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
187
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
317
188
|
return this;
|
|
318
|
-
}),
|
|
189
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
319
190
|
return "[object Generator]";
|
|
320
|
-
}),
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return r.reverse(), function next() {
|
|
325
|
-
for (; r.length;) {
|
|
326
|
-
var t = r.pop();
|
|
327
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
328
|
-
}
|
|
329
|
-
return next.done = !0, next;
|
|
191
|
+
}), (_regenerator = function () {
|
|
192
|
+
return {
|
|
193
|
+
w: i,
|
|
194
|
+
m: f
|
|
330
195
|
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
function handle(n, o) {
|
|
346
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
347
|
-
}
|
|
348
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
349
|
-
var i = this.tryEntries[o],
|
|
350
|
-
a = i.completion;
|
|
351
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
352
|
-
if (i.tryLoc <= this.prev) {
|
|
353
|
-
var c = n.call(i, "catchLoc"),
|
|
354
|
-
u = n.call(i, "finallyLoc");
|
|
355
|
-
if (c && u) {
|
|
356
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
357
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
358
|
-
} else if (c) {
|
|
359
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
360
|
-
} else {
|
|
361
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
362
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
abrupt: function (t, e) {
|
|
368
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
369
|
-
var o = this.tryEntries[r];
|
|
370
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
371
|
-
var i = o;
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
376
|
-
var a = i ? i.completion : {};
|
|
377
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
378
|
-
},
|
|
379
|
-
complete: function (t, e) {
|
|
380
|
-
if ("throw" === t.type) throw t.arg;
|
|
381
|
-
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;
|
|
382
|
-
},
|
|
383
|
-
finish: function (t) {
|
|
384
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
385
|
-
var r = this.tryEntries[e];
|
|
386
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
387
|
-
}
|
|
388
|
-
},
|
|
389
|
-
catch: function (t) {
|
|
390
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
391
|
-
var r = this.tryEntries[e];
|
|
392
|
-
if (r.tryLoc === t) {
|
|
393
|
-
var n = r.completion;
|
|
394
|
-
if ("throw" === n.type) {
|
|
395
|
-
var o = n.arg;
|
|
396
|
-
resetTryEntry(r);
|
|
397
|
-
}
|
|
398
|
-
return o;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
throw Error("illegal catch attempt");
|
|
402
|
-
},
|
|
403
|
-
delegateYield: function (e, r, n) {
|
|
404
|
-
return this.delegate = {
|
|
405
|
-
iterator: values(e),
|
|
406
|
-
resultName: r,
|
|
407
|
-
nextLoc: n
|
|
408
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
196
|
+
})();
|
|
197
|
+
}
|
|
198
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
199
|
+
var i = Object.defineProperty;
|
|
200
|
+
try {
|
|
201
|
+
i({}, "", {});
|
|
202
|
+
} catch (e) {
|
|
203
|
+
i = 0;
|
|
204
|
+
}
|
|
205
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
206
|
+
function o(r, n) {
|
|
207
|
+
_regeneratorDefine(e, r, function (e) {
|
|
208
|
+
return this._invoke(r, n, e);
|
|
209
|
+
});
|
|
409
210
|
}
|
|
410
|
-
|
|
211
|
+
r ? i ? i(e, r, {
|
|
212
|
+
value: n,
|
|
213
|
+
enumerable: !t,
|
|
214
|
+
configurable: !t,
|
|
215
|
+
writable: !t
|
|
216
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
217
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
411
218
|
}
|
|
412
219
|
function _setPrototypeOf(t, e) {
|
|
413
220
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
@@ -492,7 +299,6 @@ function defineProperty(obj, prop, val) {
|
|
|
492
299
|
}
|
|
493
300
|
|
|
494
301
|
var CommerceError = /*#__PURE__*/function (_Error) {
|
|
495
|
-
_inheritsLoose(CommerceError, _Error);
|
|
496
302
|
function CommerceError(_ref) {
|
|
497
303
|
var _this;
|
|
498
304
|
var message = _ref.message,
|
|
@@ -508,46 +314,48 @@ var CommerceError = /*#__PURE__*/function (_Error) {
|
|
|
508
314
|
if (error.code) _this.code = error.code;
|
|
509
315
|
return _this;
|
|
510
316
|
}
|
|
317
|
+
_inheritsLoose(CommerceError, _Error);
|
|
511
318
|
return CommerceError;
|
|
512
319
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
513
320
|
// Used for errors that come from a bad implementation of the hooks
|
|
514
321
|
var ValidationError = /*#__PURE__*/function (_CommerceError) {
|
|
515
|
-
_inheritsLoose(ValidationError, _CommerceError);
|
|
516
322
|
function ValidationError(options) {
|
|
517
323
|
var _this2;
|
|
518
324
|
_this2 = _CommerceError.call(this, options) || this;
|
|
519
325
|
_this2.code = 'validation_error';
|
|
520
326
|
return _this2;
|
|
521
327
|
}
|
|
328
|
+
_inheritsLoose(ValidationError, _CommerceError);
|
|
522
329
|
return ValidationError;
|
|
523
330
|
}(CommerceError);
|
|
524
331
|
var FetcherError = /*#__PURE__*/function (_CommerceError2) {
|
|
525
|
-
_inheritsLoose(FetcherError, _CommerceError2);
|
|
526
332
|
function FetcherError(options) {
|
|
527
333
|
var _this3;
|
|
528
334
|
_this3 = _CommerceError2.call(this, options) || this;
|
|
529
335
|
_this3.status = options.status;
|
|
530
336
|
return _this3;
|
|
531
337
|
}
|
|
338
|
+
_inheritsLoose(FetcherError, _CommerceError2);
|
|
532
339
|
return FetcherError;
|
|
533
340
|
}(CommerceError);
|
|
534
341
|
|
|
535
342
|
var useData = function useData(options, input, fetcherFn, swrOptions, provider) {
|
|
536
343
|
var hookInput = Array.isArray(input) ? input : Object.entries(input);
|
|
537
344
|
var fetcher = /*#__PURE__*/function () {
|
|
538
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
345
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, query, method) {
|
|
539
346
|
var _len,
|
|
540
347
|
args,
|
|
541
348
|
_key,
|
|
542
|
-
_args = arguments
|
|
543
|
-
|
|
544
|
-
|
|
349
|
+
_args = arguments,
|
|
350
|
+
_t;
|
|
351
|
+
return _regenerator().w(function (_context) {
|
|
352
|
+
while (1) switch (_context.p = _context.n) {
|
|
545
353
|
case 0:
|
|
546
|
-
_context.
|
|
354
|
+
_context.p = 0;
|
|
547
355
|
for (_len = _args.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
548
356
|
args[_key - 3] = _args[_key];
|
|
549
357
|
}
|
|
550
|
-
_context.
|
|
358
|
+
_context.n = 1;
|
|
551
359
|
return options.fetcher({
|
|
552
360
|
options: {
|
|
553
361
|
url: url,
|
|
@@ -562,22 +370,21 @@ var useData = function useData(options, input, fetcherFn, swrOptions, provider)
|
|
|
562
370
|
fetch: fetcherFn,
|
|
563
371
|
provider: provider
|
|
564
372
|
});
|
|
565
|
-
case
|
|
566
|
-
return _context.
|
|
567
|
-
case
|
|
568
|
-
_context.
|
|
569
|
-
|
|
373
|
+
case 1:
|
|
374
|
+
return _context.a(2, _context.v);
|
|
375
|
+
case 2:
|
|
376
|
+
_context.p = 2;
|
|
377
|
+
_t = _context.v;
|
|
570
378
|
// SWR will not log errors, but any error that's not an instance
|
|
571
379
|
// of CommerceError is not welcomed by this hook
|
|
572
|
-
if (!(
|
|
573
|
-
console.error(
|
|
380
|
+
if (!(_t instanceof CommerceError)) {
|
|
381
|
+
console.error(_t);
|
|
574
382
|
}
|
|
575
|
-
throw
|
|
576
|
-
case
|
|
577
|
-
|
|
578
|
-
return _context.stop();
|
|
383
|
+
throw _t;
|
|
384
|
+
case 3:
|
|
385
|
+
return _context.a(2);
|
|
579
386
|
}
|
|
580
|
-
}, _callee, null, [[0,
|
|
387
|
+
}, _callee, null, [[0, 2]]);
|
|
581
388
|
}));
|
|
582
389
|
return function fetcher(_x, _x2, _x3) {
|
|
583
390
|
return _ref.apply(this, arguments);
|
|
@@ -870,35 +677,34 @@ function AddToCartButton(props) {
|
|
|
870
677
|
var form = reactHookForm.useFormContext();
|
|
871
678
|
var addItem = useAddItem();
|
|
872
679
|
var addToCart = /*#__PURE__*/function () {
|
|
873
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
680
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
874
681
|
var _form$getValues$Produ;
|
|
875
682
|
var quantity, _form$getValues$Produ2, variantId;
|
|
876
|
-
return
|
|
877
|
-
while (1) switch (_context.
|
|
683
|
+
return _regenerator().w(function (_context) {
|
|
684
|
+
while (1) switch (_context.n) {
|
|
878
685
|
case 0:
|
|
879
686
|
quantity = +((_form$getValues$Produ = form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1);
|
|
880
687
|
if (!(isNaN(quantity) || quantity < 1)) {
|
|
881
|
-
_context.
|
|
688
|
+
_context.n = 1;
|
|
882
689
|
break;
|
|
883
690
|
}
|
|
884
691
|
throw new CommerceError({
|
|
885
692
|
message: "The item quantity has to be a valid integer greater than 0"
|
|
886
693
|
});
|
|
887
|
-
case
|
|
694
|
+
case 1:
|
|
888
695
|
if (!product) {
|
|
889
|
-
_context.
|
|
696
|
+
_context.n = 2;
|
|
890
697
|
break;
|
|
891
698
|
}
|
|
892
699
|
variantId = (_form$getValues$Produ2 = form.getValues()["ProductVariant"]) != null ? _form$getValues$Produ2 : product.variants[0].id;
|
|
893
|
-
_context.
|
|
700
|
+
_context.n = 2;
|
|
894
701
|
return addItem({
|
|
895
702
|
productId: product.id,
|
|
896
703
|
variantId: variantId,
|
|
897
704
|
quantity: quantity
|
|
898
705
|
});
|
|
899
|
-
case
|
|
900
|
-
|
|
901
|
-
return _context.stop();
|
|
706
|
+
case 2:
|
|
707
|
+
return _context.a(2);
|
|
902
708
|
}
|
|
903
709
|
}, _callee);
|
|
904
710
|
}));
|
|
@@ -923,29 +729,26 @@ function registerAddToCartButton(loader, customAddToCartButtonMeta) {
|
|
|
923
729
|
}
|
|
924
730
|
|
|
925
731
|
var fetcher$3 = /*#__PURE__*/function () {
|
|
926
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
927
|
-
var options, cartId, fetch;
|
|
928
|
-
return
|
|
929
|
-
while (1) switch (_context.
|
|
732
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
733
|
+
var options, cartId, fetch, _t;
|
|
734
|
+
return _regenerator().w(function (_context) {
|
|
735
|
+
while (1) switch (_context.n) {
|
|
930
736
|
case 0:
|
|
931
737
|
options = _ref.options, cartId = _ref.input.cartId, fetch = _ref.fetch;
|
|
932
738
|
if (!cartId) {
|
|
933
|
-
_context.
|
|
739
|
+
_context.n = 2;
|
|
934
740
|
break;
|
|
935
741
|
}
|
|
936
|
-
_context.
|
|
742
|
+
_context.n = 1;
|
|
937
743
|
return fetch(options);
|
|
938
|
-
case
|
|
939
|
-
|
|
940
|
-
_context.
|
|
744
|
+
case 1:
|
|
745
|
+
_t = _context.v;
|
|
746
|
+
_context.n = 3;
|
|
941
747
|
break;
|
|
942
|
-
case
|
|
943
|
-
|
|
944
|
-
case
|
|
945
|
-
return _context.
|
|
946
|
-
case 9:
|
|
947
|
-
case "end":
|
|
948
|
-
return _context.stop();
|
|
748
|
+
case 2:
|
|
749
|
+
_t = null;
|
|
750
|
+
case 3:
|
|
751
|
+
return _context.a(2, _t);
|
|
949
752
|
}
|
|
950
753
|
}, _callee);
|
|
951
754
|
}));
|