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